darkfoo-code 0.2.4 → 0.2.5
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/dist/main.js +121 -458
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1926,9 +1926,8 @@ function App({ model, systemPromptOverride, children }) {
|
|
|
1926
1926
|
}
|
|
1927
1927
|
|
|
1928
1928
|
// src/repl.tsx
|
|
1929
|
-
import { useState as
|
|
1929
|
+
import { useState as useState2, useCallback as useCallback2, useEffect, useRef } from "react";
|
|
1930
1930
|
import { Box as Box7, Text as Text7, useApp, useInput as useInput2 } from "ink";
|
|
1931
|
-
import Spinner2 from "ink-spinner";
|
|
1932
1931
|
import { nanoid as nanoid6 } from "nanoid";
|
|
1933
1932
|
|
|
1934
1933
|
// src/components/Banner.tsx
|
|
@@ -1938,122 +1937,11 @@ import { Box as Box2, Text as Text2 } from "ink";
|
|
|
1938
1937
|
|
|
1939
1938
|
// src/components/Fox.tsx
|
|
1940
1939
|
init_theme();
|
|
1941
|
-
import {
|
|
1940
|
+
import { memo } from "react";
|
|
1942
1941
|
import { Box, Text } from "ink";
|
|
1943
|
-
|
|
1944
|
-
// src/fox-state.ts
|
|
1945
|
-
var DEFAULT_STATS = {
|
|
1946
|
-
name: "DarkFox",
|
|
1947
|
-
happiness: 70,
|
|
1948
|
-
hunger: 80,
|
|
1949
|
-
energy: 90,
|
|
1950
|
-
timesPetted: 0,
|
|
1951
|
-
timesFed: 0,
|
|
1952
|
-
createdAt: Date.now()
|
|
1953
|
-
};
|
|
1954
|
-
var stats = { ...DEFAULT_STATS };
|
|
1955
|
-
var lastDecayTime = Date.now();
|
|
1956
|
-
function getFoxStats() {
|
|
1957
|
-
decay();
|
|
1958
|
-
return { ...stats };
|
|
1959
|
-
}
|
|
1960
|
-
function setFoxName(name) {
|
|
1961
|
-
stats.name = name;
|
|
1962
|
-
}
|
|
1963
|
-
function petFox() {
|
|
1964
|
-
decay();
|
|
1965
|
-
stats.happiness = Math.min(100, stats.happiness + 15);
|
|
1966
|
-
stats.timesPetted++;
|
|
1967
|
-
const reactions = [
|
|
1968
|
-
`${stats.name} nuzzles your hand.`,
|
|
1969
|
-
`${stats.name} purrs softly.`,
|
|
1970
|
-
`${stats.name}'s tail wags happily.`,
|
|
1971
|
-
`${stats.name} leans into the pets.`,
|
|
1972
|
-
`${stats.name} rolls over for belly rubs.`,
|
|
1973
|
-
`${stats.name} makes a happy chirping sound.`,
|
|
1974
|
-
`${stats.name} bumps your hand with their nose.`
|
|
1975
|
-
];
|
|
1976
|
-
if (stats.happiness >= 95) {
|
|
1977
|
-
return `${stats.name} is absolutely overjoyed! Maximum floof achieved.`;
|
|
1978
|
-
}
|
|
1979
|
-
return reactions[stats.timesPetted % reactions.length];
|
|
1980
|
-
}
|
|
1981
|
-
function feedFox() {
|
|
1982
|
-
decay();
|
|
1983
|
-
stats.hunger = Math.min(100, stats.hunger + 25);
|
|
1984
|
-
stats.happiness = Math.min(100, stats.happiness + 5);
|
|
1985
|
-
stats.timesFed++;
|
|
1986
|
-
const foods = [
|
|
1987
|
-
"a small cookie",
|
|
1988
|
-
"some berries",
|
|
1989
|
-
"a piece of fish",
|
|
1990
|
-
"a tiny sandwich",
|
|
1991
|
-
"some trail mix",
|
|
1992
|
-
"a warm dumpling",
|
|
1993
|
-
"a bit of cheese"
|
|
1994
|
-
];
|
|
1995
|
-
const food = foods[stats.timesFed % foods.length];
|
|
1996
|
-
if (stats.hunger >= 95) {
|
|
1997
|
-
return `${stats.name} nibbles ${food} contentedly. Completely stuffed!`;
|
|
1998
|
-
}
|
|
1999
|
-
return `${stats.name} happily munches on ${food}.`;
|
|
2000
|
-
}
|
|
2001
|
-
function restFox() {
|
|
2002
|
-
decay();
|
|
2003
|
-
stats.energy = Math.min(100, stats.energy + 30);
|
|
2004
|
-
stats.happiness = Math.min(100, stats.happiness + 5);
|
|
2005
|
-
return `${stats.name} curls up for a quick nap... Energy restored!`;
|
|
2006
|
-
}
|
|
2007
|
-
function getFoxComment() {
|
|
2008
|
-
decay();
|
|
2009
|
-
if (stats.hunger < 20) {
|
|
2010
|
-
const hungry = [
|
|
2011
|
-
`${stats.name} looks at you hopefully...`,
|
|
2012
|
-
`${stats.name}'s stomach growls.`,
|
|
2013
|
-
`${stats.name} sniffs around for food.`
|
|
2014
|
-
];
|
|
2015
|
-
return hungry[Math.floor(Math.random() * hungry.length)];
|
|
2016
|
-
}
|
|
2017
|
-
if (stats.energy < 20) {
|
|
2018
|
-
const tired = [
|
|
2019
|
-
`${stats.name} yawns widely.`,
|
|
2020
|
-
`${stats.name}'s eyelids are drooping.`,
|
|
2021
|
-
`${stats.name} stretches and looks sleepy.`
|
|
2022
|
-
];
|
|
2023
|
-
return tired[Math.floor(Math.random() * tired.length)];
|
|
2024
|
-
}
|
|
2025
|
-
if (stats.happiness < 30) {
|
|
2026
|
-
return `${stats.name} looks a bit lonely. Try /pet`;
|
|
2027
|
-
}
|
|
2028
|
-
if (Math.random() < 0.15 && stats.happiness > 60) {
|
|
2029
|
-
const happy = [
|
|
2030
|
-
`${stats.name} watches your code intently.`,
|
|
2031
|
-
`${stats.name} tilts their head curiously.`,
|
|
2032
|
-
`${stats.name} flicks an ear.`,
|
|
2033
|
-
null,
|
|
2034
|
-
null,
|
|
2035
|
-
null
|
|
2036
|
-
];
|
|
2037
|
-
return happy[Math.floor(Math.random() * happy.length)] ?? null;
|
|
2038
|
-
}
|
|
2039
|
-
return null;
|
|
2040
|
-
}
|
|
2041
|
-
function decay() {
|
|
2042
|
-
const now = Date.now();
|
|
2043
|
-
const elapsed = (now - lastDecayTime) / 6e4;
|
|
2044
|
-
if (elapsed < 1) return;
|
|
2045
|
-
lastDecayTime = now;
|
|
2046
|
-
const minutes = Math.floor(elapsed);
|
|
2047
|
-
stats.hunger = Math.max(0, stats.hunger - minutes * 1.5);
|
|
2048
|
-
stats.energy = Math.max(0, stats.energy - minutes * 0.5);
|
|
2049
|
-
if (stats.hunger < 30) stats.happiness = Math.max(0, stats.happiness - minutes * 1);
|
|
2050
|
-
if (stats.energy < 20) stats.happiness = Math.max(0, stats.happiness - minutes * 0.5);
|
|
2051
|
-
}
|
|
2052
|
-
|
|
2053
|
-
// src/components/Fox.tsx
|
|
2054
1942
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
2055
|
-
var
|
|
2056
|
-
[
|
|
1943
|
+
var FRAMES = {
|
|
1944
|
+
idle: [
|
|
2057
1945
|
" /\\_/\\ ",
|
|
2058
1946
|
" ( o.o ) ",
|
|
2059
1947
|
" > ^ < ",
|
|
@@ -2061,99 +1949,15 @@ var IDLE = [
|
|
|
2061
1949
|
" (_| |_)",
|
|
2062
1950
|
" ~ "
|
|
2063
1951
|
],
|
|
2064
|
-
[
|
|
2065
|
-
" /\\_/\\ ",
|
|
2066
|
-
" ( o.o ) ",
|
|
2067
|
-
" > ^ < ",
|
|
2068
|
-
" /| |\\ ",
|
|
2069
|
-
" (_| |_)",
|
|
2070
|
-
" ~ "
|
|
2071
|
-
],
|
|
2072
|
-
[
|
|
2073
|
-
" /\\_/\\ ",
|
|
2074
|
-
" ( o.o ) ",
|
|
2075
|
-
" > < ",
|
|
2076
|
-
" /| |\\ ",
|
|
2077
|
-
" (_| |_)",
|
|
2078
|
-
" ~ "
|
|
2079
|
-
],
|
|
2080
|
-
[
|
|
2081
|
-
" /\\_/\\ ",
|
|
2082
|
-
" ( o.o ) ",
|
|
2083
|
-
" > ^ < ",
|
|
2084
|
-
" /| |\\ ",
|
|
2085
|
-
" (_| |_)",
|
|
2086
|
-
" ~ "
|
|
2087
|
-
],
|
|
2088
|
-
[
|
|
2089
|
-
" /\\_/\\ ",
|
|
2090
|
-
" ( o.o ) ",
|
|
2091
|
-
" > ^ < ",
|
|
2092
|
-
" /| |\\ ",
|
|
2093
|
-
" (_| |_)",
|
|
2094
|
-
" ~ "
|
|
2095
|
-
],
|
|
2096
|
-
[
|
|
2097
|
-
" /\\_/\\ ",
|
|
2098
|
-
" ( o.o ) ",
|
|
2099
|
-
" > < ",
|
|
2100
|
-
" /| |\\ ",
|
|
2101
|
-
" (_| |_)",
|
|
2102
|
-
" ~ "
|
|
2103
|
-
]
|
|
2104
|
-
];
|
|
2105
|
-
var THINKING = [
|
|
2106
|
-
[
|
|
2107
|
-
" /\\_/\\ ",
|
|
2108
|
-
" ( o.o ) ",
|
|
2109
|
-
" > ^ < ",
|
|
2110
|
-
" | | ",
|
|
2111
|
-
" |___| ",
|
|
2112
|
-
" . "
|
|
2113
|
-
],
|
|
2114
|
-
[
|
|
1952
|
+
thinking: [
|
|
2115
1953
|
" /\\_/\\ ",
|
|
2116
1954
|
" ( o.- ) ",
|
|
2117
1955
|
" > ^ < ",
|
|
2118
1956
|
" | | ",
|
|
2119
1957
|
" |___| ",
|
|
2120
|
-
" . . "
|
|
2121
|
-
],
|
|
2122
|
-
[
|
|
2123
|
-
" /\\_/\\ ",
|
|
2124
|
-
" ( -.o ) ",
|
|
2125
|
-
" > ^ < ",
|
|
2126
|
-
" | | ",
|
|
2127
|
-
" |___| ",
|
|
2128
1958
|
" . . . "
|
|
2129
1959
|
],
|
|
2130
|
-
[
|
|
2131
|
-
" /\\_/\\ ",
|
|
2132
|
-
" ( o.o ) ",
|
|
2133
|
-
" > ^ < ",
|
|
2134
|
-
" | | ",
|
|
2135
|
-
" |___| ",
|
|
2136
|
-
" . . "
|
|
2137
|
-
],
|
|
2138
|
-
[
|
|
2139
|
-
" /\\_/\\ ",
|
|
2140
|
-
" ( o.. ) ",
|
|
2141
|
-
" > ^ < ",
|
|
2142
|
-
" | | ",
|
|
2143
|
-
" |___| ",
|
|
2144
|
-
" . "
|
|
2145
|
-
],
|
|
2146
|
-
[
|
|
2147
|
-
" /\\_/\\ ",
|
|
2148
|
-
" ( ..o ) ",
|
|
2149
|
-
" > ^ < ",
|
|
2150
|
-
" | | ",
|
|
2151
|
-
" |___| ",
|
|
2152
|
-
" . . . "
|
|
2153
|
-
]
|
|
2154
|
-
];
|
|
2155
|
-
var WORKING = [
|
|
2156
|
-
[
|
|
1960
|
+
working: [
|
|
2157
1961
|
" /\\_/\\ ",
|
|
2158
1962
|
" ( >.< ) ",
|
|
2159
1963
|
" > ^ < ",
|
|
@@ -2161,33 +1965,7 @@ var WORKING = [
|
|
|
2161
1965
|
" (_| |_)",
|
|
2162
1966
|
" ~\\ "
|
|
2163
1967
|
],
|
|
2164
|
-
[
|
|
2165
|
-
" /\\_/\\ ",
|
|
2166
|
-
" ( >.< ) ",
|
|
2167
|
-
" > ^ < ",
|
|
2168
|
-
" /| |\\ ",
|
|
2169
|
-
" (_| |_)",
|
|
2170
|
-
" /~ "
|
|
2171
|
-
],
|
|
2172
|
-
[
|
|
2173
|
-
" /\\_/\\ ",
|
|
2174
|
-
" ( >.> ) ",
|
|
2175
|
-
" > ^ < ",
|
|
2176
|
-
" /| |\\ ",
|
|
2177
|
-
" (_| |_)",
|
|
2178
|
-
" ~\\ "
|
|
2179
|
-
],
|
|
2180
|
-
[
|
|
2181
|
-
" /\\_/\\ ",
|
|
2182
|
-
" ( <.< ) ",
|
|
2183
|
-
" > ^ < ",
|
|
2184
|
-
" /| |\\ ",
|
|
2185
|
-
" (_| |_)",
|
|
2186
|
-
" /~ "
|
|
2187
|
-
]
|
|
2188
|
-
];
|
|
2189
|
-
var SUCCESS = [
|
|
2190
|
-
[
|
|
1968
|
+
success: [
|
|
2191
1969
|
" /\\_/\\ ",
|
|
2192
1970
|
" ( ^.^ ) ",
|
|
2193
1971
|
" > w < ",
|
|
@@ -2195,59 +1973,15 @@ var SUCCESS = [
|
|
|
2195
1973
|
" (_| |_)",
|
|
2196
1974
|
" \\~/ * "
|
|
2197
1975
|
],
|
|
2198
|
-
[
|
|
2199
|
-
" /\\_/\\ ",
|
|
2200
|
-
" ( ^.^ ) ",
|
|
2201
|
-
" > w < ",
|
|
2202
|
-
" /| * |\\ ",
|
|
2203
|
-
" (_| |_)",
|
|
2204
|
-
" \\~/ "
|
|
2205
|
-
],
|
|
2206
|
-
[
|
|
2207
|
-
" /\\_/\\ ",
|
|
2208
|
-
" ( ^.^ ) ",
|
|
2209
|
-
" > w < ",
|
|
2210
|
-
" /| |\\ ",
|
|
2211
|
-
" (_| |_)",
|
|
2212
|
-
" * \\~/ "
|
|
2213
|
-
]
|
|
2214
|
-
];
|
|
2215
|
-
var ERROR = [
|
|
2216
|
-
[
|
|
1976
|
+
error: [
|
|
2217
1977
|
" /\\_/\\ ",
|
|
2218
1978
|
" ( ;.; ) ",
|
|
2219
1979
|
" > n < ",
|
|
2220
1980
|
" | | ",
|
|
2221
1981
|
" |___| ",
|
|
2222
|
-
" . "
|
|
2223
|
-
],
|
|
2224
|
-
[
|
|
2225
|
-
" /\\_/\\ ",
|
|
2226
|
-
" ( ;_; ) ",
|
|
2227
|
-
" > n < ",
|
|
2228
|
-
" | | ",
|
|
2229
|
-
" |___| ",
|
|
2230
1982
|
" "
|
|
2231
|
-
]
|
|
2232
|
-
];
|
|
2233
|
-
var GREETING = [
|
|
2234
|
-
[
|
|
2235
|
-
" /\\_/\\ ",
|
|
2236
|
-
" ( ^.^ )/",
|
|
2237
|
-
" > w < ",
|
|
2238
|
-
" /| | ",
|
|
2239
|
-
" (_| |) ",
|
|
2240
|
-
" \\~/ "
|
|
2241
1983
|
],
|
|
2242
|
-
[
|
|
2243
|
-
" /\\_/\\ ",
|
|
2244
|
-
" ( ^.^ ) ",
|
|
2245
|
-
" > w <| ",
|
|
2246
|
-
" /| | ",
|
|
2247
|
-
" (_| |) ",
|
|
2248
|
-
" \\~/ "
|
|
2249
|
-
],
|
|
2250
|
-
[
|
|
1984
|
+
greeting: [
|
|
2251
1985
|
" /\\_/\\ ",
|
|
2252
1986
|
" ( ^.^ )/",
|
|
2253
1987
|
" > w < ",
|
|
@@ -2255,33 +1989,7 @@ var GREETING = [
|
|
|
2255
1989
|
" (_| |) ",
|
|
2256
1990
|
" \\~/ "
|
|
2257
1991
|
],
|
|
2258
|
-
[
|
|
2259
|
-
" /\\_/\\ ",
|
|
2260
|
-
" ( ^.^ ) ",
|
|
2261
|
-
" > w < ",
|
|
2262
|
-
" /| |\\ ",
|
|
2263
|
-
" (_| |_)",
|
|
2264
|
-
" \\~/ "
|
|
2265
|
-
]
|
|
2266
|
-
];
|
|
2267
|
-
var PET = [
|
|
2268
|
-
[
|
|
2269
|
-
" /\\_/\\ ",
|
|
2270
|
-
" ( ^.^ ) ",
|
|
2271
|
-
" > w < ",
|
|
2272
|
-
" /| |\\ ",
|
|
2273
|
-
" (_| ~ |_)",
|
|
2274
|
-
" \\~/ "
|
|
2275
|
-
],
|
|
2276
|
-
[
|
|
2277
|
-
" /\\_/\\ ",
|
|
2278
|
-
" ( >.< ) ",
|
|
2279
|
-
" > w < ",
|
|
2280
|
-
" /| ~ |\\ ",
|
|
2281
|
-
" (_| |_)",
|
|
2282
|
-
" \\~/ "
|
|
2283
|
-
],
|
|
2284
|
-
[
|
|
1992
|
+
pet: [
|
|
2285
1993
|
" /\\_/\\ ",
|
|
2286
1994
|
" ( ^w^ ) ",
|
|
2287
1995
|
" > ~ < ",
|
|
@@ -2289,25 +1997,7 @@ var PET = [
|
|
|
2289
1997
|
" (_| |_)",
|
|
2290
1998
|
" \\~/ * "
|
|
2291
1999
|
],
|
|
2292
|
-
[
|
|
2293
|
-
" /\\_/\\ ",
|
|
2294
|
-
" ( ^.^ ) ",
|
|
2295
|
-
" > w < ",
|
|
2296
|
-
" /| |\\ ",
|
|
2297
|
-
" (_| |_)",
|
|
2298
|
-
" * \\~/ "
|
|
2299
|
-
]
|
|
2300
|
-
];
|
|
2301
|
-
var EATING = [
|
|
2302
|
-
[
|
|
2303
|
-
" /\\_/\\ ",
|
|
2304
|
-
" ( o.o )~",
|
|
2305
|
-
" > ^ < o",
|
|
2306
|
-
" /| |\\ ",
|
|
2307
|
-
" (_| |_)",
|
|
2308
|
-
" \\~/ "
|
|
2309
|
-
],
|
|
2310
|
-
[
|
|
2000
|
+
eating: [
|
|
2311
2001
|
" /\\_/\\ ",
|
|
2312
2002
|
" ( >o< ) ",
|
|
2313
2003
|
" > ~ < ",
|
|
@@ -2315,78 +2005,14 @@ var EATING = [
|
|
|
2315
2005
|
" (_| |_)",
|
|
2316
2006
|
" \\~/ "
|
|
2317
2007
|
],
|
|
2318
|
-
[
|
|
2319
|
-
" /\\_/\\ ",
|
|
2320
|
-
" ( ^.^ ) ",
|
|
2321
|
-
" > o < ",
|
|
2322
|
-
" /| |\\ ",
|
|
2323
|
-
" (_| |_)",
|
|
2324
|
-
" \\~/ "
|
|
2325
|
-
],
|
|
2326
|
-
[
|
|
2327
|
-
" /\\_/\\ ",
|
|
2328
|
-
" ( ^w^ ) ",
|
|
2329
|
-
" > ~ < ",
|
|
2330
|
-
" /| |\\ ",
|
|
2331
|
-
" (_| |_)",
|
|
2332
|
-
" \\~/ "
|
|
2333
|
-
]
|
|
2334
|
-
];
|
|
2335
|
-
var SLEEPING = [
|
|
2336
|
-
[
|
|
2337
|
-
" /\\_/\\ ",
|
|
2338
|
-
" ( -.- ) ",
|
|
2339
|
-
" > ~ < ",
|
|
2340
|
-
" | | ",
|
|
2341
|
-
" |___| ",
|
|
2342
|
-
" z "
|
|
2343
|
-
],
|
|
2344
|
-
[
|
|
2345
|
-
" /\\_/\\ ",
|
|
2346
|
-
" ( -.- ) ",
|
|
2347
|
-
" > ~ < ",
|
|
2348
|
-
" | | ",
|
|
2349
|
-
" |___| ",
|
|
2350
|
-
" z z "
|
|
2351
|
-
],
|
|
2352
|
-
[
|
|
2008
|
+
sleeping: [
|
|
2353
2009
|
" /\\_/\\ ",
|
|
2354
2010
|
" ( -.- ) ",
|
|
2355
2011
|
" > ~ < ",
|
|
2356
2012
|
" | | ",
|
|
2357
2013
|
" |___| ",
|
|
2358
2014
|
" z z z "
|
|
2359
|
-
],
|
|
2360
|
-
[
|
|
2361
|
-
" /\\_/\\ ",
|
|
2362
|
-
" ( -.- ) ",
|
|
2363
|
-
" > ~ < ",
|
|
2364
|
-
" | | ",
|
|
2365
|
-
" |___| ",
|
|
2366
|
-
" z z "
|
|
2367
2015
|
]
|
|
2368
|
-
];
|
|
2369
|
-
var FRAME_SETS = {
|
|
2370
|
-
idle: IDLE,
|
|
2371
|
-
thinking: THINKING,
|
|
2372
|
-
working: WORKING,
|
|
2373
|
-
success: SUCCESS,
|
|
2374
|
-
error: ERROR,
|
|
2375
|
-
greeting: GREETING,
|
|
2376
|
-
pet: PET,
|
|
2377
|
-
eating: EATING,
|
|
2378
|
-
sleeping: SLEEPING
|
|
2379
|
-
};
|
|
2380
|
-
var FRAME_SPEEDS = {
|
|
2381
|
-
idle: 800,
|
|
2382
|
-
thinking: 600,
|
|
2383
|
-
working: 500,
|
|
2384
|
-
success: 600,
|
|
2385
|
-
error: 1e3,
|
|
2386
|
-
greeting: 600,
|
|
2387
|
-
pet: 500,
|
|
2388
|
-
eating: 600,
|
|
2389
|
-
sleeping: 1200
|
|
2390
2016
|
};
|
|
2391
2017
|
var BODY_COLORS = {
|
|
2392
2018
|
idle: "#5eead4",
|
|
@@ -2411,44 +2037,10 @@ var FACE_COLORS = {
|
|
|
2411
2037
|
sleeping: "#7e8ea6"
|
|
2412
2038
|
};
|
|
2413
2039
|
var Fox = memo(function Fox2({ mood = "idle" }) {
|
|
2414
|
-
const
|
|
2415
|
-
const [bubble, setBubble] = useState(null);
|
|
2416
|
-
const frames = FRAME_SETS[mood];
|
|
2417
|
-
const speed = FRAME_SPEEDS[mood];
|
|
2418
|
-
const bubbleTimer = useRef(null);
|
|
2419
|
-
useEffect(() => {
|
|
2420
|
-
setFrameIdx(0);
|
|
2421
|
-
const interval = setInterval(() => {
|
|
2422
|
-
setFrameIdx((prev) => (prev + 1) % frames.length);
|
|
2423
|
-
}, speed);
|
|
2424
|
-
return () => clearInterval(interval);
|
|
2425
|
-
}, [mood, frames.length, speed]);
|
|
2426
|
-
useEffect(() => {
|
|
2427
|
-
if (mood !== "idle") {
|
|
2428
|
-
setBubble(null);
|
|
2429
|
-
return;
|
|
2430
|
-
}
|
|
2431
|
-
const check = () => {
|
|
2432
|
-
const comment = getFoxComment();
|
|
2433
|
-
if (comment) {
|
|
2434
|
-
setBubble(comment);
|
|
2435
|
-
if (bubbleTimer.current) clearTimeout(bubbleTimer.current);
|
|
2436
|
-
bubbleTimer.current = setTimeout(() => setBubble(null), 6e3);
|
|
2437
|
-
}
|
|
2438
|
-
};
|
|
2439
|
-
const interval = setInterval(check, 15e3);
|
|
2440
|
-
return () => {
|
|
2441
|
-
clearInterval(interval);
|
|
2442
|
-
if (bubbleTimer.current) clearTimeout(bubbleTimer.current);
|
|
2443
|
-
};
|
|
2444
|
-
}, [mood]);
|
|
2445
|
-
const frame = frames[frameIdx] ?? frames[0];
|
|
2040
|
+
const frame = FRAMES[mood];
|
|
2446
2041
|
const bodyColor = BODY_COLORS[mood];
|
|
2447
2042
|
const faceColor = FACE_COLORS[mood];
|
|
2448
|
-
return /* @__PURE__ */
|
|
2449
|
-
bubble ? /* @__PURE__ */ jsx2(FoxBubble, { text: bubble }) : null,
|
|
2450
|
-
frame.map((line, i) => /* @__PURE__ */ jsx2(Text, { color: i <= 1 ? faceColor : bodyColor, children: line }, i))
|
|
2451
|
-
] });
|
|
2043
|
+
return /* @__PURE__ */ jsx2(Box, { flexDirection: "column", children: frame.map((line, i) => /* @__PURE__ */ jsx2(Text, { color: i <= 1 ? faceColor : bodyColor, children: line }, i)) });
|
|
2452
2044
|
});
|
|
2453
2045
|
function FoxBubble({ text }) {
|
|
2454
2046
|
if (!text) return null;
|
|
@@ -2643,11 +2235,10 @@ function MessageRow({ message }) {
|
|
|
2643
2235
|
init_theme();
|
|
2644
2236
|
init_format();
|
|
2645
2237
|
import { Box as Box4, Text as Text4 } from "ink";
|
|
2646
|
-
import Spinner from "ink-spinner";
|
|
2647
2238
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2648
2239
|
function ActiveToolCall({ toolName, args }) {
|
|
2649
2240
|
return /* @__PURE__ */ jsxs4(Box4, { marginLeft: 2, children: [
|
|
2650
|
-
/* @__PURE__ */ jsx5(Text4, { color: theme.cyan, children:
|
|
2241
|
+
/* @__PURE__ */ jsx5(Text4, { color: theme.cyan, children: "..." }),
|
|
2651
2242
|
/* @__PURE__ */ jsxs4(Text4, { bold: true, color: theme.yellow, children: [
|
|
2652
2243
|
" ",
|
|
2653
2244
|
toolName
|
|
@@ -2755,7 +2346,7 @@ var StatusLine = memo4(function StatusLine2({ model, messageCount, tokenEstimate
|
|
|
2755
2346
|
|
|
2756
2347
|
// src/components/UserInput.tsx
|
|
2757
2348
|
init_theme();
|
|
2758
|
-
import { useState
|
|
2349
|
+
import { useState, useCallback, memo as memo5 } from "react";
|
|
2759
2350
|
import { Box as Box6, Text as Text6, useInput } from "ink";
|
|
2760
2351
|
import TextInput from "ink-text-input";
|
|
2761
2352
|
|
|
@@ -3689,6 +3280,81 @@ var providerCommand = {
|
|
|
3689
3280
|
}
|
|
3690
3281
|
};
|
|
3691
3282
|
|
|
3283
|
+
// src/fox-state.ts
|
|
3284
|
+
var DEFAULT_STATS = {
|
|
3285
|
+
name: "DarkFox",
|
|
3286
|
+
happiness: 70,
|
|
3287
|
+
hunger: 80,
|
|
3288
|
+
energy: 90,
|
|
3289
|
+
timesPetted: 0,
|
|
3290
|
+
timesFed: 0,
|
|
3291
|
+
createdAt: Date.now()
|
|
3292
|
+
};
|
|
3293
|
+
var stats = { ...DEFAULT_STATS };
|
|
3294
|
+
var lastDecayTime = Date.now();
|
|
3295
|
+
function getFoxStats() {
|
|
3296
|
+
decay();
|
|
3297
|
+
return { ...stats };
|
|
3298
|
+
}
|
|
3299
|
+
function setFoxName(name) {
|
|
3300
|
+
stats.name = name;
|
|
3301
|
+
}
|
|
3302
|
+
function petFox() {
|
|
3303
|
+
decay();
|
|
3304
|
+
stats.happiness = Math.min(100, stats.happiness + 15);
|
|
3305
|
+
stats.timesPetted++;
|
|
3306
|
+
const reactions = [
|
|
3307
|
+
`${stats.name} nuzzles your hand.`,
|
|
3308
|
+
`${stats.name} purrs softly.`,
|
|
3309
|
+
`${stats.name}'s tail wags happily.`,
|
|
3310
|
+
`${stats.name} leans into the pets.`,
|
|
3311
|
+
`${stats.name} rolls over for belly rubs.`,
|
|
3312
|
+
`${stats.name} makes a happy chirping sound.`,
|
|
3313
|
+
`${stats.name} bumps your hand with their nose.`
|
|
3314
|
+
];
|
|
3315
|
+
if (stats.happiness >= 95) {
|
|
3316
|
+
return `${stats.name} is absolutely overjoyed! Maximum floof achieved.`;
|
|
3317
|
+
}
|
|
3318
|
+
return reactions[stats.timesPetted % reactions.length];
|
|
3319
|
+
}
|
|
3320
|
+
function feedFox() {
|
|
3321
|
+
decay();
|
|
3322
|
+
stats.hunger = Math.min(100, stats.hunger + 25);
|
|
3323
|
+
stats.happiness = Math.min(100, stats.happiness + 5);
|
|
3324
|
+
stats.timesFed++;
|
|
3325
|
+
const foods = [
|
|
3326
|
+
"a small cookie",
|
|
3327
|
+
"some berries",
|
|
3328
|
+
"a piece of fish",
|
|
3329
|
+
"a tiny sandwich",
|
|
3330
|
+
"some trail mix",
|
|
3331
|
+
"a warm dumpling",
|
|
3332
|
+
"a bit of cheese"
|
|
3333
|
+
];
|
|
3334
|
+
const food = foods[stats.timesFed % foods.length];
|
|
3335
|
+
if (stats.hunger >= 95) {
|
|
3336
|
+
return `${stats.name} nibbles ${food} contentedly. Completely stuffed!`;
|
|
3337
|
+
}
|
|
3338
|
+
return `${stats.name} happily munches on ${food}.`;
|
|
3339
|
+
}
|
|
3340
|
+
function restFox() {
|
|
3341
|
+
decay();
|
|
3342
|
+
stats.energy = Math.min(100, stats.energy + 30);
|
|
3343
|
+
stats.happiness = Math.min(100, stats.happiness + 5);
|
|
3344
|
+
return `${stats.name} curls up for a quick nap... Energy restored!`;
|
|
3345
|
+
}
|
|
3346
|
+
function decay() {
|
|
3347
|
+
const now = Date.now();
|
|
3348
|
+
const elapsed = (now - lastDecayTime) / 6e4;
|
|
3349
|
+
if (elapsed < 1) return;
|
|
3350
|
+
lastDecayTime = now;
|
|
3351
|
+
const minutes = Math.floor(elapsed);
|
|
3352
|
+
stats.hunger = Math.max(0, stats.hunger - minutes * 1.5);
|
|
3353
|
+
stats.energy = Math.max(0, stats.energy - minutes * 0.5);
|
|
3354
|
+
if (stats.hunger < 30) stats.happiness = Math.max(0, stats.happiness - minutes * 1);
|
|
3355
|
+
if (stats.energy < 20) stats.happiness = Math.max(0, stats.happiness - minutes * 0.5);
|
|
3356
|
+
}
|
|
3357
|
+
|
|
3692
3358
|
// src/commands/fox.ts
|
|
3693
3359
|
var petCommand = {
|
|
3694
3360
|
name: "pet",
|
|
@@ -3818,8 +3484,8 @@ function getCommandNames() {
|
|
|
3818
3484
|
// src/components/UserInput.tsx
|
|
3819
3485
|
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
3820
3486
|
var UserInput = memo5(function UserInput2({ value, onChange, onSubmit, disabled, history }) {
|
|
3821
|
-
const [historyIdx, setHistoryIdx] =
|
|
3822
|
-
const [suggestion, setSuggestion] =
|
|
3487
|
+
const [historyIdx, setHistoryIdx] = useState(-1);
|
|
3488
|
+
const [suggestion, setSuggestion] = useState("");
|
|
3823
3489
|
useInput((_input, key) => {
|
|
3824
3490
|
if (disabled || !history || history.length === 0) return;
|
|
3825
3491
|
if (key.upArrow) {
|
|
@@ -3921,38 +3587,38 @@ function getContextLimit3(model) {
|
|
|
3921
3587
|
function REPL({ initialPrompt }) {
|
|
3922
3588
|
const { model: initialModel, systemPromptOverride } = useDarkfooContext();
|
|
3923
3589
|
const { exit } = useApp();
|
|
3924
|
-
const [model, setModel] =
|
|
3925
|
-
const [messages, setMessages] =
|
|
3926
|
-
const [inputValue, setInputValue] =
|
|
3927
|
-
const [isStreaming, setIsStreaming] =
|
|
3928
|
-
const [streamingText, setStreamingText] =
|
|
3929
|
-
const [activeTool, setActiveTool] =
|
|
3930
|
-
const [toolResults, setToolResults] =
|
|
3931
|
-
const [commandOutput, setCommandOutput] =
|
|
3932
|
-
const [inputHistory, setInputHistory] =
|
|
3933
|
-
const [tokenCounts, setTokenCounts] =
|
|
3934
|
-
const [systemPrompt, setSystemPrompt] =
|
|
3935
|
-
const [foxMood, setFoxMood] =
|
|
3936
|
-
const [providerOnline, setProviderOnline] =
|
|
3937
|
-
const abortRef =
|
|
3938
|
-
const hasRun =
|
|
3939
|
-
const sessionId =
|
|
3940
|
-
const messagesRef =
|
|
3590
|
+
const [model, setModel] = useState2(initialModel);
|
|
3591
|
+
const [messages, setMessages] = useState2([]);
|
|
3592
|
+
const [inputValue, setInputValue] = useState2("");
|
|
3593
|
+
const [isStreaming, setIsStreaming] = useState2(false);
|
|
3594
|
+
const [streamingText, setStreamingText] = useState2("");
|
|
3595
|
+
const [activeTool, setActiveTool] = useState2(null);
|
|
3596
|
+
const [toolResults, setToolResults] = useState2([]);
|
|
3597
|
+
const [commandOutput, setCommandOutput] = useState2(null);
|
|
3598
|
+
const [inputHistory, setInputHistory] = useState2([]);
|
|
3599
|
+
const [tokenCounts, setTokenCounts] = useState2({ input: 0, output: 0 });
|
|
3600
|
+
const [systemPrompt, setSystemPrompt] = useState2("");
|
|
3601
|
+
const [foxMood, setFoxMood] = useState2("idle");
|
|
3602
|
+
const [providerOnline, setProviderOnline] = useState2(true);
|
|
3603
|
+
const abortRef = useRef(null);
|
|
3604
|
+
const hasRun = useRef(false);
|
|
3605
|
+
const sessionId = useRef(createSessionId());
|
|
3606
|
+
const messagesRef = useRef(messages);
|
|
3941
3607
|
messagesRef.current = messages;
|
|
3942
|
-
const modelRef =
|
|
3608
|
+
const modelRef = useRef(model);
|
|
3943
3609
|
modelRef.current = model;
|
|
3944
|
-
const systemPromptRef =
|
|
3610
|
+
const systemPromptRef = useRef(systemPrompt);
|
|
3945
3611
|
systemPromptRef.current = systemPrompt;
|
|
3946
3612
|
const tools = getTools();
|
|
3947
3613
|
const cwd = process.cwd();
|
|
3948
|
-
|
|
3614
|
+
useEffect(() => {
|
|
3949
3615
|
if (systemPromptOverride) {
|
|
3950
3616
|
setSystemPrompt(systemPromptOverride);
|
|
3951
3617
|
} else {
|
|
3952
3618
|
buildSystemPrompt(tools, cwd).then(setSystemPrompt);
|
|
3953
3619
|
}
|
|
3954
3620
|
}, []);
|
|
3955
|
-
|
|
3621
|
+
useEffect(() => {
|
|
3956
3622
|
const provider = getProvider();
|
|
3957
3623
|
provider.healthCheck().then((ok) => {
|
|
3958
3624
|
setProviderOnline(ok);
|
|
@@ -3985,7 +3651,7 @@ function REPL({ initialPrompt }) {
|
|
|
3985
3651
|
});
|
|
3986
3652
|
}, []);
|
|
3987
3653
|
const clearMessages = useCallback2(() => setMessages([]), []);
|
|
3988
|
-
const commandContextRef =
|
|
3654
|
+
const commandContextRef = useRef({
|
|
3989
3655
|
messages,
|
|
3990
3656
|
model,
|
|
3991
3657
|
cwd,
|
|
@@ -4146,14 +3812,14 @@ function REPL({ initialPrompt }) {
|
|
|
4146
3812
|
},
|
|
4147
3813
|
[addToHistory, exit, cwd, runQuery]
|
|
4148
3814
|
);
|
|
4149
|
-
|
|
3815
|
+
useEffect(() => {
|
|
4150
3816
|
if (initialPrompt && !hasRun.current) {
|
|
4151
3817
|
hasRun.current = true;
|
|
4152
3818
|
runQuery(initialPrompt);
|
|
4153
3819
|
}
|
|
4154
3820
|
}, [initialPrompt, runQuery]);
|
|
4155
|
-
const autoCompactRef =
|
|
4156
|
-
|
|
3821
|
+
const autoCompactRef = useRef(false);
|
|
3822
|
+
useEffect(() => {
|
|
4157
3823
|
if (isStreaming || autoCompactRef.current || messages.length < 6) return;
|
|
4158
3824
|
const totalChars = messages.reduce((sum, m) => sum + m.content.length, 0);
|
|
4159
3825
|
const estTokens = Math.ceil(totalChars / 4) + 2e3;
|
|
@@ -4205,14 +3871,11 @@ ${result.content}
|
|
|
4205
3871
|
isStreaming && streamingText ? /* @__PURE__ */ jsxs7(Box7, { marginBottom: 1, children: [
|
|
4206
3872
|
/* @__PURE__ */ jsx8(Text7, { color: theme.cyan, children: "\u23BF " }),
|
|
4207
3873
|
/* @__PURE__ */ jsx8(Text7, { color: theme.text, wrap: "wrap", children: streamingText }),
|
|
4208
|
-
/* @__PURE__ */
|
|
4209
|
-
" ",
|
|
4210
|
-
/* @__PURE__ */ jsx8(Spinner2, { type: "dots" })
|
|
4211
|
-
] })
|
|
3874
|
+
/* @__PURE__ */ jsx8(Text7, { color: theme.dim, children: " ..." })
|
|
4212
3875
|
] }) : null,
|
|
4213
3876
|
isStreaming && !streamingText && !activeTool ? /* @__PURE__ */ jsxs7(Box7, { marginLeft: 2, children: [
|
|
4214
|
-
/* @__PURE__ */ jsx8(Text7, { color: theme.cyan, children:
|
|
4215
|
-
/* @__PURE__ */ jsx8(Text7, { color: theme.dim, children: " Thinking
|
|
3877
|
+
/* @__PURE__ */ jsx8(Text7, { color: theme.cyan, children: "..." }),
|
|
3878
|
+
/* @__PURE__ */ jsx8(Text7, { color: theme.dim, children: " Thinking" })
|
|
4216
3879
|
] }) : null,
|
|
4217
3880
|
/* @__PURE__ */ jsxs7(Box7, { children: [
|
|
4218
3881
|
/* @__PURE__ */ jsx8(Box7, { flexDirection: "column", flexGrow: 1, children: /* @__PURE__ */ jsx8(
|