atris 3.30.12 → 3.31.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.
Files changed (58) hide show
  1. package/AGENTS.md +16 -3
  2. package/FOR_AGENTS.md +81 -0
  3. package/README.md +3 -1
  4. package/atris/atris.md +51 -19
  5. package/atris/skills/README.md +1 -0
  6. package/atris/skills/blocks/SKILL.md +134 -0
  7. package/atris/skills/clawhub/philosophy-of-work/SKILL.md +56 -0
  8. package/atris/skills/youtube/SKILL.md +31 -11
  9. package/atris.md +7 -0
  10. package/ax +95 -3
  11. package/bin/atris.js +126 -153
  12. package/commands/autoland.js +319 -0
  13. package/commands/autopilot.js +94 -4
  14. package/commands/business.js +1 -1
  15. package/commands/clean.js +72 -9
  16. package/commands/codex-goal.js +72 -22
  17. package/commands/computer.js +48 -3
  18. package/commands/gm.js +1 -1
  19. package/commands/harvest.js +179 -0
  20. package/commands/init.js +1 -1
  21. package/commands/land.js +442 -0
  22. package/commands/loop-front.js +122 -4
  23. package/commands/member.js +519 -19
  24. package/commands/mission.js +3330 -290
  25. package/commands/play.js +1 -1
  26. package/commands/pulse.js +65 -7
  27. package/commands/run.js +3 -3
  28. package/commands/strings.js +301 -0
  29. package/commands/task.js +575 -102
  30. package/commands/truth.js +170 -0
  31. package/commands/xp.js +32 -8
  32. package/commands/youtube.js +72 -5
  33. package/decks/README.md +6 -12
  34. package/lib/auto-accept-certified.js +10 -0
  35. package/lib/autoland.js +283 -0
  36. package/lib/context-gatherer.js +0 -8
  37. package/lib/mission-artifact.js +504 -0
  38. package/lib/mission-room.js +846 -0
  39. package/lib/next-moves.js +212 -6
  40. package/lib/pulse.js +74 -1
  41. package/lib/runner-command.js +20 -8
  42. package/lib/runs-prune.js +242 -0
  43. package/lib/task-proof.js +1 -1
  44. package/package.json +3 -3
  45. package/decks/atris-seed-pitch-v3.json +0 -118
  46. package/decks/atris-seed-pitch-v4-skeleton.json +0 -106
  47. package/decks/atris-seed-pitch-v5.json +0 -109
  48. package/decks/atris-seed-pitch-v6.json +0 -137
  49. package/decks/atris-seed-pitch-v7.json +0 -133
  50. package/decks/mark-pincus-narrative.json +0 -102
  51. package/decks/mark-pincus-sourcery.json +0 -94
  52. package/decks/yash-applied-compute-detailed.json +0 -150
  53. package/decks/yash-applied-compute-generalist.json +0 -82
  54. package/decks/yash-applied-compute-narrative.json +0 -54
  55. package/lib/ax-chat-input.js +0 -164
  56. package/lib/ax-goal.js +0 -307
  57. package/lib/ax-prefs.js +0 -63
  58. package/lib/ax-shimmer.js +0 -63
