yzcode-cli 1.0.2 → 1.0.3

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.
Files changed (117) hide show
  1. package/assistant/sessionHistory.ts +87 -0
  2. package/bootstrap/state.ts +1769 -0
  3. package/bridge/bridgeApi.ts +539 -0
  4. package/bridge/bridgeConfig.ts +48 -0
  5. package/bridge/bridgeDebug.ts +135 -0
  6. package/bridge/bridgeEnabled.ts +202 -0
  7. package/bridge/bridgeMain.ts +2999 -0
  8. package/bridge/bridgeMessaging.ts +461 -0
  9. package/bridge/bridgePermissionCallbacks.ts +43 -0
  10. package/bridge/bridgePointer.ts +210 -0
  11. package/bridge/bridgeStatusUtil.ts +163 -0
  12. package/bridge/bridgeUI.ts +530 -0
  13. package/bridge/capacityWake.ts +56 -0
  14. package/bridge/codeSessionApi.ts +168 -0
  15. package/bridge/createSession.ts +384 -0
  16. package/bridge/debugUtils.ts +141 -0
  17. package/bridge/envLessBridgeConfig.ts +165 -0
  18. package/bridge/flushGate.ts +71 -0
  19. package/bridge/inboundAttachments.ts +175 -0
  20. package/bridge/inboundMessages.ts +80 -0
  21. package/bridge/initReplBridge.ts +569 -0
  22. package/bridge/jwtUtils.ts +256 -0
  23. package/bridge/pollConfig.ts +110 -0
  24. package/bridge/pollConfigDefaults.ts +82 -0
  25. package/bridge/remoteBridgeCore.ts +1008 -0
  26. package/bridge/replBridge.ts +2406 -0
  27. package/bridge/replBridgeHandle.ts +36 -0
  28. package/bridge/replBridgeTransport.ts +370 -0
  29. package/bridge/sessionIdCompat.ts +57 -0
  30. package/bridge/sessionRunner.ts +550 -0
  31. package/bridge/trustedDevice.ts +210 -0
  32. package/bridge/types.ts +262 -0
  33. package/bridge/workSecret.ts +127 -0
  34. package/buddy/CompanionSprite.tsx +371 -0
  35. package/buddy/companion.ts +133 -0
  36. package/buddy/prompt.ts +36 -0
  37. package/buddy/sprites.ts +514 -0
  38. package/buddy/types.ts +148 -0
  39. package/buddy/useBuddyNotification.tsx +98 -0
  40. package/coordinator/coordinatorMode.ts +369 -0
  41. package/memdir/findRelevantMemories.ts +141 -0
  42. package/memdir/memdir.ts +507 -0
  43. package/memdir/memoryAge.ts +53 -0
  44. package/memdir/memoryScan.ts +94 -0
  45. package/memdir/memoryTypes.ts +271 -0
  46. package/memdir/paths.ts +278 -0
  47. package/memdir/teamMemPaths.ts +292 -0
  48. package/memdir/teamMemPrompts.ts +100 -0
  49. package/migrations/migrateAutoUpdatesToSettings.ts +61 -0
  50. package/migrations/migrateBypassPermissionsAcceptedToSettings.ts +40 -0
  51. package/migrations/migrateEnableAllProjectMcpServersToSettings.ts +118 -0
  52. package/migrations/migrateFennecToOpus.ts +45 -0
  53. package/migrations/migrateLegacyOpusToCurrent.ts +57 -0
  54. package/migrations/migrateOpusToOpus1m.ts +43 -0
  55. package/migrations/migrateReplBridgeEnabledToRemoteControlAtStartup.ts +22 -0
  56. package/migrations/migrateSonnet1mToSonnet45.ts +48 -0
  57. package/migrations/migrateSonnet45ToSonnet46.ts +67 -0
  58. package/migrations/resetAutoModeOptInForDefaultOffer.ts +51 -0
  59. package/migrations/resetProToOpusDefault.ts +51 -0
  60. package/native-ts/color-diff/index.ts +999 -0
  61. package/native-ts/file-index/index.ts +370 -0
  62. package/native-ts/yoga-layout/enums.ts +134 -0
  63. package/native-ts/yoga-layout/index.ts +2578 -0
  64. package/outputStyles/loadOutputStylesDir.ts +98 -0
  65. package/package.json +19 -2
  66. package/plugins/builtinPlugins.ts +159 -0
  67. package/plugins/bundled/index.ts +23 -0
  68. package/schemas/hooks.ts +222 -0
  69. package/screens/Doctor.tsx +575 -0
  70. package/screens/REPL.tsx +5006 -0
  71. package/screens/ResumeConversation.tsx +399 -0
  72. package/server/createDirectConnectSession.ts +88 -0
  73. package/server/directConnectManager.ts +213 -0
  74. package/server/types.ts +57 -0
  75. package/skills/bundled/batch.ts +124 -0
  76. package/skills/bundled/claudeApi.ts +196 -0
  77. package/skills/bundled/claudeApiContent.ts +75 -0
  78. package/skills/bundled/claudeInChrome.ts +34 -0
  79. package/skills/bundled/debug.ts +103 -0
  80. package/skills/bundled/index.ts +79 -0
  81. package/skills/bundled/keybindings.ts +339 -0
  82. package/skills/bundled/loop.ts +92 -0
  83. package/skills/bundled/loremIpsum.ts +282 -0
  84. package/skills/bundled/remember.ts +82 -0
  85. package/skills/bundled/scheduleRemoteAgents.ts +447 -0
  86. package/skills/bundled/simplify.ts +69 -0
  87. package/skills/bundled/skillify.ts +197 -0
  88. package/skills/bundled/stuck.ts +79 -0
  89. package/skills/bundled/updateConfig.ts +475 -0
  90. package/skills/bundled/verify/SKILL.md +3 -0
  91. package/skills/bundled/verify/examples/cli.md +3 -0
  92. package/skills/bundled/verify/examples/server.md +3 -0
  93. package/skills/bundled/verify.ts +30 -0
  94. package/skills/bundled/verifyContent.ts +13 -0
  95. package/skills/bundledSkills.ts +220 -0
  96. package/skills/loadSkillsDir.ts +1086 -0
  97. package/skills/mcpSkillBuilders.ts +44 -0
  98. package/tasks/DreamTask/DreamTask.ts +157 -0
  99. package/tasks/InProcessTeammateTask/InProcessTeammateTask.tsx +126 -0
  100. package/tasks/InProcessTeammateTask/types.ts +121 -0
  101. package/tasks/LocalAgentTask/LocalAgentTask.tsx +683 -0
  102. package/tasks/LocalMainSessionTask.ts +479 -0
  103. package/tasks/LocalShellTask/LocalShellTask.tsx +523 -0
  104. package/tasks/LocalShellTask/guards.ts +41 -0
  105. package/tasks/LocalShellTask/killShellTasks.ts +76 -0
  106. package/tasks/RemoteAgentTask/RemoteAgentTask.tsx +856 -0
  107. package/tasks/pillLabel.ts +82 -0
  108. package/tasks/stopTask.ts +100 -0
  109. package/tasks/types.ts +46 -0
  110. package/upstreamproxy/relay.ts +455 -0
  111. package/upstreamproxy/upstreamproxy.ts +285 -0
  112. package/vim/motions.ts +82 -0
  113. package/vim/operators.ts +556 -0
  114. package/vim/textObjects.ts +186 -0
  115. package/vim/transitions.ts +490 -0
  116. package/vim/types.ts +199 -0
  117. package/voice/voiceModeEnabled.ts +54 -0
