Pear updates
This commit is contained in:
+106
-108
@@ -96,15 +96,17 @@ function bareOsEmitRaw(ctx, chunk) {
|
||||
* See docs/design/ctx-pear-surface-and-bare-audit-plan.md for the full plan and design.
|
||||
*/
|
||||
|
||||
function printHelp(argv0 = 'pear') {
|
||||
console.log(`${argv0} — Pear development surface for Bare OS
|
||||
async function run(ctx, argv = []) {
|
||||
function printHelp(argv0 = 'pear') {
|
||||
ctx.console.log(`${argv0} — Pear development surface for Bare OS
|
||||
|
||||
Usage:
|
||||
${argv0} help
|
||||
${argv0} info
|
||||
${argv0} list
|
||||
${argv0} stage [dir] (stub — will use ctx.pear.pearBuild)
|
||||
${argv0} build [dir] (alias for stage in v1)
|
||||
${argv0} stage [dir]
|
||||
${argv0} build [dir]
|
||||
${argv0} init [dir]
|
||||
|
||||
The ctx.pear surface exposes selected Pear and Bare build/bundling packages
|
||||
(pear-build, pear-bundle, bare-bundle-compile, etc.) when BARE_OS_BARE_MODULES
|
||||
@@ -116,116 +118,112 @@ the P2P App Store.
|
||||
|
||||
Pear apps you create here are natural citizens of the P2P App Store:
|
||||
- Stage your app with Pear tooling
|
||||
- Publish it via `appstore` (or directly as a pear:// package)
|
||||
- Publish it via appstore (or directly as a pear:// package)
|
||||
- Other users can discover and run it
|
||||
|
||||
Use the `pear-dev` agent skill together with the `appstore` skill for
|
||||
Use the pear-dev agent skill together with the appstore skill for
|
||||
autonomous "build Pear app → publish to my store" workflows.
|
||||
`)
|
||||
}
|
||||
|
||||
async function cmdInfo(ctx) {
|
||||
console.log('pear — Pear development tools (ctx.pear surface)')
|
||||
console.log('Bare OS version of selected Pear runtime packages.')
|
||||
console.log('')
|
||||
if (ctx.pear && typeof ctx.pear === 'object') {
|
||||
const keys = Object.keys(ctx.pear).sort()
|
||||
console.log(`Exposed on ctx.pear (${keys.length} packages):`)
|
||||
for (const k of keys) {
|
||||
const val = ctx.pear[k]
|
||||
const type = typeof val
|
||||
console.log(` ${k.padEnd(20)} ${type}`)
|
||||
}
|
||||
} else {
|
||||
console.log('ctx.pear is not currently populated (BARE_OS_BARE_MODULES may be disabled).')
|
||||
}
|
||||
console.log('')
|
||||
console.log('Run "pear list" for the same view.')
|
||||
}
|
||||
|
||||
async function cmdList(ctx) {
|
||||
if (!ctx.pear || typeof ctx.pear !== 'object') {
|
||||
console.log('ctx.pear is not available in this environment.')
|
||||
return
|
||||
}
|
||||
const keys = Object.keys(ctx.pear).sort()
|
||||
if (keys.length === 0) {
|
||||
console.log('No packages currently exposed on ctx.pear.')
|
||||
return
|
||||
}
|
||||
console.log(`ctx.pear — ${keys.length} package(s) available:\n`)
|
||||
for (const k of keys) {
|
||||
console.log(` ${k}`)
|
||||
}
|
||||
}
|
||||
|
||||
async function cmdInit(ctx, targetDir = '.') {
|
||||
const name = 'my-pear-app'
|
||||
const dir = targetDir === '.' ? `${(ctx.env?.HOME || '/home/guest')}/pear-projects/${name}` : targetDir
|
||||
|
||||
console.log(`pear init: creating minimal Pear app skeleton at ${dir} (stub implementation)`)
|
||||
|
||||
try {
|
||||
await ctx.vfs.mkdir(dir, { recursive: true })
|
||||
const packageJson = {
|
||||
name,
|
||||
version: '0.1.0',
|
||||
main: 'index.js',
|
||||
type: 'module',
|
||||
pear: {
|
||||
name: 'my-pear-app',
|
||||
type: 'desktop'
|
||||
}
|
||||
}
|
||||
await ctx.vfs.writeFile(`${dir}/package.json`, ctx.b4a.from(JSON.stringify(packageJson, null, 2)))
|
||||
await ctx.vfs.writeFile(`${dir}/index.js`, ctx.b4a.from('console.log("Hello from my Pear app!");\n'))
|
||||
console.log('Created basic package.json + index.js')
|
||||
console.log('Next (when fully wired): run "pear stage ' + dir + '" using ctx.pear.pearBuild')
|
||||
} catch (err) {
|
||||
console.error('Failed to init:', err?.message || err)
|
||||
}
|
||||
}
|
||||
|
||||
// The coreutils runner executes this file body with `ctx` in scope.
|
||||
// We run the command logic directly at the bottom (consistent with other commands like appstore).
|
||||
|
||||
const sub = (typeof argv !== 'undefined' && argv[1] ? argv[1] : 'help').toLowerCase()
|
||||
|
||||
switch (sub) {
|
||||
case 'help':
|
||||
case '--help':
|
||||
case '-h':
|
||||
printHelp(typeof argv !== 'undefined' ? argv[0] : 'pear')
|
||||
break
|
||||
case 'info':
|
||||
await cmdInfo(ctx)
|
||||
break
|
||||
case 'list':
|
||||
case 'ls':
|
||||
await cmdList(ctx)
|
||||
break
|
||||
case 'stage':
|
||||
case 'build':
|
||||
const target = (typeof argv !== 'undefined' ? argv[2] : null) || '.'
|
||||
if (ctx.pear && ctx.pear.pearBuild) {
|
||||
console.log(`Attempting stage of ${target} using ctx.pear.pearBuild (early integration)...`)
|
||||
try {
|
||||
console.log('ctx.pear.pearBuild is available. Full stage pipeline landing in upcoming plan items.')
|
||||
console.log('Exposed Pear build surface:', Object.keys(ctx.pear).filter(k => k.toLowerCase().includes('build') || k.toLowerCase().includes('bundle')))
|
||||
} catch (e) {
|
||||
console.error('Stage attempt error:', e?.message || e)
|
||||
async function cmdInfo() {
|
||||
ctx.console.log('pear — Pear development tools (ctx.pear surface)')
|
||||
ctx.console.log('Bare OS version of selected Pear runtime packages.')
|
||||
ctx.console.log('')
|
||||
if (ctx.pear && typeof ctx.pear === 'object') {
|
||||
const keys = Object.keys(ctx.pear).sort()
|
||||
ctx.console.log(`Exposed on ctx.pear (${keys.length} packages):`)
|
||||
for (const k of keys) {
|
||||
const val = ctx.pear[k]
|
||||
const type = typeof val
|
||||
ctx.console.log(` ${k.padEnd(20)} ${type}`)
|
||||
}
|
||||
} else {
|
||||
console.log('pear stage / build: advanced integration in progress (ctx.pear.pearBuild available).')
|
||||
console.log('Current exposed packages on ctx.pear:')
|
||||
await cmdList(ctx)
|
||||
ctx.console.log('ctx.pear is not currently populated (BARE_OS_BARE_MODULES may be disabled).')
|
||||
}
|
||||
break
|
||||
case 'init':
|
||||
await cmdInit(ctx, (typeof argv !== 'undefined' ? argv[2] : null))
|
||||
break
|
||||
default:
|
||||
console.error(`Unknown subcommand: ${sub}`)
|
||||
printHelp(typeof argv !== 'undefined' ? argv[0] : 'pear')
|
||||
break
|
||||
}
|
||||
ctx.console.log('')
|
||||
ctx.console.log('Run "pear list" for the same view.')
|
||||
}
|
||||
|
||||
async function cmdList() {
|
||||
if (!ctx.pear || typeof ctx.pear !== 'object') {
|
||||
ctx.console.log('ctx.pear is not available in this environment.')
|
||||
return
|
||||
}
|
||||
const keys = Object.keys(ctx.pear).sort()
|
||||
if (keys.length === 0) {
|
||||
ctx.console.log('No packages currently exposed on ctx.pear.')
|
||||
return
|
||||
}
|
||||
ctx.console.log(`ctx.pear — ${keys.length} package(s) available:\n`)
|
||||
for (const k of keys) {
|
||||
ctx.console.log(` ${k}`)
|
||||
}
|
||||
}
|
||||
|
||||
async function cmdInit(targetDir = '.') {
|
||||
const name = 'my-pear-app'
|
||||
const dir = targetDir === '.' ? `${(ctx.env?.HOME || '/home/guest')}/pear-projects/${name}` : targetDir
|
||||
|
||||
ctx.console.log(`pear init: creating minimal Pear app skeleton at ${dir}`)
|
||||
|
||||
try {
|
||||
await ctx.vfs.mkdir(dir, { recursive: true })
|
||||
const packageJson = {
|
||||
name,
|
||||
version: '0.1.0',
|
||||
main: 'index.js',
|
||||
type: 'module',
|
||||
pear: {
|
||||
name: 'my-pear-app',
|
||||
type: 'desktop'
|
||||
}
|
||||
}
|
||||
await ctx.vfs.writeFile(`${dir}/package.json`, ctx.b4a.from(JSON.stringify(packageJson, null, 2)))
|
||||
await ctx.vfs.writeFile(`${dir}/index.js`, ctx.b4a.from('console.log("Hello from my Pear app!");\n'))
|
||||
ctx.console.log('Created basic package.json + index.js')
|
||||
ctx.console.log(`Next: run "pear stage ${dir}" (uses ctx.pear.pearBuild when available)`)
|
||||
} catch (err) {
|
||||
ctx.console.error('Failed to init:', err?.message || err)
|
||||
}
|
||||
}
|
||||
|
||||
const sub = (argv[1] || 'help').toLowerCase()
|
||||
|
||||
switch (sub) {
|
||||
case 'help':
|
||||
case '--help':
|
||||
case '-h':
|
||||
printHelp(argv[0] || 'pear')
|
||||
break
|
||||
case 'info':
|
||||
await cmdInfo()
|
||||
break
|
||||
case 'list':
|
||||
case 'ls':
|
||||
await cmdList()
|
||||
break
|
||||
case 'stage':
|
||||
case 'build':
|
||||
const target = argv[2] || '.'
|
||||
if (ctx.pear && ctx.pear.pearBuild) {
|
||||
ctx.console.log(`Attempting stage of ${target} using ctx.pear.pearBuild...`)
|
||||
ctx.console.log('ctx.pear.pearBuild is available. Full pipeline implementation in progress.')
|
||||
ctx.console.log('Exposed build-related keys:', Object.keys(ctx.pear).filter(k =>
|
||||
k.toLowerCase().includes('build') || k.toLowerCase().includes('bundle')
|
||||
))
|
||||
} else {
|
||||
ctx.console.log('pear stage / build: ctx.pear.pearBuild not yet available in this environment.')
|
||||
ctx.console.log('Current exposed packages on ctx.pear:')
|
||||
await cmdList()
|
||||
}
|
||||
break
|
||||
case 'init':
|
||||
await cmdInit(argv[2])
|
||||
break
|
||||
default:
|
||||
ctx.console.error(`Unknown subcommand: ${sub}`)
|
||||
printHelp(argv[0] || 'pear')
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"schema": 2,
|
||||
"profileId": "bare-os-posix-like",
|
||||
"generatedAt": "2026-05-26T21:57:58.462Z",
|
||||
"generatedAt": "2026-05-26T22:02:23.960Z",
|
||||
"note": "Sparse POSIX Issue 7 coverage hints for /bin utilities. Omitted command names are not yet profiled here.",
|
||||
"commandIndex": [
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"atMs": 1779832678462,
|
||||
"atMs": 1779832943959,
|
||||
"commands": [
|
||||
"agent",
|
||||
"appctl",
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user