@@ -1,102 +0,0 @@
1
- {
2
- "theme": "noir",
3
- "brand": { "name": "Sourcery", "accent": "." },
4
- "slides": [
5
- {
6
- "type": "title",
7
- "headline": "Separate the **instinct** from the idea.",
8
- "sub": "Mark Pincus on Life at the Speed of Play. Zynga, FarmVille, Words With Friends, Hivemind. A Sourcery episode with Molly O'Shea."
9
- },
10
- {
11
- "type": "quote",
12
- "text": "Your number one job as a founder is to be **right.**",
13
- "author": "Mark Pincus",
14
- "role": "Life at the Speed of Play"
15
- },
16
- {
17
- "type": "interstitial",
18
- "kicker": "the vein",
19
- "text": "Instinct is the **emotional vein.**",
20
- "sub": "Something broken in human experience. SMS taxi was right. The Tribe.net instincts were right.",
21
- "align": "START"
22
- },
23
- {
24
- "type": "columns",
25
- "heading": "Three things people **conflate**",
26
- "columns": [
27
- {
28
- "h": "Instinct",
29
- "b": "The emotional vein. Something broken in human experience that keeps pulling you back."
30
- },
31
- {
32
- "h": "Idea",
33
- "b": "One product bet on that instinct. Often a B+. Kill it fast so the A can show up."
34
- },
35
- {
36
- "h": "Calibration",
37
- "b": "The skill that sharpens with reps. Ask is this it? and you already know."
38
- }
39
- ]
40
- },
41
- {
42
- "type": "interstitial",
43
- "kicker": "the method",
44
- "text": "Proven, better, **new.**",
45
- "sub": "Run them in that order. Give yourself four shots on goal instead of one grind up a hill.",
46
- "align": "START"
47
- },
48
- {
49
- "type": "timeline",
50
- "heading": "The order that **wins**",
51
- "steps": [
52
- { "label": "Proven", "sub": "find the closest success, same audience, deconstruct every pixel" },
53
- { "label": "Better", "sub": "one change the audience would all notice", "active": true },
54
- { "label": "New", "sub": "the novel hook, expect it to fail, isolate the experiment" }
55
- ],
56
- "sub": "Four shots on goal beat one slow march up a single hill."
57
- },
58
- {
59
- "type": "bignumber",
60
- "number": "Day 365",
61
- "label": "retention beats virality in consumer",
62
- "sub": "40,000 games launched. Zero held the top 25. People download zero new apps a month. Build for the life stack."
63
- },
64
- {
65
- "type": "prose",
66
- "heading": "Why **retention** is the only number",
67
- "paragraphs": [
68
- "Virality buys you a spike. Day 365 measures whether the spike turned into a habit, and habit is the whole game in consumer.",
69
- "Forty thousand games launched and none of them held a top 25 spot. Most people add zero new apps to their phone in a month.",
70
- "So build for the life stack. Earn a place people return to without a push notification dragging them back."
71
- ]
72
- },
73
- {
74
- "type": "split",
75
- "heading": "Real CEO, **fake CEO**",
76
- "body": "The real job lives in the product. Great product teams. Products users love. Half the calendar spent here. iPhone home screen research as a daily habit. The fake version tours investors, lectures on culture, chases press and Davos, and pushes an agenda detached from the product.",
77
- "accent": "50%+",
78
- "accentSub": "of a real CEO calendar sits inside the product itself."
79
- },
80
- {
81
- "type": "prose",
82
- "heading": "The tech assistant is **vampire blood**",
83
- "paragraphs": [
84
- "Bezos, Grove, and Gates each had someone shadow them. Proximity transfers judgment faster than any memo can.",
85
- "Pluck the talent early, let them shadow the CEO, then hand them a mini-CEO project to ship on their own.",
86
- "Ian Cinnamon: MIT early, built apps, marked low on paper. As an expert witness he sat closest to the data. Plucked early, shadowed the CEO, went on to found Apex."
87
- ]
88
- },
89
- {
90
- "type": "statement",
91
- "text": "Organ rejection hides your best **gems.**",
92
- "sub": "The talent a system instinctively pushes out is often the talent worth the most. Non-scalable leverage compounds."
93
- },
94
- {
95
- "type": "hero",
96
- "headline": "Life at the **speed of play.**",
97
- "sub": "Book: Life at the Speed of Play. Episode: Mark Pincus, How to Spot a Fake CEO. Sourcery with Molly O'Shea.",
98
- "mono": "youtube.com/watch?v=2z-sSISO9BE",
99
- "footer": "sourcery.vc · 2026"
100
- }
101
- ]
102
- }
@@ -1,94 +0,0 @@
1
- {
2
- "theme": "noir",
3
- "brand": { "name": "Sourcery", "accent": "." },
4
- "slides": [
5
- {
6
- "type": "title",
7
- "headline": "Separate the **instinct** from the idea.",
8
- "sub": "Mark Pincus on Life at the Speed of Play. Zynga, FarmVille, Words With Friends, Hivemind. A builder playbook from Sourcery.",
9
- "panel": {
10
- "header": { "title": "Proven better new", "meta": "framework" },
11
- "rows": [
12
- { "title": "Proven", "sub": "same audience, worked before", "value": "1", "sev": 2 },
13
- { "title": "Better", "sub": "10/10 say hell yeah", "value": "2", "sev": 1, "active": true },
14
- { "title": "New", "sub": "reason to try it", "value": "3", "sev": 0 },
15
- { "title": "Test", "sub": "many shots on goal", "value": "4", "sev": 2 }
16
- ],
17
- "footer": { "left": "white lab coat", "right": "no attachment" }
18
- }
19
- },
20
- {
21
- "type": "quote",
22
- "text": "Your number one job as a founder is to be **right.**",
23
- "author": "Mark Pincus",
24
- "role": "Life at the Speed of Play"
25
- },
26
- {
27
- "type": "columns",
28
- "heading": "Instinct and idea are different things",
29
- "columns": [
30
- {
31
- "h": "Instinct",
32
- "b": "The emotional vein. Something broken in human experience. SMS taxi was right. Tribe.net instincts were right."
33
- },
34
- {
35
- "h": "Idea",
36
- "b": "One product bet on that instinct. Often a B+. Kill it fast so the A can show up."
37
- },
38
- {
39
- "h": "Calibration",
40
- "b": "The skill that improves with time. If you ask is this it?, you already know."
41
- }
42
- ]
43
- },
44
- {
45
- "type": "stack",
46
- "heading": "Proven better new, in order",
47
- "layers": [
48
- { "title": "Proven", "sub": "Find the closest success. Same audience. Deconstruct every pixel." },
49
- { "title": "Better", "sub": "One change the existing audience would all notice." },
50
- { "title": "New", "sub": "The novel hook. Expect it to fail. Isolate the experiment." }
51
- ],
52
- "sub": "Give yourself four shots on goal, not one grind up a hill."
53
- },
54
- {
55
- "type": "bignumber",
56
- "number": "Day 365",
57
- "label": "retention beats virality in consumer",
58
- "sub": "40,000 games launched. Zero sustained top 25. People download zero new apps a month. Build for the life stack."
59
- },
60
- {
61
- "type": "versus",
62
- "heading": "Real CEO vs fake CEO",
63
- "left": {
64
- "label": "Real job",
65
- "items": ["great product teams", "products users love", "50%+ calendar here", "iPhone home screen research"]
66
- },
67
- "right": {
68
- "label": "Fake job",
69
- "items": ["investor touring", "culture lectures", "press and Davos", "agenda without product"]
70
- }
71
- },
72
- {
73
- "type": "receipt",
74
- "heading": "Tech assistant = vampire blood.",
75
- "sub": "Bezos, Grove, Gates. Shadow the CEO. Transfer judgment. Then ship a mini-CEO project.",
76
- "receiptTitle": "model · ian cinnamon",
77
- "fields": [
78
- { "k": "recruit", "v": "MIT early, built apps, marked low" },
79
- { "k": "signal", "v": "expert witness, closest to data" },
80
- { "k": "move", "v": "pluck early, shadow CEO" },
81
- { "k": "output", "v": "build cool shit, then found Apex" },
82
- { "k": "lesson", "v": "organ rejection hides gems" }
83
- ],
84
- "stamp": "non-scalable leverage"
85
- },
86
- {
87
- "type": "hero",
88
- "headline": "Life at the **speed of play.**",
89
- "sub": "Book: Life at the Speed of Play. Episode: Mark Pincus, How to Spot a Fake CEO. Sourcery with Molly O'Shea.",
90
- "mono": "youtube.com/watch?v=2z-sSISO9BE",
91
- "footer": "sourcery.vc · 2026"
92
- }
93
- ]
94
- }
@@ -1,150 +0,0 @@
1
- {
2
- "theme": "ink",
3
- "brand": { "name": "The Generalist", "accent": "." },
4
- "slides": [
5
- {
6
- "type": "interstitial",
7
- "kicker": "Yash Patil · Applied Compute · The Generalist · 68 min",
8
- "text": "Own or **be owned.**"
9
- },
10
- {
11
- "type": "lede",
12
- "headline": "Frontier models are a **blowtorch.** Most jobs need a knife.",
13
- "dek": "23-year-old ex-OpenAI post-training researcher. $1.3B company in year one. Trains custom models on private evals for DoorDash, Cognition, and Mercor.",
14
- "byline": "Own or Be Owned · June 2026 · generalist.com/p/own-or-be-owned"
15
- },
16
- {
17
- "type": "quote",
18
- "text": "A model-less company is sitting on **shifting sand.**",
19
- "author": "Yash Patil",
20
- "role": "On Fable 5 guardrails and frontier provider control"
21
- },
22
- {
23
- "type": "prose",
24
- "heading": "Why Fable 5 sparked the own-or-be-owned thesis.",
25
- "paragraphs": [
26
- "Anthropic's system card flagged restrictions on AI model development queries. Reasonable safety on one reading. Also: the model provider decides what capabilities you get.",
27
- "If Anthropic holds out a capability for competitive reasons, downstream products built on their API get Sherlocked. The fix is owning your intelligence stack."
28
- ]
29
- },
30
- {
31
- "type": "statement",
32
- "text": "Evals are the new **PRD.**",
33
- "sub": "Every company codifies what good looks like. Proprietary evals stay home. Goldman and Mercor will never ship scorecards to frontier APIs."
34
- },
35
- {
36
- "type": "columns",
37
- "heading": "What Applied Compute does",
38
- "columns": [
39
- { "h": "Post-train", "b": "Start from open-weight models. RLVR hill climb on customer data. Task-specific, not general." },
40
- { "h": "Serve", "b": "Deploy in production at scale. Revenue mostly on inference, not training fees." },
41
- { "h": "Improve", "b": "Capture usage → new training data → continuous loop. Model learns the more you use it." }
42
- ]
43
- },
44
- {
45
- "type": "timeline",
46
- "heading": "Customer engagement loop",
47
- "steps": [
48
- { "label": "eval", "sub": "define good" },
49
- { "label": "data", "sub": "your traces" },
50
- { "label": "train", "sub": "RLVR climb", "active": true },
51
- { "label": "serve", "sub": "host + infer" },
52
- { "label": "loop", "sub": "never ends" }
53
- ],
54
- "sub": "Applied researchers embed with customer ML teams. Palantir-style FDE model. Platform is the repeatable layer."
55
- },
56
- {
57
- "type": "split",
58
- "heading": "DoorDash beat frontier on one narrow task.",
59
- "body": "100k+ new merchants per year. Unstructured menu photo in. High-fidelity DoorDash storefront out. Build eval → training data → RL → deploy. Specialized model exceeded frontier quality on this workflow.",
60
- "accent": "100k+",
61
- "accentSub": "merchants/year · menu photo → storefront · owned intelligence"
62
- },
63
- {
64
- "type": "stack",
65
- "heading": "Post-training stack (how RLVR works)",
66
- "layers": [
67
- { "title": "Pre-training", "sub": "internet-scale data, next-token prediction, sets the floor" },
68
- { "title": "SFT", "sub": "behavior cloning on good completion examples" },
69
- { "title": "RLVR", "sub": "verifiable rewards, many attempts, hill climb the eval" },
70
- { "title": "Continuous", "sub": "sparse rewards from production usage, Cursor Composer-style online RL" }
71
- ],
72
- "sub": "Microsoft called it the hill-climbing machine. If you define the hill well, the algorithm works."
73
- },
74
- {
75
- "type": "columns",
76
- "heading": "Right model for the right task",
77
- "columns": [
78
- { "h": "Frontier (20%)", "b": "Hardest tasks. Sets the floor. Shared capability. Blowtorch scale." },
79
- { "h": "Custom (80%)", "b": "Your evals. Cost + latency fit. Private data. Raises the ceiling." },
80
- { "h": "Cost driver now", "b": "Token apocalypse. Inference dominates spend. Better, cheaper, faster open-weight models." }
81
- ]
82
- },
83
- {
84
- "type": "prose",
85
- "heading": "Moat beyond the weights.",
86
- "paragraphs": [
87
- "Kirkland & Ellis talked about half a billion on AI tools competitors cannot use. The model is part of the moat. Training inside your harness with your context is the rest.",
88
- "Same model + same frontier API as your competitor = no differentiation. Own the post-training loop on private evals."
89
- ]
90
- },
91
- {
92
- "type": "chips",
93
- "heading": "Customers and context",
94
- "chips": [
95
- "DoorDash merchant onboarding",
96
- "Cognition",
97
- "Mercor agent training",
98
- "AI natives",
99
- "Digital natives",
100
- "Large enterprises",
101
- "Hyperscalers"
102
- ],
103
- "mono": "appliedcompute.com/case-studies/doordash"
104
- },
105
- {
106
- "type": "columns",
107
- "heading": "Training infrastructure bets",
108
- "columns": [
109
- { "h": "Async pipeline", "b": "Sample next problems while training runs. Off-policy corrections. Cut total GPU time on long-horizon tasks." },
110
- { "h": "Replayable envs", "b": "Sandboxes with codebases and services. Same problem attempted 1,000x. Verifier assigns reward." },
111
- { "h": "GPU perf", "b": "Own GPUs. ML infra researchers close to hardware. Environment perf so GPUs never idle on CPU work." }
112
- ]
113
- },
114
- {
115
- "type": "bignumber",
116
- "number": "$1.3B",
117
- "label": "Applied Compute valuation, ~14 months in",
118
- "sub": "Ex-OpenAI post-training team. ~2/3 of hires are ex-founders. High-agency FDE culture."
119
- },
120
- {
121
- "type": "prose",
122
- "heading": "Yash's path to Applied Compute",
123
- "paragraphs": [
124
- "Stanford dropout (sophomore). Almost landed on ChatGPT engineering. Pulled last-minute to post-training infra. Mentored by Luke Metz, Barret Zoph, John Schulman.",
125
- "Cold-emailed Sam Altman after a campus dinner. Residency required burning the boats. Lived through the Sam ouster weekend. Hug on the stairs when he returned."
126
- ]
127
- },
128
- {
129
- "type": "columns",
130
- "heading": "Predictions and roadblocks",
131
- "columns": [
132
- { "h": "Decades, not years", "b": "AI diffusion is slow. Large institutions resist change. DeployCo exists because deployment is hard." },
133
- { "h": "No one is data ready", "b": "Even best companies. Messy traces. Field notes from Michael Chan on FDE reality." },
134
- { "h": "Compute crunch", "b": "Inference demand will balloon. Personal AI × enterprise models. Pareto-optimal cost-performance wins." }
135
- ]
136
- },
137
- {
138
- "type": "quote",
139
- "text": "There is truly some **atrophy** happening by relying too much on AI tools.",
140
- "author": "Yash Patil",
141
- "role": "Recommends The Design of Everyday Things · humans stay overlords"
142
- },
143
- {
144
- "type": "interstitial",
145
- "text": "Train on your evals. **Keep your moat.**",
146
- "sub": "youtube.com/watch?v=B-MxM-OqON8 · appliedcompute.com · yashpatil.me",
147
- "align": "START"
148
- }
149
- ]
150
- }
@@ -1,82 +0,0 @@
1
- {
2
- "theme": "ink",
3
- "brand": { "name": "The Generalist", "accent": "." },
4
- "slides": [
5
- {
6
- "type": "title",
7
- "headline": "Own or **be owned.**",
8
- "sub": "Yash Patil, Applied Compute. Custom models on your data. Smaller, cheaper, built for the work you actually do.",
9
- "panel": {
10
- "header": { "title": "Applied Compute", "meta": "loop" },
11
- "rows": [
12
- { "title": "Evals", "sub": "your scorecard", "value": "1", "sev": 2 },
13
- { "title": "Post-train", "sub": "hill climb RLVR", "value": "2", "sev": 0, "active": true },
14
- { "title": "Deploy", "sub": "production at scale", "value": "3", "sev": 1 },
15
- { "title": "Improve", "sub": "continuous learning", "value": "4", "sev": 2 }
16
- ],
17
- "footer": { "left": "open weights in", "right": "your evals stay" }
18
- }
19
- },
20
- {
21
- "type": "quote",
22
- "text": "Evals are the new **PRD.**",
23
- "author": "Yash Patil",
24
- "role": "Applied Compute · The Generalist"
25
- },
26
- {
27
- "type": "versus",
28
- "heading": "Right model for the right task",
29
- "left": {
30
- "label": "Frontier model",
31
- "items": ["sets the floor", "hardest 20% of spend", "shared capability", "blowtorch scale"]
32
- },
33
- "right": {
34
- "label": "Your model",
35
- "items": ["raises the ceiling", "80% of task spend", "private evals", "cost + latency fit"]
36
- }
37
- },
38
- {
39
- "type": "timeline",
40
- "heading": "How Applied Compute works",
41
- "steps": [
42
- { "label": "eval", "sub": "define good" },
43
- { "label": "data", "sub": "your traces" },
44
- { "label": "train", "sub": "RLVR hill climb", "active": true },
45
- { "label": "serve", "sub": "production" },
46
- { "label": "improve", "sub": "never ends" }
47
- ],
48
- "sub": "Start from eval. Train on data that looks like the eval. Deploy. Loop forever."
49
- },
50
- {
51
- "type": "receipt",
52
- "heading": "DoorDash beat frontier on one task.",
53
- "sub": "100k+ merchants per year. Menu photo in. Storefront out.",
54
- "receiptTitle": "case study · merchant onboarding",
55
- "fields": [
56
- { "k": "input", "v": "unstructured menu photos" },
57
- { "k": "eval", "v": "what a good storefront looks like" },
58
- { "k": "train", "v": "small specialized model + RL" },
59
- { "k": "result", "v": "quality above frontier on this task" },
60
- { "k": "why", "v": "task-specific beats general at scale" }
61
- ],
62
- "stamp": "own the intelligence"
63
- },
64
- {
65
- "type": "metricgrid",
66
- "heading": "The squeeze",
67
- "metrics": [
68
- { "value": "$1.3B", "label": "Applied Compute valuation, year one" },
69
- { "value": "100k+", "label": "merchants onboarded at DoorDash yearly" },
70
- { "value": "80/20", "label": "custom vs frontier spend split Yash cites" },
71
- { "value": "Decades", "label": "AI diffusion into the real economy" }
72
- ]
73
- },
74
- {
75
- "type": "hero",
76
- "headline": "Train on your evals. **Keep your moat.**",
77
- "sub": "DoorDash, Cognition, Mercor. Ex-OpenAI post-training. Open weights in, private scorecards stay home.",
78
- "mono": "youtube.com/watch?v=B-MxM-OqON8",
79
- "footer": "generalist.com · appliedcompute.com · 2026"
80
- }
81
- ]
82
- }
@@ -1,54 +0,0 @@
1
- {
2
- "theme": "ink",
3
- "brand": { "name": "The Generalist", "accent": "." },
4
- "slides": [
5
- {
6
- "type": "interstitial",
7
- "kicker": "Applied Compute · The Generalist · 68 min",
8
- "text": "Own or **be owned.**"
9
- },
10
- {
11
- "type": "lede",
12
- "headline": "Frontier models are a **blowtorch.** Most jobs need a knife.",
13
- "dek": "Yash Patil left OpenAI to help companies train custom models on private evals. DoorDash, Cognition, Mercor.",
14
- "byline": "Episode · Own or Be Owned"
15
- },
16
- {
17
- "type": "statement",
18
- "text": "Evals are the new **PRD.**",
19
- "sub": "Every company codifies what good looks like. Those scorecards stay private. They will never ship them to frontier providers."
20
- },
21
- {
22
- "type": "prose",
23
- "heading": "If evals are yours, post-training should be yours too.",
24
- "paragraphs": [
25
- "Open weights in. Your hill to climb. RLVR on traces that look like the eval, not the internet.",
26
- "Goldman will not send its production scorecard to a shared frontier API. Neither will DoorDash, Cognition, or Mercor."
27
- ]
28
- },
29
- {
30
- "type": "bignumber",
31
- "number": "$1.3B",
32
- "label": "Applied Compute valuation, year one",
33
- "sub": "Mercor as customer. Ex-OpenAI post-training team."
34
- },
35
- {
36
- "type": "split",
37
- "heading": "DoorDash beat frontier on one task.",
38
- "body": "100k+ merchants onboarded per year. Menu photo in, storefront out. A small specialized model trained on what a good storefront looks like, not general intelligence.",
39
- "accent": "100k+",
40
- "accentSub": "merchants per year · one narrow task · owned intelligence"
41
- },
42
- {
43
- "type": "statement",
44
- "text": "80% of spend on custom models. **20% on frontier.**",
45
- "sub": "Frontier sets the floor. Your model raises the ceiling. AI diffusion into the real economy takes decades, not quarters."
46
- },
47
- {
48
- "type": "interstitial",
49
- "text": "Train on your evals. **Keep your moat.**",
50
- "sub": "youtube.com/watch?v=B-MxM-OqON8 · generalist.com · appliedcompute.com",
51
- "align": "START"
52
- }
53
- ]
54
- }
@@ -1,164 +0,0 @@
1
- const MULTILINE_CSI = [
2
- '\x1b[13;2~',
3
- '\x1b[27;2;13~',
4
- '\x1b[23~',
5
- '\x1b[13;2u',
6
- ];
7
-
8
- const MULTILINE_CSI_RE = /\x1b\[(?:13;2~|27;2;13~|23~|13;2u)/;
9
- const MULTILINE_CSI_VISIBLE_RE = /\[(?:13;2~|27;2;13~|23~|13;2u)/g;
10
-
11
- // Node's readline cannot emit a 'line' whose buffer contains a literal "\n"
12
- // (it reorders the text around the newline on submit). So newlines live in the
13
- // buffer as this sentinel while typing is rendered, then are restored to "\n"
14
- // when the answer is read back via stripMultilineCsiText.
15
- const MULTILINE_PLACEHOLDER = '\x1f';
16
- const MULTILINE_PLACEHOLDER_RE = /\x1f/g;
17
-
18
- function isMultilineCsiPrefix(buffer) {
19
- const value = String(buffer || '');
20
- if (!value) return false;
21
- return MULTILINE_CSI.some((seq) => seq.startsWith(value));
22
- }
23
-
24
- function isMultilineCsiComplete(buffer) {
25
- return MULTILINE_CSI.includes(String(buffer || ''));
26
- }
27
-
28
- function isMultilineCsiKey(key) {
29
- const sequence = String(key?.sequence || '');
30
- return MULTILINE_CSI_RE.test(sequence);
31
- }
32
-
33
- function isMultilineInsertKey(str, key) {
34
- if (!key) return str === '\n';
35
- if (key.shift && (key.name === 'return' || key.name === 'enter')) return true;
36
- if (key.meta && (key.name === 'return' || key.name === 'enter')) return true;
37
- if (str === '\n' && key.name !== 'return') return true;
38
- return false;
39
- }
40
-
41
- function isSubmitKey(str, key) {
42
- if (key && (key.name === 'return' || key.name === 'enter') && !key.shift && !key.meta) return true;
43
- if (!key && str === '\r') return true;
44
- return false;
45
- }
46
-
47
- function stripMultilineCsiText(text) {
48
- return String(text || '')
49
- .replace(MULTILINE_PLACEHOLDER_RE, '\n')
50
- .replace(/\x1b\[20[01]~/g, '')
51
- .replace(/\x1b\[(?:13;2~|27;2;13~|23~|13;2u)/g, '\n')
52
- .replace(MULTILINE_CSI_VISIBLE_RE, '\n')
53
- .replace(/\^?\[\[27;2;13~/g, '\n');
54
- }
55
-
56
- // The raw bytes a keypress represents. readline's keypress decoder mangles
57
- // some CSI sequences (e.g. it splits \x1b[27;2;13~ into a malformed escape
58
- // whose `sequence` is \x1b[27;2; followed by literal "1", "3", "~"), so when
59
- // `str` is empty we fall back to the decoded `sequence`.
60
- function keyBytes(str, key) {
61
- if (typeof str === 'string' && str.length > 0) return str;
62
- if (key && typeof key.sequence === 'string' && key.sequence.length > 0) return key.sequence;
63
- return typeof str === 'string' ? str : '';
64
- }
65
-
66
- function defaultInsertBreak(rl) {
67
- if (!rl) return;
68
- // _insertString splices a literal newline at the cursor; rl.write('\n')
69
- // would instead SUBMIT the line, so it must not be used here.
70
- if (typeof rl._insertString === 'function') {
71
- rl._insertString('\n');
72
- return;
73
- }
74
- if (typeof rl.line === 'string') {
75
- const cursor = Number.isFinite(rl.cursor) ? rl.cursor : rl.line.length;
76
- rl.line = rl.line.slice(0, cursor) + '\n' + rl.line.slice(cursor);
77
- rl.cursor = cursor + 1;
78
- if (typeof rl._refreshLine === 'function') rl._refreshLine();
79
- return;
80
- }
81
- if (typeof rl.write === 'function') rl.write('\n');
82
- }
83
-
84
- function attachMultilineChatInput(rl, { insertBreak = defaultInsertBreak, onSubmit } = {}) {
85
- if (!rl || typeof rl._ttyWrite !== 'function') return () => {};
86
- const ttyWrite = rl._ttyWrite.bind(rl);
87
- let escBuffer = null;
88
-
89
- rl._ttyWrite = (str, key) => {
90
- const bytes = keyBytes(str, key);
91
-
92
- // Mid-sequence: keypress decoder shredded a multiline CSI across calls and
93
- // we're reassembling it (e.g. \x1b[27;2; then "1", "3", "~").
94
- if (escBuffer !== null) {
95
- escBuffer += bytes;
96
- if (isMultilineCsiComplete(escBuffer)) {
97
- escBuffer = null;
98
- insertBreak(rl);
99
- return;
100
- }
101
- if (isMultilineCsiPrefix(escBuffer) && escBuffer.length <= 24) {
102
- return;
103
- }
104
- // Diverged from every target sequence: replay the swallowed bytes
105
- // literally (current keypress is already included in the buffer).
106
- const replay = escBuffer;
107
- escBuffer = null;
108
- for (const ch of replay) ttyWrite(ch);
109
- return;
110
- }
111
-
112
- // Whole multiline CSI delivered in a single keypress (terminals or Node
113
- // versions that don't shred it).
114
- if (isMultilineCsiKey(key) || MULTILINE_CSI_RE.test(bytes)) {
115
- insertBreak(rl);
116
- return;
117
- }
118
-
119
- // Start of a shredded multiline CSI: begin buffering from the raw escape.
120
- if (bytes && bytes.charCodeAt(0) === 0x1b && isMultilineCsiPrefix(bytes)) {
121
- escBuffer = bytes;
122
- if (isMultilineCsiComplete(escBuffer)) {
123
- escBuffer = null;
124
- insertBreak(rl);
125
- }
126
- return;
127
- }
128
-
129
- // Plain Shift+Enter / Meta+Enter / synthetic \n.
130
- if (isMultilineInsertKey(str, key)) {
131
- insertBreak(rl);
132
- return;
133
- }
134
-
135
- // Submit (Enter): the line buffer keeps its literal "\n" so readline's own
136
- // multiline cursor math advances past every wrapped row (otherwise the box
137
- // bottom border overwrites a row). readline mangles the emitted 'line'
138
- // string when it holds a newline, so we hand the true buffer to onSubmit
139
- // and the caller reads that instead of the line event.
140
- if (isSubmitKey(str, key) && typeof rl.line === 'string' && rl.line.includes('\n')) {
141
- if (typeof onSubmit === 'function') onSubmit(rl.line);
142
- }
143
-
144
- ttyWrite(str, key);
145
- };
146
-
147
- return () => {
148
- rl._ttyWrite = ttyWrite;
149
- escBuffer = null;
150
- };
151
- }
152
-
153
- module.exports = {
154
- MULTILINE_CSI,
155
- MULTILINE_PLACEHOLDER,
156
- attachMultilineChatInput,
157
- isMultilineCsiComplete,
158
- isMultilineCsiKey,
159
- isMultilineInsertKey,
160
- isMultilineCsiPrefix,
161
- isSubmitKey,
162
- stripMultilineCsiText,
163
- keyBytes,
164
- };