package/vim/types.ts ADDED
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Vim Mode State Machine Types
3
+ *
4
+ * This file defines the complete state machine for vim input handling.
5
+ * The types ARE the documentation - reading them tells you how the system works.
6
+ *
7
+ * State Diagram:
8
+ * ```
9
+ * VimState
10
+ * ┌──────────────────────────────┬──────────────────────────────────────┐
11
+ * │ INSERT │ NORMAL │
12
+ * │ (tracks insertedText) │ (CommandState machine) │
13
+ * │ │ │
14
+ * │ │ idle ──┬─[d/c/y]──► operator │
15
+ * │ │ ├─[1-9]────► count │
16
+ * │ │ ├─[fFtT]───► find │
17
+ * │ │ ├─[g]──────► g │
18
+ * │ │ ├─[r]──────► replace │
19
+ * │ │ └─[><]─────► indent │
20
+ * │ │ │
21
+ * │ │ operator ─┬─[motion]──► execute │
22
+ * │ │ ├─[0-9]────► operatorCount│
23
+ * │ │ ├─[ia]─────► operatorTextObj
24
+ * │ │ └─[fFtT]───► operatorFind │
25
+ * └──────────────────────────────┴──────────────────────────────────────┘
26
+ * ```
27
+ */
28
+
29
+ // ============================================================================
30
+ // Core Types
31
+ // ============================================================================
32
+
33
+ export type Operator = 'delete' | 'change' | 'yank'
34
+
35
+ export type FindType = 'f' | 'F' | 't' | 'T'
36
+
37
+ export type TextObjScope = 'inner' | 'around'
38
+
39
+ // ============================================================================
40
+ // State Machine Types
41
+ // ============================================================================
42
+
43
+ /**
44
+ * Complete vim state. Mode determines what data is tracked.
45
+ *
46
+ * INSERT mode: Track text being typed (for dot-repeat)
47
+ * NORMAL mode: Track command being parsed (state machine)
48
+ */
49
+ export type VimState =
50
+ | { mode: 'INSERT'; insertedText: string }
51
+ | { mode: 'NORMAL'; command: CommandState }
52
+
53
+ /**
54
+ * Command state machine for NORMAL mode.
55
+ *
56
+ * Each state knows exactly what input it's waiting for.
57
+ * TypeScript ensures exhaustive handling in switches.
58
+ */
59
+ export type CommandState =
60
+ | { type: 'idle' }
61
+ | { type: 'count'; digits: string }
62
+ | { type: 'operator'; op: Operator; count: number }
63
+ | { type: 'operatorCount'; op: Operator; count: number; digits: string }
64
+ | { type: 'operatorFind'; op: Operator; count: number; find: FindType }
65
+ | {
66
+ type: 'operatorTextObj'
67
+ op: Operator
68
+ count: number
69
+ scope: TextObjScope
70
+ }
71
+ | { type: 'find'; find: FindType; count: number }
72
+ | { type: 'g'; count: number }
73
+ | { type: 'operatorG'; op: Operator; count: number }
74
+ | { type: 'replace'; count: number }
75
+ | { type: 'indent'; dir: '>' | '<'; count: number }
76
+
77
+ /**
78
+ * Persistent state that survives across commands.
79
+ * This is the "memory" of vim - what gets recalled for repeats and pastes.
80
+ */
81
+ export type PersistentState = {
82
+ lastChange: RecordedChange | null
83
+ lastFind: { type: FindType; char: string } | null
84
+ register: string
85
+ registerIsLinewise: boolean
86
+ }
87
+
88
+ /**
89
+ * Recorded change for dot-repeat.
90
+ * Captures everything needed to replay a command.
91
+ */
92
+ export type RecordedChange =
93
+ | { type: 'insert'; text: string }
94
+ | {
95
+ type: 'operator'
96
+ op: Operator
97
+ motion: string
98
+ count: number
99
+ }
100
+ | {
101
+ type: 'operatorTextObj'
102
+ op: Operator
103
+ objType: string
104
+ scope: TextObjScope
105
+ count: number
106
+ }
107
+ | {
108
+ type: 'operatorFind'
109
+ op: Operator
110
+ find: FindType
111
+ char: string
112
+ count: number
113
+ }
114
+ | { type: 'replace'; char: string; count: number }
115
+ | { type: 'x'; count: number }
116
+ | { type: 'toggleCase'; count: number }
117
+ | { type: 'indent'; dir: '>' | '<'; count: number }
118
+ | { type: 'openLine'; direction: 'above' | 'below' }
119
+ | { type: 'join'; count: number }
120
+
121
+ // ============================================================================
122
+ // Key Groups - Named constants, no magic strings
123
+ // ============================================================================
124
+
125
+ export const OPERATORS = {
126
+ d: 'delete',
127
+ c: 'change',
128
+ y: 'yank',
129
+ } as const satisfies Record<string, Operator>
130
+
131
+ export function isOperatorKey(key: string): key is keyof typeof OPERATORS {
132
+ return key in OPERATORS
133
+ }
134
+
135
+ export const SIMPLE_MOTIONS = new Set([
136
+ 'h',
137
+ 'l',
138
+ 'j',
139
+ 'k', // Basic movement
140
+ 'w',
141
+ 'b',
142
+ 'e',
143
+ 'W',
144
+ 'B',
145
+ 'E', // Word motions
146
+ '0',
147
+ '^',
148
+ '$', // Line positions
149
+ ])
150
+
151
+ export const FIND_KEYS = new Set(['f', 'F', 't', 'T'])
152
+
153
+ export const TEXT_OBJ_SCOPES = {
154
+ i: 'inner',
155
+ a: 'around',
156
+ } as const satisfies Record<string, TextObjScope>
157
+
158
+ export function isTextObjScopeKey(
159
+ key: string,
160
+ ): key is keyof typeof TEXT_OBJ_SCOPES {
161
+ return key in TEXT_OBJ_SCOPES
162
+ }
163
+
164
+ export const TEXT_OBJ_TYPES = new Set([
165
+ 'w',
166
+ 'W', // Word/WORD
167
+ '"',
168
+ "'",
169
+ '`', // Quotes
170
+ '(',
171
+ ')',
172
+ 'b', // Parens
173
+ '[',
174
+ ']', // Brackets
175
+ '{',
176
+ '}',
177
+ 'B', // Braces
178
+ '<',
179
+ '>', // Angle brackets
180
+ ])
181
+
182
+ export const MAX_VIM_COUNT = 10000
183
+
184
+ // ============================================================================
185
+ // State Factories
186
+ // ============================================================================
187
+
188
+ export function createInitialVimState(): VimState {
189
+ return { mode: 'INSERT', insertedText: '' }
190
+ }
191
+
192
+ export function createInitialPersistentState(): PersistentState {
193
+ return {
194
+ lastChange: null,
195
+ lastFind: null,
196
+ register: '',
197
+ registerIsLinewise: false,
198
+ }
199
+ }
@@ -0,0 +1,54 @@
1
+ import { feature } from 'bun:bundle'
2
+ import { getFeatureValue_CACHED_MAY_BE_STALE } from '../services/analytics/growthbook.js'
3
+ import {
4
+ getClaudeAIOAuthTokens,
5
+ isAnthropicAuthEnabled,
6
+ } from '../utils/auth.js'
7
+
8
+ /**
9
+ * Kill-switch check for voice mode. Returns true unless the
10
+ * `tengu_amber_quartz_disabled` GrowthBook flag is flipped on (emergency
11
+ * off). Default `false` means a missing/stale disk cache reads as "not
12
+ * killed" — so fresh installs get voice working immediately without
13
+ * waiting for GrowthBook init. Use this for deciding whether voice mode
14
+ * should be *visible* (e.g., command registration, config UI).
15
+ */
16
+ export function isVoiceGrowthBookEnabled(): boolean {
17
+ // Positive ternary pattern — see docs/feature-gating.md.
18
+ // Negative pattern (if (!feature(...)) return) does not eliminate
19
+ // inline string literals from external builds.
20
+ return feature('VOICE_MODE')
21
+ ? !getFeatureValue_CACHED_MAY_BE_STALE('tengu_amber_quartz_disabled', false)
22
+ : false
23
+ }
24
+
25
+ /**
26
+ * Auth-only check for voice mode. Returns true when the user has a valid
27
+ * Anthropic OAuth token. Backed by the memoized getClaudeAIOAuthTokens —
28
+ * first call spawns `security` on macOS (~20-50ms), subsequent calls are
29
+ * cache hits. The memoize clears on token refresh (~once/hour), so one
30
+ * cold spawn per refresh is expected. Cheap enough for usage-time checks.
31
+ */
32
+ export function hasVoiceAuth(): boolean {
33
+ // Voice mode requires Anthropic OAuth — it uses the voice_stream
34
+ // endpoint on claude.ai which is not available with API keys,
35
+ // Bedrock, Vertex, or Foundry.
36
+ if (!isAnthropicAuthEnabled()) {
37
+ return false
38
+ }
39
+ // isAnthropicAuthEnabled only checks the auth *provider*, not whether
40
+ // a token exists. Without this check, the voice UI renders but
41
+ // connectVoiceStream fails silently when the user isn't logged in.
42
+ const tokens = getClaudeAIOAuthTokens()
43
+ return Boolean(tokens?.accessToken)
44
+ }
45
+
46
+ /**
47
+ * Full runtime check: auth + GrowthBook kill-switch. Callers: `/voice`
48
+ * (voice.ts, voice/index.ts), ConfigTool, VoiceModeNotice — command-time
49
+ * paths where a fresh keychain read is acceptable. For React render
50
+ * paths use useVoiceEnabled() instead (memoizes the auth half).
51
+ */
52
+ export function isVoiceModeEnabled(): boolean {
53
+ return hasVoiceAuth() && isVoiceGrowthBookEnabled()
54
+ }