@@ -0,0 +1,445 @@
2+title = "Scry Reference"
7+The various clay scries are specified by a `care`, which is a single character that corresponds with a clay submodule. Apart from `%s` they just take a path to a desk, file or directory. All examples are dojo commands, the ='s in the path are automatically populated by the dojo like:
11+[~.~zod ~.home ~.~2021.4.26..02.29.03..d31b ~]
16+- [`a`](#a) - Build a hoon file.
17+- [`b`](#b) - Dynamic mark.
18+- [`c`](#c) - Dynamic mark conversion.
19+- [`d`](#d) - List desks.
20+- [`e`](#e) - Static mark.
21+- [`f`](#f) - Static mark conversion.
22+- [`p`](#p) - File permissions.
23+- [`r`](#r) - Vase-wrapped file data.
24+- [`s`](#s) - Miscellaneous scries:
25+ - [`yaki`](#yaki) - `yaki:clay` of the specified commit.
26+ - [`blob`](#blob) - `blob:clay` of file.
27+ - [`hash`](#hash) - Content hash of the specified commit.
28+ - [`cage`](#cage) - `cage` of the data of a file.
29+ - [`open`](#open) - Compile prelude of file.
30+ - [`late`](#late) - Most recent case of desk.
31+ - [`base`](#base) - Mergebase of two desks.
32+- [`t`](#t) - List files in directory.
33+- [`u`](#u) - Check for existence of file.
34+- [`v`](#v) - Desk state.
35+- [`w`](#w) - Revision number of the given desk case.
36+- [`x`](#x) - Raw data of file.
37+- [`y`](#y) - `arch` of a file or directory.
38+- [`z`](#z) - Content hash of a file or directory.
42+A scry with a care of `%a` will build a hoon file and return it as a `vase`.
47+.^(vase %ca /===/lib/strandio/hoon)
52+A scry with a care of `%b` will produce a `dais:clay` processed mark core for the specified mark. The `path` in the scry is a `mark`.
57+.^(dais:clay %cb /===/txt)
62+A scry with a care of `%c` will produce a `tube:clay` dynamically typed mark conversion gate. The `path` specifies two marks - *from* and *to*, like `/txt/noun`.
67+> =a .^(tube:clay %cc /===/txt/mime)
68+> !< mime (a !>(~['foo']))
69+[p=/text/plain q=[p=3 q=7.303.014]]
74+A scry with a care of `%d` will return a `(set desk)` of the desks that exist on your ship.
79+> .^((set desk) %cd /===)
85+A scry with a care of `%e` will return a statically typed `nave:clay` mark core in a `vase`. The `path` in the scry specifies the `mark`.
90+.^(vase %ce /===/noun)
95+A scry with a care of `%f` will return a static mark conversion gate. The `path` specifies two marks - *from* and *to*, like `/txt/mime`.
98+> =a .^($-(text mime) %cf /===/txt/mime)
100+[p=/text/plain q=[p=3 q=7.303.014]]
105+A scry with a care of `%p` will return the permissions of the file or directory in question. The type returned is a `[dict:clay dict:clay]` where the head is read permissions and the tail is write permissions.
110++$ dict [src=path rul=real]
117+ $: mod=?(%black %white)
118+ who=(pair (set ship) (map @ta crew))
124+- `mod` specifies either a **black**list or a **white**list.
126+ - the set of allowed/disallowed ships.
127+ - allowed/disallowed named crews (a crew is just a set of ships) - basically groups.
129+If the specified file or directory has no permissions set, it will default to the permissions of its parent. If nothing above it has permissions set, it will default to empty whitelists. If the specified file or directory doesn't exist, it will also return the default empty whitelist.
134+> .^([dict:clay dict:clay] %cp /===/gen)
135+[[src=/ rul=[mod=%white who=[p={} q={}]]] src=/ rul=[mod=%white who=[p={} q={}]]]
140+A scry with a care of `%r` will return the data of the given file wrapped in a vase or crash if it's a directory. It's basically just a vase-wrapped `x`.
145+> .^(vase %cr /===/gen/hood/hi/hoon)
148+ 3.548.750.706.400.251.607.252.023.288.575.526.190.856.734.474.077.821.289.791.377.301.707.878.697.553.411.219.689.905.949.957.893.633.811.025.757.107.990.477.902.858.170.125.439.223.250.551.937.540.468.638.902.955.378.837.954.792.031.592.462.617.422.136.386.332.469.076.584.061.249.923.938.374.214.925.312.954.606.277.212.923.859.309.330.556.730.410.200.952.056.760.727.611.447.500.996.168.035.027.753.417.869.213.425.113.257.514.474.700.810.203.348.784.547.006.707.150.406.298.809.062.567.217.447.347.357.039.994.339.342.906
153+> !< @t .^(vase %cr /===/gen/hood/hi/hoon)
154+':: Helm: send message to an urbit\0a::\0a:::: /hoon/hi/hood/gen\0a ::\0a/? 310\0a:- %say\0a|=([^ [who=ship mez=$@(~ [a=tape ~])] ~] helm-send-hi+[who ?~(mez ~ `a.mez)])\0a'
158+> .^(vase %cr /===/gen)
164+A scry with a care of `%s` is more complex than the rest. Rather than just a path to a file, the path has a head of one of `%yaki %blob %hash %cage %open %late %base`. The rest of the path will depend on which of these tags you use. We'll look at each in turn. Note that `%s` is miscellaneous internal and debug functions and is liable to change in the future.
168+This will return the `yaki:clay` of the specified commit. It takes a `tako:clay`.
172+Here we scry the `dome:clay` for `/===`, get the latest `tako:clay` and the do a `%s` scry for the `yaki:clay` in question.
175+> =/ =dome:clay .^(dome:clay %cv /===)
176+ =/ =tako:clay (~(got by hit.dome) let.dome)
177+ .^(yaki:clay %cs /===/yaki/(scot %uv tako))
178+[ p=~[80.174.473.756.485.530.520.259.753.935.584.637.641.665.425.899.348.092.348.244.635.557.986.495.151.006]
180+ { [p=/mar/hark/graph-hook-update/hoon q=0v5.ea0bj.21s5c.mjrop.ishic.fpkvl.e5bbs.91kc9.tdo41.ifi06.60v41]
181+ [p=/gen/hood/autocommit/hoon q=0v19.rh7jv.sa67o.t3jrb.4sdvs.7c45f.pv2u0.ragik.psp20.agqd8.8srkj]
183+ [p=/tests/lib/primitive-rsa/hoon q=0v1g.3qmq3.6i15q.arh6h.lfsqu.gvc9m.ql6m5.e2rdr.vnnt9.tptc6.mv9u7]
184+ [p=/tests/sys/vane/gall/hoon q=0va.alspc.qptqn.7tuj0.bgecg.1093t.gtsjs.up03k.d1fmk.4jrh8.2tdfa]
186+ r=88.666.797.531.755.181.802.690.473.856.185.443.710.929.766.582.249.039.904.824.278.074.149.777.897.099
187+ t=~2021.4.16..10.41.57..3565
193+This will return the `blob:clay` of some file. It takes a `lobe:clay`.
197+Here we grab the `lobe:clay` of `/gen/hood/hi/hoon` with a `%y` scry, then use it to do a `%s` scry for the `blob:clay` of the file.
200+> =/ =arch .^(arch %cy /===/gen/hood/hi/hoon)
203+ .^(blob:clay %cs /===/blob/(scot %uv u.fil.arch))
205+ p=0vp.k7nsm.qkdr3.t17rp.33bae.8gajg.v27gi.40itr.2u9qa.nppbt.7k255
209+3.548.750.706.400.251.607.252.023.288.575.526.190.856.734.474.077.821.289.791.377.301.707.878.697.553.411.219.689.905.949.957.893.633.811.025.757.107.990.477.902.858.170.125.439.223.250.551.937.540.468.638.902.955.378.837.954.792.031.592.462.617.422.136.386.332.469.076.584.061.249.923.938.374.214.925.312.954.606.277.212.923.859.309.330.556.730.410.200.952.056.760.727.611.447.500.996.168.035.027.753.417.869.213.425.113.257.514.474.700.810.203.348.784.547.006.707.150.406.298.809.062.567.217.447.347.357.039.994.339.342.906
216+This will return the `@uvI` content hash of the specified commit. It takes a `tako:clay`.
220+Here we grab the `dome:clay` for `/===` with a `%v` scry, get the latest `tako:clay` and then do a `%s` `%hash` scry for it.
223+> =/ =dome:clay .^(dome:clay %cv /===)
224+ =/ =tako:clay (~(got by hit.dome) let.dome)
225+ .^(tako:clay %cs /===/hash/(scot %uv tako))
226+0v16.er7uq.oke4u.cru7u.nglu9.q3su7.6ub1o.bh4qk.r5uav.ut12d.5rdl5
231+This will return a `cage` of the data of some file. It takes a `lobe:clay`.
235+Here we grab the `lobe:clay` of `/gen/hood/hi/hoon` with a `%y` scry, then use it to do a `%s` scry for the `cage` of the data.
238+> =/ =arch .^(arch %cy /===/gen/hood/hi/hoon)
241+ .^(cage %cs /===/cage/(scot %uv u.fil.arch))
246+3.548.750.706.400.251.607.252.023.288.575.526.190.856.734.474.077.821.289.791.377.301.707.878.697.553.411.219.689.905.949.957.893.633.811.025.757.107.990.477.902.858.170.125.439.223.250.551.937.540.468.638.902.955.378.837.954.792.031.592.462.617.422.136.386.332.469.076.584.061.249.923.938.374.214.925.312.954.606.277.212.923.859.309.330.556.730.410.200.952.056.760.727.611.447.500.996.168.035.027.753.417.869.213.425.113.257.514.474.700.810.203.348.784.547.006.707.150.406.298.809.062.567.217.447.347.357.039.994.339.342.906
253+This is like an `%a` scry but it only compiles the prelude to the file, eg. the ford rune imports. Proper documentation for this will be done as part of ford documentaton at a later date.
257+This will return the most recent revision number of a desk that has been fully downloaded. The type it returns is a `cass:clay`. The case in the `beak` must be a revision number rather than a date. You can just provide a case of `1` since it returns the latest regardless. If we have nothing for the specified desk, this will just return the bunt of a `cass:clay` like `cass=[ud=0 da=~2000.1.1]`
262+> .^(=cass:clay %cs /(scot %p (sein:title our now our))/kids/1/late)
263+cass=[ud=50 da=~2021.4.22..10.38.50..57a8]
267+> .^(=cass:clay %cs /~sampel/kids/1/late)
268+cass=[ud=0 da=~2000.1.1]
273+This will return the mergebase (i.e. most recent common ancestor) between two desks. The type it returns is a `(list tako:clay)`. The first desk will just be the one in the `beak` path prefix and the second will be specified like `/ship/desk` at the end of the scry path. If there is no common ancestor between the two desks, this will just produce an empty list.
278+> .^((list tako:clay) %cs /===/base/(scot %p (sein:title our now our))/kids)
279+~[102.787.244.596.033.419.950.995.540.301.493.841.569.518.772.322.508.085.465.561.801.703.148.627.263.473]
283+> .^((list tako:clay) %cs /===/base/~sampel/kids)
289+A scry with a care of `%t` will return a `(list path)` of all files in the given directory, or just a `(list path)` of the single file if it's a file. This is done recursively so will provide files in sub-directories as well. The paths will be fully qualified except for the ship, desk and case. If the directory or file specified does not exist, it will return null.
294+> .^((list path) %ct /===/app/landscape)
296+ /app/landscape/css/index/css
297+ /app/landscape/img/favicon/png
298+ /app/landscape/img/imageupload/png
299+ /app/landscape/img/touch_icon/png
300+ /app/landscape/index/html
301+ /app/landscape/js/channel/js
306+> .^((list path) %ct /===/gen/group-store/add/hoon)
307+~[/gen/group-store/add/hoon]
311+> .^((list path) %ct /===/foobar)
317+A scry with a care of `%u` will return a `?` depending on whether the file exists. It will produce `%.n` if it's a directory or doesn't exist and will produce `%.y` if it's a file and exists.
327+> .^(? %cu /===/gen/code/hoon)
332+> .^(? %cu /===/foobar)
338+A scry with a care of `%v` will return the entire state of a desk as a `dome:clay`.
343+> =a .^(dome:clay %cv /===)
348+If you try printing this it will take forever and probably OOM your ship.
352+A scry with a care of `%w` will return the revision number and date of a given case. The type returned is a `cass:clay` like `[ud=@ud da=@da]` where `ud` is the revision number and `da` is the date.
357+> .^(cass:clay %cw /===)
358+[ud=2 da=~2021.4.13..19.12.49..3389]
363+A scry with a care of `%x` will return the raw data of a file as an `@` or crash if it's a directory.
369+> .^(@ %cx /===/gen/hood/hi/hoon)
370+3.548.750.706.400.251.607.252.023.288.575.526.190.856.734.474.077.821.289.791.377.301.707.878.697.553.411.219.689.905.949.957.893.633.811.025.757.107.990.477.902.858.170.125.439.223.250.551.937.540.468.638.902.955.378.837.954.792.031.592.462.617.422.136.386.332.469.076.584.061.249.923.938.374.214.925.312.954.606.277.212.923.859.309.330.556.730.410.200.952.056.760.727.611.447.500.996.168.035.027.753.417.869.213.425.113.257.514.474.700.810.203.348.784.547.006.707.150.406.298.809.062.567.217.447.347.357.039.994.339.342.906
374+> .^(@t %cx /===/gen/hood/hi/hoon)
375+':: Helm: send message to an urbit\0a::\0a:::: /hoon/hi/hood/gen\0a ::\0a/? 310\0a:- %say\0a|=([^ [who=ship mez=$@(~ [a=tape ~])] ~] helm-send-hi+[who ?~(mez ~ `a.mez)])\0a'
379+> .^(@ %cx /===/gen/hood)
385+A scry with a care of `%y` will return the `arch` of a file or directory.
387+An `arch` is a `[fil=(unit lobe:clay) dir=(map @ta ~)]`. The `fil` will contain the `lobe:clay` hash if it's a file, otherwise will be null. The `dir` will contain a map of the files and directories it contains, otherwise will be null.
389+It will return the bunt of an arch—`[fil=~ dir={}]`—if the file or directory is not found.
394+> .^(arch %cy /===/gen/group-store)
397+ { [p=~.allow-ships q=~]
403+ [p=~.allow-ranks q=~]
410+> .^(arch %cy /===/gen/group-store/allow-ships)
411+[fil=~ dir={[p=~.hoon q=~]}]
415+> .^(arch %cy /===/gen/group-store/allow-ships/hoon)
416+[fil=[~ 0vb.g8sqs.7gjm9.bl3vu.nk677.h5be1.g9eg3.4v1jo.00ivf.g8ndu.48a53] dir={}]
420+> .^(arch %cy /===/foobar)
426+A scry with a care of `%z` will return the hash of a file or the recursive hash of a directory. If the file or directory doesn't exist it will return a null value.
428+The type returned is a `@uxI`.
433+> .^(@uvI %cz /===/gen)
434+0v5.itmhj.lt7ak.lgr1k.dr7vu.u7u9s.ko5rf.idfcr.ukrd2.t088n.3ml1k
438+> .^(@uvI %cz /===/gen/code/hoon)
439+0v1t.vi1pf.3ba4n.87g6h.dcc1p.4t4l8.rm6a9.b4de4.v77qc.p9dc0.p8289
443+> .^(@uvI %cz /===/foobar)