pico-engine 1.6.4 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -9
- package/dist/RulesetRegistryLoaderFs.js +60 -6
- package/dist/auth/cookies.js +32 -0
- package/dist/auth/index.js +6 -1
- package/dist/channelIdentityPolicy.js +22 -0
- package/dist/cli.js +106 -69
- package/dist/engineConfig.js +291 -0
- package/dist/identity/IdentityService.js +90 -0
- package/dist/identity/crossPico.js +24 -8
- package/dist/identity/didoModule.js +80 -18
- package/dist/identity/establishSubscription.js +2 -2
- package/dist/identity/identityPortable.js +92 -0
- package/dist/identity/index.js +10 -1
- package/dist/identity/localPeerReconcile.js +65 -0
- package/dist/identity/peerDid4.js +175 -0
- package/dist/identity/peerDid4Create.js +90 -0
- package/dist/identity/portableExportPrepare.js +196 -0
- package/dist/identity/portableMove.js +87 -0
- package/dist/identity/skyIntro.js +6 -3
- package/dist/identity/skyProtocol.js +26 -1
- package/dist/identity/skyRotation.js +121 -0
- package/dist/identity/store.js +5 -1
- package/dist/identity/subscriptionEntSync.js +72 -0
- package/dist/identity/veramoDidComm.js +41 -2
- package/dist/identity/webvh.js +4 -2
- package/dist/identity/webvhRelocation.js +115 -0
- package/dist/index.js +84 -27
- package/dist/logging.js +156 -16
- package/dist/oauth/OAuthService.js +6 -2
- package/dist/policyConfigFromJson.js +112 -0
- package/dist/runMcp.js +27 -0
- package/dist/server.js +261 -24
- package/dist/stageKrl.js +26 -0
- package/dist/subtreeWrangler.js +180 -0
- package/dist/uiChannelPolicies.js +15 -0
- package/dist/xmluiRuntime.js +68 -0
- package/krl/io.picolabs.oauth.krl +41 -2
- package/krl/io.picolabs.pds.krl +131 -10
- package/krl/io.picolabs.pico-engine-ui.krl +217 -94
- package/krl/io.picolabs.portable_subtree.krl +97 -0
- package/krl/io.picolabs.subscription.krl +180 -72
- package/krl/io.picolabs.wrangler.krl +313 -57
- package/krl/io.picolabs.xmlui.krl +295 -0
- package/mcp/devResources.js +118 -0
- package/mcp/devTools.js +351 -0
- package/mcp/engineClient.js +133 -0
- package/mcp/meshHttp.js +137 -0
- package/mcp/meshTools.js +189 -0
- package/mcp/runStdio.js +34 -0
- package/mcp/schemaToZod.js +56 -0
- package/package.json +24 -9
- package/public/.DS_Store +0 -0
- package/public/docs/_sidebar.md +3 -1
- package/public/docs/llms-full.txt +630 -0
- package/public/docs/llms.txt +38 -0
- package/public/docs/openapi.yaml +78 -0
- package/public/docs/pico-engine.md +239 -4
- package/public/docs/pico-overview.md +117 -0
- package/public/docs/pico-views-xmlui.md +5 -0
- package/public/docs/pico-views.md +140 -0
- package/public/docs/pico.md +3 -1
- package/public/docs/rulesets/README.md +26 -0
- package/public/docs/rulesets/io.picolabs.oauth.md +71 -0
- package/public/docs/rulesets/io.picolabs.pds.md +327 -0
- package/public/docs/rulesets/io.picolabs.pico-engine-ui.md +65 -0
- package/public/docs/rulesets/io.picolabs.portable_subtree.md +94 -0
- package/public/docs/rulesets/io.picolabs.subscription.md +398 -0
- package/public/docs/rulesets/io.picolabs.wrangler.md +471 -0
- package/public/pico-engine-ui.css +1 -1
- package/public/pico-engine-ui.js +27 -23
- package/public/xmlui/0.12.7.js +419 -0
- package/public/xmlui/pico-view-boot.js +153 -0
- package/src/RulesetRegistryLoaderFs.ts +66 -7
- package/src/auth/cookies.ts +34 -0
- package/src/auth/index.ts +7 -0
- package/src/channelIdentityPolicy.ts +29 -0
- package/src/cli.ts +70 -37
- package/src/engineConfig.ts +363 -0
- package/src/identity/IdentityService.ts +189 -1
- package/src/identity/crossPico.ts +57 -8
- package/src/identity/didoModule.ts +140 -23
- package/src/identity/establishSubscription.ts +2 -2
- package/src/identity/identityPortable.ts +153 -0
- package/src/identity/index.ts +14 -0
- package/src/identity/localPeerReconcile.ts +97 -0
- package/src/identity/peerDid4.ts +197 -0
- package/src/identity/peerDid4Create.ts +121 -0
- package/src/identity/portableExportPrepare.ts +302 -0
- package/src/identity/portableMove.ts +193 -0
- package/src/identity/skyIntro.ts +11 -11
- package/src/identity/skyProtocol.ts +46 -0
- package/src/identity/skyRotation.ts +211 -0
- package/src/identity/store.ts +5 -1
- package/src/identity/subscriptionEntSync.ts +97 -0
- package/src/identity/veramoDidComm.ts +52 -2
- package/src/identity/webvh.ts +4 -4
- package/src/identity/webvhRelocation.ts +167 -0
- package/src/index.ts +123 -31
- package/src/logging.ts +173 -18
- package/src/oauth/OAuthService.ts +11 -3
- package/src/policyConfigFromJson.ts +131 -0
- package/src/runMcp.ts +30 -0
- package/src/server.ts +328 -27
- package/src/stageKrl.ts +26 -0
- package/src/subtreeWrangler.ts +278 -0
- package/src/uiChannelPolicies.ts +15 -0
- package/src/xmluiRuntime.ts +66 -0
- package/krl/io.picolabs.did-o.krl +0 -349
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
ruleset io.picolabs.xmlui {
|
|
2
|
+
meta {
|
|
3
|
+
name "XMLUI views"
|
|
4
|
+
description "Optional ruleset for pico views (XMLUI): file(), markup helpers, app channels."
|
|
5
|
+
author "PICOLABS"
|
|
6
|
+
|
|
7
|
+
use module io.picolabs.wrangler alias wrangler
|
|
8
|
+
|
|
9
|
+
provides query_url, event_url, query, event, escape, app_url, create_app_channel, rotate_app_channel, xmluiRuntimePath
|
|
10
|
+
shares file, query_url, event_url, query, event, escape, app_url, xmluiRuntimePath
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
global {
|
|
14
|
+
xmluiRuntimeVersion = "0.12.7"
|
|
15
|
+
xmluiFileRid = "io.picolabs.xmlui"
|
|
16
|
+
|
|
17
|
+
xmluiRuntimePath = function() {
|
|
18
|
+
"/xmlui/" + xmluiRuntimeVersion + ".js"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
query_url = function(name, rid, eci) {
|
|
22
|
+
"/sky/query/" + (eci || meta:eci) + "/" + (rid || meta:rid) + "/" + name
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
event_url = function(domain, type, eci) {
|
|
26
|
+
"/sky/event/" + (eci || meta:eci) + "/xmlui/" + domain + "/" + type
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
escape = function(s) {
|
|
30
|
+
s.replace("&", "&")
|
|
31
|
+
.replace("<", "<")
|
|
32
|
+
.replace(">", ">")
|
|
33
|
+
.replace("\"", """)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
escapeAttr = function(s) {
|
|
37
|
+
escape(s)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
queryArgsSuffix = function(args) {
|
|
41
|
+
args.isnull() || args == {} => "" |
|
|
42
|
+
args.keys().length() == 0 => "" |
|
|
43
|
+
"?" + args.keys()
|
|
44
|
+
.sort()
|
|
45
|
+
.map(function(k) {
|
|
46
|
+
k + "=" + args{k}
|
|
47
|
+
})
|
|
48
|
+
.join("&")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param id DataSource id
|
|
53
|
+
* @param name shared query name on app_rid
|
|
54
|
+
* @param opts rid, args (map, values may be XMLUI bindings), select
|
|
55
|
+
*/
|
|
56
|
+
query = function(id, name, opts) {
|
|
57
|
+
"<DataSource id=\"" + escapeAttr(id) + "\" url=\"" +
|
|
58
|
+
escapeAttr(
|
|
59
|
+
query_url(
|
|
60
|
+
name,
|
|
61
|
+
(opts.defaultsTo({}){"rid"} || meta:rid),
|
|
62
|
+
meta:eci
|
|
63
|
+
) + queryArgsSuffix(opts.defaultsTo({}){"args"})
|
|
64
|
+
) +
|
|
65
|
+
"\" headers=\"{appGlobals.auth}\"" +
|
|
66
|
+
(opts.defaultsTo({}){"select"}.isnull() => "" |
|
|
67
|
+
" resultSelector=\"" + escapeAttr(opts.defaultsTo({}){"select"}) + "\"") +
|
|
68
|
+
" />"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @param id APICall id
|
|
73
|
+
* @param opts refresh (array of DataSource ids), confirm
|
|
74
|
+
*/
|
|
75
|
+
event = function(id, domain, type, opts) {
|
|
76
|
+
"<APICall id=\"" + escapeAttr(id) + "\" method=\"post\" url=\"" +
|
|
77
|
+
escapeAttr(event_url(domain, type, meta:eci)) +
|
|
78
|
+
"\" headers=\"{appGlobals.auth}\" body=\"{$param}\"" +
|
|
79
|
+
(opts.defaultsTo({}){"refresh"}.isnull() => "" |
|
|
80
|
+
" onSuccess=\"" + opts.defaultsTo({}){"refresh"}.map(function(ds) {
|
|
81
|
+
ds + ".refetch()"
|
|
82
|
+
}).join(";") + "\"") +
|
|
83
|
+
(opts.defaultsTo({}){"confirm"}.isnull() => "" |
|
|
84
|
+
" confirm=\"" + escapeAttr(opts.defaultsTo({}){"confirm"}) + "\"") +
|
|
85
|
+
" />"
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
newestChannelWithTags = function(tags) {
|
|
89
|
+
wrangler:channels(tags).sort(function(a, b) {
|
|
90
|
+
a{"id"} cmp b{"id"}
|
|
91
|
+
}).reverse().head()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
app_url = function(tags, app_rid) {
|
|
95
|
+
newestChannelWithTags(tags).isnull() => null |
|
|
96
|
+
"/ui/" + newestChannelWithTags(tags){"id"} + "/" +
|
|
97
|
+
(app_rid || meta:rid) + "/"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
shareNamesForApp = function(app_rid) {
|
|
101
|
+
wrangler:rulesetSchema(app_rid){"queries"}
|
|
102
|
+
.defaultsTo([])
|
|
103
|
+
.map(function(q) {
|
|
104
|
+
q{"name"}
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
queryPolicyForApp = function(app_rid, queries) {
|
|
109
|
+
(queries.isnull() => shareNamesForApp(app_rid) | queries)
|
|
110
|
+
.map(function(q) {
|
|
111
|
+
{ "rid": app_rid, "name": q }
|
|
112
|
+
})
|
|
113
|
+
.append([{ "rid": xmluiFileRid, "name": "file" }])
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
eventPolicyForDomains = function(domains) {
|
|
117
|
+
{
|
|
118
|
+
"allow": domains.map(function(d) {
|
|
119
|
+
{ "domain": d, "name": "*" }
|
|
120
|
+
}),
|
|
121
|
+
"deny": []
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
create_app_channel = defaction(tags, domains, queries, app_rid) {
|
|
126
|
+
wrangler:createChannel(
|
|
127
|
+
tags,
|
|
128
|
+
eventPolicyForDomains(domains.defaultsTo([])),
|
|
129
|
+
{
|
|
130
|
+
"allow": queryPolicyForApp(app_rid || meta:rid, queries),
|
|
131
|
+
"deny": []
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
rotate_app_channel = defaction(tags) {
|
|
137
|
+
template = newestChannelWithTags(tags)
|
|
138
|
+
wrangler:createChannel(
|
|
139
|
+
template{"tags"},
|
|
140
|
+
template{"eventPolicy"},
|
|
141
|
+
template{"queryPolicy"}
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
viewComponentName = function(fn) {
|
|
146
|
+
fn.substr(0, 1).uc() + fn.substr(1)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
viewQueriesOnChannel = function(app_rid) {
|
|
150
|
+
wrangler:channelSchema(meta:eci){"queries"}
|
|
151
|
+
.defaultsTo([])
|
|
152
|
+
.filter(function(q) {
|
|
153
|
+
q{"rid"} == app_rid && not q{"view"}.isnull()
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
launcherRids = function() {
|
|
158
|
+
wrangler:channelSchema(meta:eci){"queries"}
|
|
159
|
+
.defaultsTo([])
|
|
160
|
+
.filter(function(q) {
|
|
161
|
+
not q{"view"}.isnull()
|
|
162
|
+
})
|
|
163
|
+
.map(function(q) {
|
|
164
|
+
q{"rid"}
|
|
165
|
+
})
|
|
166
|
+
.sort()
|
|
167
|
+
.reduce(function(acc, rid) {
|
|
168
|
+
acc >< rid => acc | acc.append(rid)
|
|
169
|
+
}, [])
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
pageRoute = function(view, fn, multiView) {
|
|
173
|
+
not view{"path"}.isnull() => view{"path"} |
|
|
174
|
+
multiView => "/" + fn | "/"
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
navVisible = function(view) {
|
|
178
|
+
view{"path"}.isnull() => true |
|
|
179
|
+
view{"path"}.split(":").length() == 1
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
firstNavViewQuery = function(app_rid) {
|
|
183
|
+
viewQueriesOnChannel(app_rid).filter(function(q) {
|
|
184
|
+
navVisible(q{"view"})
|
|
185
|
+
}).head()
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
fallbackWhenNoNavViews = function(multiView) {
|
|
189
|
+
not multiView => "/" | "/"
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
fallbackPathForApp = function(app_rid, multiView) {
|
|
193
|
+
nav = firstNavViewQuery(app_rid)
|
|
194
|
+
nav.isnull() => fallbackWhenNoNavViews(multiView) |
|
|
195
|
+
pageRoute(nav{"view"}, nav{"name"}, multiView)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
multiViewForApp = function(app_rid) {
|
|
199
|
+
viewQueriesOnChannel(app_rid).length() > 1
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
appRulesetName = function(app_rid) {
|
|
203
|
+
wrangler:rulesetMeta(app_rid).isnull() => app_rid |
|
|
204
|
+
wrangler:rulesetMeta(app_rid){"name"} || app_rid
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
indexHtml = function(app_rid) {
|
|
208
|
+
"<html lang=\"en\"><head><meta charset=\"UTF-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /><script>window.__PUBLIC_PATH=\"/ui/" +
|
|
209
|
+
meta:eci + "/" + app_rid + "\";window.__PICO_VIEW_ECI=\"" + meta:eci +
|
|
210
|
+
"\";window.__PICO_XMLUI_SCRIPT=\"" + xmluiRuntimePath() +
|
|
211
|
+
"\";window.__XMLUI_FALLBACK_PATH=\"" +
|
|
212
|
+
escapeAttr(fallbackPathForApp(app_rid, multiViewForApp(app_rid))) +
|
|
213
|
+
"\";window.__PICO_VIEW_USE_HASH_ROUTING=\"true\";</script><base href=\"/ui/" +
|
|
214
|
+
meta:eci + "/" + app_rid +
|
|
215
|
+
"/\" /><script src=\"/xmlui/pico-view-boot.js?v=" + xmluiRuntimeVersion +
|
|
216
|
+
"-pico2\"></script></head><body></body></html>"
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
launcherTitle = function(rid) {
|
|
220
|
+
wrangler:rulesetMeta(rid).isnull() => rid |
|
|
221
|
+
wrangler:rulesetMeta(rid){"name"} || rid
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
launcherHtml = function() {
|
|
225
|
+
"<html><body><ul>" +
|
|
226
|
+
launcherRids().map(function(rid) {
|
|
227
|
+
"<li><a href=\"/ui/" + meta:eci + "/" + rid + "\">" +
|
|
228
|
+
escape(launcherTitle(rid)) + "</a></li>"
|
|
229
|
+
}).join("") +
|
|
230
|
+
"</ul></body></html>"
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
navLinksForApp = function(app_rid, multiView) {
|
|
234
|
+
viewQueriesOnChannel(app_rid).filter(function(q) {
|
|
235
|
+
navVisible(q{"view"})
|
|
236
|
+
}).map(function(q) {
|
|
237
|
+
"<NavLink label=\"" + escapeAttr(q{"view"}{"title"}) + "\" to=\"" +
|
|
238
|
+
escapeAttr(pageRoute(q{"view"}, q{"name"}, multiView)) + "\" />"
|
|
239
|
+
}).join("")
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
pagesForApp = function(app_rid, multiView) {
|
|
243
|
+
viewQueriesOnChannel(app_rid).map(function(q) {
|
|
244
|
+
"<Page url=\"" + escapeAttr(pageRoute(q{"view"}, q{"name"}, multiView)) +
|
|
245
|
+
"\"><" + viewComponentName(q{"name"}) + " /></Page>"
|
|
246
|
+
}).join("")
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
navPanelForApp = function(app_rid, multiView) {
|
|
250
|
+
not multiView => "" |
|
|
251
|
+
navLinksForApp(app_rid, multiView) == "" => "" |
|
|
252
|
+
"<NavPanel>" + navLinksForApp(app_rid, multiView) + "</NavPanel>"
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// XMLUI defaults: layout condensed-sticky, scrollWholePage true. That combo
|
|
256
|
+
// mis-measures header height in WebKit (Safari) and can hide page content.
|
|
257
|
+
shellAppAttrs = function() {
|
|
258
|
+
" layout=\"vertical-sticky\" scrollWholePage=\"false\""
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
mainXmlui = function(app_rid) {
|
|
262
|
+
viewQueriesOnChannel(app_rid).length() == 0 => null |
|
|
263
|
+
"<App name=\"" + escapeAttr(appRulesetName(app_rid)) + "\"" +
|
|
264
|
+
shellAppAttrs() + ">" +
|
|
265
|
+
navPanelForApp(app_rid, multiViewForApp(app_rid)) +
|
|
266
|
+
"<Pages fallbackPath=\"" +
|
|
267
|
+
escapeAttr(fallbackPathForApp(app_rid, multiViewForApp(app_rid))) +
|
|
268
|
+
"\">" +
|
|
269
|
+
pagesForApp(app_rid, multiViewForApp(app_rid)) +
|
|
270
|
+
"</Pages></App>"
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
configJson = function(app_rid) {
|
|
274
|
+
{
|
|
275
|
+
"name": appRulesetName(app_rid),
|
|
276
|
+
"appGlobals": {
|
|
277
|
+
"eci": meta:eci,
|
|
278
|
+
"appRid": app_rid,
|
|
279
|
+
"picoName": wrangler:name(),
|
|
280
|
+
"useHashBasedRouting": true
|
|
281
|
+
},
|
|
282
|
+
"xmluiConfig": { "useHashBasedRouting": true }
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
file = function(rid, path) {
|
|
287
|
+
rid == "" => launcherHtml() |
|
|
288
|
+
path.defaultsTo("index.html") == "index.html" => indexHtml(rid) |
|
|
289
|
+
path.defaultsTo("index.html") == "Main.xmlui" => mainXmlui(rid) |
|
|
290
|
+
path.defaultsTo("index.html") == "config.json" => configJson(rid) |
|
|
291
|
+
null
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
function readDoc(relativeFromPackage) {
|
|
7
|
+
const filePath = path.join(__dirname, "..", relativeFromPackage);
|
|
8
|
+
try {
|
|
9
|
+
return fs.readFileSync(filePath, "utf8");
|
|
10
|
+
} catch (_e) {
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function registerDevResources(server, client) {
|
|
16
|
+
server.resource(
|
|
17
|
+
"krl-conventions",
|
|
18
|
+
"pico://docs/krl-conventions",
|
|
19
|
+
{
|
|
20
|
+
description: "KRL rule shape and conventions (from CLAUDE.md)",
|
|
21
|
+
mimeType: "text/markdown",
|
|
22
|
+
},
|
|
23
|
+
async () => ({
|
|
24
|
+
contents: [
|
|
25
|
+
{
|
|
26
|
+
uri: "pico://docs/krl-conventions",
|
|
27
|
+
mimeType: "text/markdown",
|
|
28
|
+
text: readDoc("../../../CLAUDE.md"),
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
server.resource(
|
|
35
|
+
"pico-overview",
|
|
36
|
+
"pico://docs/pico-overview",
|
|
37
|
+
{
|
|
38
|
+
description: "Pico model overview",
|
|
39
|
+
mimeType: "text/markdown",
|
|
40
|
+
},
|
|
41
|
+
async () => ({
|
|
42
|
+
contents: [
|
|
43
|
+
{
|
|
44
|
+
uri: "pico://docs/pico-overview",
|
|
45
|
+
mimeType: "text/markdown",
|
|
46
|
+
text:
|
|
47
|
+
readDoc("public/docs/pico-overview.md") ||
|
|
48
|
+
readDoc("../../../docs/design/pico-overview.md"),
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
server.resource(
|
|
55
|
+
"pico-engine-operator",
|
|
56
|
+
"pico://docs/pico-engine",
|
|
57
|
+
{
|
|
58
|
+
description: "Pico engine operator notes",
|
|
59
|
+
mimeType: "text/markdown",
|
|
60
|
+
},
|
|
61
|
+
async () => ({
|
|
62
|
+
contents: [
|
|
63
|
+
{
|
|
64
|
+
uri: "pico://docs/pico-engine",
|
|
65
|
+
mimeType: "text/markdown",
|
|
66
|
+
text: readDoc("public/docs/pico-engine.md"),
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
server.prompt(
|
|
73
|
+
"write-ruleset",
|
|
74
|
+
"Draft KRL using pico conventions; optionally pass target ECI to embed channel schema",
|
|
75
|
+
{
|
|
76
|
+
purpose: zOptionalString(),
|
|
77
|
+
eci: zOptionalString(),
|
|
78
|
+
},
|
|
79
|
+
async ({ purpose, eci }) => {
|
|
80
|
+
let schemaBlock = "";
|
|
81
|
+
if (eci) {
|
|
82
|
+
try {
|
|
83
|
+
const ui = await client.resolveUiEci();
|
|
84
|
+
const target = eci || ui;
|
|
85
|
+
const data = await client.channelQuery(
|
|
86
|
+
target,
|
|
87
|
+
"io.picolabs.wrangler",
|
|
88
|
+
"channelSchema",
|
|
89
|
+
{ eci: target }
|
|
90
|
+
);
|
|
91
|
+
schemaBlock = `\n\nChannel schema (JSON):\n\`\`\`json\n${JSON.stringify(data, null, 2)}\n\`\`\`\n`;
|
|
92
|
+
} catch (err) {
|
|
93
|
+
schemaBlock = `\n\n(Could not load channel schema: ${String(err)})\n`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const conventions = readDoc("../../../CLAUDE.md");
|
|
97
|
+
return {
|
|
98
|
+
messages: [
|
|
99
|
+
{
|
|
100
|
+
role: "user",
|
|
101
|
+
content: {
|
|
102
|
+
type: "text",
|
|
103
|
+
text:
|
|
104
|
+
`Write a KRL ruleset${purpose ? ` for: ${purpose}` : ""}. Follow these conventions:\n\n${conventions}${schemaBlock}`,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function zOptionalString() {
|
|
114
|
+
const { z } = require("zod");
|
|
115
|
+
return z.string().optional();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
module.exports = { registerDevResources };
|