This commit is contained in:
Raven Scott
2026-04-21 19:36:45 -04:00
parent be6ca4a40c
commit cc757e44fc
14 changed files with 106 additions and 64 deletions
@@ -110,8 +110,12 @@ function bareBaresayRainbowCodes() {
/** Extract cow body from .cow text (Perl heredoc or raw template). */
function bareBaresayExtractCow(raw) {
const s = String(raw || '').replace(/^\ufeff/, '')
const m = s.match(/\$the_cow\s*=\s*<<"EOC"\s*\r?\n([\s\S]*?)\r?\nEOC\b/)
if (m) return m[1].replace(/\r\n/g, '\n')
// cowsay uses: $the_cow = <<"EOC"; ← semicolon before newline
const m = s.match(
/\$the_cow\s*=\s*<<"EOC"\s*;?\s*\r?\n([\s\S]*?)\r?\n\s*EOC\s*(?:\r?\n|$)/m
)
if (m)
return m[1].replace(/\r\n/g, '\n').replace(/\n+$/, '') + '\n'
return s.replace(/\r\n/g, '\n').trimEnd() + '\n'
}
@@ -123,11 +127,15 @@ function bareBaresayExtractCow(raw) {
*/
function bareBaresayFillCow(template, eyes, tongue, thoughts) {
const e = (eyes || 'oo').slice(0, 2).padEnd(2, 'o')
const L = e.charAt(0) || 'o'
const R = e.charAt(1) || 'o'
const tg = (tongue || ' ').slice(0, 1)
const th = thoughts || '\\'
return template
.replace(/\$thoughts/g, th)
.replace(/\$eyes/g, e)
.replace(/\$L/g, L)
.replace(/\$R/g, R)
.replace(/\$tongue/g, tg)
}
@@ -175,12 +183,12 @@ function bareBaresayCompose(message, cowBody, opts) {
function bareBaresayFallbackBearTemplate() {
return [
' $thoughts',
' $thoughts .--.--.',
' $thoughts ( @ @ )',
' $thoughts / $eyes \\',
' $thoughts | $tongue |',
' $thoughts \\______/',
' $thoughts ||',
' $thoughts ~~'
' $thoughts __ __',
' $thoughts / \\.-"""-./ \\',
' $thoughts \\ - - /',
' $thoughts | $L $R |',
' $thoughts \\ .-\'\'\'-. /',
" $thoughts '-\\__Y__/-'",
' $thoughts \u0060---\u0060'
].join('\n')
}
@@ -7,7 +7,7 @@
],
"description": "Like cowsay for Bare OS: wraps MESSAGE (or stdin, if none) in a speech balloon and prints it above an ASCII character read from /share/baresay/<name>.cow. Default character is bear. Full behavior is in packages/bare-os-coreutils/src/baresay.js and lib/baresay-engine.js.",
"files": [
"/share/baresay/*.cow — ASCII templates with $thoughts, $eyes, $tongue placeholders"
"/share/baresay/*.cow — ASCII templates with $thoughts, $eyes, $L (left eye), $R (right eye), $tongue"
],
"options": [
{
+17 -9
View File
@@ -199,8 +199,12 @@ function bareBaresayRainbowCodes() {
/** Extract cow body from .cow text (Perl heredoc or raw template). */
function bareBaresayExtractCow(raw) {
const s = String(raw || '').replace(/^\ufeff/, '')
const m = s.match(/\$the_cow\s*=\s*<<"EOC"\s*\r?\n([\s\S]*?)\r?\nEOC\b/)
if (m) return m[1].replace(/\r\n/g, '\n')
// cowsay uses: $the_cow = <<"EOC"; ← semicolon before newline
const m = s.match(
/\$the_cow\s*=\s*<<"EOC"\s*;?\s*\r?\n([\s\S]*?)\r?\n\s*EOC\s*(?:\r?\n|$)/m
)
if (m)
return m[1].replace(/\r\n/g, '\n').replace(/\n+$/, '') + '\n'
return s.replace(/\r\n/g, '\n').trimEnd() + '\n'
}
@@ -212,11 +216,15 @@ function bareBaresayExtractCow(raw) {
*/
function bareBaresayFillCow(template, eyes, tongue, thoughts) {
const e = (eyes || 'oo').slice(0, 2).padEnd(2, 'o')
const L = e.charAt(0) || 'o'
const R = e.charAt(1) || 'o'
const tg = (tongue || ' ').slice(0, 1)
const th = thoughts || '\\'
return template
.replace(/\$thoughts/g, th)
.replace(/\$eyes/g, e)
.replace(/\$L/g, L)
.replace(/\$R/g, R)
.replace(/\$tongue/g, tg)
}
@@ -264,13 +272,13 @@ function bareBaresayCompose(message, cowBody, opts) {
function bareBaresayFallbackBearTemplate() {
return [
' $thoughts',
' $thoughts .--.--.',
' $thoughts ( @ @ )',
' $thoughts / $eyes \\',
' $thoughts | $tongue |',
' $thoughts \\______/',
' $thoughts ||',
' $thoughts ~~'
' $thoughts __ __',
' $thoughts / \\.-"""-./ \\',
' $thoughts \\ - - /',
' $thoughts | $L $R |',
' $thoughts \\ .-\'\'\'-. /',
" $thoughts '-\\__Y__/-'",
' $thoughts \u0060---\u0060'
].join('\n')
}
+17 -9
View File
@@ -199,8 +199,12 @@ function bareBaresayRainbowCodes() {
/** Extract cow body from .cow text (Perl heredoc or raw template). */
function bareBaresayExtractCow(raw) {
const s = String(raw || '').replace(/^\ufeff/, '')
const m = s.match(/\$the_cow\s*=\s*<<"EOC"\s*\r?\n([\s\S]*?)\r?\nEOC\b/)
if (m) return m[1].replace(/\r\n/g, '\n')
// cowsay uses: $the_cow = <<"EOC"; ← semicolon before newline
const m = s.match(
/\$the_cow\s*=\s*<<"EOC"\s*;?\s*\r?\n([\s\S]*?)\r?\n\s*EOC\s*(?:\r?\n|$)/m
)
if (m)
return m[1].replace(/\r\n/g, '\n').replace(/\n+$/, '') + '\n'
return s.replace(/\r\n/g, '\n').trimEnd() + '\n'
}
@@ -212,11 +216,15 @@ function bareBaresayExtractCow(raw) {
*/
function bareBaresayFillCow(template, eyes, tongue, thoughts) {
const e = (eyes || 'oo').slice(0, 2).padEnd(2, 'o')
const L = e.charAt(0) || 'o'
const R = e.charAt(1) || 'o'
const tg = (tongue || ' ').slice(0, 1)
const th = thoughts || '\\'
return template
.replace(/\$thoughts/g, th)
.replace(/\$eyes/g, e)
.replace(/\$L/g, L)
.replace(/\$R/g, R)
.replace(/\$tongue/g, tg)
}
@@ -264,13 +272,13 @@ function bareBaresayCompose(message, cowBody, opts) {
function bareBaresayFallbackBearTemplate() {
return [
' $thoughts',
' $thoughts .--.--.',
' $thoughts ( @ @ )',
' $thoughts / $eyes \\',
' $thoughts | $tongue |',
' $thoughts \\______/',
' $thoughts ||',
' $thoughts ~~'
' $thoughts __ __',
' $thoughts / \\.-"""-./ \\',
' $thoughts \\ - - /',
' $thoughts | $L $R |',
' $thoughts \\ .-\'\'\'-. /',
" $thoughts '-\\__Y__/-'",
' $thoughts \u0060---\u0060'
].join('\n')
}
@@ -1,7 +1,7 @@
{
"schema": 2,
"profileId": "bare-os-posix-like",
"generatedAt": "2026-04-21T23:27:43.821Z",
"generatedAt": "2026-04-21T23:36:19.353Z",
"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": 1776814063820,
"atMs": 1776814579352,
"commands": [
"arch",
"awk",
@@ -1,9 +1,10 @@
$the_cow = <<"EOC";
$thoughts
$thoughts .--. Bare OS
$thoughts | ( $eyes ) |
$thoughts | ( $tongue ) |
$thoughts | --- |
$thoughts `-- mm --'
$thoughts ||
$thoughts __ __
$thoughts / \.-"""-./ \
$thoughts \ - - /
$thoughts | $L $R |
$thoughts \ .-'''-. /
$thoughts '-\__Y__/-'
$thoughts `---`
EOC
File diff suppressed because one or more lines are too long