yzcode-cli 1.0.1 → 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 +22 -5
  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
@@ -0,0 +1,197 @@
1
+ import { getSessionMemoryContent } from '../../services/SessionMemory/sessionMemoryUtils.js'
2
+ import type { Message } from '../../types/message.js'
3
+ import { getMessagesAfterCompactBoundary } from '../../utils/messages.js'
4
+ import { registerBundledSkill } from '../bundledSkills.js'
5
+
6
+ function extractUserMessages(messages: Message[]): string[] {
7
+ return messages
8
+ .filter((m): m is Extract<typeof m, { type: 'user' }> => m.type === 'user')
9
+ .map(m => {
10
+ const content = m.message.content
11
+ if (typeof content === 'string') return content
12
+ return content
13
+ .filter(
14
+ (b): b is Extract<typeof b, { type: 'text' }> => b.type === 'text',
15
+ )
16
+ .map(b => b.text)
17
+ .join('\n')
18
+ })
19
+ .filter(text => text.trim().length > 0)
20
+ }
21
+
22
+ const SKILLIFY_PROMPT = `# Skillify {{userDescriptionBlock}}
23
+
24
+ You are capturing this session's repeatable process as a reusable skill.
25
+
26
+ ## Your Session Context
27
+
28
+ Here is the session memory summary:
29
+ <session_memory>
30
+ {{sessionMemory}}
31
+ </session_memory>
32
+
33
+ Here are the user's messages during this session. Pay attention to how they steered the process, to help capture their detailed preferences in the skill:
34
+ <user_messages>
35
+ {{userMessages}}
36
+ </user_messages>
37
+
38
+ ## Your Task
39
+
40
+ ### Step 1: Analyze the Session
41
+
42
+ Before asking any questions, analyze the session to identify:
43
+ - What repeatable process was performed
44
+ - What the inputs/parameters were
45
+ - The distinct steps (in order)
46
+ - The success artifacts/criteria (e.g. not just "writing code," but "an open PR with CI fully passing") for each step
47
+ - Where the user corrected or steered you
48
+ - What tools and permissions were needed
49
+ - What agents were used
50
+ - What the goals and success artifacts were
51
+
52
+ ### Step 2: Interview the User
53
+
54
+ You will use the AskUserQuestion to understand what the user wants to automate. Important notes:
55
+ - Use AskUserQuestion for ALL questions! Never ask questions via plain text.
56
+ - For each round, iterate as much as needed until the user is happy.
57
+ - The user always has a freeform "Other" option to type edits or feedback -- do NOT add your own "Needs tweaking" or "I'll provide edits" option. Just offer the substantive choices.
58
+
59
+ **Round 1: High level confirmation**
60
+ - Suggest a name and description for the skill based on your analysis. Ask the user to confirm or rename.
61
+ - Suggest high-level goal(s) and specific success criteria for the skill.
62
+
63
+ **Round 2: More details**
64
+ - Present the high-level steps you identified as a numbered list. Tell the user you will dig into the detail in the next round.
65
+ - If you think the skill will require arguments, suggest arguments based on what you observed. Make sure you understand what someone would need to provide.
66
+ - If it's not clear, ask if this skill should run inline (in the current conversation) or forked (as a sub-agent with its own context). Forked is better for self-contained tasks that don't need mid-process user input; inline is better when the user wants to steer mid-process.
67
+ - Ask where the skill should be saved. Suggest a default based on context (repo-specific workflows → repo, cross-repo personal workflows → user). Options:
68
+ - **This repo** (\`.claude/skills/<name>/SKILL.md\`) — for workflows specific to this project
69
+ - **Personal** (\`~/.claude/skills/<name>/SKILL.md\`) — follows you across all repos
70
+
71
+ **Round 3: Breaking down each step**
72
+ For each major step, if it's not glaringly obvious, ask:
73
+ - What does this step produce that later steps need? (data, artifacts, IDs)
74
+ - What proves that this step succeeded, and that we can move on?
75
+ - Should the user be asked to confirm before proceeding? (especially for irreversible actions like merging, sending messages, or destructive operations)
76
+ - Are any steps independent and could run in parallel? (e.g., posting to Slack and monitoring CI at the same time)
77
+ - How should the skill be executed? (e.g. always use a Task agent to conduct code review, or invoke an agent team for a set of concurrent steps)
78
+ - What are the hard constraints or hard preferences? Things that must or must not happen?
79
+
80
+ You may do multiple rounds of AskUserQuestion here, one round per step, especially if there are more than 3 steps or many clarification questions. Iterate as much as needed.
81
+
82
+ IMPORTANT: Pay special attention to places where the user corrected you during the session, to help inform your design.
83
+
84
+ **Round 4: Final questions**
85
+ - Confirm when this skill should be invoked, and suggest/confirm trigger phrases too. (e.g. For a cherrypick workflow you could say: Use when the user wants to cherry-pick a PR to a release branch. Examples: 'cherry-pick to release', 'CP this PR', 'hotfix.')
86
+ - You can also ask for any other gotchas or things to watch out for, if it's still unclear.
87
+
88
+ Stop interviewing once you have enough information. IMPORTANT: Don't over-ask for simple processes!
89
+
90
+ ### Step 3: Write the SKILL.md
91
+
92
+ Create the skill directory and file at the location the user chose in Round 2.
93
+
94
+ Use this format:
95
+
96
+ \`\`\`markdown
97
+ ---
98
+ name: {{skill-name}}
99
+ description: {{one-line description}}
100
+ allowed-tools:
101
+ {{list of tool permission patterns observed during session}}
102
+ when_to_use: {{detailed description of when Claude should automatically invoke this skill, including trigger phrases and example user messages}}
103
+ argument-hint: "{{hint showing argument placeholders}}"
104
+ arguments:
105
+ {{list of argument names}}
106
+ context: {{inline or fork -- omit for inline}}
107
+ ---
108
+
109
+ # {{Skill Title}}
110
+ Description of skill
111
+
112
+ ## Inputs
113
+ - \`$arg_name\`: Description of this input
114
+
115
+ ## Goal
116
+ Clearly stated goal for this workflow. Best if you have clearly defined artifacts or criteria for completion.
117
+
118
+ ## Steps
119
+
120
+ ### 1. Step Name
121
+ What to do in this step. Be specific and actionable. Include commands when appropriate.
122
+
123
+ **Success criteria**: ALWAYS include this! This shows that the step is done and we can move on. Can be a list.
124
+
125
+ IMPORTANT: see the next section below for the per-step annotations you can optionally include for each step.
126
+
127
+ ...
128
+ \`\`\`
129
+
130
+ **Per-step annotations**:
131
+ - **Success criteria** is REQUIRED on every step. This helps the model understand what the user expects from their workflow, and when it should have the confidence to move on.
132
+ - **Execution**: \`Direct\` (default), \`Task agent\` (straightforward subagents), \`Teammate\` (agent with true parallelism and inter-agent communication), or \`[human]\` (user does it). Only needs specifying if not Direct.
133
+ - **Artifacts**: Data this step produces that later steps need (e.g., PR number, commit SHA). Only include if later steps depend on it.
134
+ - **Human checkpoint**: When to pause and ask the user before proceeding. Include for irreversible actions (merging, sending messages), error judgment (merge conflicts), or output review.
135
+ - **Rules**: Hard rules for the workflow. User corrections during the reference session can be especially useful here.
136
+
137
+ **Step structure tips:**
138
+ - Steps that can run concurrently use sub-numbers: 3a, 3b
139
+ - Steps requiring the user to act get \`[human]\` in the title
140
+ - Keep simple skills simple -- a 2-step skill doesn't need annotations on every step
141
+
142
+ **Frontmatter rules:**
143
+ - \`allowed-tools\`: Minimum permissions needed (use patterns like \`Bash(gh:*)\` not \`Bash\`)
144
+ - \`context\`: Only set \`context: fork\` for self-contained skills that don't need mid-process user input.
145
+ - \`when_to_use\` is CRITICAL -- tells the model when to auto-invoke. Start with "Use when..." and include trigger phrases. Example: "Use when the user wants to cherry-pick a PR to a release branch. Examples: 'cherry-pick to release', 'CP this PR', 'hotfix'."
146
+ - \`arguments\` and \`argument-hint\`: Only include if the skill takes parameters. Use \`$name\` in the body for substitution.
147
+
148
+ ### Step 4: Confirm and Save
149
+
150
+ Before writing the file, output the complete SKILL.md content as a yaml code block in your response so the user can review it with proper syntax highlighting. Then ask for confirmation using AskUserQuestion with a simple question like "Does this SKILL.md look good to save?" — do NOT use the body field, keep the question concise.
151
+
152
+ After writing, tell the user:
153
+ - Where the skill was saved
154
+ - How to invoke it: \`/{{skill-name}} [arguments]\`
155
+ - That they can edit the SKILL.md directly to refine it
156
+ `
157
+
158
+ export function registerSkillifySkill(): void {
159
+ if (process.env.USER_TYPE !== 'ant') {
160
+ return
161
+ }
162
+
163
+ registerBundledSkill({
164
+ name: 'skillify',
165
+ description:
166
+ "Capture this session's repeatable process into a skill. Call at end of the process you want to capture with an optional description.",
167
+ allowedTools: [
168
+ 'Read',
169
+ 'Write',
170
+ 'Edit',
171
+ 'Glob',
172
+ 'Grep',
173
+ 'AskUserQuestion',
174
+ 'Bash(mkdir:*)',
175
+ ],
176
+ userInvocable: true,
177
+ disableModelInvocation: true,
178
+ argumentHint: '[description of the process you want to capture]',
179
+ async getPromptForCommand(args, context) {
180
+ const sessionMemory =
181
+ (await getSessionMemoryContent()) ?? 'No session memory available.'
182
+ const userMessages = extractUserMessages(
183
+ getMessagesAfterCompactBoundary(context.messages),
184
+ )
185
+
186
+ const userDescriptionBlock = args
187
+ ? `The user described this process as: "${args}"`
188
+ : ''
189
+
190
+ const prompt = SKILLIFY_PROMPT.replace('{{sessionMemory}}', sessionMemory)
191
+ .replace('{{userMessages}}', userMessages.join('\n\n---\n\n'))
192
+ .replace('{{userDescriptionBlock}}', userDescriptionBlock)
193
+
194
+ return [{ type: 'text', text: prompt }]
195
+ },
196
+ })
197
+ }
@@ -0,0 +1,79 @@
1
+ import { registerBundledSkill } from '../bundledSkills.js'
2
+
3
+ // Prompt text contains `ps` commands as instructions for Claude to run,
4
+ // not commands this file executes.
5
+ // eslint-disable-next-line custom-rules/no-direct-ps-commands
6
+ const STUCK_PROMPT = `# /stuck — diagnose frozen/slow Claude Code sessions
7
+
8
+ The user thinks another Claude Code session on this machine is frozen, stuck, or very slow. Investigate and post a report to #claude-code-feedback.
9
+
10
+ ## What to look for
11
+
12
+ Scan for other Claude Code processes (excluding the current one — PID is in \`process.pid\` but for shell commands just exclude the PID you see running this prompt). Process names are typically \`claude\` (installed) or \`cli\` (native dev build).
13
+
14
+ Signs of a stuck session:
15
+ - **High CPU (≥90%) sustained** — likely an infinite loop. Sample twice, 1-2s apart, to confirm it's not a transient spike.
16
+ - **Process state \`D\` (uninterruptible sleep)** — often an I/O hang. The \`state\` column in \`ps\` output; first character matters (ignore modifiers like \`+\`, \`s\`, \`<\`).
17
+ - **Process state \`T\` (stopped)** — user probably hit Ctrl+Z by accident.
18
+ - **Process state \`Z\` (zombie)** — parent isn't reaping.
19
+ - **Very high RSS (≥4GB)** — possible memory leak making the session sluggish.
20
+ - **Stuck child process** — a hung \`git\`, \`node\`, or shell subprocess can freeze the parent. Check \`pgrep -lP <pid>\` for each session.
21
+
22
+ ## Investigation steps
23
+
24
+ 1. **List all Claude Code processes** (macOS/Linux):
25
+ \`\`\`
26
+ ps -axo pid=,pcpu=,rss=,etime=,state=,comm=,command= | grep -E '(claude|cli)' | grep -v grep
27
+ \`\`\`
28
+ Filter to rows where \`comm\` is \`claude\` or (\`cli\` AND the command path contains "claude").
29
+
30
+ 2. **For anything suspicious**, gather more context:
31
+ - Child processes: \`pgrep -lP <pid>\`
32
+ - If high CPU: sample again after 1-2s to confirm it's sustained
33
+ - If a child looks hung (e.g., a git command), note its full command line with \`ps -p <child_pid> -o command=\`
34
+ - Check the session's debug log if you can infer the session ID: \`~/.claude/debug/<session-id>.txt\` (the last few hundred lines often show what it was doing before hanging)
35
+
36
+ 3. **Consider a stack dump** for a truly frozen process (advanced, optional):
37
+ - macOS: \`sample <pid> 3\` gives a 3-second native stack sample
38
+ - This is big — only grab it if the process is clearly hung and you want to know *why*
39
+
40
+ ## Report
41
+
42
+ **Only post to Slack if you actually found something stuck.** If every session looks healthy, tell the user that directly — do not post an all-clear to the channel.
43
+
44
+ If you did find a stuck/slow session, post to **#claude-code-feedback** (channel ID: \`C07VBSHV7EV\`) using the Slack MCP tool. Use ToolSearch to find \`slack_send_message\` if it's not already loaded.
45
+
46
+ **Use a two-message structure** to keep the channel scannable:
47
+
48
+ 1. **Top-level message** — one short line: hostname, Claude Code version, and a terse symptom (e.g. "session PID 12345 pegged at 100% CPU for 10min" or "git subprocess hung in D state"). No code blocks, no details.
49
+ 2. **Thread reply** — the full diagnostic dump. Pass the top-level message's \`ts\` as \`thread_ts\`. Include:
50
+ - PID, CPU%, RSS, state, uptime, command line, child processes
51
+ - Your diagnosis of what's likely wrong
52
+ - Relevant debug log tail or \`sample\` output if you captured it
53
+
54
+ If Slack MCP isn't available, format the report as a message the user can copy-paste into #claude-code-feedback (and let them know to thread the details themselves).
55
+
56
+ ## Notes
57
+ - Don't kill or signal any processes — this is diagnostic only.
58
+ - If the user gave an argument (e.g., a specific PID or symptom), focus there first.
59
+ `
60
+
61
+ export function registerStuckSkill(): void {
62
+ if (process.env.USER_TYPE !== 'ant') {
63
+ return
64
+ }
65
+
66
+ registerBundledSkill({
67
+ name: 'stuck',
68
+ description:
69
+ '[ANT-ONLY] Investigate frozen/stuck/slow Claude Code sessions on this machine and post a diagnostic report to #claude-code-feedback.',
70
+ userInvocable: true,
71
+ async getPromptForCommand(args) {
72
+ let prompt = STUCK_PROMPT
73
+ if (args) {
74
+ prompt += `\n## User-provided context\n\n${args}\n`
75
+ }
76
+ return [{ type: 'text', text: prompt }]
77
+ },
78
+ })
79
+ }