shrub/pkg/arvo/app/neo.hoon
2024-04-03 14:36:49 -04:00

2732 lines
66 KiB
Plaintext

/- neo, sole-sur=sole
/+ default-agent, dbug, verb, shoe, serv=server
/* txt-hoon-imp %hoon /neo/src/std/imp/hoon/hoon
/* txt-term-imp %hoon /neo/src/std/imp/term/hoon
/* txt-ford-same %hoon /neo/src/std/imp/ford-same/hoon
/* txt-ford-slop %hoon /neo/src/std/imp/ford-slop/hoon
/* txt-ford-slap %hoon /neo/src/std/imp/ford-slap/hoon
/* txt-ford-face %hoon /neo/src/std/imp/ford-face/hoon
/* txt-ford-face %hoon /neo/src/std/imp/ford-face/hoon
/* txt-ford-reef %hoon /neo/src/std/imp/ford-reef/hoon
|%
++ pave pave:neo
++ ford ford:neo
++ slug
|= a=tang
^+ same
?~ a same
~_ i.a $(a t.a)
++ bump-ever
|= =ever:neo
^- ever:neo
[+(-.ever) +(+.ever)]
::
++ trace-card-gall
|= =card
^- tank
?: ?=(%give -.card)
leaf/"give"
?> ?=(%pass -.card)
leaf/"%pass {(spud p.card)}"
::
++ sole
|%
+$ id sole-id:sole-sur
+$ action sole-action:sole-sur
--
++ show-iota
|= i=iota
^- @t
?@ i i (scot i)
+$ pith pith:neo
+$ card card:shoe
+$ race-form _*eval-form:(pike:neo ,ewer:neo)
+$ race
$: rout=term
form=race-form
grab=(list item:pike:neo)
have=(list clot:goon:neo)
==
+$ shell
$: cwd=name:neo
race=(unit race)
==
+$ hull
$% [%clot =clot:goon:neo]
[%ls ~]
[%tree depth=@ud]
[%show ~]
[%cd =name:neo]
[%race rout=@tas]
[%poke p=hoon]
[%ford ~]
[%comm ~]
[%clay ~]
==
+$ state-0
$: %0
apex=(axal:neo room:neo)
:: diary=(axal:neo memo:neo)
:: dead=(map @uvH (axal:neo room:neo))
=sound:neo
foreign=(map tour:neo riot:neo)
=halt:neo
=fleet:neo
$= fiesta
$: by-grab=(jug stud:neo stud:neo)
by-grow=(jug stud:neo stud:neo)
con=(map [stud:neo stud:neo] stud:neo)
==
husks=(jug stud:neo name:neo)
shells=(map id:sole shell)
races=(map id:sole race)
hear=(map name:neo sound:neo)
$= unix
$: timers=(jug @da pith:neo)
clay-peers=(set [src=pith hand=pith])
http-req=(map @ta path)
==
adult=_|
==
++ is-parent-p
|= [parent=path kid=path]
^- ?
?~ parent &
?~ kid |
?. =(i.parent i.kid)
|
$(parent t.parent, kid t.kid)
++ is-parent
|= [parent=pith kid=pith]
^- ?
?~ parent &
?~ kid |
?. =(i.parent i.kid)
|
$(parent t.parent, kid t.kid)
++ get-ship
|= =pith
^- @p
?> ?=([[%p @] *] pith)
+.i.pith
--
=| state-0
=* state -
=<
%- agent:dbug
%+ verb |
%- (agent:shoe hull)
|_ =bowl:gall
+* this .
run ~(. +> [bowl ~])
def ~(. (default-agent this %|) bowl)
++ on-init
^- (quip card _this)
=^ cards state
abet:init:run
[cards this]
++ on-save !>(`state-0`state)
++ on-load
|= =vase
=+ !<(old=state-0 vase)
`this(state old)
++ on-poke
|= [=mark =vase]
^- (quip card _this)
=^ cards state
abet:(poke:run mark vase)
[cards this]
++ on-watch
|= =path
^- (quip card _this)
=^ cards state
abet:(watch:run path)
[cards this]
::
++ on-leave
|= =path
^- (quip card _this)
=^ cards state
abet:(leave:run path)
[cards this]
::
++ on-agent
|= [=wire =sign:agent:gall]
^- (quip card _this)
=^ cards state
abet:(take-agent:run wire sign)
[cards this]
++ on-arvo
|= [=(pole knot) syn=sign-arvo]
^- (quip card _this)
?: ?=([%bind-site ~] pole)
`this
?: ?=([%next-clay ~] pole)
=^ cards state
abet:(next-clay:run syn)
[cards this]
?. ?=([%sys rest=*] pole)
`this
=^ cards state
abet:(take:sys:run rest.pole syn)
[cards this]
++ on-fail on-fail:def
++ on-peek peek:run
++ command-parser
|= =id:sole
~(parser walk:run id)
++ tab-list
|= [=id:sole query=@t]
(~(tab walk:run id) query)
++ on-command
|= [=id:sole =hull]
=^ cards state
abet:(~(do walk:run id) hull)
[cards this]
::
++ can-connect
|= =id:sole
=(our src):bowl
++ on-connect
|= =id:sole
=^ cards state
abet:(conn:run id)
[cards this]
++ on-disconnect
|= =id:sole
=^ cards state
abet:~(drop walk:run id)
[cards this]
--
|_ [=bowl:gall cards=(list card)]
++ abet [(flop cards) state]
++ run .
++ emit |=(=card run(cards [card cards]))
++ pass |=([=wire =note:agent:gall] (emit %pass wire note))
++ give |=(=gift:agent:gall (emit %give gift))
++ fact |=([pas=(list path) =cage] (give %fact pas cage))
++ emil |=(caz=(list card) run(cards (welp (flop caz) cards)))
++ std-warp
=/ =rave:clay
[%next %z da/now.bowl /neo]
(pass /next-clay %arvo %c %warp our.bowl q.byk.bowl `rave)
++ poke-our
|=([=wire =cage] (pass wire %agent [our dap]:bowl %poke cage))
::
++ poke-move
|= =move:neo
=/ =wire local/(pout p.move)
(poke-our wire neo-move+!>(move))
++ poke-neo
|=([=wire her=ship =cage] (pass wire %agent [her dap.bowl] %poke cage))
++ of-top ~(. of:neo apex)
++ clay-beak ^- path
/(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)
++ bump-room-tree
|= =room:neo
^+ room
room(tree.ever.icon +(tree.ever.icon.room))
++ hall
|= =pith:neo
=/ =room:neo (got:of-top pith)
|%
++ pail `pail:neo`[state-stud state]
++ vial (pail:soften pail)
++ state state.icon.room
++ state-stud `stud:neo`state.room
++ ever ever.icon.room
++ cane
|= =care:neo
|^ ^- cane:neo
:* care
ever
pail
^- (map pith:neo [ever:neo pail:neo])
?- care
%x *(map pith:neo [ever:neo pail:neo])
%y (~(run by (~(kid of:neo apex) pith)) room-to-ever)
%z *(map pith:neo [ever:neo pail:neo])
==
==
++ room-to-ever
|= =room:neo
^- [ever:neo pail:neo]
[ever.icon.room [state.room state.icon.room]]
--
--
++ leave
|= =(pole knot)
^+ run
?. ?=([%sync %init as=@ car=@ rest=*] pole)
run
=+ ;;(=care:neo car.pole)
=+ ;;(=pulp:neo as.pole)
=/ pax=pith:neo (pave:neo rest.pole)
=/ =tone:neo [%peer pulp pole]
=. sound (~(del ju sound) [care rest.pole] tone)
run
::
++ next-clay
|= syn=sign-arvo
^+ run
?> ?=([%clay %writ *] syn)
=. run std-warp
?~ p.syn
~& %weird-clay-next
run
(copy-clay ~)
::
++ init
|^ ^+ run
=+ .^(neo-vase=vase %ca (welp clay-beak /sur/neo/hoon))
=/ reef=vase (slop !>(..zuse) neo-vase(p [%face %neo p.neo-vase]))
=/ riff=room:neo
[%ford-riff %ford-out ~ [1 1] !>(`[cac=(unit vase) ~]`[`!>(ford-riff) ~]) ~ ~]
=. apex (put:of-top #/out/std/imp/ford-riff riff)
=. run (make-riff #/out/reef reef)
=. run (re-export reef %hoon !,(*hoon @t))
=. run (make-riff #/out/std/pro/ford-out (ford-out reef))
=. run (make-riff #/out/std/pro/ford-in (ford-in reef))
=. run (make-riff #/out/std/pro/term (term reef))
=. run (make-riff-slap #/out/std/imp/hoon reef txt-hoon-imp)
=. run (make-riff-slap #/out/std/imp/term reef txt-term-imp)
=. run (make-riff-slap #/out/std/imp/ford-same reef txt-ford-same)
=. run (make-riff-slap #/out/std/imp/ford-face reef txt-ford-face)
=. run (make-riff-slap #/out/std/imp/ford-slop reef txt-ford-slop)
=. run (make-riff-slap #/out/std/imp/ford-slap reef txt-ford-slap)
=. run (re-export reef %json !,(*hoon json))
=. run (re-export reef %mime !,(*hoon mime))
=. run (poke %noun !>(%clay))
=. run (emit %pass /bind-site %arvo %e %connect [~ dap.bowl ~] dap.bowl)
std-warp
++ make-riff-slap
|= [wer=pith:neo reef=vase txt=@t]
~| wer
=; =vase
(make-riff wer vase)
=+ vaz=(vang & (pout wer))
%+ slap reef
(scan (trip txt) (full (ifix [gay gay] tall:vaz)))
::
++ ford-riff
^- firm:neo
|%
++ state %ford-out
++ poke *(set stud:neo)
++ kids ~
++ deps ~
++ form
^- form:neo
|_ [=bowl:neo =ever:neo state-vase=vase *]
+* sta !<([cache=(unit vase) ~] state-vase)
++ poke
|= =pail:neo
^- (quip card:neo vase)
`state-vase
::
++ init
|= old=(unit vase)
^- (quip card:neo vase)
=+ !<(sta=[ref=(unit vase) ~] (need old))
`!>(sta)
--
--
++ re-export
|= [reef=vase =stud:neo =hoon]
^+ run
%+ make-riff ~(pith pro stud)
(slap reef hoon)
::
++ term
|= reef=vase
^- vase
%+ slap reef
!, *hoon
,term
::
++ ford-out
|= reef=vase
^- vase
%+ slap reef
!, *hoon
,[cache=(unit vase) *]
::
++ ford-in
|= reef=vase
^- vase
%+ slap reef
!,(*hoon ,~)
::
++ make-riff
|= [=pith riff=vase]
^+ run
=. pith [p/our.bowl pith]
(on-card pith %make %ford-riff `!>([`riff ~]) ~)
--
::
++ sync-room
|= [=stud:neo =name:neo]
^+ run
=/ =wire sync/(pout pith.name)
:: =. run abet:(~(init xeno name) stud/stud)
(emit %pass wire %agent [ship.name dap.bowl] %watch [%sync %init (pout pith.name)])
++ our-sys-name `name:neo`[our.bowl `pith:neo`#/$/sys]
++ our-sys-pith (en-pith:name:neo our-sys-name)
::
++ peek
|= pax=path
^- (unit (unit cage))
?. ?=([%x *] pax)
[~ ~]
=/ pax=(pole iota) (pave:neo t.pax)
?+ pax [~ ~]
[as=@ car=@ [%p who=@] pith=*] (run-peek [as car who pith]:pax)
==
++ run-peek
|= [as=term car=term =name:neo]
^- (unit (unit cage))
=+ ;;(=care:neo car)
?. =(our.bowl ship.name)
[~ ~] :: XX: todo
=/ res (cane:(hall pith.name) care)
?+ as [~ ~]
%noun ``neo-cane+!>(res)
%json
~& %json
``json+!>((cane:enjs:neo res !<($-(pail:neo json) (all-grow %json))))
::
%html
=* en-html
~(. en-html:neo [#/['~']/scry/[dap.bowl]/html (en-pith:name:neo name)])
=- ``hymn+!>(-)
%+ lift-to-hymn:en-html pith.name
(cane:en-html res !<($-(pail:neo manx) (all-grow %node)))
==
::
++ take-arvo
|= [=pith syn=sign-arvo]
^+ run
?: ?=(%remote -.pith)
!! :: abet:(~(take xeno pith) syn)
?: ?=([%husk @ *] pith)
!! :: (~(take husk i.t.pith) (pout t.t.pith) syn)
!!
:: abet:(take-arvo:(abed:arvo our-sys-pith pith) pith syn)
::
++ forward-poke
|= [=name:neo pok=*]
^+ run
=/ =wire forward/(en-path:name:neo name)
=/ =dock [ship.name dap.bowl]
run :: XX: revive
:: =- (emit %pass wire %agent dock %poke -)
:: noun+!>(`card:neo`[(en-pith:name:neo name) %poke pok])
++ print-dbug
|= veb=?
|^ ^+ same
%- %*(. slog pri 1)
%- lure
:+ %rose [ret "Shrubbery" sep]
:* leaf/"Local"
(local-axal *pith apex)
leaf/"Remote"
%+ turn ~(tap by fleet)
|= [=ship =brig:neo]
(remote-axal [p/ship]~ brig)
==
++ ret [',' (reap 4 ' ')]
++ sep *tape
++ remote-kids
|= [=pith =(axal:neo cane:neo)]
^- tank
!!
:: ?: =(~ kid.axal)
:: leaf/"No children"
:: :+ %rose [ret "Kids:" sep]
:: %+ murn ~(tap by kid.axal)
:: |= [=iota a=(axal:neo cell:neo)]
:: ^- (unit tank)
:: ?: &(veb =(pith ~) |(=(iota %src) =(iota %pre)))
:: ~
:: `(remote-axal (snoc pith iota) a)
++ remote-axal
|= [=pith =(axal:neo cane:neo)]
^- tank
!!
:: :+ %rose [ret (en-tape:pith:neo pith) sep]
:: ^- (list tank)
:: %- snoc
:: :_ (remote-kids pith axal)
:: ^- (list tank)
:: ?~ fil.axal
:: ~[leaf/"No data"]
:: =/ =cell:neo u.fil.axal
:: ?: =(case.cell 0)
:: ~[leaf/"No data at this path"]
:: :~ leaf/"State"
:: ?: (lth 10.000 (met 3 (jam q.state.cell)))
:: leaf/"Too large to print"
:: (sell state.cell)
::
:: leaf/"Case: {(scow %ud case.cell)}"
:: ::
:: ::
:: leaf/"Source: {<p.span.cell>}"
:: ==
++ local-kids
|= [=pith =(axal:neo room:neo)]
^- tank
?: =(~ kid.axal)
leaf/"No children"
:+ %rose [ret "Kids:" sep]
%+ murn ~(tap by kid.axal)
|= [=iota a=(axal:neo room:neo)]
^- (unit tank)
?: &(veb =(pith ~) |(=(iota %src) =(iota %pre)))
~
`(local-axal (snoc pith iota) a)
++ local-axal
|= [=pith =(axal:neo room:neo)]
^- tank
:+ %rose [ret (en-tape:pith:neo pith) sep]
^- (list tank)
%- snoc
:_ (local-kids pith axal)
^- (list tank)
?~ fil.axal
~[leaf/"No data"]
=/ =room:neo u.fil.axal
?: =(ever.icon.room [0 0])
~[leaf/"No data at this path"]
:* leaf/"State"
?: (lth 10.000 (met 3 (jam q.state.icon.room)))
leaf/"Too large to print"
(sell state.icon.room)
leaf/"Case: {(scow %ud node.ever.icon.room)}"
::
::
leaf/"Source: {<code.room>}"
^- (list tank)
?: =(~ conf.room)
~
:_ ~
:+ %rose [" " "Dependencies" sep]
%+ turn ~(tap by conf.room)
|= [=term p=^pith]
leaf/"{<term>} -> {(en-tape:pith:neo p)}"
==
--
::
++ poke
|= [=mark =vase]
^+ run
?: =(%handle-http-request mark)
=- (~(on-req srv id) req)
!<([id=@ta req=inbound-request:eyre] vase)
?: =(%neo-raw-poke mark)
=+ !<(raw=raw-poke:neo vase)
(on-move (raw-poke:harden raw))
?: =(%neo-move mark)
=+ !<(=move:neo vase)
(on-move move)
?> ?=(%noun mark)
?: =(%clay q.vase)
(copy-clay ~)
?: ?=([%file *] q.vase)
=+ ;;(=path +.q.vase)
(copy-clay `path)
?: ?=([%dbug veb=?] q.vase)
?> =(our src):bowl
%- (print-dbug veb.q.vase)
run
?: ?=(%out -.q.vase)
=+ ;;(=out:neo +.q.vase)
(do-out out)
=+ ;;(=card:neo q.vase)
=/ =name:neo (de-pith:name:neo p.card)
?. =(our.bowl ship.name)
?> ?=(%poke -.q.card)
!! :: XX: fix(forward-poke name val.q.card)
(on-card card)
++ dove
|_ here=pith:neo
++ curr
?~ rom=(get:of-top here)
;summary: Nothing here
;div(class "w-1/3")
;+ (val u.rom)
;dl
;* (room-meta here u.rom)
;dt: Dependecies
;dd
;dl
;* %- zing
%+ turn ~(tap by conf.u.rom)
|= [=term dep=pith:neo]
:~
;dt: {(trip term)}
;dd: {(en-tape:pith:neo dep)}
==
==
==
==
==
++ val
|= =room:neo
^- manx
=+ !<(grow=$-(pail:neo manx) (all-grow %node))
?^ man=(mole |.((grow [state.room state.icon.room])))
u.man
;code
{":: unable to render state as manx"}
{(text state.icon.room)}
==
++ style
%- trip
'''
dl {
display: grid;
grid-gap: 4px 16px;
grid-template-columns: max-content;
}
dt {
font-weight: bold;
}
dd {
margin: 0;
grid-column-start: 2;
}
'''
::
++ lift
|= in=manx
^- manx
;html
;head
;title: {(en-tape:pith:neo here)}
;style: {style}
;script@"https://cdn.tailwindcss.com";
==
;body
;+ in
==
==
++ stud-tape
|= s=stud:neo
^- tape
?@ s (trip s)
"{(scow %p ship.s)}/{(trip desk.s)}/{(trip mark.s)}"
++ pith-a
|= [=pith:neo in=manx]
=/ tap (en-tape:pith:neo pith)
^- manx
?. |(=(~ pith) (has:of-top pith))
;span
;+ in
==
;a.underline/"/neo/hawk{tap}.html"
;+ in
==
::
++ room-li
|= [=pith:neo =room:neo]
^- manx
;li
;dl
;dt: Pith
;dd
;+ (pith-a (welp here pith) ;/((en-tape:pith:neo pith)))
==
;* (room-meta pith room)
==
==
++ navbar-item
|= [=pith:neo in=manx]
^- manx
;li.p-2.border
;+ (pith-a pith in)
==
++ home
^- manx
;li.p-2.border
;a.underline/"/neo/hawk": Root
==
::
++ navbar
;nav.w-full.my-2
;ol.flex.align-center.justify-center.w-full.space-x-4
;*
:- home
=< q
^- (pair pith:neo (list manx))
%+ roll here
|= [=iota pit=pith:neo out=(list manx)]
^- (pair pith:neo (list manx))
=. pit (snoc pit iota)
:- pit
%+ snoc out
%+ navbar-item pit
;/(?@(iota "%{(trip iota)}" (scow iota)))
==
==
++ room-meta
|= [=pith:neo =room:neo]
^- (list manx)
:~
;dt: Code
;dd: {(stud-tape code.room)}
;dt: State
;dd: {(stud-tape state.room)}
==
--
++ is-sys
|= =pith:neo
^- ?
?. ?=([@ *] pith)
|
|(=('out' i.pith) =('pre' i.pith) =('src' i.pith))
++ hawk
|= req=inbound-request:eyre
^- simple-payload:http
=/ line=request-line:serv (parse-request-line:serv url.request.req)
?> ?=([@ @ *] site.line)
~& site/site.line
=/ =pith:neo (pave:neo t.t.site.line)
=? pith ?=([%$ ~] pith)
~
~& pith/pith
=/ kids (kid:of-top pith)
=* dov ~(. dove pith)
%- manx-response:gen:serv
^- manx
%- lift:dov
;main.flex.flex-col.space-y-4
;+ navbar:dov
;div.flex
;* ?:((has:of-top pith) (limo curr:dov ~) *(list manx))
;div.flex.flex-col
;h3: Children
;ol.flex.flex-col
;* (turn (skip ~(tap by kids) |=([p=pith:neo *] (is-sys p))) room-li:dov)
==
==
==
==
::
++ srv
|_ eyre-id=@ta
++ send
|= res=simple-payload:http
^+ run
(emil (give-simple-payload:app:serv eyre-id res))
::
++ err
|= =tang
=. http-req.unix (~(del by http-req.unix) eyre-id)
(send (error:gen:serv tang))
::
++ response
|= =path
%- send
=/ res=(unit (unit cage))
=/ res (mule |.((peek %x path)))
?: ?=(%& -.res)
p.res
%- (slog leaf/"Failed to generate response" p.res)
[~ ~]
?. ?=([~ ~ *] res)
not-found:gen:serv
=* cag u.u.res
?+ p.cag invalid-req:gen:serv
%json (json-response:gen:serv !<(json q.cag))
%hymn (manx-response:gen:serv !<(manx q.cag))
%noun
:_ `(as-octs:mimes:html (jam q.q.cag))
[200 [['content-type' 'application/x-urb-jam'] ~]]
==
::
++ on-req
|= req=inbound-request:eyre
^+ run
:: XX: revive when privacy
:: ?. authenticated.req
:: (login-redirect:app:serv request.req)
=/ line=request-line:serv (parse-request-line:serv url.request.req)
?> &(?=([@ @ *] site.line) =('neo' i.site.line))
?. =('scry' i.t.site.line)
?> =('hawk' i.t.site.line)
(send (hawk req))
=/ =path t.t.site.line
?: =(%'POST' method.request.req)
:: ?> authenticated.req
(on-post path (need (de:json:html q:(need body.request.req))))
?. =('GET' method.request.req)
(send invalid-req:gen:serv)
(response path)
::
++ on-post
|= [=(pole knot) jon=json]
^+ run
?> ?=([as=@ car=@ ship=@ rest=*] pole)
?. =((slav %p ship.pole) our.bowl)
(send invalid-req:gen:serv)
=/ conv
!<($-([@ json] vase) (all-grab %json))
=/ =pail:neo
((pail:dejs:neo conv) jon)
=/ =move:neo
:- #/[p/our.bowl]/$/eyre/req/[eyre-id]
[(pave:neo [ship rest]:pole) %poke pail]
=. http-req.unix (~(put by http-req.unix) eyre-id pole)
=. run (poke-move move)
finish-post :: XX: stale
::
++ finish-post
=/ =(pole knot) (~(got by http-req.unix) eyre-id)
=. http-req.unix (~(del by http-req.unix) eyre-id)
(response pole)
--
::
::
++ on-card
|= =card:neo
^+ run
(on-move our-sys-pith card)
::
++ on-move
|= =move:neo
=/ =name:neo (de-pith:name:neo p.q.move)
?> =(our.bowl ship.name)
=/ src=name:neo [src.bowl p.move]
?. ?=([%$ *] pith.name)
abet:(arvo move)
(on-move:sys p.move q.move(p t.pith.name))
++ sys
|%
++ on-move
|= [src=pith =card:neo]
|^ ^+ run
?+ p.card ~|(bad-sys-move-pith/p.card !!)
[%behn ~] (behn q.card)
[%clay ~] (clay q.card)
==
++ clay
|= =note:neo
?> ?=(%poke -.note)
?> ?=(%clay-req p.pail.note)
=+ !<(=req:clay:neo q.pail.note)
?- -.req
%pull
=. clay-peers.unix (~(del in clay-peers.unix) src pith.req)
run
::
%peer
=. clay-peers.unix (~(put in clay-peers.unix) src pith.req)
=/ =wire (welp /sys/clay/peer (pout (en:drive:neo ~[src pith.req])))
=/ =rave:^clay [%sing =,(peer.req [care da/now.bowl path])]
(emit %pass wire %arvo %c %warp our.bowl desk.peer.req `rave)
==
::
++ behn
|= =note:neo
^+ run
?> ?=(%poke -.note)
?> ?=(%behn-req p.pail.note)
=+ !<(=req:behn:neo q.pail.note)
?- -.req
%rest
=/ =wire /sys/behn/wait/(scot %da p.req)
=. timers.unix (~(del ju timers.unix) p.req src)
?. =(~ (~(get ju timers.unix) p.req))
run
(emit %pass wire %arvo %b %rest p.req)
::
%wait
=/ =wire /sys/behn/wait/(scot %da p.req)
=. timers.unix (~(put ju timers.unix) p.req src)
?. =(1 ~(wyt in (~(get ju timers.unix) p.req)))
run
(emit %pass wire %arvo %b %wait p.req)
==
--
++ take
|= [=(pole knot) syn=sign-arvo]
|^ ^+ run
?+ pole ~|(bad-sys-take/pole !!)
[%behn %wait date=@da ~] (behn-wait (slav %da date.pole))
[%clay %writ res=*] (clay-writ res.pole)
:: [%behn %res date=@da ~] (behn-res (slav %da date.pole))
==
++ clay-writ
?> ?=(%writ +<.syn)
|= wir=(^pole knot)
=/ paxs=(^pole pith:neo)
(de:drive:neo (pave:neo wir))
?> ?=([src=* hand=* ~] paxs)
=/ src=pith src.paxs
=/ hand=pith hand.paxs
?. (~(has in clay-peers.unix) [src hand])
run
=/ =note:neo [%poke %clay-res !>(`res:clay:neo`[hand %writ p.syn])]
=/ =move:neo [[p/our.bowl #/$/clay] src note]
=/ =wire (welp /sys/clay/res wir)
(poke-our wire neo-move+!>(move))
::
++ behn-wait
|= =@da
?> ?=(%wake +<.syn)
=/ requested ~(tap in (~(get ju timers.unix) da))
=/ =wire /sys/behn/res/(scot %da da)
=/ =note:neo [%poke %behn-res !>([%wake ~])]
|- ^+ run
?~ requested
run
=/ =move:neo [[p/our.bowl #/$/behn] i.requested note]
=. run (poke-our wire neo-move+!>(move))
$(requested t.requested)
--
++ take-agent
|= [=(pole knot) =sign:agent:gall]
^+ run
?> ?=(%poke-ack -.sign)
?: ?=([%eyre %req eyre-id=@ ~] pole)
?^ p.sign
(~(err srv eyre-id.pole) u.p.sign)
~(finish-post srv eyre-id.pole)
?> ?=([%behn %res date=@da ~] pole)
%. run
?~ p.sign same
(slog u.p.sign)
--
++ all-grab
|= grab=stud:neo
^- vase :: of $-([to=stud grab-type] vase)
=/ in=vase (need ~(get pro grab))
=/ fiesta=vase !>(fiesta)
%+ slap
%+ with-faces:ford:neo get-reef
:~ in/in
fiesta/fiesta
grow/!>(grow)
apex/!>(apex)
con/!>(con)
grab/!>(grab)
==
!, *hoon
|= [to=stud:neo in=in]
^- vase
=/ =stud:neo
~| missing-con/[grab to]
(~(got by con.fiesta) [grab to])
=/ conv ~(do con stud)
(slym run:conv in)
::
++ all-grow
|= grow=stud:neo
^- vase :: of $-(pail grow-type)
=/ out=vase (need ~(get pro grow))
=/ fiesta=vase !>(fiesta)
%+ slap
%+ with-faces:ford:neo get-reef
:~ out/out
fiesta/fiesta
grow/!>(grow)
apex/!>(apex)
con/!>(con)
==
!, *hoon
|= =pail:neo
^- out
~! p.pail
~! grow
=/ =stud:neo
~| missing-con/[p.pail grow]
(~(got by con.fiesta) [p.pail grow])
=/ conv ~(do con stud)
!<(out (slam run:conv q.pail))
::
++ juice
|_ =pulp:neo
++ cane
|= =cane:neo
^- cage
?- pulp
%noun
neo-wand+!>((cane:soften cane))
%json
json+!>((cane:enjs:neo cane !<($-(pail:neo json) (all-grow %json))))
==
--
::
++ watch
|= =(pole knot)
^+ run
?+ pole ~|(bad-path/pole !!)
[%http-response *] run
::
[%sync rest=*]
?+ rest.pole !!
[%init as=@ car=@ ship=@p path=*]
?> =(our.bowl (slav %p ship.rest.pole))
=+ ;;(=pulp:neo as.rest.pole)
=+ ;;(=care:neo car.rest.pole)
=/ =tone:neo [%peer pulp pole]
=/ =pith:neo (pave path.rest.pole)
=. sound (~(put ju sound) [care pith] tone)
=/ =cane:neo (make-cane:neo care [p/our.bowl pith] (dip:of-top pith))
(fact ~ (~(cane juice pulp) cane))
==
==
++ do-out
|= =out:neo
^+ run
=; new=_run
=. run new
run
?- -.out
%sync (grab-tour p.out)
%stop (drop-tour p.out)
==
++ take-agent
|= [=(pole knot) =sign:agent:gall]
|^ ^+ run
?+ pole ~|(on-agent-bad-wire/pole !!)
[%sys rest=*] (take-agent:sys rest.pole sign)
[%test ~] test-wire
[%sync %init as=@ care=@ rest=*] (sync care.pole (pave rest.pole))
[%forward rest=*] (forward (pave rest.pole))
[%local rest=*] (take-local-agent (pave rest.pole) sign)
[%nack ~] take-nack
==
++ take-nack
?> ?=(%poke-ack -.sign)
%. run
?~ p.sign same
(slog leaf/"failed poke" u.p.sign)
++ test-wire
?. ?=(%poke-ack -.sign)
!!
%. run
?~ p.sign
same
(slog leaf/"nack on test wire" u.p.sign)
++ forward
|= =pith
?. ?=(%poke-ack -.sign)
~|(weird-forward-sign/-.sign !!)
%. run
?~ p.sign
same
(slog leaf/"failed forward poke {(spud (pout pith))}" u.p.sign)
::
++ sync
|= [=knot =pith]
=+ ;;(=care:neo knot)
?+ -.sign ~|(weird-sync-sign/-.sign !!)
%watch-ack
%. run
?~ p.sign same
%+ slog
leaf/"Failed sync from {(spud (pout pith))}"
u.p.sign
:: TODO: security vuln, confused deputy
%fact
?+ p.cage.sign !!
%neo-wand (~(cane hear [care pith]) (wand:harden !<(wand:neo q.cage.sign)))
%neo-twig (~(stem hear [care pith]) (twig:harden !<(twig:neo q.cage.sign)))
==
::
%kick
~& 'TODO: resub logic'
run
==
++ hear-wand
|= [=care:neo =pith:neo =wand:neo]
^+ run
=/ =cane:neo (wand:harden wand)
=/ =riot:neo [cane ~]
=. foreign (~(put by foreign) [care pith] riot)
(resolved:stop care pith)
++ hear-twig
|= [=care:neo =pith:neo =twig:neo]
=/ rot=(unit riot:neo) (~(get by foreign) [care pith])
?~ rot
~& heard-twig-no-cane/[care pith]
run
=/ =stem:neo (twig:harden twig)
=. cane.u.rot (beat-cane cane.u.rot stem)
=. foreign (~(put by foreign) [care pith] u.rot)
run
--
++ is-our
|= pax=pith:neo
?> ?=([[%p @] *] pax)
=(our.bowl +.i.pax)
++ shout
|= stems=(map tour:neo stem:neo)
^+ run
=/ stems ~(tap by stems)
|-
=* loop-stems $
?~ stems
run
=/ [=tour:neo =stem:neo]
i.stems
=/ tones ~(tap in (~(get ju sound) tour))
|-
=* loop-tones $
?~ tones
loop-stems(stems t.stems)
=/ =tone:neo i.tones
=. run (yell tone tour stem)
loop-tones(tones t.tones)
++ yell
|= [=tone:neo =tour:neo =stem:neo]
|^ ^+ run
?- -.tone
%peer (peer +.tone)
%rely (rely +.tone)
==
++ peer
|= =peer:neo
?> =(pulp.peer %noun)
(fact ~[path.peer] %neo-twig !>((stem:soften stem)))
++ rely
|= [=term pax=pith:neo]
=/ =rely:neo [term stem]
(poke-rely pith.tour pax rely)
--
::
++ dial
=| stems=(map tour:neo stem:neo)
|= changes=(map pith:neo mode:neo)
=/ changes ~(tap by changes)
|- ^+ run
=* loop-changes $
?~ changes
(shout stems)
=/ [pax=pith:neo =mode:neo]
i.changes
=/ tours=(list tour:neo)
~(tap in ~(tours yelp pax))
|- =* loop-tours $
?~ tours
loop-changes(changes t.changes)
=/ =tour:neo i.tours
=/ =stem:neo (~(gut by stems) tour (make-stem care.tour (got:of-top pax)))
=/ pith-tour
?> ?=(^ pith.tour)
t.pith.tour
?: =(pith-tour pax)
$(stems (~(put by stems) tour stem), tours t.tours)
?> ?=(?(%y %z) -.q.stem)
=. kids.q.stem
=/ sfix=pith:neo (slag (lent pith-tour) pax)
=/ =room:neo (got:of-top pax)
(~(put by kids.q.stem) sfix [ever.icon.room mode [state state.icon]:room])
$(stems (~(put by stems) tour stem), tours t.tours)
::
++ wash
|_ =dish:neo
++ is-our
?> ?=([[%p @] *] p.dish)
=(our.bowl +.i.p.dish)
++ local
?> ?=([[%p @] *] p.dish)
t.p.dish
++ peer
?. is-our
!! :: XX: revive
:: =/ tones ~(tones yelp local)
~
--
++ yelp
|_ =pith:neo
++ tours
(~(uni in (~(uni in check-x) check-y)) check-z)
++ check-x
^- (set tour:neo)
?: =(~ (~(get ju sound) [%x pith]))
~
(~(gas in *(set tour:neo)) [%x pith] ~)
++ check-y
^- (set tour:neo)
%- ~(gas in *(set tour:neo))
;: welp
*(list tour:neo)
?~ par-pith=(parent:of-top pith)
~
=/ parent=room:neo (got:of-top u.par-pith)
?: =(~ (~(get ju sound) [%y u.par-pith]))
~
[%y u.par-pith]^~
::
?: =(~ (~(get ju sound) [%y pith]))
~
[%y pith]^~
==
++ check-z
^- (set tour:neo)
%+ roll ~(tap in (anc:of-top pith))
|= [pax=pith:neo out=(set tour:neo)]
%- ~(gas in out)
?: =(~ (~(get ju sound) [%z pax]))
~
[%z pax]^~
--
++ bash-cane
|= [then=cane:neo now=cane:neo]
|^ ^- stem:neo
?> =(care.then care.now)
:- ever.now
?- care.now
%x [%x pail.now]
%y [%y pail.now get-kids]
%z [%z pail.now get-kids]
==
++ get-kids
%- ~(gas by *(map pith [ever:neo mode:neo pail:neo]))
^- (list [pith:neo ever:neo mode:neo pail:neo])
%- zing
:~ ^- (list [pith:neo ever:neo mode:neo pail:neo])
%+ turn ~(tap by get-add)
|= [pa=pith:neo e=ever:neo p=pail:neo]
[pa e %add p]
::
^- (list [pith:neo ever:neo mode:neo pail:neo])
%+ turn ~(tap by get-dif)
|= [pa=pith:neo e=ever:neo p=pail:neo]
[pa e %dif p]
::
^- (list [pith:neo ever:neo mode:neo pail:neo])
%+ turn ~(tap by get-dif)
|= [pa=pith:neo e=ever:neo p=pail:neo]
[pa e %del p]
==
++ get-add
(~(dif by kids.now) kids.then)
++ get-dif
(~(int by kids.now) kids.then)
++ get-del
(~(dif by kids.then) kids.now)
--
::
++ beat-cane
|= [=cane:neo =stem:neo]
^+ cane
?> =(care.cane -.q.stem)
:* care.cane
p.stem
::
?- -.q.stem
%x [pail.q.stem ~]
::
%y
:- pail.q.stem
%- ~(gas by kids.cane)
%+ turn ~(tap by kids.q.stem)
|= [p=pith:neo e=ever:neo m=mode:neo pa=pail:neo]
^- [pith:neo ever:neo pail:neo]
[p e pa]
::
%z
:- pail.q.stem
%- ~(gas by kids.cane)
%+ turn ~(tap by kids.q.stem)
|= [p=pith:neo e=ever:neo m=mode:neo pa=pail:neo]
^- [pith:neo ever:neo pail:neo]
[p e pa]
==
==
++ stop
|%
++ fresh
|= [block=(set tour:neo) =move:neo]
=/ =flow:neo [p p.q]:move
~& fresh-stop/flow
?. =(~ (~(get by clog.halt) flow))
~| trying-to-block-on-congested-flow/flow
!!
=/ q=(qeu move:neo) (~(put to *(qeu move:neo)) move)
=. clog.halt (~(put by clog.halt) flow q)
=/ block=(list tour:neo) ~(tap in block)
|- ^+ run
?~ block
run
=/ =tour:neo i.block
=. by-tour.halt (~(put by by-tour.halt) tour flow)
=. by-flow.halt (~(put ju by-flow.halt) flow tour)
=. run (grab-tour tour)
$(block t.block)
++ is-congested
|= =move:neo
=/ =flow:neo [p p.q]:move
(~(has by clog.halt) flow)
::
++ add
|= =move:neo
=/ =flow:neo [p p.q]:move
=/ q
~| adding-to-empty-clog/flow
(~(got by clog.halt) flow)
=. q (~(put to q) move)
=. clog.halt (~(put by clog.halt) flow q)
run
++ resolved
|= =tour:neo
=/ fow=(unit flow:neo) (~(get by by-tour.halt) tour)
?~ fow
run
=. by-tour.halt (~(del by by-tour.halt) tour)
=. by-flow.halt (~(del ju by-flow.halt) u.fow tour)
=/ tours=(set tour:neo)
(~(get ju by-flow.halt) u.fow)
?. =(~ tours)
run
=/ q (~(got by clog.halt) u.fow)
|-
?: =(~ q)
=. clog.halt (~(del by clog.halt) u.fow)
run
=^ nex=move:neo q ~(get to q)
=. run (poke-move nex)
$
--
::
++ harden
|%
++ raw-poke
|= raw=raw-poke:neo
^- move:neo
[p.p.raw q.p.raw %poke (vial q.raw)]
++ vial
|= =vial:neo
:- p.vial
(slym (need ~(get pro p.vial)) q.vial)
++ wand
|= w=wand:neo
^- cane:neo
:^ care.w ever.w (vial vial.w)
(~(run by kids.w) |=([e=ever:neo v=vial:neo] [e (vial v)]))
::
++ twig
|= =twig:neo
^- stem:neo
:- p.twig
?- -.q.twig
%x [%x (vial vial.q.twig)]
%y
:+ %y (vial vial.q.twig)
(~(run by kids.q.twig) |=([e=ever:neo m=mode:neo v=vial:neo] [e m (vial v)]))
::
%z
:+ %z (vial vial.q.twig)
%- ~(run by kids.q.twig)
|=([e=ever:neo m=mode:neo v=vial:neo] [e m (vial v)])
==
--
++ soften
|%
++ pail
|= pal=pail:neo
^- vial:neo
[p.pal q.q.pal]
++ cane
|= can=cane:neo
^- wand:neo
:^ care.can ever.can (pail pail.can)
(~(run by kids.can) |=([e=ever:neo pal=pail:neo] [e (pail pal)]))
++ stem
|= sem=stem:neo
^- twig:neo
:- p.sem
?- -.q.sem
%x [%x (pail pail.q.sem)]
%y [%y (pail pail.q.sem) (~(run by kids.q.sem) |=([e=ever:neo m=mode:neo p=pail:neo] [e m (pail p)]))]
%z [%z (pail pail.q.sem) (~(run by kids.q.sem) |=([e=ever:neo m=mode:neo p=pail:neo] [e m (pail p)]))]
==
--
::
++ con
|_ =stud:neo
++ do
=+ !<([vix=(unit vase) *] state.icon:(got:of-top pith))
=/ vax (need vix)
|%
++ grab !<(stud:neo (slot 4 vax))
++ grow !<(stud:neo (slot 5 vax))
++ run (slot 3 vax)
++ register
^+ fiesta
%_ fiesta
by-grab (~(put ju by-grab.fiesta) grab grow)
by-grow (~(put ju by-grow.fiesta) grow grab)
con (~(put by con.fiesta) [grab grow] stud)
==
++ vale
^- ?
=; rap=(trap ?)
=/ res (mule rap)
?: ?=(%& -.res)
p.res
%- (slog leaf/"mark-vale" p.res)
|
|. ^- ?
=/ src=vase (need ~(get pro grab))
=/ dst=vase (need ~(get pro grow))
=/ need=type
=< p
%+ slap (with-faces:ford:neo get-reef src/src dst/dst ~)
!,(*hoon *$-(src dst))
=/ have=type -:(slot 3 vax)
(~(nest ut need) & have)
--
++ pith
`pith:neo`(pave:neo path)
++ path
^- ^path
:- %out
?@ stud
/std/con/[stud]
?: =(our.bowl ship.stud)
/our/[desk.stud]/con/[mark.stud]
:+ %ext (scot %p ship.stud)
/[desk.stud]/con/[mark.stud]
--
++ get-disks
^- (set disk:neo)
=/ res (~(put in *(set disk:neo)) ~)
res :: XX: fix
++ floppy
|_ =disk:neo
++ pith
^- pith:neo
:- %src
?@ disk
#/std
?: =(our.bowl ship.disk)
[%our term.disk ~]
[%ext p/ship.disk term.disk ~]
++ pro
^- (set stud:neo)
=/ fat (dip:of-top (snoc pith %pro))
%- ~(gas in *(set stud:neo))
%+ murn ~(tap by kid.fat)
|= [=iota =(axal:neo room:neo)]
^- (unit stud:neo)
?. ?=(@ iota)
~& weird-pro/[disk iota]
~
?@ disk
`iota
`[iota disk]
--
++ omen
|_ pax=pith:neo
++ pol `(pole iota)`pax
++ eject
^- [(unit disk:neo) _pax]
?. ?=([@ *] pax)
`pax
=/ pol `(pole iota)`t.pax
?+ pol `pax
[%std rest=*] [`~ rest.pol]
[%our desk=@ rest=*] [`[our.bowl desk.pol] rest.pol]
[%ext [%p ship=@] desk=@ rest=*] [`[ship.pol desk.pol] rest.pol]
==
++ post
^- (unit post:neo)
=^ dis=(unit disk:neo) pax eject
?~ dis ~
?. ?=([tack:neo @ ~] pax)
~
=/ =stud:neo ?~(u.dis i.t.pax [i.t.pax u.dis])
`[i.pax stud]
--
::
++ pro
|_ =stud:neo
++ get grab
++ grab
=/ rom (got:of-top pith)
=+ !<([cac=(unit vase) *] state.icon.rom)
cac
++ built
(has:of-top pith)
++ pith
`pith:neo`(pave:neo path)
++ path
^- ^path
:- %out
?@ stud
/std/pro/[stud]
?: =(our.bowl ship.stud)
/our/[desk.stud]/pro/[mark.stud]
:+ %ext (scot %p ship.stud)
/[desk.stud]/pro/[mark.stud]
++ exists
=/ pax path
?> ?=(^ pax)
(exists-file %src t.pax)
--
++ root
/(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)/neo
++ exists-file
|= pax=path
=/ p=path
(welp root pax)
=. p (snoc p %hoon)
.^(? %cu p)
++ get-reef
=+ !<([ref=(unit vase) *] state:icon:(got:of-top #/out/reef))
(need ref)
::
++ copy-clay
|= just=(unit path)
~> %bout.[1 %build]
|^ ^+ run
=/ paths=(list path)
?~ just
.^((list path) %ct root)
~[u.just]
:: =. paths
:: %+ sort paths
:: |= [a=path b=path]
:: =- ~& sorting/[a b -] -
:: ?> ?=([@ @ *] a)
:: ?> ?=([@ @ *] b)
:: =/ fall (lte i.t.a i.t.b)
:: =/ a (pave:neo t.a)
:: =/ b (pave:neo t.b)
:: =/ a-pos ~(post omen a)
:: =/ b-pos ~(post omen b)
:: ?~ a-pos
:: ?~ b-pos fall
:: %.n
:: ?~ b-pos
:: %.y
:: ?: =(%imp p.u.a-pos)
:: ?: =(%imp p.u.b-pos)
:: (aor (get-stud-name:neo q.u.a-pos) (get-stud-name:neo q.u.b-pos))
:: %.n
:: ?: =(%imp p.u.b-pos)
:: %.y
:: fall
:: ~& paths/path
=. paths
%+ turn paths
|= pax=path
=. pax (snip pax)
?> ?=(^ pax)
t.pax
=/ is-imp
|= pax=path
^- ?
=/ pix (pave:neo pax)
?~ pos=~(post omen pix)
|
=(%imp u.pos)
=/ is-ford
|= pax=path
^- ?
=/ pix (pave:neo pax)
?~ pos=~(post omen pix)
|
?. ?=(@ q.u.pos)
|
=(%ford (end 3^4 q.u.pos))
=^ main=(list path) paths
[(skip paths is-ford) (skim paths is-ford)]
=^ imps=(list path) main
[(skim main is-imp) (skip main is-imp)]
|- ^+ run =* loop $
?~ paths
?^ main
loop(paths main, main ~)
?^ imps
loop(imps ~, paths imps)
run(adult &)
=^ pat=(unit path) run
(read-file i.paths)
?~ pat
loop(paths t.paths)
loop(paths (snoc t.paths u.pat))
++ build-pipe
=/ disks ~(tap in get-disks)
|- ^+ run
=* loop-disk $
?~ disks
run
=/ pros ~(pro floppy i.disks)
|-
=* loop-pro $
?~ pros
loop-disk(disks t.disks)
!!
:: vale -> [grow
::
++ lib
|_ =name:neo
++ path
^- ^path
?> =(our.bowl ship.name)
(pout pith.name)
++ built
(has:of-top %src pith.name)
++ pith
[p/ship.name pith.name]
++ exists
(exists-file path)
--
++ do-make
|= [=pith:neo lib=term sta=(unit vase) =conf:neo]
=/ =name:neo [our.bowl pith]
~| conf/conf
~| make-name/name
=. run
(on-card (en-pith:name:neo name) %make lib sta conf)
?: |(=(lib %hoon) =(lib %term))
run
~| ~(key by ~(tar of:neo apex))
=/ rom (got:of-top pith.name)
=+ !<([cache=(unit vase) *] state.icon.rom)
?~ cache
~& failed-to-build/pith
run
:: :: !!
?~ pos=~(post omen pith)
run
?. ?=(%con p.u.pos)
run
=* do-con ~(do con q.u.pos)
?. vale:do-con
run
=. fiesta register:do-con
run
++ ford-slap
|= [wer=pith sut=pith src=pith]
%^ do-make wer %ford-slap
`(~(gas by *conf:neo) sut/(ours sut) hoon/(ours src) ~)
::
++ slop
|= [wer=pith a=pith b=pith]
~| %ford-slop
%^ do-make wer %ford-slop
`(~(gas by *conf:neo) a/(ours a) b/(ours b) ~)
++ face
|= [wer=pith face=pith sut=pith]
~| %ford-face
%^ do-make wer %ford-face
`(~(gas by *conf:neo) face/(ours face) sut/(ours sut) ~)
++ same
|= [wer=pith from=pith]
~| ford-same/[wer from]
%^ do-make wer %ford-same
`(~(gas by *conf:neo) src/(ours from) ~)
++ ours
|= p=pith:neo `pith:neo`[p/our.bowl p]
++ make-pros
=| idx=@ud
|= [pat=pith pros=(list pro:ford)]
^+ run
?~ pros
~| pat
%+ same pat
?: =(0 idx)
#/out/reef
(snoc pat ud/(dec idx))
=/ wer=pith (snoc pat ud/idx)
=/ fac=pith (snoc wer %face)
=/ fav=pith (snoc fac %term)
=. run
(do-make fav %term `!>(face.i.pros) ~)
=. run
(face fac fav ~(pith pro stud.i.pros))
=/ prev=pith
?: =(idx 0)
#/out/reef
(snoc pat ud/(dec idx))
=. run
(slop wer fac prev)
$(pros t.pros, idx +(idx))
++ make-prelude
|= [pax=pith =file:ford]
^- [pith _run]
=/ pre-path=pith [%pre pax]
[pre-path (make-pros pre-path pro.file)]
++ write-hoon
|= [pax=pith fil=@t]
(do-make pax %hoon `!>(fil) ~)
++ src-to-out
|= pax=pith:neo
^- pith:neo
?> ?=([@ *] pax)
[%out t.pax]
++ has-modified
|= [txt=@t pax=pith:neo]
?. adult
&
?~ rom=(get:of-top pax)
&
!=(txt q.state.icon.u.rom)
++ read-file
|= pax=path
^- [(unit path) _run]
?: =((rear pax) %ford-parser)
`run
=+ .^(src=@t %cx `path`(snoc `path`(welp root pax) %hoon))
?. (has-modified src (pave:neo pax))
`run
~? >>> adult
[%update pax]
=/ =file:ford
~| parsing/pax
(scan (trip src) (rein:ford [our.bowl (pave:neo pax)]))
=/ has-imports=?
?& (levy pro.file |=(pro:ford ~(exists pro stud)))
(levy lib.file |=(lib:ford ~(exists lib name)))
==
?. has-imports
~| pro.file
~| lib.file
~| %no-imports
!!
=/ built-imports=?
?& (levy pro.file |=(pro:ford ~(built pro stud)))
(levy lib.file |=(lib:ford ~(built lib name)))
==
?. built-imports
[`pax run]
=^ pre=pith run
(make-prelude pax file)
=/ =conf:neo
(~(gas by *conf:neo) [%sut (ours pre)] ~)
=. run (write-hoon pax src)
=/ pit (src-to-out pax)
:- ~
(ford-slap (src-to-out pax) pre pax)
--
++ get-tour
|= =tour:neo
^- (unit cane:neo)
=/ =name:neo (de-pith:name:neo pith.tour)
?: =(our.bowl ship.name)
?. (has:of-top pith.name)
~
=/ hall (hall pith.name)
=/ =pail:neo pail:hall
=/ kids
?: ?=(%x care.tour)
~
~ :: XX: revive
`[care.tour ever:hall pail kids]
?~ rot=(~(get by foreign) tour)
~
`cane.u.rot
++ acquire
|= =(pole iota:neo)
^- (unit pail:neo)
?> ?=([[%p ship=@] rest=*] pole)
?: =(our.bowl ship.pole)
?~ val=(get:of-top rest.pole)
~
`[state.u.val state.icon.u.val]
?~ val=(~(get by foreign) [%x pole])
~
`pail.cane.u.val
:: XX: check typing
++ can-inject
|= [=pith:neo =quay:neo]
!=(~ (acquire pith))
++ get-val-at-path
|= =pith
^- (unit vase)
?~ val=(get:of-top pith)
~
`state.icon.u.val
++ get-pail-local
|= =pith
^- (unit pail:neo)
?~ val=(get:of-top pith)
~
`[state.u.val state.icon.u.val]
++ get-vial-local
|= =pith
^- (unit vial:neo)
?~ val=(get:of-top pith)
~
`[state.u.val q.state.icon.u.val]
:: XX: invert and check typing
++ check-conf
|= [=conf:neo =deps:neo]
^- [bad=(set term) block=(set tour:neo)]
%+ roll ~(tap by deps)
|= [[=term required=? =quay:neo] bad=(set term) block=(set tour:neo)]
?: &(required !(~(has by conf) term))
:_(block (~(put in bad) term))
?: &(!required !(~(has by conf) term))
[bad block]
=/ pit=pith:neo (~(got by conf) term)
?~ can=(get-tour -.quay pit)
[bad (~(put in block) -.quay pit)]
[bad block]
::
++ hear-watch
|= [=care:neo =pith:neo =watch:neo]
^+ run
?~ watch
run
:: =. run
:: abet:(~(hear xeno [src.bowl pith.i.watch]) +.i.watch)
$(watch t.watch)
++ husk
|_ =stud:neo
++ pith
^- pith:neo
:- %out
%- pave:neo
?@ stud
/std/imp/[stud]
?: =(our.bowl ship.stud)
/our/[desk.stud]/imp/[mark.stud]
/her/(scot %p ship.stud)/[desk.stud]/imp/[mark.stud]
++ firm-vase
~| firm/pith
=/ rom=room:neo (got:of-top pith)
~| vase/(sell state.icon.rom)
~| room/rom(state.icon *vase)
=+ !<([cac=(unit vase) *] state.icon.rom)
(need cac)
++ firm
!<(firm:neo firm-vase)
++ wire
%+ welp /husk/stud
(pout pith)
--
:: ?> ?=(@ stud)
:: =/ =riff:clay
:: [q.byk.bowl `[%sing %a da/now.bowl spur]]
:: =/ wir (snoc wire %build)
:: (emit %pass wir %arvo %c %warp our.bowl riff)
:: ++ take
:: |= [=(pole knot) syn=sign-arvo]
:: ^+ run
:: ?> ?=([%build ~] pole)
:: ?> ?=([%clay %writ *] syn)
:: ?~ p.syn
:: ~& bad-take-husk/pole
:: =. husks (~(del in husks) stud)
:: run
:: ?: =(~ (~(get ju husks) stud))
:: run
:: watch
::
++ hear
|_ =tour:neo
++ cane
|= =cane:neo
=/ =riot:neo (~(gut by foreign) tour %*(. *riot:neo care.cane care.cane))
=/ =stem:neo (bash-cane cane.riot cane)
=. cane.riot cane
=. foreign (~(put by foreign) tour riot)
(tell stem ~(tap in deps.riot))
++ tell
|= [=stem:neo deps=(list rave:neo)]
?~ deps
(resolved:stop tour)
=/ =rely:neo [term.i.deps stem]
=. run (poke-rely-xeno pith.tour pith.i.deps rely)
$(deps t.deps)
::
++ stem
|= =stem:neo
=/ =riot:neo
~| hear-stem-no-riot/tour
(~(got by foreign) tour)
=. cane.riot (beat-cane cane.riot stem)
=. foreign (~(put by foreign) tour riot)
(tell stem ~(tap in deps.riot))
--
::
++ xeno
|_ =tour:neo
++ ship `@p`?>(?=([%p @] pith.tour) +.i.pith.tour)
++ here ?>(?=([%p @] pith.tour) t.pith.tour)
++ brig (fall (~(get by fleet) ship) *brig:neo)
++ got (~(got of:neo brig) here)
++ get (~(get of:neo brig) here)
++ put
|= =cane:neo
=. fleet
%+ ~(put by fleet) ship
(~(put of:neo brig) here cane)
run
++ wire `^wire`(welp /xeno/[care.tour] (pout pith.tour))
++ dock `^dock`[ship dap.bowl]
++ apply
|= =stem:neo
(put (beat-cane got stem))
::
++ watch
=/ =path [%sync %init (pout pith.tour)]
=. run
(emit %pass wire %agent dock %watch path)
run
++ hear
|= [=stud:neo case=@ud =pith =diff:neo]
^+ run
~| hear-name/tour
run
::=/ firm ~(firm-vase husk p.span.cel)
:: =| =vase
::kk(put cel(case case, state vase))
--
::
++ take-local-agent
|= [=pith =sign:agent:gall]
^+ run
?+ -.sign !!
%poke-ack
%. run
?~ p.sign
same
%+ slog
leaf/"Poke-ack failed for shrub {(en-tape:pith:neo pith)}"
u.p.sign
::
==
::
++ give-nack
|= [src=name:neo dst=name:neo err=tang]
^+ run
?: =(src our-sys-name)
%- (slog leaf/"nack on sys" err)
run
:: TODO: revisit ordering semantics
=/ =wire /nack
:: XX: handle remote case
%^ poke-neo wire ship.src
:- %neo-move
!> ^- move:neo
:+ (en-pith:name:neo src)
(en-pith:name:neo dst)
[%poke %ack !>([%err err])]
++ serving-tours
^- (set [pulp:neo tour:neo])
%- ~(gas in *(set [pulp:neo tour:neo]))
%+ murn ~(tap by sup.bowl)
|= [=duct =ship =(pole knot)]
^- (unit [pulp:neo tour:neo])
?. ?=([%sync as=@ %init car=@ ship=@ rest=*] pole)
~
=+ ;;(=pulp:neo as.pole)
=+ ;;(=care:neo car.pole)
=/ =pith:neo (pave:neo ship.pole rest.pole)
`[pulp care pith]
++ match-tour
|= [=pith:neo =tour:neo]
?> ?=([[%p @] *] pith)
?> ?=([[%p @] *] pith.tour)
?> =(our.bowl +.i.pith)
^- ?
?- care.tour
%x =(pith pith.tour)
%y
=/ par (parent:of-top t.pith)
|(=(pith.tour pith) =([~ pith.tour] par))
%z
|(=(pith.tour pith) (~(has in (anc:of-top t.pith)) t.pith.tour))
==
::
++ grab-twig
|= [=care:neo =pith:neo]
=/ h (hall pith)
=/ =vial:neo vial:h
:- ever:h
?- care
%x [%x vial]
%y [%y vial ~]
%z [%z vial ~]
==
++ bi by
::
++ give-facts
=| twigs=(map tour:neo twig:neo)
|= changes=(list [=pith:neo =mode:neo])
^+ run
=/ change changes
=/ tours ~(tap in serving-tours)
|- =* loop-tour $
?~ tours
=/ twigs ~(tap by twigs)
|-
?~ twigs run
=/ [=tour:neo =twig:neo] i.twigs
=/ =pith:neo
(welp #/sync/init/noun tour)
=. run (fact ~[(pout pith)] neo-twig+!>(twig))
$(twigs t.twigs)
=/ [=pulp:neo =tour:neo] i.tours
|- =* loop-change $
?~ change
:: ?~ tours run
loop-tour(change changes, tours t.tours)
?. (match-tour pith.i.change tour)
loop-change(change t.change)
=/ [=pith:neo =mode:neo] i.change
?> ?=([[%p @] *] pith.tour)
?> ?=([[%p @] *] pith)
=/ =twig:neo
(~(gut bi twigs) tour (grab-twig tour(pith t.pith.tour)))
?: =(pith.tour pith)
=. twigs (~(put by twigs) tour twig)
loop-change(change t.change)
?< ?=(%x -.q.twig)
=> .(pith.tour `pith:neo`pith.tour, pith `pith:neo`pith)
=/ sfix=pith:neo (slag (lent pith.tour) pith)
?> ?=([[%p @] *] pith)
=/ h (hall t.pith)
=. kids.q.twig (~(put by kids.q.twig) sfix ever:h mode vial:h)
=. twigs (~(put by twigs) tour twig)
loop-change(change t.change)
::
++ poke-rely
|= [from=pith:neo to=pith:neo =rely:neo]
(poke-move [p/our.bowl from] to %poke %rely !>(rely))
::
++ poke-rely-xeno
|= [from=pith:neo to=pith:neo =rely:neo]
(poke-move from to %poke %rely !>(rely))
::
++ make-stem
|= [=care:neo =room:neo]
^- stem:neo
=/ =ever:neo ever.icon.room
=/ =pail:neo
[state.room state.icon.room]
?- care
%x [ever %x pail]
%y [ever %y pail ~]
%z [ever %z pail ~]
==
::
++ dep-change
|= [from=name:neo =term to=name:neo]
^+ run
!!
:: ?> =(our.bowl ship.to)
:: %+ poke-move (en-pith:name:neo from)
:: :- (en-pith:name:neo to)
::
:: !! :: [%poke %rely !>(
::
++ send-sync
|= =name:neo
^+ run
?. =(our.bowl ship.name)
~& sync-for-foreign/ship.name
run
=/ =room:neo (got:of-top pith.name)
=/ =cage
:- %neo-twig
!> *update:neo
:: ?> ?=(%stud -.p.span.room)
:: [pith.name p.p.span.room [case %init q.state]:icon.room]
=; paths=(list path)
?: =(~ paths)
run
(give %fact paths cage)
=/ target=path
%+ welp /sync/init
(pout pith.name)
=- ~(tap in -)
%- ~(gas in *(set path))
%+ murn ~(val by sup.bowl)
|= [=ship =path]
?. (is-parent-p target path)
~
`path
++ grab-tour
|= =tour:neo
?> ?=([[%p @] *] pith.tour)
=/ =path (welp /sync/init/noun/[`@ta`care.tour] (pout pith.tour))
=/ =tone:neo
[%peer %noun path]
(emit %pass path %agent [+.i.pith.tour %neo] %watch path)
++ drop-tour
|= =tour:neo
?> ?=([[%p @] *] pith.tour)
=/ =path (welp /sync/init/noun/[`@ta`care.tour] (pout t.pith.tour))
(emit %pass path %agent [+.i.pith.tour %neo] %leave ~)
::
++ arvo
=+ verb=&
=/ old apex
=| =block:neo
:: callstack
=| $: done=(list move:neo)
down=(list move:neo)
up=(list move:neo)
change=(map pith mode:neo)
==
|= =move:neo
=/ src=name:neo (de-pith:name:neo p.move)
=/ init=[src=name:neo dst=name:neo]
[src (de-pith:name:neo p.q.move)]
=/ init-move move
=/ src=name:neo src.init
=/ here pith.dst.init
?> =(our.bowl ship.dst.init)
=<
?. (is-congested:stop move)
(apply move)
=. run (add:stop move)
arvo
|%
++ abet
^+ run
?: =([~ ~] block)
=. cards (welp cards (turn up deal))
(dial change)
:: %+ turn ~(tap by change)
:: |=([=pith:neo =mode:neo] ^+(+< [[p/our.bowl pith] mode]))
:: run
~& >>> %reverting
=. apex old :: XX: is apex only state that is touched?
?. =(~ get.block)
(fresh:stop get.block init-move)
?> ?=(^ err.block)
%- (slog u.err.block)
(give-nack src.init dst.init u.err.block)
::
++ deal
|= =move:neo
^- card
:+ %pass move/(pout p.move)
^- note:agent:gall
=/ her=ship
~| p.move
?> ?=([[%p @p] *] p.q.move)
+.i.p.q.move
?: =(our.bowl her)
[%agent [her dap.bowl] %poke neo-move+!>(move)]
=/ raw=raw-poke:neo
?> ?=(%poke -.q.q.move)
[[p p.q]:move (pail:soften pail.q.q.move)]
?> ?=(%poke -.q.q.move)
[%agent [her dap.bowl] %poke neo-raw-poke+!>(raw)]
++ arvo .
++ emit |=(=move:neo arvo(down [move down]))
++ trace-card
|= =move:neo
^- tank
:- %leaf
"{(en-tape:pith:neo p.move)} -> {(en-tape:pith:neo p.q.move)}: {<-.q.q.move>}"
++ trace
|= =tang
?. verb same
%. tang
%* . slog
pri 2
==
++ inside (cury is-parent init)
++ echo arvo :: TODO walk done
++ work
^+ arvo
|- ^+ arvo
?^ err.block
arvo
?~ down
arvo
=/ nex=move:neo i.down
=/ new-arvo (apply:arvo(down t.down) nex) :: XX: weird compiler?
$(arvo new-arvo, done (snoc done nex))
++ poke
|= =pail:neo
^+ arvo
=^ cards=(list card:neo) arvo
(soft-site |.(si-abet:(si-poke:site pail)))
(ingest cards)
::
++ apply
|= =move:neo
^+ arvo
?. =(~ err.block)
:: skip if we have errored
arvo
~| apply/[p.move p.q.move]
=. src (de-pith:name:neo p.move)
=/ =name:neo (de-pith:name:neo p.q.move)
=. here +:p.q.move
%- (trace leaf/"{<-.q.q.move>} {(spud (pout here))}" ~)
?+ -.q.q.move !!
%make (make +.q.q:move)
%poke (poke +.q.q:move)
%link !!
==
::
++ ingest
|= caz=(list card:neo)
^+ arvo
=/ =pith [p/our.bowl here]
=. up
%+ welp up
%+ murn caz
|= =card:neo
^- (unit move:neo)
?: (is-parent pith p.card)
~
`[pith card]
=. down
%- welp
:_ down
%+ murn caz
|= =card:neo
^- (unit move:neo)
?. (is-parent pith p.card)
~
`[pith card]
work
::
++ listen-conf
|= [=conf:neo =deps:neo]
^+ arvo
%+ roll ~(tap by conf)
|= [[=term dep=pith:neo] a=_arvo]
?> ?=([[%p @] *] dep)
=/ [req=? =quay:neo] (~(got by deps) term)
=/ =tour:neo [-.quay dep]
=/ =pith:neo [p/our.bowl here]
?: =(our.bowl +.i.dep)
=/ =tone:neo [%rely term pith]
=. sound (~(put ju sound) [-.quay t.dep] tone)
arvo
::
=/ =riot:neo (~(got by foreign) tour)
=/ =rave:neo [term pith]
=. deps.riot (~(put in deps.riot) rave)
=. foreign (~(put by foreign) tour riot)
arvo
:: XX: enforce conformance
::
++ make
|= [src=stud:neo init=(unit vase) =conf:neo]
=/ =firm:neo ~(firm husk src)
:: =. run (~(start husk src) our.bowl pith)
=/ =form:neo form:firm
=/ =icon:neo [[0 0] *vase ~ ~]
=/ =deps:neo deps:firm
=^ bad=(set term) get.block
(check-conf conf deps:firm)
?. =(~ bad)
~| missing-dependecies/~(tap in bad)
!!
?. =(~ get.block)
~& get/get.block
arvo
=. arvo (listen-conf conf deps:firm)
=/ =room:neo [src state:firm conf icon]
=. apex (put:of-top here room)
=^ cards=(list card:neo) arvo
(soft-site |.(si-abet:(si-init:site init)))
(ingest cards)
++ soft-site
|= tap=(trap (quip card:neo _arvo))
^- (quip card:neo _arvo)
=/ res=(each (quip card:neo _arvo) tang)
(mule tap)
?: ?=(%& -.res)
p.res
=. err.block `p.res
`arvo
::
++ site
=/ =room:neo
(got:of-top here)
=| cards=(list card:neo)
|%
++ site .
++ si-emil |=(caz=(list card:neo) site(cards (welp cards caz)))
++ si-abet
:: TODO: bump
=. apex (put:of-top here room)
[cards arvo]
::
++ si-resolve-kids
%- ~(gas by *(map pith vase))
%+ turn ~(tap by (kid:of-top here))
|= [=pith:neo =room:neo]
^- [pith:neo vase]
[pith state.icon.room]
++ si-resolve-deps
%- ~(gas by *(map term [pith cane:neo]))
^- (list [term pith cane:neo])
%+ murn ~(tap by deps:si-firm)
|= [=term required=? =quay:neo]
^- (unit [^term pith cane:neo])
=/ dep=(unit pith) (~(get by conf.room) term)
?~ dep
~| invariant-missing-required-conf/term
?< required
~
=/ =name:neo (de-pith:name:neo u.dep)
=/ val (get-tour -.quay u.dep)
?~ val
~| invariant-no-value-at-path/pith.name
!!
`[term u.dep u.val]
:: TODO type this w/ port??
++ si-bowl
:: =/ hare pith:(de-pith:name:neo here)
:: ~& hare/hare
=/ hare [p/our.bowl here]
[src our.bowl hare hare now.bowl si-resolve-deps si-resolve-kids]
++ si-form ~(. form:si-firm [si-bowl icon.room])
++ si-firm `firm:neo`~(firm husk code.room)
++ si-tell
|= =mode:neo
=. change (~(put by change) here mode)
site
++ si-grab-watch
^- watch:neo
*watch:neo :: [here p.p.span.room [case %init q.state]:icon.room]~
++ si-sync-paths
^- (list path)
=- ~(tap in -)
%- ~(gas in *(set path))
%+ murn ~(val by sup.bowl)
|= [=ship =path]
:: TODO: tighten
^- (unit _path)
?. ?=([%sync *] path)
~
`path
++ si-bump
=. apex (~(anc-jab of:neo apex) here bump-room-tree)
site
++ si-init
|= old=(unit vase)
^+ site
=^ cards=(list card:neo) state.icon.room
(init:si-form old)
=. ever.icon.room [1 1]
=. site si-bump
=. site (si-emil cards)
(si-tell %add)
++ si-poke
|= =pail:neo
^+ site
=^ cards state.icon.room
(poke:si-form pail)
=. site (si-emil cards)
:: XX: maybe skip if no change?
=. ever.icon.room (bump-ever ever.icon.room)
=. site si-bump
(si-tell %dif)
--
--
++ sock
|_ for=@tas
++ spur
^- path
/lib/plan/[for]/hoon
++ resolve
^- path
%+ welp
/(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)
spur
++ sock-vase
.^(vase %ca resolve)
++ plan form:(pike:neo ewer:neo)
++ get
!<(plan sock-vase)
--
++ conn
|= =id:sole
=/ =shell [[our.bowl ~] ~]
=. shells (~(put by shells) id shell)
~(start walk id)
++ tell
|_ =name:neo
++ get
^- (unit room:neo)
?. =(our.bowl ship.name)
~
(get:of-top pith.name)
++ kids (desc 0)
++ ford
=/ rom (need get)
^+ run
=+ !<([vax=(unit vase) *] state.icon.rom)
%. run
?~ vax
(slog leaf/"no ford build here" ~)
(slog leaf/"Ford build" (sell u.vax) ~)
++ desc
=/ dip
?> =(our.bowl ship.name)
(dip:of-top pith.name)
|= depth=@ud
=* loop $
^- (list (list dime))
%- zing
%+ turn ~(tap by kid.dip)
|= [seg=iota ax=(axal:neo room:neo)]
^- (list (list dime))
=. pith.name (snoc pith.name seg)
=/ res ?:(=(depth 0) ~ loop(dip ax, depth +(depth)))
?~ fil.ax
:_ res
~[t/(spat (pout pith.name)) t/'Directory' ud/0]
:_ res
row:item
++ item
=/ rom get
|%
++ code
|= =stud:neo
^- @t
%- spat
^- path
?@ stud
/kelvin/(scot %ud zuse)/[stud]
=, stud
/(scot %p ship)/[desk]/[mark]
++ row
^- (list dime)
?~ rom
~
:~ t/(spat (pout pith.name))
t/(code code.u.rom)
ud/node.ever.icon.u.rom
ud/tree.ever.icon.u.rom
==
--
++ show
^- tang
=/ rom get
%- lure
?~ rom
leaf/"No data"
(sell state.icon.u.rom)
--
++ walk
|_ =id:sole
++ start
abet:prompt:peel
++ drop
^+ run
run(shells (~(del by shells) id))
++ peel
=/ =shell (~(got by shells) id)
|%
++ peel .
++ abet
run(shells (~(put by shells) id shell))
++ tell ~(. ^tell cwd.shell)
++ race (need race.shell)
++ has-race !=(~ race.shell)
++ add-race
|= r=^race
=. race.shell `r
peel
++ del-race
=. race.shell ~
peel
++ prompt
|^
=; ef=shoe-effect:shoe
=. run (shoe-ef ef)
peel
:- %sole
:^ %pro & %foo
^- styx
=, shell
:- [un ~['/' (scot %p ship.cwd)]]
%- snoc
:_ '> '
^- (list @t)
%- zing
^- (list (list @t))
%+ turn pith.cwd
|= =iota:neo
^- (list @t)
=- ~['/' -]
?@ iota iota
(scot iota)
++ un
`styl`[`%un ~ ~]
--
++ cwd
|%
++ get cwd.shell
++ set |=(n=name:neo =.(cwd.shell n prompt))
--
--
++ lily
|* [naf=@ sab=rule]
=+ vex=(sab [1 1] (trip naf))
?~ q.vex ~
[~ u=p.u.q.vex]
++ default-list
^- (list [@t tank])
:~ 'ls'^leaf/"List child shrubs at current path"
'cd'^leaf/"Change directory"
'.'^leaf/"Print node at path"
't'^leaf/"List child shrubs at current path, recursively"
'p'^leaf/"manual poke (takes [=stud val=*])"
'r'^leaf/"start form (takes form-name)"
==
++ tab
|= query=@t
=/ query (trip query)
=+ vex=(parser [1 1] query)
?~ q.vex
default-list
=/ [[? =hull] =nail] u.q.vex
=/ parsed (scag (sub (lent query) (lent q.nail)) query)
|^ ^- (list [@t tank])
?+ -.hull ~
%cd (cd name.hull)
==
++ cd
|= =name:neo
^- (list [@t tank])
=/ dip (dip:of-top pith.name)
=/ last
?:(=(~ pith.name) %$ (rear pith.name))
=/ remove-len (met 3 (show-iota last))
=? pith.name =([~ ~] dip)
(snip pith.name)
=? parsed =([~ ~] dip)
(scag (sub (lent parsed) remove-len) parsed)
=. dip
(dip:of-top pith.name)
?: =(~ kid.dip)
~
%+ turn ~(tap by kid.dip)
|= [seg=iota ax=(axal:neo room:neo)]
^- [@t tank]
:_ *tank
%+ cat 3
:- (crip parsed)
?@ seg seg
(scot seg)
--
++ parser
|^ ^+ |~(nail *(like [? hull]))
%+ stag |
?: has-race:peel
%+ stag %clot
clot
;~ pose
:: (csym %ls (easy ~))
(cold ls/~ (jest 'ls'))
(cold show/~ dot)
(cold ford/~ (jest 'f'))
(stag %tree ;~(pfix (jest 't') dem:ag))
(stag %race ;~(pfix (jest 'r') ace sym))
(stag %poke ;~(pfix (jest 'p') ace van))
::
cd
;~(pfix wut (cold clay/~ (jest 'clay')))
;~(pfix hax (cold comm/~ (star prn)))
==
++ van tall:(vang & /test)
++ cd
:: ^- _|~(nail *(like hull))
:: %+ csym %cd
%+ stag %cd
%+ ifix [(jest 'cd ') (easy ~)]
;~ pose
rule:name:neo
%+ sear
|= [kets=(list *) =pith:neo]
^- (unit name:neo)
=/ cwd get:cwd:peel
=/ up (lent kets)
?: (gth up (lent pith.cwd))
~
=. pith.cwd (scag (sub (lent pith.cwd) up) pith.cwd)
`cwd(pith (welp pith.cwd pith))
;~(plug (star ket) (more fas spot:stip:neo))
==
++ csym
|* [term=* rul=rule]
(stag term ;~(pfix (jest term) rul))
++ clot
:: ^- _|~(nail *(like [? gait]))
=/ race race:peel
^- $-(nail (like clot:goon:neo))
?> ?=(^ grab.race)
?+ scar.i.grab.race !!
%cord (stag %cord (cook crip (star prn)))
%patud (stag %patud dem:ag)
%patp (stag %patp ;~(pfix sig fed:ag))
==
--
++ shoe-ef
|= ef=shoe-effect:shoe
^+ run
(emit %shoe ~[id] ef)
++ do
|= =hull
|^ ^+ run
?- -.hull
%clot abet:(clot:hike clot.hull)
%show (shoe-ef %sole %tan show:tell:peel)
%ls (tree 0)
%cd abet:(set:cwd:peel name.hull)
%tree (tree depth.hull)
%ford ford:tell:peel
%race (do-race rout.hull)
%poke (do-poke p.hull)
%comm run
%clay clay
==
++ do-poke
|= =hoon
=/ vax=vase
(slap (slop !>(..zuse) (with-face:ford %neo !>(neo))) hoon)
=+ !<([=stud:neo rest=*] vax)
=. vax (slot 3 vax)
(on-card (en-pith:name:neo get:cwd:peel) %poke stud vax)
++ clay
=/ rom (got:of-top pith:get:cwd:peel)
=+ !<([cac=(unit vase) *] state.icon.rom)
=/ desc=@t
?~ cac
'No cache'
'Has cache'
=/ sho=shoe-effect:shoe
[%sole %klr ~[desc]]
(shoe-ef sho)
++ do-race
|= rout=@tas
^+ run
=/ bad=shoe-effect:shoe
[%sole %klr ~['No pokes here']]
=/ cwd get:cwd:peel
?~ rom=(get:of-top pith.cwd)
(shoe-ef bad)
=/ =plan:sock ~(get sock rout)
=/ =race [rout plan ~ ~]
=. run abet:(add-race:peel rout plan ~ ~)
abet:start:hike
++ tree
|= dep=@ud
%- shoe-ef
:- %table
:+ (limo tas/%path tas/%code tas/%node tas/%tree ~)
(limo 40 40 6 6 ~)
(desc:tell:peel dep)
--
++ hike
=/ =race race:peel
|%
++ abet `_run`?~(grab.race abet:del-race:peel abet:(add-race:peel race))
++ make-bowl
`bowl:pike:neo`[our.bowl get:cwd:peel eny.bowl now.bowl]
++ hike .
++ start ^+(hike (take ~))
++ clot
|= =clot:goon:neo
^+ hike
=. have.race (snoc have.race clot)
=. grab.race
?> ?=(^ grab.race)
t.grab.race
?^ grab.race
show-grab
=/ have have.race
=. have.race ~
(take `[%grab have])
++ take
|= syn=(unit sign:pike:neo)
|- ^+ hike
=/ pike (pike:neo pail:neo)
=^ res=eval-result:pike form.race
(take:pike form.race [make-bowl syn])
?- -.res
%done
=/ =pith:neo (en-pith:name:neo get:cwd:peel)
=/ =card:neo [pith %poke value.res]
=. run (on-card card)
=; ef=shoe-effect:shoe
=. run (shoe-ef ef)
hike
:+ %sole %klr
=/ =styl [~ ~ `%g]
=/ txt=styx ~['Poke success']
`styx`~[styl^txt]
::
%fail
=. races (~(del by races) id)
hike
%emit
?- -.car.res
:: TODO: actually scry
%peek $(syn `[%peek addr-info/!>(['New York' 'NY'])])
%grab
=. grab.race items.car.res
show-grab
==
==
++ show-grab
|- ^+ hike
?~ grab.race
hike
=/ =item:pike:neo i.grab.race
=; ef=shoe-effect:shoe
=. run (shoe-ef ef)
hike
:+ %sole %klr
~[(crip "{(trip lede.item)}: {(trip info.item)}")]
--
:: ++ start
:: |= soc=@tas
:: ^+ run
:: =/ =race
:: [soc ~(form sock soc) ~ ~]
:: =. races (~(put by races) id race)
:: (take ~)
:: ?~
:: =/ =wire /race/(scot %p who.id)/[ses.id]
:: (emit %pass wire %agent [
--
--