@celljs/ta-town 0.0.0-stage → 4.11.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.en.md +115 -0
- package/README.md +113 -2
- package/package.json +49 -4
- package/web/index.js +14650 -0
package/README.en.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Cell - Ta Town
|
|
2
|
+
|
|
3
|
+
A Ta extension of its own (not built in; install it when you want it): a pixel town after Stanford's Smallville (Generative Agents), where the double, the agents and the tasks are residents, so that who does what, and where, shows at a glance, and you can talk to them right there.
|
|
4
|
+
|
|
5
|
+
## What is in the town
|
|
6
|
+
|
|
7
|
+
- **The double's office** (at the top): a checkered floor, shelves, a board of notes, a coffee machine and a water cooler, three screens. The double sits at its desk while it answers you, its screens lit; it stands in its office while something waits for you; late at night it naps by the sofa.
|
|
8
|
+
- **Meeting rooms of the channels** (beside the office): one for each of your own channels of `@celljs/ta-channels`, a whiteboard, a long table, a water cooler. Members answering in a channel sit at its table, and bob a little as they type.
|
|
9
|
+
- **The park** (in the middle): a plaza with a fountain, benches, lamps and flowers, a pond with ducks at the bottom left, a café with parasols at the bottom right. Free members stroll here and greet each other as they meet; a cat wanders about, butterflies by day, a flock of birds now and then, fireflies at night.
|
|
10
|
+
- **The members' homes** (below the park): one each, the bed in the colour of its face, a desk, a TV, a floor lamp, windows in the back wall. A member working in its own conversation sits at its desk; one with something new for you stays home.
|
|
11
|
+
- **The task workshop** (at the bottom of the town): a workbench for each task of the double (every one that goes on or needs you, the latest ended up to 12), tools on the wall. The agents Ta made for a task sit at its bench; the free double goes round the running benches.
|
|
12
|
+
|
|
13
|
+
## Around the town
|
|
14
|
+
|
|
15
|
+
All of it is an island in the sea: sand along the coasts of the west and the east, the cliffs of the mountains straight into the sea in the north, the sea deeper further out. Roads go round the town, and from them and the park out into the wilds (zoom out to see it all):
|
|
16
|
+
|
|
17
|
+
- **Mountains to the north**: two rows of snowy peaks, a cliff at their foot, pines and boulders below; a path up to a lookout with a telescope and a bench. A waterfall comes down the mountains, and the river starts there.
|
|
18
|
+
- **A forest to the west**: pines and broadleaf trees, an orange one of autumn now and then, mushrooms, stumps and fallen leaves; a lake with reeds. The park's path goes on to a camp in a clearing: a tent, a campfire and logs around it.
|
|
19
|
+
- **The river and a farm to the east**: the river runs from the waterfall down to the sea under a wooden bridge; across it a red barn, hay bales and fields of four crops (wheat, cabbages, carrots, sunflowers), with a scarecrow.
|
|
20
|
+
- **A beach and the sea to the south**: parasols and towels, a sandcastle, shells and starfish, palms along the grass; a pier into the sea from the town's south road, a boat tied by it; a lighthouse on rocks at the east end. Waves come up the sand and go back, the sea glints, a sailboat goes between the pier and the lighthouse, gulls by day, a fish jumping now and then.
|
|
21
|
+
|
|
22
|
+
Now and then a free resident goes out a while: to the beach, the camp, the lookout, the bridge, the farm or the pier.
|
|
23
|
+
|
|
24
|
+
The town keeps hours: from 11:30 to 13:30 the free have lunch at the café (🍜), from 0:00 to 6:00 they sleep at home (💤), at weekends from 10:00 to 17:00 they go to the beach (🏖️), on Friday from 17:00 to 20:00 they gather at the fountain (🎉), every evening from 20:00 to 23:00 they sit by the campfire in the woods (🔥). The light follows the time: warm at dawn and dusk, bluish at night; the dark theme is the town at night (lamps, screens and the campfire glow, the lighthouse's beam goes round).
|
|
25
|
+
|
|
26
|
+
Over each resident are an emoji and its name (💬 meeting, 💻 working, 📬 news, ⏳ waiting for you, 💭 answering, 👂 listening to you, 👀 going round; the free one of ☕ 🌳 🎵 📖 🚶); what it just said floats in a bubble for 6 seconds. Residents too near each other show their emoji only, until picked; the picked one has a green tag and a green ring at its feet. An amber dot by a sign needs you.
|
|
27
|
+
|
|
28
|
+
## Talking to residents
|
|
29
|
+
|
|
30
|
+
Tap a resident (the double or a member): under its card is the very message box of a conversation (`ui.Composer`):
|
|
31
|
+
|
|
32
|
+
- **Hold to talk**: on a phone hold the box (while the keyboard is down), or tap the microphone for the 按住 说话 bar and hold it; let go to send, slide onto 取消 to drop it, onto 编辑 to put it in the box. With a mouse, click the microphone to dictate; what it hears is sent. It turns to listen as you talk (👂).
|
|
33
|
+
- **Type**: Enter sends, Shift+Enter is a new line; while a member answers, the send button stops it.
|
|
34
|
+
- The card keeps a short thread: what you said on the right, its answers on the left (in Markdown, as a conversation shows them), in full once written. Said by voice, an answer is read aloud in the voice of the settings; the wave button in the box stops reading, the speaker by an answer reads it again.
|
|
35
|
+
- It stops and faces you as you talk (👂), and shows 💭 as it answers; the double's message goes to its own conversation (the `send` of its view), a member's to its own session.
|
|
36
|
+
- Tap a meeting room and the same box speaks in that channel (`@` lists its members); its members answer there.
|
|
37
|
+
- Open conversation at the top right of the card opens the whole conversation; tapping a resident twice does too.
|
|
38
|
+
|
|
39
|
+
## Possess: walk the town in 3D
|
|
40
|
+
|
|
41
|
+
The gamepad button at the top right (or Possess on a resident's card) makes the town a world of blocks (`pi.ui.Game3D`, Three.js) and puts you in the double or the resident picked, in the first person. All of the map is there: the office, the meeting rooms, the furniture of each home, the park and its fountain, and out in the wilds the mountains, the waterfall, the camp in the forest, the farm, the river, the beach, the pier and the lighthouse. The others go about what they do as on the map; back on the map, the one you were in stays where you took it.
|
|
42
|
+
|
|
43
|
+
- **Moving**: on a phone the left of the screen is a stick (where the thumb comes down is its middle; all the way out runs), a drag anywhere on the right looks round (a tap there does nothing, so turning never acts by mistake); with keys WASD or the arrows walk, Shift runs, Space jumps, a click locks the mouse to look round (Esc frees it), a drag looks too. A block in the way is jumped by itself; you swim with the head out of the water; jump twice to fly, hold the jump to rise, look down and go forward to come down, and landing ends it.
|
|
44
|
+
- **Full screen**: the world in 3D covers the whole screen (`pi.ui.FullScreen`), with no head of the page and no black edges by the notch on a phone held sideways; the buttons keep off the notch and the home bar, and a slide from an edge is the game's, not one back to the list. In an app older than it, the world fixes itself over the whole page (the layers of the shell's sheets that would hold a fixed element let it go meanwhile, as they were after), with no head or black edges either. A long press, a double tap or a drag in the game selects no text and opens no menu, and the shell hears none of those touches; only the text of the talk and of the guide can be selected.
|
|
45
|
+
- **Feel**: walking eases up to speed in about a fifth of a second and stops as you let go; the base of the stick follows a thumb that goes past it, so turning back needs no reach; behind, the camera comes in at once when something is in the way and goes back out smoothly.
|
|
46
|
+
- **The map**: in the top right, north up, you the green arrow, residents dots; tapped, the map of the island with the names of its parts, where a tap walks you there by itself: along the ways round the houses and the water, looking where you like, a dashed line on the map and a red pillar of light at the end, a jump where it is stuck; the stick, a key or Stop takes over. M opens it with keys.
|
|
47
|
+
- **View**: the eye button (V) goes between the first person and behind, where you see the resident or the dinosaur you are in.
|
|
48
|
+
- **Buttons on a phone**: the buttons at the bottom right stay where they are whatever the cross is on, laid out as in a shooter on a phone: the big one uses what is in hand (the pickaxe, a block; the hand, it acts), held it chops, mines and builds on, a ring round the cross filling as a tree or a rock takes the hits, and a thumb slid on it turns the view; the small one above it is the bare hand, the only one that opens a talk (blue, saying Talk, on a resident); the jump is below it. Possess is under the cross, out of the thumb's way.
|
|
49
|
+
- **Acting**: under the cross is what you can do with what it is on; with keys E (or F, a right click) does it with the bare hand: sit (benches, chairs, sofas, stumps, the logs by the fire), nap (beds, towels, the tent), switch lights and TVs, type at a desk, have a coffee (faster for a while), toast marshmallows, shake a tree (a palm drops a coconut), pick flowers, eat a mushroom (higher jumps for a while), shout at the mountains for an echo, get in the boat, look through the spyglass (it zooms), kick the sandcastle over or build it again, scare the crows, read the shelves, open crates, hammer at a bench, water a plant, jump in the hay, wish at the fountain (a rainbow every third), fish in the water.
|
|
50
|
+
- **Animals**: a cat (petted, it follows you a while), the ducks of the pond, hens and sheep by the barn (a sheep can be shorn; its wool grows back), gulls, fish that jump, fireflies in the woods and butterflies by the flowers.
|
|
51
|
+
- **Residents**: with the cross on one, E or the hand's button on a phone opens a talk with it (the box of its card, held to talk too); with the pickaxe or a block, a click or the big button never does. Q or Possess under the cross goes into it. The talk button at the top talks to the one you are in.
|
|
52
|
+
- The light follows the map's: the dark theme or the evening is night, under the sky of Van Gogh's Starry Night (a shader on a dome about the eye): strokes of deep blue that flow and twist into great swirls (the greatest pair over the mountains to the north), stars in rings of yellow light that breathe, an orange crescent moon in its halo to the north-east, pale wisps over the horizon, the far land fading into its blue fog; the stars and swirls stay where they are as you turn, the swirls turning slowly (still with less motion); with windows, lamps and the lighthouse lit, stars and the glow of the fire; busy places have their screens on. Back at the top left (or Esc twice) returns to the map.
|
|
53
|
+
- **Weather**: as in a game of blocks, clear, cloudy, rain, a thunderstorm, snow and fog follow one another by themselves, each fading into the next (the weather button at the top picks one that stays, or back to by itself). Rain and snow fall about you, stopping on the roofs, none indoors; in the rain the sky goes grey, the fog comes nearer, the land darker and wet, the campfire goes out, the butterflies and fireflies hide, the fish bite sooner; in a storm lightning strikes far off and the sky flashes white; in the snow the land and the tops of the blocks slowly turn white; up on the mountains the rain is snow; when the rain stops and the sky clears, a rainbow stands against the sun.
|
|
54
|
+
- **Creative and adventure**: two modes, switched at the top. In the creative mode you fly, blocks are without end and nothing hurts. In the adventure you gather what you build with, a fall from high up hurts (ten hearts, coming back slowly, or with a mushroom or a nap), slimes come out of the dark at night and in a storm and hop at you, a big one splitting in two, melting at day; a chest is hidden on the highest peak and in each part of the island, the arrow at the top right pointing to the nearest, and finding them all sets off fireworks over the fountain. Fainting, you wake up by the fountain.
|
|
55
|
+
- **The bar and building**: the bar at the bottom is what is in your hand: the hand (the acts of before), the pickaxe and blocks (planks, log, stone, bricks, glass, leaves, sand, dirt, snow, lamp, gold, diamond). With a block, aim at the land or the face of a block to put it there; with the pickaxe, break blocks, chop trees (they grow again in a few minutes), mine the mountains (now and then gold or a diamond, snow up high), dig sand and dirt; at the campfire sand bakes into glass and dirt into bricks, at the workbench a log is sawn into planks, glass and a plank make a lamp. Blocks are stood on, climbed one at a time, and in the way of the head. A click uses what is in hand (held, again and again), E, F or a right click always the bare hand; 1–9 and the wheel pick, on a phone a tap on the bar.
|
|
56
|
+
- **Achievements**: a first block, a tree chopped, a diamond, a fish in the rain, the highest peak, a mountain in a storm, a rainbow, slimes, treasures, out to sea, a whale, scores of the games… 20 of them, told at the top as they come, all in the guide. What you built, the mode, the weather, what you carry, the treasures found and the achievements are kept in the extension's storage, there again next time.
|
|
57
|
+
- **Styles of the sky**: the weather button also changes the sky: classic (a blue day, Van Gogh's starry night at night), the Starry Night all day, the northern lights (curtains of green and violet over the north at night), an endless sunset, candy (mint, pink, lilac and clouds of cotton) and the Milky Way (nebulae, many stars, a planet with rings). The fog and the horizon take the colours of the sky, the lamps and windows light as it is dark.
|
|
58
|
+
- **Out to sea**: the bare hand on the boat by the pier boards it; the stick (WASD) sails where it is pushed, on the lake and the river and out to sea, 80 m off shore at most; it rocks on the waves with a wake behind it. An islet is off each coast, its chest opened from the boat (gold and diamonds); far out a whale comes up now and then. By a shore the jump (the anchor on a phone, or Land in the bar) lands; the boat stays where it was left.
|
|
59
|
+
- **Games**: Play at the top has, beside creative and adventure, two games of shooting, each with its best score. The shooting range: 60 s, targets come up in front where they can be seen, some moving; gold is worth 5, black costs 3, hits in a row multiply. The sky shooter: 90 s in a little plane over the island, always forward where you look; drag (the mouse) to steer, the stick forward for speed, back to slow, aside to slide; shoot balloons and drones, fly through gold rings for 4 s more; it pulls up by itself over the land. On a phone the big button fires (held, it goes on; slide on it to steer). At the end the score and the best show, and Play again.
|
|
60
|
+
- **Let it walk**: possessing someone, Let it walk beside its name at the top lets go: the double or the agent goes where its day takes it (a meeting, its desk, the fountain…), the view behind it following, what it says over its head; the stick or WASD takes over, or Take over.
|
|
61
|
+
|
|
62
|
+
## Together: walk and build with friends
|
|
63
|
+
|
|
64
|
+
The Together button at the top of the 3D world (it needs the built-in Rooms extension, @celljs/ta-rooms):
|
|
65
|
+
|
|
66
|
+
- **New room**: the panel opens over the world (from the bottom on a phone); give the room a name and make it: the layout of your town (the kinds of its places only, not the names of agents or tasks) becomes its map, and in it the panel shows its QR code and until when its link works, to copy, share or renew.
|
|
67
|
+
- **Asking and letting in**: who asks to join shows at the top of the owner's panel (Ta friends marked), let in or refused there; the members show who is online, the owner takes one out or closes the room, a member leaves it.
|
|
68
|
+
- **Join with a link**: paste the link a friend sent to ask to join; a room waiting for its owner is under Your rooms, to cancel.
|
|
69
|
+
- **Enter**: the town rooms you are in. Inside, each one is its dinosaur on the owner's map, where they are said five times a second; the blocks built or broken are the room's shared state by chunks of 16×16, read again and set again on their version when two change one at once. Blocks of a room do not go into your own town.
|
|
70
|
+
- **Play alone**: back to your own town. Who comes and goes is said over the world. A room you were just let into opens as the town does.
|
|
71
|
+
|
|
72
|
+
## Using it
|
|
73
|
+
|
|
74
|
+
- Drag or scroll to move: the map stays under the finger, glides on after a flick and slows as a scroll view of iOS, stops at an edge; a tap while it glides only stops it. Pinch, Ctrl/⌘ + wheel or − / + at the top right to zoom; it settles smoothly on a whole zoom so pixels stay sharp.
|
|
75
|
+
- The map button at the top right (or M, or − at the least zoom, or pinching out all the way) shows the whole map, fitted into what the card and the keyboard leave of the view, with the names of the mountains, the forest, the lake, the camp, the river, the farm, the beach and the sea, and a dot for each resident in the colour of its shirt (the double's green); a tap flies back in there, a tap on a dot picks that resident, the button again goes back to where you were.
|
|
76
|
+
- On a phone, when the box of a card brings up the keyboard, the town is not drawn again lower (no flash, no jump): the card sits on the keyboard, at most a little over half of what is left, its thread shrinking first, and the one you talk to stays in sight above it.
|
|
77
|
+
- ? at the top right is the town guide; the count opens the list of residents (beside the town on a wide screen), the busiest first; a row finds its resident.
|
|
78
|
+
- Keys (while the town has the focus): arrows or WASD move, + and − zoom, M the whole map, H finds the double, N and P go through the residents, Enter opens, Esc lets go.
|
|
79
|
+
|
|
80
|
+
## Eggs (spoilers)
|
|
81
|
+
|
|
82
|
+
Tap the fountain to make a wish, seven bring a rainbow; a tree drops leaves, and now and then a bird flies off or a squirrel peeks out; a duck quacks and paddles away; the cat sends hearts; tap the little dinosaur four times and it jumps and roars; type ↑↑↓↓←→←→BA for a party (confetti, everyone 💃).
|
|
83
|
+
|
|
84
|
+
The wilds have theirs: shout at the mountains for an echo; the campfire sparks and toasts marshmallows; the sailboat calls ahoy and turns about; the lighthouse shines its beam; the scarecrow sends crows off; a mushroom gives a 1UP; a palm drops a coconut; the sandcastle, the tent and the telescope each have a word; the sea and the river splash, and sometimes a fish jumps.
|
|
85
|
+
|
|
86
|
+
## What it reads
|
|
87
|
+
|
|
88
|
+
The town reads through public APIs, and writes only what you send:
|
|
89
|
+
|
|
90
|
+
| Source | What |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| `pi.packages.getExtensionData('@celljs/ta-channels', …)` | `team`, `working`, `messages/<channel>`, `ui.agentsToLook`, `ui.seenTasks` (see the README of ta-channels), read every 2.5 seconds while the town is seen |
|
|
93
|
+
| `pi.ui.useTasks()` | the double's tasks and the teams Ta built |
|
|
94
|
+
| `pi.ui.useSessions()`, `pi.server.listSavedSessions()` | who answers in their own session, what each member said last |
|
|
95
|
+
| `pi.ui.useView('assistant/assistant')` | whether the double answers, its last line, and `send` to talk to it |
|
|
96
|
+
|
|
97
|
+
A member gets a message by `pi.server.prompt` (its session opened first, if it is not, by `openAgent` of the server side of ta-channels, `packages.callPackageHost('@celljs/ta-channels', 'request', ...)`); a channel by its `post`. The box is the page's `ui.Composer` (`voiceSends` sends what it hears, `onTalkSent` tells the town a line was said so its answer is read aloud, `onListening` turns the resident to listen, `working` / `onStop` stop a member); reading aloud is `ui.voice`, the whole answer `pi.server.getLastAssistantText`. Without ta-channels, the town has the double and the tasks only.
|
|
98
|
+
|
|
99
|
+
## Install
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
ta install npm:@celljs/ta-town
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Or put the built directory (`package.json` and `web/`) in `~/.ta/agent/extensions/ta-town/`. It starts on open (`webActivation: open`), under Discover and in Quick open.
|
|
106
|
+
|
|
107
|
+
## Development
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
bun run build # tsc → lib/, bun build → web/index.js
|
|
111
|
+
bun run test
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`town-model.ts` makes residents and places of the data (with the hours of the town and whom you talk to), `town-map.ts` lays out the map and finds the way (A*, `heap.ts`), `town-tiles.ts` paints the tileset in code, `pixel-art.ts` the furniture and characters (no image is loaded). The Phaser scene (`pi.ui.Game`) is `town-scene.ts`: the ground a Tilemap layer, the furniture images sorted by their feet (`town-ground.ts`); a resident (`resident-view.ts`) walks by Phaser animations, its tag and bubble by tweens; signs, light, screens and the ring of a pick are `town-decor.ts`; ducks, the cat, butterflies, fireflies, birds and the eggs are `town-life.ts`; `town-camera.ts` moves, glides, zooms and hears the keys. The page is `town.tsx`, the card and its bar `town-card.tsx`, talking in place `quick-talk.ts`. Where the residents are and go is `town-walk.ts`, the same for the map and the world in 3D. That world is `world/`: `world-grid.ts` makes the map heights of blocks (walls three high, the mountains higher to the north, the sea deeper out), `world-models.ts` the land and each kind of furniture as boxes, `world-blocks.ts` draws them as instanced meshes (the grain of the blocks taken in the shader from where they are), `world-figures.ts` the residents and the dinosaur of blocks, `world-player.ts` walking, jumping, swimming, flying and what is in the way, `world-acts.ts` what the cross is on and what can be done with it, `world-life.ts` the animals, the fire, the waterfall, the lighthouse, the sky and what flies, `world-sky.ts` the Starry Night of the night, a shader, `world-nav.ts` the way to where the user picked, the A* of the map pulled taut to a few corners, and the keys of each frame along it, `world-minimap.ts` the map in the top right and that of the whole island, `world-weather.ts` the weather, one after another, and its rain, snow, lightning and rainbow, `world-build.ts` the blocks the user built (by cell and by column, for what is stood on and what is over the he... [truncated]
|
|
115
|
+
[Truncated: PARTIAL view — /Users/yangsubo/workspace/cell-ta-town2/ta-packages/ta-town/README.en.md: showing lines 1-99 of 99 (18189 bytes). 1 line exceeded 2000 characters and was truncated in place; offset/limit cannot recover the rest of that line — use Grep to find a specific section or read a narrower range. Do NOT answer from this page alone if the answer may be further in the file.]
|
package/README.md
CHANGED
|
@@ -1,3 +1,114 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Cell - Ta Town
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
一个独立的 Ta 扩展(不是内置包,按需安装):参照斯坦福小镇(Smallville,Generative Agents)的像素小镇,把分身、智能体和任务画成小镇里的居民,一眼看到谁在哪儿做什么,也能就地和它们说话。
|
|
4
|
+
|
|
5
|
+
## 小镇里有什么
|
|
6
|
+
|
|
7
|
+
- **分身的办公室**(最上方):棋盘地砖、书架、便签板、咖啡机和饮水机、三块屏幕。分身回答你时坐在桌前、屏幕亮起;有事等你看时站在办公室里;深夜在沙发边打盹。
|
|
8
|
+
- **频道的会议室**(办公室两侧):`@celljs/ta-channels` 里你自己的频道,各一间,白板、长桌、饮水机。在频道里回答的成员坐到桌旁,敲键盘时会轻轻上下动。
|
|
9
|
+
- **公园**(中间):喷泉广场、长椅、路灯、花丛,左下是有小鸭子的池塘,右下是带遮阳伞的咖啡亭。闲着的成员在这里散步,两人碰面会打个招呼;一只小猫到处溜达,白天有蝴蝶,偶尔有鸟群飞过,夜里有萤火虫。
|
|
10
|
+
- **成员的家**(公园下方):每人一间,床的颜色是它头像的颜色,还有书桌、电视、落地灯,后墙有窗。在自己对话里干活的坐在桌前;有新消息等你看的待在家里。
|
|
11
|
+
- **任务工坊**(小镇最下方):分身的每个任务一张工作台(进行中和需要你看的全部列出,已结束的补到 12 张),墙上挂着工具。Ta 为任务临时建的成员坐在它的工作台旁;分身空闲时挨个巡视进行中的工作台。
|
|
12
|
+
|
|
13
|
+
## 小镇外面
|
|
14
|
+
|
|
15
|
+
整个小镇在一座岛上,四面是海:西边和东边的海岸是沙滩,北边雪山的悬崖直接落进海里,海越往外越深。小镇四周有环路,路从公园和环路通向野外(缩小地图就能看到全貌):
|
|
16
|
+
|
|
17
|
+
- **北边是雪山**:两排山峰,山脚是悬崖,山下的松林里散着石头;一条小路通到山下的瞭望台,有望远镜和长椅。山间有瀑布,河从这里流出。
|
|
18
|
+
- **西边是森林**:松树和阔叶树混杂,偶尔一棵秋天的橙树,地上有蘑菇、树桩和落叶;林中有个湖,湖边长着芦苇。公园的横路一直通到林间空地的营地:帐篷、篝火和一圈原木凳。
|
|
19
|
+
- **东边是河和农场**:河从瀑布一路流到海里,过河有木桥;河对岸是红色谷仓、干草垛和四种庄稼的田(麦子、白菜、胡萝卜、向日葵),田里有稻草人。
|
|
20
|
+
- **南边是海滩和大海**:沙滩上有遮阳伞和毛巾、沙堡、贝壳和海星,草地边有椰子树;从小镇南路下来是伸进海里的栈桥,旁边拴着小船;东头的礁石上有座灯塔。海浪一涨一落,海面有闪光,帆船在栈桥和灯塔之间来回,白天有海鸥,偶尔有鱼跃出水面。
|
|
21
|
+
|
|
22
|
+
闲着的居民偶尔会出镇走走:去海滩、营地、瞭望台、桥上、农场或栈桥。
|
|
23
|
+
|
|
24
|
+
小镇有作息:11:30–13:30 闲着的去咖啡亭吃午饭(🍜),0:00–6:00 回家睡觉(💤),周末 10:00–17:00 去海滩(🏖️),周五 17:00–20:00 在喷泉边聚会(🎉),每晚 20:00–23:00 围着林间篝火(🔥)。光线跟着时间:清晨和傍晚暖色、夜里偏蓝,深色主题是夜晚(路灯、屏幕和篝火会发光,灯塔的光束转起来)。
|
|
25
|
+
|
|
26
|
+
每个居民头顶是一个 emoji 和名字(💬 开会、💻 干活、📬 有新消息、⏳ 等你回复、💭 正在回答、👂 在听你说、👀 巡视,闲着的是 ☕ 🌳 🎵 📖 🚶 之一);刚说的话以气泡显示 6 秒。名字挨得太近时只显示 emoji,点开再看;选中的居民名牌带绿框,脚下有绿圈。屋顶招牌旁的黄点表示需要你看。
|
|
27
|
+
|
|
28
|
+
## 和居民说话
|
|
29
|
+
|
|
30
|
+
点一个居民(分身或成员),底部卡片下方是和对话里一模一样的输入框(`ui.Composer`):
|
|
31
|
+
|
|
32
|
+
- **按住说话**:手机上按住输入框说话(键盘收起时),或点麦克风换成“按住 说话”条再按住;松手发出,滑到“取消”丢掉,滑到“编辑”放进输入框改。用鼠标时点麦克风听写,听完直接发出。说话时它会转过来听你(👂)。
|
|
33
|
+
- **打字**:回车发出,Shift+回车换行;成员正在回答时发送键变成停止。
|
|
34
|
+
- 卡片里是一小段对话:你说的在右、它的回答在左(Markdown 显示,和对话里一样),回答写完后取全文。用语音说的,回答会用设置里的声音读出来;输入框右侧的声波按钮停止朗读,每条回答旁的喇叭再听一遍。
|
|
35
|
+
- 说话时它会停下来面对你(👂),回答时是 💭;分身的消息发到它自己的对话(视图的 `send`),成员的消息发到它自己的会话。
|
|
36
|
+
- 点会议室,同一个输入框是在这个频道里发言(`@` 列出它的成员),成员会在频道里接着回答。
|
|
37
|
+
- 卡片右上的“打开对话”进入完整对话;连点两下居民也直接打开。
|
|
38
|
+
|
|
39
|
+
## 附身:走进 3D 小镇
|
|
40
|
+
|
|
41
|
+
右上角的手柄按钮(或居民卡片上的“附身”)把小镇变成一个方块世界(`pi.ui.Game3D`,Three.js),你附身在分身或选中的居民身上,以第一人称在里面走——地图里的一切都在:办公室、会议室、各家的家具、公园和喷泉,外面的雪山、瀑布、森林营地、农场、河、海滩、栈桥和灯塔。其他居民照常按自己的事走来走去,回到地图时你附身的那位留在你走到的地方。
|
|
42
|
+
|
|
43
|
+
- **移动**:手机上屏幕左边是摇杆(拇指按下就是中心,推到底就跑),右边任意位置拖动看四周(只点一下什么都不会发生,转视角不会误操作);电脑上 WASD / 方向键走、Shift 跑、空格跳,点一下锁定鼠标转视角(Esc 解开),拖动也行。撞到一格高的东西会自己跳上去;能游泳(头露在水面上);连按两次跳会飞起来,按住跳上升、看着地面往前飞会降落,落地就停。
|
|
44
|
+
- **全屏**:3D 世界铺满整个屏幕(`pi.ui.FullScreen`),手机横屏时没有页面顶栏,也没有刘海两侧的黑边;按钮都避开刘海和底部横条,屏幕边缘的滑动也归游戏,不会把页面滑回列表。比它旧的 App 里,世界自己固定铺满整页(把挡住 fixed 的外壳动画层暂时放开,离开时还原),同样没有顶栏和黑边。游戏里长按、双击、拖动都不会选中文字或弹出菜单,外壳也收不到这些触摸;只有对话卡片和指南里的文字可以选。
|
|
45
|
+
- **手感**:走动有加速和减速(约 0.2 秒到速、松手就停),摇杆被拇指拖出圈时底座跟着走,回头不用把拇指挪回去;第三人称镜头被挡住时立刻拉近、之后平滑退回。
|
|
46
|
+
- **小地图导航**:右上角是小地图(北在上,绿色箭头是你,彩点是居民);点开是整座岛的地图,写着各处的名字,点哪里就自动走过去:沿路绕开房子和水,路上看哪儿都行,地图上是虚线、远处有一根红色光柱标着终点,卡住了会自己跳;推摇杆或按方向键就停下,也可以点“停下”。电脑上 M 打开地图。
|
|
47
|
+
- **视角**:眼睛按钮(V)在第一人称和身后视角间切换,第三人称能看到自己附身的小人或恐龙。
|
|
48
|
+
- **手机按钮**:右下一组按钮位置固定、不随准星对着的东西变动,照射击类手游的布局:大按钮用手里的东西(镐、方块;拿着手时就是互动),按住不放就连续砍树、挖矿、放方块,准星外圈显示还要砍几下,按住时拇指还能在按钮上滑动转视角;它左上的小按钮是空手互动,只有它会打开对话(对着居民时变蓝、显示“对话”);左下是跳。附身的按钮在准星下方,拇指够不着,不会误触。
|
|
49
|
+
- **互动**:准星对着的东西下方写着能做什么,电脑上 E(或 F、右键)空手做——坐下(长椅、椅子、沙发、树桩、篝火边的木头)、睡一觉(床、毛巾、帐篷)、开关灯和电视、在书桌前敲键盘、喝咖啡(之后走得更快)、烤棉花糖、摇树掉叶子(椰子树掉椰子)、采花、吃蘑菇(之后跳得更高)、对着雪山喊回声、上船、看望远镜(视野拉近)、踢倒或堆回沙堡、吓乌鸦、翻书架、开箱子、在工作台敲敲打打、给盆栽浇水、跳进草垛、在喷泉许愿(三次出彩虹)、对着水面钓鱼。
|
|
50
|
+
- **动物**:小猫(摸摸后会跟着你走一阵)、池塘的鸭子、谷仓边的鸡和羊(羊可以剪毛,过一会儿长回来)、海鸥、跳出水面的鱼、林间的萤火虫和花丛的蝴蝶。
|
|
51
|
+
- **居民**:准星对着居民时,E 或手机上的空手按钮打开和它的对话(与卡片同一个输入框,可以按住说话);拿着镐或方块时左键和大按钮不会打开对话。Q 或准星下方的“附身”换到它身上。顶栏的对话按钮和你附身的人说话。
|
|
52
|
+
- 世界的天色跟着地图走:深色主题或晚上是夜里,天空是梵高的《星月夜》(着色器画在包着视野的穹顶上):深蓝的笔触顺着气流卷成几个大漩涡(最大的一对在北边雪山上空),星星裹着一圈圈呼吸的黄光,东北方是橙色光晕里的一弯新月,地平线上有淡淡的云絮,远处的地面融进地平线的蓝色雾里;星星和漩涡固定在天上,转头时不跟着动,漩涡慢慢转(减少动画时静止);窗户、路灯和灯塔亮起,有星星和篝火光;忙碌的地方屏幕会亮。左上角返回(或连按两次 Esc)回到地图。
|
|
53
|
+
- **天气**:像方块游戏一样,晴、多云、下雨、雷雨、下雪、大雾会自己轮换,一种天气慢慢过渡成下一种(顶部的天气按钮可以指定一种并保持,或改回自动)。雨和雪在你周围落下,打在屋顶上就停,屋里不下;雨里天色变灰、雾变近、地面变暗变湿,篝火被浇灭、蝴蝶和萤火虫躲起来,鱼咬钩更快;雷雨时远处劈下闪电,天空一白;下雪时地面和方块顶上慢慢积起一层雪;山上冷,下雨在高处也会变成下雪;雨停天晴后,背着太阳的方向挂起一道彩虹。
|
|
54
|
+
- **创造与冒险**:顶部切换两种模式。创造模式能飞、方块无限、不会受伤。冒险模式下材料要自己采集,从高处摔下会掉血(十颗心,过一会儿慢慢回满,吃蘑菇、睡觉也能回),夜里和雷雨天会从暗处冒出史莱姆,一跳一跳地扑过来,大的打散了变成两只小的,天亮就化掉;岛上最高峰和每个区域各藏着一个宝箱,右上角的箭头指向最近的那个,全部找到会在喷泉上空放烟花。晕倒了就在喷泉边醒来。
|
|
55
|
+
- **物品栏与建造**:底部的物品栏是手里拿的东西:手(原来的各种互动)、镐和方块(木板、原木、石头、砖、玻璃、树叶、沙、泥土、雪、灯、金、钻石)。拿着方块对着地面或方块的一面就能放下,拿镐能拆掉方块、砍树(过几分钟会再长出来)、在山上挖矿(偶尔挖到金子和钻石,高处挖出雪块)、在地上挖沙子和泥土;在篝火边能把沙子烧成玻璃、泥土烧成砖,在工作台上把原木锯成木板、用玻璃和木板做灯。方块可以站上去、一格一格往上跳,也会挡住头顶。左键用手里的东西(按住连续),E、F 或右键总是空手;数字键 1–9 和滚轮切换,手机上点物品栏。
|
|
56
|
+
- **成就**:第一次放方块、砍倒树、挖到钻石、雨中钓鱼、登上最高峰、雷雨中站在山上、看到彩虹、打败史莱姆、找到宝藏、驾船出海、看见鲸鱼、射击拿高分……共 20 个,达成时顶部会提示,指南里能看到全部。建造的方块、模式、天气、天空风格、背包、找到的宝藏、小游戏最高分和成就都保存在扩展的存储里,下次进来还在。
|
|
57
|
+
- **天空风格**:天气按钮里还能换天空:经典(白天蓝天、夜里梵高的星月夜)、整天的星月夜、极光(夜里绿紫色的光幕在北方摇曳)、永恒晚霞、糖果(薄荷、粉、淡紫和棉花糖云)、银河(星云、密集的星星和带环的行星)。远处的雾和地平线跟着天空变色,灯和窗户按天空的明暗亮起。
|
|
58
|
+
- **坐船出海**:对着码头边的小船按互动就上船,摇杆(WASD)往哪推船就往哪开,可以开进湖和河,也能一直开出海,最远离岸 80 米;船会随浪起伏、身后留下浪花。海上四个方向各有一座小岛,岛上的宝箱可以在船上打开(金块和钻石);离岸远了偶尔会有鲸鱼浮上来喷水。靠岸后按跳跃(手机上是锚按钮,或提示条里的“下船”)回到岸上,船停在原地。
|
|
59
|
+
- **小游戏**:顶部的“玩法”按钮除了创造/冒险,还有两个射击小游戏,各记最高分。射击靶场:60 秒,靶子在你面前看得见的地方冒出来,有的会横移,金靶 5 分,黑靶扣 3 分,连续命中有连击倍数。空中射击:开着小飞机在岛的上空飞 90 秒,总是朝看的方向飞,拖动(鼠标)转向,摇杆前推加速、后拉减速、左右平移,击落气球和无人机,穿过金环加 4 秒;贴近地面会自动拉起。手机上大按钮变成射击(按住连发、按住时还能滑动转向)。结束时弹出得分和最高分,可以再来一局。
|
|
60
|
+
- **让它自己走**:附身后顶部名字旁的“让它自己走”会松开控制,你附身的分身或智能体按自己的安排继续走(去开会、去工位、去喷泉……),视角切到身后跟着它,头顶显示它在说的话;动一下摇杆或 WASD 就接手,或点“我来控制”。
|
|
61
|
+
|
|
62
|
+
## 联机:和朋友一起逛、一起搭
|
|
63
|
+
|
|
64
|
+
3D 世界顶栏的"联机"按钮(需要内置的房间扩展 @celljs/ta-rooms):
|
|
65
|
+
|
|
66
|
+
- **新建房间**:面板以浮层打开(手机上从底部弹出),可以改房间名再创建,把你小镇的布局(只有地点的种类,不含智能体、任务的名字)作为房间的地图;进入后面板里直接显示邀请二维码、有效期,可以复制、分享或换新链接。
|
|
67
|
+
- **申请与同意**:别人申请加入时,房主在面板顶部看到申请(Ta 好友会标出来),直接点同意或拒绝;成员列表里能看到谁在线,房主可以移出成员、关闭房间,成员可以退出房间。
|
|
68
|
+
- **用链接加入**:把好友发来的邀请链接粘贴进去申请,等待房主同意的房间显示在“我的房间”里,可以取消。
|
|
69
|
+
- **进入**:列出你所在的小镇房间,进入后大家都以自己的恐龙出现在房主的地图上,位置每秒同步 5 次;搭建和拆除的方块按 16×16 的区块存在房间的共享状态里,两人同时改同一区块时按版本号重读再写。房间里的方块不写进你自己的小镇存档。
|
|
70
|
+
- **自己玩**:回到自己的小镇。别人加入或离开时世界上方有提示。刚被同意加入的房间,打开小镇时自动进入。
|
|
71
|
+
|
|
72
|
+
## 操作
|
|
73
|
+
|
|
74
|
+
- 拖动或滚轮平移:地图从手指所在处跟手,快速划动后带惯性滑行(与 iOS 滚动视图相同的减速),碰到边缘停下,滑行中点一下只会停住。捏合、Ctrl/⌘ + 滚轮或右上角的 − / + 缩放,松手后平滑吸附到整数倍,像素保持清晰。
|
|
75
|
+
- 右上角的地图按钮(或键盘 M、或在最小缩放时再点 −、双指一直缩小)切到全景:整张地图自适应地放进卡片和键盘没挡住的地方,写着雪山、森林、湖、营地、小河、农场、海滩、大海,每个居民是一个它衣服颜色的圆点(分身是绿色);点哪里就飞回去放大到哪里,点圆点直接选中那个居民,再按一次地图按钮回到刚才的位置。
|
|
76
|
+
- 在手机上点卡片里的输入框弹出键盘时,小镇不跟着变矮重画(不闪、不跳),卡片贴在键盘上方、最多占剩余高度的一半多,对话记录先收缩;正在说话的居民始终留在卡片上方看得见的地方。
|
|
77
|
+
- 右上角的 ? 是小镇指南;人数按钮打开居民列表(宽屏时默认在右侧),按忙碌程度排序,点一行定位到它。
|
|
78
|
+
- 键盘(小镇获得焦点时):方向键或 WASD 移动,+ − 缩放,M 全景,H 找到分身,N / P 切换居民,Enter 打开对话,Esc 取消选择。
|
|
79
|
+
|
|
80
|
+
## 彩蛋(剧透)
|
|
81
|
+
|
|
82
|
+
点喷泉投币许愿,许满七个出彩虹;点树会掉叶子,有时惊起一只鸟或探出一只松鼠;点小鸭子会“嘎”一声游开;点小猫会冒爱心;连点小恐龙四下它会跳起来吼一声;键盘输入 ↑↑↓↓←→←→BA 开派对(彩带和全员 💃)。
|
|
83
|
+
|
|
84
|
+
野外也有:对着雪山喊一声会有回声;点篝火迸出火星、烤棉花糖;点帆船它会喊“起航啦”并掉头;点灯塔它会亮起光束;点稻草人惊飞几只乌鸦;点蘑菇 1UP;点椰子树掉椰子;点沙堡、帐篷、望远镜各有一句;点海面或河面溅起水花,有时还会跳出一条鱼。
|
|
85
|
+
|
|
86
|
+
## 怎么读数据
|
|
87
|
+
|
|
88
|
+
小镇只通过公开接口读取,发消息时才写:
|
|
89
|
+
|
|
90
|
+
| 来源 | 内容 |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| `pi.packages.getExtensionData('@celljs/ta-channels', …)` | `team`、`working`、`messages/<频道>`、`ui.agentsToLook`、`ui.seenTasks`(见 ta-channels 的 README),小镇可见时每 2.5 秒读一次 |
|
|
93
|
+
| `pi.ui.useTasks()` | 分身的任务与 Ta 建的团队 |
|
|
94
|
+
| `pi.ui.useSessions()`、`pi.server.listSavedSessions()` | 谁在自己的会话里回答、各成员最后说的话 |
|
|
95
|
+
| `pi.ui.useView('assistant/assistant')` | 分身是否在回答、最后一句,以及给它发消息的 `send` |
|
|
96
|
+
|
|
97
|
+
给成员发消息用 `pi.server.prompt`(会话没打开时先请 ta-channels 的服务端 `openAgent`:`packages.callPackageHost('@celljs/ta-channels', 'request', ...)`),在频道里发言用它的 `post`。输入框是页面的 `ui.Composer`(`voiceSends` 让听到的话直接发出,`onTalkSent` 告诉小镇这句是说的、回答要朗读,`onListening` 让居民转过来听,`working` / `onStop` 停止成员),朗读用 `ui.voice`,回答全文用 `pi.server.getLastAssistantText`。没装或关掉 ta-channels 时,小镇里只有分身和任务。
|
|
98
|
+
|
|
99
|
+
## 安装
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
ta install npm:@celljs/ta-town
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
或者把构建好的目录(`package.json` 与 `web/`)放到 `~/.ta/agent/extensions/ta-town/`。它按需启动(`webActivation: open`),出现在“发现”和快捷打开里。
|
|
106
|
+
|
|
107
|
+
## 开发
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
bun run build # tsc → lib/,bun build → web/index.js
|
|
111
|
+
bun run test
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`town-model.ts` 把数据变成居民和地点(含作息与正在说话的人),`town-map.ts` 排布地图并寻路(A*,`heap.ts`),`town-tiles.ts` 用代码画瓦片集,`pixel-art.ts` 画家具和角色(不加载任何图片)。Phaser 场景(`pi.ui.Game`)在 `town-scene.ts`:地面是 Tilemap 图层,家具是按脚下位置排深度的图片(`town-ground.ts`);居民(`resident-view.ts`)的走路是 Phaser 动画,标签与气泡用补间;招牌、光线、屏幕和选中框在 `town-decor.ts`;鸭子、小猫、蝴蝶、萤火虫、鸟和彩蛋在 `town-life.ts`;`town-camera.ts` 管平移、惯性、缩放和键盘。页面在 `town.tsx`,卡片与对话栏在 `town-card.tsx`,就地对话在 `quick-talk.ts`。居民在哪、往哪走在 `town-walk.ts`,地图和 3D 世界共用。3D 世界在 `world/`:`world-grid.ts` 把地图变成每格的高度(墙三格高、雪山越往北越高、海越远越深),`world-models.ts` 把地形和每种家具做成方块,`world-blocks.ts` 用实例化网格画出来(方块颗粒纹理在着色器里按世界坐标取),`world-figures.ts` 是方块小人和恐龙,`world-player.ts` 管走、跳、游泳、飞和碰撞,`world-acts.ts` 判断准星对着什么、能做什么,`world-life.ts` 是动物、篝火、瀑布、灯塔、天空和粒子,`world-sky.ts` 是夜里的星月夜着色器,`world-nav.ts` 把地图上的 A* 路线拉直成几个拐点并给出每帧的方向键,`world-minimap.ts` 画右上角的小地图和整岛地图,`world-weather.ts` 是天气的轮换和雨雪、闪电、彩虹,`world-build.ts` 是玩家建造的方块(按格和按列存,供站立和头顶碰撞查询),`world-adventure.ts` 是冒险模式的生命、史莱姆、宝藏位置和成就列表,`world-play.ts` 把物品栏、建造、采集、天气、两种模式和存档接到一起,`world-view.ts` 把它们接到 `ui.Game3D` 的每帧循环;页面上的按钮和对话在 `town-world.tsx`。
|
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-town",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "4.11.0",
|
|
4
|
+
"description": "A pi package for Ta: a pixel town after Stanford's Smallville, where the double, the agents of ta-channels and the tasks live and go about what they are doing",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/cellbang/cell",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/cellbang/cell/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/cellbang/cell.git"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"files": [
|
|
18
|
+
"web",
|
|
19
|
+
"!**/*.map"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -b && bun build web-src/index.tsx --format esm --target browser --outfile web/index.js",
|
|
23
|
+
"clean": "rm -rf lib web *.tsbuildinfo",
|
|
24
|
+
"test": "bun test ./lib",
|
|
25
|
+
"watch": "tsc -b -w --preserveWatchOutput"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@celljs/ta-protocol": "4.11.0",
|
|
29
|
+
"@celljs/ta-web": "4.11.0",
|
|
30
|
+
"@types/react": "^19.3.0",
|
|
31
|
+
"phaser": "^4.2.1"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"pi": {
|
|
37
|
+
"title": {
|
|
38
|
+
"en": "Town",
|
|
39
|
+
"zh-CN": "小镇"
|
|
40
|
+
},
|
|
41
|
+
"summary": {
|
|
42
|
+
"en": "Your double, agents and tasks as residents of a pixel town, after Stanford's Smallville.",
|
|
43
|
+
"zh-CN": "参照斯坦福小镇,把分身、智能体和任务画成像素小镇里的居民。"
|
|
44
|
+
},
|
|
45
|
+
"icon": "House",
|
|
46
|
+
"webActivation": "open",
|
|
47
|
+
"web": [
|
|
48
|
+
"./web/index.js"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
}
|