peachsim 0.1.2399 → 0.1.2401
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 +2 -2
- package/cli/bin.ts +1 -1
- package/cli/catalog/content.ts +520 -0
- package/cli/catalog/index.ts +4 -0
- package/cli/catalog/meta.ts +3881 -0
- package/cli/catalog/renderers.ts +659 -0
- package/cli/catalog/routes.ts +237 -0
- package/cli/catalog/types.ts +96 -0
- package/cli/commands/inspect.ts +3 -3
- package/cli/commands/record.ts +1 -1
- package/cli/dev-build-freshness.ts +1 -0
- package/cli/help-core.ts +6 -6
- package/cli/hidden-runtime-alias.ts +1 -1
- package/cli/outbound-endpoints.ts +5 -0
- package/cli/parse-args.ts +1 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +53 -46
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +2 -2
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +51 -44
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +53 -46
- package/dist-lib/host/fetch-proxy-handler.cjs +44 -41
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +48 -45
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +53 -50
- package/dist-lib/native-app-identity-project.cjs +22 -19
- package/dist-lib/native-app-identity-project.mjs +4 -3
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +24 -24
- package/dist-lib/public-origins-lib.json +59 -59
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +68 -61
- package/dist-lib/swift-compile.cjs +28 -30
- package/dist-lib/swift-compile.mjs +24 -26
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +29 -31
- package/dist-lib/vite.cjs +39 -36
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/capture/browserAccessibilityContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/webViewBridgeContract.d.ts +2 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/kotlin/toolchain.json +2 -2
- package/package.json +1 -3
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/GameplayKit.framework/Headers/GKState.h +78 -0
- package/sdk/ios/System/Library/Frameworks/GameplayKit.framework/Headers/GKStateMachine.h +69 -0
- package/sdk/ios/System/Library/Frameworks/GameplayKit.framework/Headers/GameplayKit.apinotes +269 -0
- package/sdk/ios/System/Library/Frameworks/GameplayKit.framework/Headers/GameplayKit.h +15 -0
- package/sdk/ios/System/Library/Frameworks/GameplayKit.framework/Headers/GameplayKitBase.h +38 -0
- package/sdk/ios/System/Library/Frameworks/GameplayKit.framework/Modules/module.modulemap +6 -0
- package/src/expo-swift-host.ts +30 -22
- package/src/wasm-optimize.ts +23 -24
- package/src/worklets-babel.ts +2 -6
- package/cli/registry.ts +0 -2
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
import { cliCommandSections, cliOverviewSections } from './content'
|
|
2
|
+
import {
|
|
3
|
+
cliCommandMetas,
|
|
4
|
+
cliGlobalFlags,
|
|
5
|
+
cliInspectVerbMetas,
|
|
6
|
+
DEFAULT_CLI_DOC_CONTEXT,
|
|
7
|
+
getCliCommandMeta,
|
|
8
|
+
getCliInspectVerbMeta,
|
|
9
|
+
} from './meta'
|
|
10
|
+
import type {
|
|
11
|
+
CliCommandMeta,
|
|
12
|
+
CliDocPage,
|
|
13
|
+
CliDocRenderContext,
|
|
14
|
+
CliDocSection,
|
|
15
|
+
CliInspectVerbMeta,
|
|
16
|
+
CliOptionMeta,
|
|
17
|
+
} from './types'
|
|
18
|
+
|
|
19
|
+
function applyDocContext(
|
|
20
|
+
value: string,
|
|
21
|
+
context: CliDocRenderContext = DEFAULT_CLI_DOC_CONTEXT,
|
|
22
|
+
) {
|
|
23
|
+
return value
|
|
24
|
+
.replaceAll('{{bridgePort}}', String(context.bridgePort))
|
|
25
|
+
.replaceAll('{{defaultShellUrl}}', context.defaultShellUrl)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// outside backtick-wrapped code spans, escape `<` and `{` so MDX doesn't try
|
|
29
|
+
// to parse placeholder syntax like `<id>` as a JSX tag or `${KEY}` / `{x,y}`
|
|
30
|
+
// as a JSX expression.
|
|
31
|
+
function escapeMdxAngles(value: string) {
|
|
32
|
+
return value
|
|
33
|
+
.split(/(`[^`]*`)/g)
|
|
34
|
+
.map((segment, i) =>
|
|
35
|
+
i % 2 === 1 ? segment : segment.replace(/</g, '<').replace(/\{/g, '{'),
|
|
36
|
+
)
|
|
37
|
+
.join('')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function renderFrontmatterValue(value: string) {
|
|
41
|
+
return JSON.stringify(value)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function sortCommandMetas() {
|
|
45
|
+
return cliCommandMetas
|
|
46
|
+
.filter((meta) => !meta.hidden)
|
|
47
|
+
.slice()
|
|
48
|
+
.sort((a, b) => a.order - b.order)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function renderOptionList(
|
|
52
|
+
options: CliCommandMeta['options'],
|
|
53
|
+
context: CliDocRenderContext,
|
|
54
|
+
) {
|
|
55
|
+
const visibleOptions = options?.filter((item) => !item.hidden)
|
|
56
|
+
if (!visibleOptions?.length) return ''
|
|
57
|
+
return [
|
|
58
|
+
'## Options',
|
|
59
|
+
'',
|
|
60
|
+
'| flag | description |',
|
|
61
|
+
'| --- | --- |',
|
|
62
|
+
...visibleOptions.map((item) => {
|
|
63
|
+
const flag = applyDocContext(item.flag, context).replace(/\|/g, '\\|')
|
|
64
|
+
const description = escapeMdxAngles(
|
|
65
|
+
applyDocContext(item.description, context).replace(/\|/g, '\\|'),
|
|
66
|
+
)
|
|
67
|
+
return `| \`${flag}\` | ${description} |`
|
|
68
|
+
}),
|
|
69
|
+
'',
|
|
70
|
+
].join('\n')
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function renderExamples(
|
|
74
|
+
examples: CliCommandMeta['examples'],
|
|
75
|
+
context: CliDocRenderContext,
|
|
76
|
+
) {
|
|
77
|
+
const visibleExamples = examples?.filter((item) => !item.hidden)
|
|
78
|
+
if (!visibleExamples?.length) return ''
|
|
79
|
+
return [
|
|
80
|
+
'## Examples',
|
|
81
|
+
'',
|
|
82
|
+
'```bash',
|
|
83
|
+
...visibleExamples.map((item) => applyDocContext(item.command, context)),
|
|
84
|
+
'```',
|
|
85
|
+
'',
|
|
86
|
+
].join('\n')
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function renderRelated(meta: CliCommandMeta) {
|
|
90
|
+
if (!meta.related?.length) return ''
|
|
91
|
+
return [
|
|
92
|
+
'## Related',
|
|
93
|
+
'',
|
|
94
|
+
...meta.related.map((item) => `- [\`${item}\`](/docs/peach/cli/${item})`),
|
|
95
|
+
'',
|
|
96
|
+
].join('\n')
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// site-page markdown for a grouping command's sub-verbs (do / get / debug /
|
|
100
|
+
// wait / shell). the terminal `--help` renders this same registry via
|
|
101
|
+
// renderGroupVerbList; here we emit a markdown table per subgroup so the
|
|
102
|
+
// generated page surfaces every verb with its options + a real description
|
|
103
|
+
// instead of the hand-picked example subset the command meta carries.
|
|
104
|
+
function renderGroupSubcommands(group: string, context: CliDocRenderContext) {
|
|
105
|
+
const all = verbsInGroup(group)
|
|
106
|
+
if (!all.length) return ''
|
|
107
|
+
|
|
108
|
+
const subgroupOrder: string[] = []
|
|
109
|
+
const bySubgroup = new Map<string, CliInspectVerbMeta[]>()
|
|
110
|
+
for (const v of all) {
|
|
111
|
+
const key = v.subgroup ?? ''
|
|
112
|
+
if (!subgroupOrder.includes(key)) subgroupOrder.push(key)
|
|
113
|
+
const bucket = bySubgroup.get(key) ?? []
|
|
114
|
+
bucket.push(v)
|
|
115
|
+
bySubgroup.set(key, bucket)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const blocks: string[] = []
|
|
119
|
+
for (const key of subgroupOrder) {
|
|
120
|
+
const bucket = (bySubgroup.get(key) ?? []).slice().sort((a, b) => {
|
|
121
|
+
const ao = a.order ?? Number.POSITIVE_INFINITY
|
|
122
|
+
const bo = b.order ?? Number.POSITIVE_INFINITY
|
|
123
|
+
if (ao !== bo) return ao - bo
|
|
124
|
+
return a.verb.localeCompare(b.verb)
|
|
125
|
+
})
|
|
126
|
+
const rows = bucket.map((v) => {
|
|
127
|
+
const name = displayNameForVerb(v, group).replace(/\|/g, '\\|')
|
|
128
|
+
const desc = escapeMdxAngles(
|
|
129
|
+
applyDocContext(shortDescFor(v), context).replace(/\|/g, '\\|'),
|
|
130
|
+
)
|
|
131
|
+
return `| \`${name}\` | ${desc} |`
|
|
132
|
+
})
|
|
133
|
+
blocks.push(
|
|
134
|
+
[
|
|
135
|
+
key ? `### ${key}` : '',
|
|
136
|
+
'',
|
|
137
|
+
'| subcommand | description |',
|
|
138
|
+
'| --- | --- |',
|
|
139
|
+
...rows,
|
|
140
|
+
'',
|
|
141
|
+
]
|
|
142
|
+
.filter((line, i) => !(i === 0 && line === ''))
|
|
143
|
+
.join('\n'),
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return [
|
|
148
|
+
'## Subcommands',
|
|
149
|
+
'',
|
|
150
|
+
`Run \`peach ${group} <verb> --help\` for the flags and examples of any subcommand.`,
|
|
151
|
+
'',
|
|
152
|
+
...blocks,
|
|
153
|
+
].join('\n')
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function renderSections(
|
|
157
|
+
sections: CliDocSection[] | undefined,
|
|
158
|
+
context: CliDocRenderContext,
|
|
159
|
+
) {
|
|
160
|
+
if (!sections?.length) return ''
|
|
161
|
+
return sections
|
|
162
|
+
.map((section) => {
|
|
163
|
+
return [
|
|
164
|
+
`## ${section.title}`,
|
|
165
|
+
'',
|
|
166
|
+
applyDocContext(section.body.trim(), context),
|
|
167
|
+
'',
|
|
168
|
+
].join('\n')
|
|
169
|
+
})
|
|
170
|
+
.join('\n')
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function renderCommandPage(
|
|
174
|
+
meta: CliCommandMeta,
|
|
175
|
+
context: CliDocRenderContext = DEFAULT_CLI_DOC_CONTEXT,
|
|
176
|
+
) {
|
|
177
|
+
const sections = cliCommandSections[meta.id] || []
|
|
178
|
+
return [
|
|
179
|
+
'---',
|
|
180
|
+
`title: ${renderFrontmatterValue(meta.title)}`,
|
|
181
|
+
`description: ${renderFrontmatterValue(applyDocContext(meta.description, context))}`,
|
|
182
|
+
'---',
|
|
183
|
+
'',
|
|
184
|
+
escapeMdxAngles(applyDocContext(meta.summary, context)),
|
|
185
|
+
'',
|
|
186
|
+
'```bash',
|
|
187
|
+
...meta.usage.map((item) => applyDocContext(item, context)),
|
|
188
|
+
'```',
|
|
189
|
+
'',
|
|
190
|
+
meta.aliases?.length
|
|
191
|
+
? ['## Aliases', '', ...meta.aliases.map((alias) => `- \`${alias}\``), ''].join(
|
|
192
|
+
'\n',
|
|
193
|
+
)
|
|
194
|
+
: '',
|
|
195
|
+
renderOptionList(meta.options, context),
|
|
196
|
+
renderExamples(meta.examples, context),
|
|
197
|
+
renderSections(sections, context),
|
|
198
|
+
renderGroupSubcommands(meta.id, context),
|
|
199
|
+
renderRelated(meta),
|
|
200
|
+
]
|
|
201
|
+
.filter(Boolean)
|
|
202
|
+
.join('\n')
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function renderOverviewPage(context: CliDocRenderContext): string {
|
|
206
|
+
const commandsTable = [
|
|
207
|
+
'| command | description |',
|
|
208
|
+
'| --- | --- |',
|
|
209
|
+
...sortCommandMetas()
|
|
210
|
+
.filter((meta) => !meta.docsPending)
|
|
211
|
+
.map((meta) => {
|
|
212
|
+
return `| [\`${meta.id}\`](/docs/peach/cli/${meta.slug}) | ${escapeMdxAngles(applyDocContext(meta.description, context))} |`
|
|
213
|
+
}),
|
|
214
|
+
].join('\n')
|
|
215
|
+
|
|
216
|
+
const globalFlagsTable = [
|
|
217
|
+
'| flag | description |',
|
|
218
|
+
'| --- | --- |',
|
|
219
|
+
...cliGlobalFlags.map((flag) => {
|
|
220
|
+
return `| \`${flag.flag}\` | ${escapeMdxAngles(applyDocContext(flag.description, context))} |`
|
|
221
|
+
}),
|
|
222
|
+
].join('\n')
|
|
223
|
+
|
|
224
|
+
return `---
|
|
225
|
+
title: ${renderFrontmatterValue('CLI Reference')}
|
|
226
|
+
description: ${renderFrontmatterValue('peach command-line interface')}
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
${applyDocContext(
|
|
230
|
+
'The peach CLI is the operational surface for booting shells, opening sims, driving automation, and exposing the bridge host to agents.',
|
|
231
|
+
context,
|
|
232
|
+
)}
|
|
233
|
+
|
|
234
|
+
\`\`\`bash
|
|
235
|
+
peach [command] [options]
|
|
236
|
+
\`\`\`
|
|
237
|
+
|
|
238
|
+
## Commands
|
|
239
|
+
|
|
240
|
+
${commandsTable}
|
|
241
|
+
|
|
242
|
+
## Global Flags
|
|
243
|
+
|
|
244
|
+
${globalFlagsTable}
|
|
245
|
+
|
|
246
|
+
${renderSections(cliOverviewSections, context)}`
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function renderCliSiteDocsPages(
|
|
250
|
+
context: CliDocRenderContext = DEFAULT_CLI_DOC_CONTEXT,
|
|
251
|
+
): CliDocPage[] {
|
|
252
|
+
// every related[] link renders as /docs/peach/cli/<slug>; a value that is
|
|
253
|
+
// not a real command slug ships a 404. fail generation loudly instead.
|
|
254
|
+
const visibleMetas = cliCommandMetas.filter((meta) => !meta.hidden && !meta.docsPending)
|
|
255
|
+
const validSlugs = new Set(visibleMetas.map((meta) => meta.slug))
|
|
256
|
+
const deadLinks = visibleMetas.flatMap((meta) =>
|
|
257
|
+
(meta.related ?? [])
|
|
258
|
+
.filter((slug) => !validSlugs.has(slug))
|
|
259
|
+
.map((slug) => `${meta.id} → ${slug}`),
|
|
260
|
+
)
|
|
261
|
+
if (deadLinks.length) {
|
|
262
|
+
throw new Error(
|
|
263
|
+
`cli docs: related[] links have no command page: ${deadLinks.join(', ')}. ` +
|
|
264
|
+
'add a CliCommandMeta for the target or fix the ref.',
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return [
|
|
269
|
+
{ slug: 'index', content: renderOverviewPage(context) },
|
|
270
|
+
...sortCommandMetas()
|
|
271
|
+
.filter((meta) => !meta.docsPending)
|
|
272
|
+
.map((meta) => ({
|
|
273
|
+
slug: meta.slug,
|
|
274
|
+
content: renderCommandPage(meta, context),
|
|
275
|
+
})),
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// two-column aligned listing. ` ` indent, then the name column padded to
|
|
280
|
+
// cover the longest entry plus a 2-char gutter, then the description.
|
|
281
|
+
function renderVerbGroup(
|
|
282
|
+
header: string,
|
|
283
|
+
entries: ReadonlyArray<{ name: string; desc: string }>,
|
|
284
|
+
): string {
|
|
285
|
+
const nameWidth = Math.max(...entries.map((e) => e.name.length), 0) + 2
|
|
286
|
+
const lines = entries.map((e) => ` ${e.name.padEnd(nameWidth)}${e.desc}`)
|
|
287
|
+
return ` ${header}\n${lines.join('\n')}`
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// pull the first usage line for a verb and strip the `peach <group> ` /
|
|
291
|
+
// `peach ` prefix so the name column shows just the verb + args.
|
|
292
|
+
function displayNameForVerb(verb: CliInspectVerbMeta, group: string | null): string {
|
|
293
|
+
const raw = verb.usage[0] ?? `peach ${verb.verb}`
|
|
294
|
+
const prefixes = [group ? `peach ${group} ` : '', 'peach '].filter(Boolean)
|
|
295
|
+
let tail = raw
|
|
296
|
+
for (const p of prefixes) {
|
|
297
|
+
if (tail.startsWith(p)) {
|
|
298
|
+
tail = tail.slice(p.length)
|
|
299
|
+
break
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return tail
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function shortDescFor(verb: CliInspectVerbMeta): string {
|
|
306
|
+
return verb.shortDescription ?? verb.description
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function verbsInGroup(group: string): CliInspectVerbMeta[] {
|
|
310
|
+
return cliInspectVerbMetas.filter((v) => v.group === group)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function renderGroupVerbList(group: string): string {
|
|
314
|
+
const all = verbsInGroup(group)
|
|
315
|
+
if (!all.length) return ''
|
|
316
|
+
|
|
317
|
+
const bySubgroup = new Map<string, CliInspectVerbMeta[]>()
|
|
318
|
+
for (const v of all) {
|
|
319
|
+
const key = v.subgroup ?? ''
|
|
320
|
+
const bucket = bySubgroup.get(key) ?? []
|
|
321
|
+
bucket.push(v)
|
|
322
|
+
bySubgroup.set(key, bucket)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// preserve first-appearance order of subgroup labels so related clusters
|
|
326
|
+
// stay together in the order the registry already reads naturally.
|
|
327
|
+
const subgroupOrder: string[] = []
|
|
328
|
+
for (const v of all) {
|
|
329
|
+
const key = v.subgroup ?? ''
|
|
330
|
+
if (!subgroupOrder.includes(key)) subgroupOrder.push(key)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// for each subgroup, sort entries by explicit `order` then alphabetically.
|
|
334
|
+
const sections: string[] = []
|
|
335
|
+
for (const key of subgroupOrder) {
|
|
336
|
+
const bucket = bySubgroup.get(key) ?? []
|
|
337
|
+
bucket.sort((a, b) => {
|
|
338
|
+
const ao = a.order ?? Number.POSITIVE_INFINITY
|
|
339
|
+
const bo = b.order ?? Number.POSITIVE_INFINITY
|
|
340
|
+
if (ao !== bo) return ao - bo
|
|
341
|
+
return a.verb.localeCompare(b.verb)
|
|
342
|
+
})
|
|
343
|
+
const entries = bucket.map((v) => ({
|
|
344
|
+
name: displayNameForVerb(v, group),
|
|
345
|
+
desc: shortDescFor(v),
|
|
346
|
+
}))
|
|
347
|
+
const nameWidth = Math.max(...entries.map((e) => e.name.length), 0) + 2
|
|
348
|
+
const header = key ? ` ${key}:` : ''
|
|
349
|
+
const lines = entries.map((e) => ` ${e.name.padEnd(nameWidth)}${e.desc}`)
|
|
350
|
+
sections.push([header, ...lines].filter(Boolean).join('\n'))
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return sections.join('\n\n')
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// render the listing for `peach <group> --help` (do / get / debug / wait).
|
|
357
|
+
// pulls every verb with `group === <group>` from the registry, clusters by
|
|
358
|
+
// subgroup, and appends a shared options / examples / "see also" footer.
|
|
359
|
+
export function renderCliGroupHelp(
|
|
360
|
+
group: string,
|
|
361
|
+
context: CliDocRenderContext = DEFAULT_CLI_DOC_CONTEXT,
|
|
362
|
+
): string | null {
|
|
363
|
+
const groupTitles: Record<string, { title: string; noun: string }> = {
|
|
364
|
+
do: { title: 'interact with the running peach instance', noun: '<action>' },
|
|
365
|
+
get: { title: 'read state from the running peach instance', noun: '<noun>' },
|
|
366
|
+
debug: {
|
|
367
|
+
title: 'drive __sootsimDebug: channels, snapshots, inspectors',
|
|
368
|
+
noun: '<tool>',
|
|
369
|
+
},
|
|
370
|
+
wait: { title: 'block until a runtime condition is met', noun: '<condition>' },
|
|
371
|
+
}
|
|
372
|
+
const header = groupTitles[group]
|
|
373
|
+
if (!header) return null
|
|
374
|
+
|
|
375
|
+
const listing = renderGroupVerbList(group)
|
|
376
|
+
if (!listing) return null
|
|
377
|
+
|
|
378
|
+
const commandMeta = getCliCommandMeta(group)
|
|
379
|
+
const usage = (commandMeta?.usage ?? [])
|
|
380
|
+
.map((line) => ` ${applyDocContext(line, context)}`)
|
|
381
|
+
.join('\n')
|
|
382
|
+
const examples = [
|
|
383
|
+
...(commandMeta?.examples ?? []).filter((e) => !e.hidden),
|
|
384
|
+
...verbsInGroup(group).flatMap((v) => (v.examples ?? []).filter((e) => !e.hidden)),
|
|
385
|
+
]
|
|
386
|
+
.slice(0, 8)
|
|
387
|
+
.map((e) => ` ${applyDocContext(e.command, context)}`)
|
|
388
|
+
.join('\n')
|
|
389
|
+
const commandOptions = (commandMeta?.options ?? [])
|
|
390
|
+
.filter((entry) => !entry.hidden)
|
|
391
|
+
.map(
|
|
392
|
+
(entry) =>
|
|
393
|
+
` ${applyDocContext(entry.flag, context).padEnd(20)}${applyDocContext(entry.description, context)}`,
|
|
394
|
+
)
|
|
395
|
+
.join('\n')
|
|
396
|
+
|
|
397
|
+
const sharedOptions = `
|
|
398
|
+
options:
|
|
399
|
+
--port <port> WS bridge port (default: ${context.bridgePort})
|
|
400
|
+
--sim <sim> target a specific connected sim
|
|
401
|
+
--timeout <ms> per-command timeout (default: 15000)${commandOptions ? '\n' + commandOptions : ''}`
|
|
402
|
+
|
|
403
|
+
const seeAlsoGroups: string[] = ['do', 'get', 'debug', 'wait']
|
|
404
|
+
.filter((g) => g !== group)
|
|
405
|
+
.map((g) => `peach ${g} --help`)
|
|
406
|
+
const seeAlsoLine = `see also: ${seeAlsoGroups.join(', ')}`
|
|
407
|
+
|
|
408
|
+
return `
|
|
409
|
+
peach ${group} ${header.noun} — ${header.title}
|
|
410
|
+
|
|
411
|
+
${usage ? `usage:\n${usage}\n\n` : ''}${listing}
|
|
412
|
+
${examples ? `\nexamples:\n${examples}\n` : ''}${sharedOptions}
|
|
413
|
+
|
|
414
|
+
${seeAlsoLine}
|
|
415
|
+
`.trim()
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function renderGlobalFlagList(context: CliDocRenderContext) {
|
|
419
|
+
return cliGlobalFlags
|
|
420
|
+
.map(
|
|
421
|
+
(entry) =>
|
|
422
|
+
` ${entry.flag.padEnd(27)} ${applyDocContext(entry.description, context)}`,
|
|
423
|
+
)
|
|
424
|
+
.join('\n')
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export function renderCliIndexHelp(
|
|
428
|
+
context: CliDocRenderContext = DEFAULT_CLI_DOC_CONTEXT,
|
|
429
|
+
) {
|
|
430
|
+
// core commands — top-level entry points you run directly. grouping verbs
|
|
431
|
+
// (do/get/debug/wait) render separately below via the registry.
|
|
432
|
+
const groupingVerbs = new Set(['get', 'do', 'debug', 'wait'])
|
|
433
|
+
const commandMetas = sortCommandMetas().filter((meta) => !groupingVerbs.has(meta.id))
|
|
434
|
+
const commandWidth = Math.max(16, ...commandMetas.map((meta) => meta.id.length)) + 1
|
|
435
|
+
const commands = commandMetas
|
|
436
|
+
.map(
|
|
437
|
+
(meta) =>
|
|
438
|
+
` ${meta.id.padEnd(commandWidth)}${applyDocContext(meta.description, context)}`,
|
|
439
|
+
)
|
|
440
|
+
.join('\n')
|
|
441
|
+
|
|
442
|
+
const findForms = verbsInGroup('find')
|
|
443
|
+
// fallback: if `find` isn't marked as a group, pull the flag forms from
|
|
444
|
+
// its verb meta's options so we still render a rich listing.
|
|
445
|
+
const findMeta = getCliInspectVerbMeta('find')
|
|
446
|
+
const findEntries: Array<{ name: string; desc: string }> = findForms.length
|
|
447
|
+
? findForms.map((v) => ({
|
|
448
|
+
name: displayNameForVerb(v, null),
|
|
449
|
+
desc: shortDescFor(v),
|
|
450
|
+
}))
|
|
451
|
+
: [
|
|
452
|
+
{ name: 'find <text>', desc: 'findByText (shorthand — bare text)' },
|
|
453
|
+
...(findMeta?.options ?? []).map((opt) => ({
|
|
454
|
+
name: `find ${opt.flag.split(',')[0]?.trim() ?? ''}`.trim(),
|
|
455
|
+
desc: opt.description,
|
|
456
|
+
})),
|
|
457
|
+
]
|
|
458
|
+
|
|
459
|
+
const describeDesc = shortDescFor(
|
|
460
|
+
getCliInspectVerbMeta('describe') ?? { verb: 'describe', description: '', usage: [] },
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
const compactList = (group: string): Array<{ name: string; desc: string }> =>
|
|
464
|
+
verbsInGroup(group)
|
|
465
|
+
.slice()
|
|
466
|
+
.sort((a, b) => {
|
|
467
|
+
const ao = a.order ?? Number.POSITIVE_INFINITY
|
|
468
|
+
const bo = b.order ?? Number.POSITIVE_INFINITY
|
|
469
|
+
if (ao !== bo) return ao - bo
|
|
470
|
+
return a.verb.localeCompare(b.verb)
|
|
471
|
+
})
|
|
472
|
+
.map((v) => ({
|
|
473
|
+
name: displayNameForVerb(v, group),
|
|
474
|
+
desc: shortDescFor(v),
|
|
475
|
+
}))
|
|
476
|
+
|
|
477
|
+
const getVerbs = compactList('get')
|
|
478
|
+
const doVerbs = compactList('do')
|
|
479
|
+
const debugVerbs = compactList('debug')
|
|
480
|
+
const waitVerbs = compactList('wait')
|
|
481
|
+
|
|
482
|
+
return `
|
|
483
|
+
peach — iOS and Android simulator for React Native
|
|
484
|
+
|
|
485
|
+
usage:
|
|
486
|
+
peach open ConnectRN (the first run sets up this machine)
|
|
487
|
+
peach [command] [options]
|
|
488
|
+
|
|
489
|
+
start here:
|
|
490
|
+
peach doctor check what of this app Peach runs
|
|
491
|
+
peach open 8081 open the app Metro serves on port 8081
|
|
492
|
+
peach skill install give your coding agent the Peach skills
|
|
493
|
+
peach describe read the screen the app shows
|
|
494
|
+
|
|
495
|
+
commands:
|
|
496
|
+
${commands}
|
|
497
|
+
|
|
498
|
+
runtime verbs:
|
|
499
|
+
peach describe [filter] [--verbose] [--json]
|
|
500
|
+
${describeDesc}
|
|
501
|
+
|
|
502
|
+
${renderVerbGroup('peach find <...> unified finder', findEntries)}
|
|
503
|
+
|
|
504
|
+
${renderVerbGroup('peach get <noun> read runtime state', getVerbs)}
|
|
505
|
+
|
|
506
|
+
${renderVerbGroup('peach do <action> drive the app', doVerbs)}
|
|
507
|
+
|
|
508
|
+
peach shell <action> simulator shell + chrome
|
|
509
|
+
launch <appId> launch an app
|
|
510
|
+
home go home
|
|
511
|
+
switcher open app switcher
|
|
512
|
+
appearance <mode> set light/dark/auto/toggle
|
|
513
|
+
lock toggle lock state
|
|
514
|
+
shake trigger shake
|
|
515
|
+
|
|
516
|
+
${renderVerbGroup('peach debug <tool> instrumentation', debugVerbs)}
|
|
517
|
+
|
|
518
|
+
${renderVerbGroup('peach wait <condition> block on runtime state', waitVerbs)}
|
|
519
|
+
|
|
520
|
+
sim targeting:
|
|
521
|
+
peach list show every connected sim and its id
|
|
522
|
+
peach use <sim> make one sim current (saved default)
|
|
523
|
+
peach --sim <sim> <cmd> override the saved default for one call
|
|
524
|
+
peach claim <sim> take an exclusive lease on a sim
|
|
525
|
+
|
|
526
|
+
agent setup:
|
|
527
|
+
peach skill install install the bundled setup, debug, test, visual, and performance skills
|
|
528
|
+
restart the agent session after installation so it reloads the skill list
|
|
529
|
+
|
|
530
|
+
global flags:
|
|
531
|
+
${renderGlobalFlagList(context)}
|
|
532
|
+
|
|
533
|
+
examples:
|
|
534
|
+
peach open start in browser
|
|
535
|
+
peach open 8081 start in browser, opening React Native app on 8081
|
|
536
|
+
peach desktop open desktop companion
|
|
537
|
+
peach describe inspect the current UI tree
|
|
538
|
+
peach find --testid loginButton look up a node by testID
|
|
539
|
+
peach get errors 5 show the latest console failures
|
|
540
|
+
peach get screens current route / modal / keyboard state
|
|
541
|
+
peach do tap-text "Sign in" tap a node by its text
|
|
542
|
+
peach debug state shell inspect shell runtime state
|
|
543
|
+
peach shell appearance dark set simulator appearance
|
|
544
|
+
peach skill install teach coding agents the peach workflows
|
|
545
|
+
`.trimStart()
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function renderOptionTable(
|
|
549
|
+
options: CliOptionMeta[] | undefined,
|
|
550
|
+
context: CliDocRenderContext,
|
|
551
|
+
): string {
|
|
552
|
+
const visibleOptions = options?.filter((o) => !o.hidden)
|
|
553
|
+
if (!visibleOptions?.length) return ''
|
|
554
|
+
const width = Math.max(...visibleOptions.map((o) => o.flag.length), 0) + 2
|
|
555
|
+
const lines = visibleOptions.map(
|
|
556
|
+
(o) =>
|
|
557
|
+
` ${applyDocContext(o.flag, context).padEnd(width)}${applyDocContext(o.description, context)}`,
|
|
558
|
+
)
|
|
559
|
+
return `\noptions:\n${lines.join('\n')}\n`
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function renderVerbInvocation(
|
|
563
|
+
verbRef: string | CliInspectVerbMeta,
|
|
564
|
+
currentGroup?: string | null,
|
|
565
|
+
): string {
|
|
566
|
+
const verbName = typeof verbRef === 'string' ? verbRef : verbRef.verb
|
|
567
|
+
const verb =
|
|
568
|
+
typeof verbRef === 'string'
|
|
569
|
+
? ((currentGroup !== undefined
|
|
570
|
+
? getCliInspectVerbMeta(verbName, currentGroup)
|
|
571
|
+
: undefined) ?? getCliInspectVerbMeta(verbName))
|
|
572
|
+
: verbRef
|
|
573
|
+
if (verb?.group) return `peach ${verb.group} ${verb.verb}`
|
|
574
|
+
const command = getCliCommandMeta(verbName)
|
|
575
|
+
return `peach ${command?.id ?? verbName}`
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function renderInspectVerbHelp(verb: CliInspectVerbMeta, context: CliDocRenderContext) {
|
|
579
|
+
const optionsBlock = renderOptionTable(verb.options, context)
|
|
580
|
+
const examplesBlock = verb.examples?.length
|
|
581
|
+
? `\nexamples:\n${verb.examples
|
|
582
|
+
.filter((item) => !item.hidden)
|
|
583
|
+
.map((item) => ` ${applyDocContext(item.command, context)}`)
|
|
584
|
+
.join('\n')}\n`
|
|
585
|
+
: ''
|
|
586
|
+
const notesBlock = verb.notes ? `\nnote:\n ${verb.notes}\n` : ''
|
|
587
|
+
const seeAlsoBlock = verb.seeAlso?.length
|
|
588
|
+
? `\nsee also: ${verb.seeAlso.map((item) => renderVerbInvocation(item, verb.group)).join(', ')}\n`
|
|
589
|
+
: ''
|
|
590
|
+
|
|
591
|
+
// footer link to the parent group's full listing. a standalone top-level
|
|
592
|
+
// command (describe, find, screenshot) has no parent to point at.
|
|
593
|
+
const groupPath = verb.group ? `peach ${verb.group} --help` : null
|
|
594
|
+
const footerLine = groupPath ? `\n full list: ${groupPath}` : ''
|
|
595
|
+
const invocation = renderVerbInvocation(verb)
|
|
596
|
+
return `
|
|
597
|
+
${invocation} — ${verb.description}
|
|
598
|
+
|
|
599
|
+
usage:
|
|
600
|
+
${verb.usage.map((item) => applyDocContext(item, context)).join('\n ')}${optionsBlock}${examplesBlock}${notesBlock}${seeAlsoBlock}${footerLine}`.trimEnd()
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export function renderCliCommandHelp(
|
|
604
|
+
name: string,
|
|
605
|
+
context: CliDocRenderContext = DEFAULT_CLI_DOC_CONTEXT,
|
|
606
|
+
options: { prefer?: 'command' | 'verb'; group?: string | null } = {},
|
|
607
|
+
) {
|
|
608
|
+
const renderVerb = () => {
|
|
609
|
+
const verbMeta = getCliInspectVerbMeta(name, options.group)
|
|
610
|
+
return verbMeta ? renderInspectVerbHelp(verbMeta, context) : null
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
const renderCommand = () => {
|
|
614
|
+
const meta = getCliCommandMeta(name)
|
|
615
|
+
if (!meta) return null
|
|
616
|
+
|
|
617
|
+
const aliasesBlock = meta.aliases?.length
|
|
618
|
+
? `\naliases:\n ${meta.aliases.join(', ')}\n`
|
|
619
|
+
: ''
|
|
620
|
+
const visibleOptions = meta.options?.filter((item) => !item.hidden)
|
|
621
|
+
const optionsBlock = visibleOptions?.length
|
|
622
|
+
? (() => {
|
|
623
|
+
// size the flag column to the widest flag (+2) so a long flag like
|
|
624
|
+
// `--preview-public-origin <url>` keeps a gap before its description
|
|
625
|
+
// instead of abutting it — a fixed padEnd(24) silently failed there.
|
|
626
|
+
const optionWidth =
|
|
627
|
+
Math.max(
|
|
628
|
+
...visibleOptions.map((o) => applyDocContext(o.flag, context).length),
|
|
629
|
+
) + 2
|
|
630
|
+
return `\noptions:\n${visibleOptions
|
|
631
|
+
.map(
|
|
632
|
+
(item) =>
|
|
633
|
+
` ${applyDocContext(item.flag, context).padEnd(optionWidth)}${applyDocContext(item.description, context)}`,
|
|
634
|
+
)
|
|
635
|
+
.join('\n')}\n`
|
|
636
|
+
})()
|
|
637
|
+
: ''
|
|
638
|
+
const visibleExamples = meta.examples?.filter((item) => !item.hidden)
|
|
639
|
+
const examplesBlock = visibleExamples?.length
|
|
640
|
+
? `\nexamples:\n${visibleExamples
|
|
641
|
+
.map((item) => ` ${applyDocContext(item.command, context)}`)
|
|
642
|
+
.join('\n')}\n`
|
|
643
|
+
: ''
|
|
644
|
+
|
|
645
|
+
const unsupportedBlock = meta.unsupported
|
|
646
|
+
? `\n\n⚠ ${applyDocContext(meta.unsupported, context)}`
|
|
647
|
+
: ''
|
|
648
|
+
|
|
649
|
+
return `
|
|
650
|
+
peach ${meta.id} — ${applyDocContext(meta.description, context)}${unsupportedBlock}
|
|
651
|
+
|
|
652
|
+
usage:
|
|
653
|
+
${meta.usage.map((item) => applyDocContext(item, context)).join('\n ')}${aliasesBlock}${optionsBlock}${examplesBlock}`.trimEnd()
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
return options.prefer === 'verb'
|
|
657
|
+
? (renderVerb() ?? renderCommand())
|
|
658
|
+
: (renderCommand() ?? renderVerb())
|
|
659
|
+
}
|