@vsuryav/agent-sim 0.1.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.md +25 -0
- package/bin/agent-sim.js +25 -0
- package/package.json +72 -0
- package/src/app-paths.ts +29 -0
- package/src/app-sync.test.ts +75 -0
- package/src/app-sync.ts +110 -0
- package/src/cli.ts +129 -0
- package/src/collector/claude-code.test.ts +102 -0
- package/src/collector/claude-code.ts +133 -0
- package/src/collector/codex-cli.test.ts +116 -0
- package/src/collector/codex-cli.ts +149 -0
- package/src/collector/db.test.ts +59 -0
- package/src/collector/db.ts +125 -0
- package/src/collector/names.test.ts +21 -0
- package/src/collector/names.ts +28 -0
- package/src/collector/personality.test.ts +40 -0
- package/src/collector/personality.ts +46 -0
- package/src/collector/remote-sync.test.ts +31 -0
- package/src/collector/remote-sync.ts +171 -0
- package/src/collector/sync.test.ts +67 -0
- package/src/collector/sync.ts +148 -0
- package/src/collector/types.ts +1 -0
- package/src/engine/bootstrap/state.ts +3 -0
- package/src/engine/buddy/CompanionSprite.tsx +371 -0
- package/src/engine/buddy/companion.ts +133 -0
- package/src/engine/buddy/prompt.ts +36 -0
- package/src/engine/buddy/sprites.ts +514 -0
- package/src/engine/buddy/types.ts +148 -0
- package/src/engine/buddy/useBuddyNotification.tsx +98 -0
- package/src/engine/ink/Ansi.tsx +292 -0
- package/src/engine/ink/bidi.ts +139 -0
- package/src/engine/ink/clearTerminal.ts +74 -0
- package/src/engine/ink/colorize.ts +231 -0
- package/src/engine/ink/components/AlternateScreen.tsx +80 -0
- package/src/engine/ink/components/App.tsx +658 -0
- package/src/engine/ink/components/AppContext.ts +21 -0
- package/src/engine/ink/components/Box.tsx +214 -0
- package/src/engine/ink/components/Button.tsx +192 -0
- package/src/engine/ink/components/ClockContext.tsx +112 -0
- package/src/engine/ink/components/CursorDeclarationContext.ts +32 -0
- package/src/engine/ink/components/ErrorOverview.tsx +109 -0
- package/src/engine/ink/components/Link.tsx +42 -0
- package/src/engine/ink/components/Newline.tsx +39 -0
- package/src/engine/ink/components/NoSelect.tsx +68 -0
- package/src/engine/ink/components/RawAnsi.tsx +57 -0
- package/src/engine/ink/components/ScrollBox.tsx +237 -0
- package/src/engine/ink/components/Spacer.tsx +20 -0
- package/src/engine/ink/components/StdinContext.ts +49 -0
- package/src/engine/ink/components/TerminalFocusContext.tsx +52 -0
- package/src/engine/ink/components/TerminalSizeContext.tsx +7 -0
- package/src/engine/ink/components/Text.tsx +254 -0
- package/src/engine/ink/constants.ts +2 -0
- package/src/engine/ink/dom.ts +484 -0
- package/src/engine/ink/events/click-event.ts +38 -0
- package/src/engine/ink/events/dispatcher.ts +233 -0
- package/src/engine/ink/events/emitter.ts +39 -0
- package/src/engine/ink/events/event-handlers.ts +73 -0
- package/src/engine/ink/events/event.ts +11 -0
- package/src/engine/ink/events/focus-event.ts +21 -0
- package/src/engine/ink/events/input-event.ts +205 -0
- package/src/engine/ink/events/keyboard-event.ts +51 -0
- package/src/engine/ink/events/terminal-event.ts +107 -0
- package/src/engine/ink/events/terminal-focus-event.ts +19 -0
- package/src/engine/ink/focus.ts +181 -0
- package/src/engine/ink/frame.ts +124 -0
- package/src/engine/ink/get-max-width.ts +27 -0
- package/src/engine/ink/global.d.ts +18 -0
- package/src/engine/ink/hit-test.ts +130 -0
- package/src/engine/ink/hooks/use-animation-frame.ts +57 -0
- package/src/engine/ink/hooks/use-app.ts +8 -0
- package/src/engine/ink/hooks/use-declared-cursor.ts +73 -0
- package/src/engine/ink/hooks/use-input.ts +92 -0
- package/src/engine/ink/hooks/use-interval.ts +67 -0
- package/src/engine/ink/hooks/use-search-highlight.ts +53 -0
- package/src/engine/ink/hooks/use-selection.ts +104 -0
- package/src/engine/ink/hooks/use-stdin.ts +8 -0
- package/src/engine/ink/hooks/use-tab-status.ts +72 -0
- package/src/engine/ink/hooks/use-terminal-focus.ts +16 -0
- package/src/engine/ink/hooks/use-terminal-title.ts +31 -0
- package/src/engine/ink/hooks/use-terminal-viewport.ts +96 -0
- package/src/engine/ink/ink.tsx +1723 -0
- package/src/engine/ink/instances.ts +10 -0
- package/src/engine/ink/layout/engine.ts +6 -0
- package/src/engine/ink/layout/geometry.ts +97 -0
- package/src/engine/ink/layout/node.ts +152 -0
- package/src/engine/ink/layout/yoga.ts +308 -0
- package/src/engine/ink/line-width-cache.ts +24 -0
- package/src/engine/ink/log-update.ts +773 -0
- package/src/engine/ink/measure-element.ts +23 -0
- package/src/engine/ink/measure-text.ts +47 -0
- package/src/engine/ink/node-cache.ts +54 -0
- package/src/engine/ink/optimizer.ts +93 -0
- package/src/engine/ink/output.ts +797 -0
- package/src/engine/ink/parse-keypress.ts +801 -0
- package/src/engine/ink/reconciler.ts +512 -0
- package/src/engine/ink/render-border.ts +231 -0
- package/src/engine/ink/render-node-to-output.ts +1462 -0
- package/src/engine/ink/render-to-screen.ts +231 -0
- package/src/engine/ink/renderer.ts +178 -0
- package/src/engine/ink/root.ts +184 -0
- package/src/engine/ink/screen.ts +1486 -0
- package/src/engine/ink/searchHighlight.ts +93 -0
- package/src/engine/ink/selection.ts +917 -0
- package/src/engine/ink/squash-text-nodes.ts +92 -0
- package/src/engine/ink/stringWidth.ts +222 -0
- package/src/engine/ink/styles.ts +771 -0
- package/src/engine/ink/supports-hyperlinks.ts +57 -0
- package/src/engine/ink/tabstops.ts +46 -0
- package/src/engine/ink/terminal-focus-state.ts +47 -0
- package/src/engine/ink/terminal-querier.ts +212 -0
- package/src/engine/ink/terminal.ts +248 -0
- package/src/engine/ink/termio/ansi.ts +75 -0
- package/src/engine/ink/termio/csi.ts +319 -0
- package/src/engine/ink/termio/dec.ts +60 -0
- package/src/engine/ink/termio/esc.ts +67 -0
- package/src/engine/ink/termio/osc.ts +493 -0
- package/src/engine/ink/termio/parser.ts +394 -0
- package/src/engine/ink/termio/sgr.ts +308 -0
- package/src/engine/ink/termio/tokenize.ts +319 -0
- package/src/engine/ink/termio/types.ts +236 -0
- package/src/engine/ink/useTerminalNotification.ts +126 -0
- package/src/engine/ink/warn.ts +9 -0
- package/src/engine/ink/widest-line.ts +19 -0
- package/src/engine/ink/wrap-text.ts +74 -0
- package/src/engine/ink/wrapAnsi.ts +20 -0
- package/src/engine/native-ts/yoga-layout/enums.ts +134 -0
- package/src/engine/native-ts/yoga-layout/index.ts +2578 -0
- package/src/engine/stubs/bootstrap-state.ts +4 -0
- package/src/engine/stubs/debug.ts +6 -0
- package/src/engine/stubs/log.ts +4 -0
- package/src/engine/utils/debug.ts +5 -0
- package/src/engine/utils/earlyInput.ts +4 -0
- package/src/engine/utils/env.ts +15 -0
- package/src/engine/utils/envUtils.ts +4 -0
- package/src/engine/utils/execFileNoThrow.ts +24 -0
- package/src/engine/utils/fullscreen.ts +4 -0
- package/src/engine/utils/intl.ts +9 -0
- package/src/engine/utils/log.ts +3 -0
- package/src/engine/utils/semver.ts +13 -0
- package/src/engine/utils/sliceAnsi.ts +10 -0
- package/src/engine/utils/theme.ts +17 -0
- package/src/game/App.tsx +141 -0
- package/src/game/agents/behavior.ts +249 -0
- package/src/game/agents/speech.ts +57 -0
- package/src/game/canvas.ts +98 -0
- package/src/game/launch.ts +36 -0
- package/src/game/ship/ShipView.tsx +145 -0
- package/src/game/ship/ship-map.ts +172 -0
- package/src/game/ui/AgentBio.tsx +72 -0
- package/src/game/ui/HUD.tsx +63 -0
- package/src/game/ui/StatusBar.tsx +49 -0
- package/src/game/useKeyboard.ts +62 -0
- package/src/main.tsx +22 -0
- package/src/run-interactive.ts +74 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import sliceAnsi from '../utils/sliceAnsi.js'
|
|
2
|
+
import { stringWidth } from './stringWidth.js'
|
|
3
|
+
import type { Styles } from './styles.js'
|
|
4
|
+
import { wrapAnsi } from './wrapAnsi.js'
|
|
5
|
+
|
|
6
|
+
const ELLIPSIS = '…'
|
|
7
|
+
|
|
8
|
+
// sliceAnsi may include a boundary-spanning wide char (e.g. CJK at position
|
|
9
|
+
// end-1 with width 2 overshoots by 1). Retry with a tighter bound once.
|
|
10
|
+
function sliceFit(text: string, start: number, end: number): string {
|
|
11
|
+
const s = sliceAnsi(text, start, end)
|
|
12
|
+
return stringWidth(s) > end - start ? sliceAnsi(text, start, end - 1) : s
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function truncate(
|
|
16
|
+
text: string,
|
|
17
|
+
columns: number,
|
|
18
|
+
position: 'start' | 'middle' | 'end',
|
|
19
|
+
): string {
|
|
20
|
+
if (columns < 1) return ''
|
|
21
|
+
if (columns === 1) return ELLIPSIS
|
|
22
|
+
|
|
23
|
+
const length = stringWidth(text)
|
|
24
|
+
if (length <= columns) return text
|
|
25
|
+
|
|
26
|
+
if (position === 'start') {
|
|
27
|
+
return ELLIPSIS + sliceFit(text, length - columns + 1, length)
|
|
28
|
+
}
|
|
29
|
+
if (position === 'middle') {
|
|
30
|
+
const half = Math.floor(columns / 2)
|
|
31
|
+
return (
|
|
32
|
+
sliceFit(text, 0, half) +
|
|
33
|
+
ELLIPSIS +
|
|
34
|
+
sliceFit(text, length - (columns - half) + 1, length)
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
return sliceFit(text, 0, columns - 1) + ELLIPSIS
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default function wrapText(
|
|
41
|
+
text: string,
|
|
42
|
+
maxWidth: number,
|
|
43
|
+
wrapType: Styles['textWrap'],
|
|
44
|
+
): string {
|
|
45
|
+
if (wrapType === 'wrap') {
|
|
46
|
+
return wrapAnsi(text, maxWidth, {
|
|
47
|
+
trim: false,
|
|
48
|
+
hard: true,
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (wrapType === 'wrap-trim') {
|
|
53
|
+
return wrapAnsi(text, maxWidth, {
|
|
54
|
+
trim: true,
|
|
55
|
+
hard: true,
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (wrapType!.startsWith('truncate')) {
|
|
60
|
+
let position: 'end' | 'middle' | 'start' = 'end'
|
|
61
|
+
|
|
62
|
+
if (wrapType === 'truncate-middle') {
|
|
63
|
+
position = 'middle'
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (wrapType === 'truncate-start') {
|
|
67
|
+
position = 'start'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return truncate(text, maxWidth, position)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return text
|
|
74
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import wrapAnsiNpm from 'wrap-ansi'
|
|
2
|
+
|
|
3
|
+
type WrapAnsiOptions = {
|
|
4
|
+
hard?: boolean
|
|
5
|
+
wordWrap?: boolean
|
|
6
|
+
trim?: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const wrapAnsiBun =
|
|
10
|
+
typeof Bun !== 'undefined' && typeof Bun.wrapAnsi === 'function'
|
|
11
|
+
? Bun.wrapAnsi
|
|
12
|
+
: null
|
|
13
|
+
|
|
14
|
+
const wrapAnsi: (
|
|
15
|
+
input: string,
|
|
16
|
+
columns: number,
|
|
17
|
+
options?: WrapAnsiOptions,
|
|
18
|
+
) => string = wrapAnsiBun ?? wrapAnsiNpm
|
|
19
|
+
|
|
20
|
+
export { wrapAnsi }
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Yoga enums — ported from yoga-layout/src/generated/YGEnums.ts
|
|
3
|
+
* Kept as `const` objects (not TS enums) per repo convention.
|
|
4
|
+
* Values match upstream exactly so callers don't change.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const Align = {
|
|
8
|
+
Auto: 0,
|
|
9
|
+
FlexStart: 1,
|
|
10
|
+
Center: 2,
|
|
11
|
+
FlexEnd: 3,
|
|
12
|
+
Stretch: 4,
|
|
13
|
+
Baseline: 5,
|
|
14
|
+
SpaceBetween: 6,
|
|
15
|
+
SpaceAround: 7,
|
|
16
|
+
SpaceEvenly: 8,
|
|
17
|
+
} as const
|
|
18
|
+
export type Align = (typeof Align)[keyof typeof Align]
|
|
19
|
+
|
|
20
|
+
export const BoxSizing = {
|
|
21
|
+
BorderBox: 0,
|
|
22
|
+
ContentBox: 1,
|
|
23
|
+
} as const
|
|
24
|
+
export type BoxSizing = (typeof BoxSizing)[keyof typeof BoxSizing]
|
|
25
|
+
|
|
26
|
+
export const Dimension = {
|
|
27
|
+
Width: 0,
|
|
28
|
+
Height: 1,
|
|
29
|
+
} as const
|
|
30
|
+
export type Dimension = (typeof Dimension)[keyof typeof Dimension]
|
|
31
|
+
|
|
32
|
+
export const Direction = {
|
|
33
|
+
Inherit: 0,
|
|
34
|
+
LTR: 1,
|
|
35
|
+
RTL: 2,
|
|
36
|
+
} as const
|
|
37
|
+
export type Direction = (typeof Direction)[keyof typeof Direction]
|
|
38
|
+
|
|
39
|
+
export const Display = {
|
|
40
|
+
Flex: 0,
|
|
41
|
+
None: 1,
|
|
42
|
+
Contents: 2,
|
|
43
|
+
} as const
|
|
44
|
+
export type Display = (typeof Display)[keyof typeof Display]
|
|
45
|
+
|
|
46
|
+
export const Edge = {
|
|
47
|
+
Left: 0,
|
|
48
|
+
Top: 1,
|
|
49
|
+
Right: 2,
|
|
50
|
+
Bottom: 3,
|
|
51
|
+
Start: 4,
|
|
52
|
+
End: 5,
|
|
53
|
+
Horizontal: 6,
|
|
54
|
+
Vertical: 7,
|
|
55
|
+
All: 8,
|
|
56
|
+
} as const
|
|
57
|
+
export type Edge = (typeof Edge)[keyof typeof Edge]
|
|
58
|
+
|
|
59
|
+
export const Errata = {
|
|
60
|
+
None: 0,
|
|
61
|
+
StretchFlexBasis: 1,
|
|
62
|
+
AbsolutePositionWithoutInsetsExcludesPadding: 2,
|
|
63
|
+
AbsolutePercentAgainstInnerSize: 4,
|
|
64
|
+
All: 2147483647,
|
|
65
|
+
Classic: 2147483646,
|
|
66
|
+
} as const
|
|
67
|
+
export type Errata = (typeof Errata)[keyof typeof Errata]
|
|
68
|
+
|
|
69
|
+
export const ExperimentalFeature = {
|
|
70
|
+
WebFlexBasis: 0,
|
|
71
|
+
} as const
|
|
72
|
+
export type ExperimentalFeature =
|
|
73
|
+
(typeof ExperimentalFeature)[keyof typeof ExperimentalFeature]
|
|
74
|
+
|
|
75
|
+
export const FlexDirection = {
|
|
76
|
+
Column: 0,
|
|
77
|
+
ColumnReverse: 1,
|
|
78
|
+
Row: 2,
|
|
79
|
+
RowReverse: 3,
|
|
80
|
+
} as const
|
|
81
|
+
export type FlexDirection = (typeof FlexDirection)[keyof typeof FlexDirection]
|
|
82
|
+
|
|
83
|
+
export const Gutter = {
|
|
84
|
+
Column: 0,
|
|
85
|
+
Row: 1,
|
|
86
|
+
All: 2,
|
|
87
|
+
} as const
|
|
88
|
+
export type Gutter = (typeof Gutter)[keyof typeof Gutter]
|
|
89
|
+
|
|
90
|
+
export const Justify = {
|
|
91
|
+
FlexStart: 0,
|
|
92
|
+
Center: 1,
|
|
93
|
+
FlexEnd: 2,
|
|
94
|
+
SpaceBetween: 3,
|
|
95
|
+
SpaceAround: 4,
|
|
96
|
+
SpaceEvenly: 5,
|
|
97
|
+
} as const
|
|
98
|
+
export type Justify = (typeof Justify)[keyof typeof Justify]
|
|
99
|
+
|
|
100
|
+
export const MeasureMode = {
|
|
101
|
+
Undefined: 0,
|
|
102
|
+
Exactly: 1,
|
|
103
|
+
AtMost: 2,
|
|
104
|
+
} as const
|
|
105
|
+
export type MeasureMode = (typeof MeasureMode)[keyof typeof MeasureMode]
|
|
106
|
+
|
|
107
|
+
export const Overflow = {
|
|
108
|
+
Visible: 0,
|
|
109
|
+
Hidden: 1,
|
|
110
|
+
Scroll: 2,
|
|
111
|
+
} as const
|
|
112
|
+
export type Overflow = (typeof Overflow)[keyof typeof Overflow]
|
|
113
|
+
|
|
114
|
+
export const PositionType = {
|
|
115
|
+
Static: 0,
|
|
116
|
+
Relative: 1,
|
|
117
|
+
Absolute: 2,
|
|
118
|
+
} as const
|
|
119
|
+
export type PositionType = (typeof PositionType)[keyof typeof PositionType]
|
|
120
|
+
|
|
121
|
+
export const Unit = {
|
|
122
|
+
Undefined: 0,
|
|
123
|
+
Point: 1,
|
|
124
|
+
Percent: 2,
|
|
125
|
+
Auto: 3,
|
|
126
|
+
} as const
|
|
127
|
+
export type Unit = (typeof Unit)[keyof typeof Unit]
|
|
128
|
+
|
|
129
|
+
export const Wrap = {
|
|
130
|
+
NoWrap: 0,
|
|
131
|
+
Wrap: 1,
|
|
132
|
+
WrapReverse: 2,
|
|
133
|
+
} as const
|
|
134
|
+
export type Wrap = (typeof Wrap)[keyof typeof Wrap]
|