@@ -0,0 +1,169 @@
1+/- s=seek
2+/+ default-agent, verb, dbug
3+/+ *seek
4+/+ sift
5+^- agent:gall
6+=>
7+ |%
8+ +$ card card:agent:gall
9+ +$ state-0
10+ $: %0
11+ =lookup:s
12+ =trail:s
13+ =directory:s
14+ published=directory:s
15+ ==
16+ --
17+=| state-0
18+=* state -
19+=<
20+ %+ verb &
21+ %- agent:dbug
22+ |_ =bowl:gall
23+ +* this .
24+ def ~(. (default-agent this %.n) bowl)
25+ cor ~(. +> [bowl ~])
26+ ++ on-init
27+ ^- (quip card _this)
28+ =^ cards state
29+ abet:init:cor
30+ [cards this]
31+ ::
32+ ++ on-save !>(state)
33+ ++ on-load
34+ |= =vase
35+ ^- (quip card _this)
36+ =/ old=(unit state-0)
37+ (mole |.(!<(state-0 vase)))
38+ ?^ old `this(state u.old)
39+ ~& >>> "Incompatible load, nuking"
40+ =^ cards this on-init
41+ :_ this
42+ =- (welp - cards)
43+ %+ turn ~(tap in ~(key by wex.bowl))
44+ |= [=wire =ship =term]
45+ ^- card
46+ [%pass wire %agent [ship term] %leave ~]
47+ ::
48+ ++ on-poke
49+ |= [=mark =vase]
50+ ^- (quip card _this)
51+ =^ cards state
52+ abet:(poke:cor mark vase)
53+ [cards this]
54+ ++ on-watch
55+ |= =path
56+ ^- (quip card _this)
57+ =^ cards state
58+ abet:(watch:cor path)
59+ [cards this]
60+ ::
61+ ++ on-peek peek:cor
62+ ::
63+ ++ on-leave on-leave:def
64+ ++ on-fail on-fail:def
65+ ::
66+ ++ on-agent
67+ |= [=wire =sign:agent:gall]
68+ ^- (quip card _this)
69+ =^ cards state
70+ abet:(agent:cor wire sign)
71+ [cards this]
72+ ++ on-arvo
73+ |= [=wire sign=sign-arvo]
74+ ^- (quip card _this)
75+ =^ cards state
76+ abet:(arvo:cor wire sign)
77+ [cards this]
78+ --
79+|_ [=bowl:gall cards=(list card)]
80+++ abet [(flop cards) state]
81+++ cor .
82+++ emit |=(=card cor(cards [card cards]))
83+++ give |=(=gift:agent:gall (emit %give gift))
84+++ init
85+ ^+ cor
86+ cor
87+++ poke
88+ |= [=mark =vase]
89+ |^ ^+ cor
90+ ?+ mark ~|(bad-poke/mark !!)
91+ %directory-notice
92+ =+ !<(=notice:s vase)
93+ (publish notice)
94+ ==
95+ ++ publish
96+ |= =notice:s
97+ ^+ cor
98+ ?> =(src.bowl source.q.notice)
99+ ?> =(p.notice (digest q.notice))
100+ di-abet:(di-init:(di-abed:di-core p.notice) q.notice)
101+ --
102+::
103+++ watch
104+ |= =path
105+ ^+ cor
106+ cor
107+++ agent
108+ |= [=wire =sign:agent:gall]
109+ ^+ cor
110+ cor
111+++ arvo
112+ |= [=wire sign=sign-arvo]
113+ ^+ cor
114+ ~& arvo/wire
115+ cor
116+++ peek
117+ |= =path
118+ ^- (unit (unit cage))
119+ ?+ path [~ ~]
120+ [%x %lookup @ ~]
121+ =- ``listings+!>(-)
122+ ^- (list listing:s)
123+ %+ turn
124+ %+ turn
125+ %+ sort (~(gut by lookup) i.t.t.path *(list entry:s))
126+ |= [a=entry:s b=entry:s]
127+ (gte rank.a rank.b)
128+ |=(=entry:s hash.entry)
129+ |= =hash:s
130+ (~(got by directory) hash)
131+ ::
132+ ==
133+::
134+++ from-self =(our src):bowl
135+++ di-core
136+ |_ [=listing:s =hash:s]
137+ ++ di-core .
138+ ++ di-abet
139+ cor(directory (~(put by directory) hash listing))
140+ ++ di-abed
141+ |= h=hash:s
142+ di-core(hash h, listing (~(gut by directory) h *listing:s))
143+ ++ di-init
144+ |= l=listing:s
145+ =. listing l
146+ =/ entries=lookup:s
147+ %- malt
148+ %- zing
149+ :~ ~[[title.l ~[[hash rank=0]]]]
150+ %+ turn
151+ tags.l
152+ |= tag=@t
153+ [tag ~[[hash rank=1]]]
154+ %+ turn
155+ (sift:sift description.l)
156+ |= word=@t
157+ [word ~[[hash rank=2]]]
158+ ==
159+ ~& -:!>(entries)
160+ ~& -:!>(lookup)
161+ =. lookup
162+ %- ~(uni by entries)
163+ %- ~(rut by lookup)
164+ |= [=key:s value=(list entry:s)]
165+ ?. (~(has by entries) key) value
166+ (weld value (~(got by entries) key))
167+ di-core
168+ --
169+--