@atlassian/chippy 0.0.0-stage → 0.0.1-beta.2

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 (133) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +276 -2
  3. package/bin/chippy.mjs +92 -0
  4. package/bin/pack.mjs +204 -0
  5. package/bin/skill-dir.mjs +15 -0
  6. package/lib/avalanche.js +2601 -0
  7. package/lib/avalanche.js.map +7 -0
  8. package/lib/bootstrap.d.ts +1 -0
  9. package/lib/bootstrap.js +70 -0
  10. package/lib/bootstrap.js.map +7 -0
  11. package/lib/browser.js +15 -0
  12. package/lib/browser.js.map +7 -0
  13. package/lib/extension/avalanche.es.js +5535 -0
  14. package/lib/extension/avalanche.es.js.map +1 -0
  15. package/lib/extension/chippy-page-bridge.js +1953 -0
  16. package/lib/extension/inspect-react.js +216 -0
  17. package/lib/extension/layout-lab.js +1453 -0
  18. package/lib/extension/panel-dom.js +90 -0
  19. package/lib/extension/resolve-probes.js +342 -0
  20. package/lib/mcp-skill/LICENSE +201 -0
  21. package/lib/mcp-skill/README.md +148 -0
  22. package/lib/mcp-skill/SKILL.md +335 -0
  23. package/lib/mcp-skill/browser-scripts/playwright-probes.js +368 -0
  24. package/lib/mcp-skill/browser-scripts/playwright-session.js +114 -0
  25. package/lib/mcp-skill/extension/armed-reload-startup.js +83 -0
  26. package/lib/mcp-skill/extension/avalanche.es.js +5535 -0
  27. package/lib/mcp-skill/extension/avalanche.es.js.map +1 -0
  28. package/lib/mcp-skill/extension/avalanche.iife.js +5536 -0
  29. package/lib/mcp-skill/extension/avalanche.iife.js.map +1 -0
  30. package/lib/mcp-skill/extension/background.js +325 -0
  31. package/lib/mcp-skill/extension/chippy-page-bridge.js +1953 -0
  32. package/lib/mcp-skill/extension/content-script.js +190 -0
  33. package/lib/mcp-skill/extension/devtools-hook-shim.js +85 -0
  34. package/lib/mcp-skill/extension/early-bootstrap.js +49 -0
  35. package/lib/mcp-skill/extension/icon-128.png +0 -0
  36. package/lib/mcp-skill/extension/icon-16.png +0 -0
  37. package/lib/mcp-skill/extension/icon-32.png +0 -0
  38. package/lib/mcp-skill/extension/icon-48.png +0 -0
  39. package/lib/mcp-skill/extension/inspect-react.js +216 -0
  40. package/lib/mcp-skill/extension/layout-lab.js +1453 -0
  41. package/lib/mcp-skill/extension/logo.svg +14 -0
  42. package/lib/mcp-skill/extension/manifest.json +69 -0
  43. package/lib/mcp-skill/extension/panel-dom.js +90 -0
  44. package/lib/mcp-skill/extension/panel-settings.js +173 -0
  45. package/lib/mcp-skill/extension/popup.html +41 -0
  46. package/lib/mcp-skill/extension/popup.js +80 -0
  47. package/lib/mcp-skill/extension/probe-descriptor.js +241 -0
  48. package/lib/mcp-skill/extension/resolve-probes.js +342 -0
  49. package/lib/mcp-skill/extension/startup-handoff.js +30 -0
  50. package/lib/mcp-skill/package.json +1 -0
  51. package/lib/mcp-skill/references/README.md +56 -0
  52. package/lib/mcp-skill/references/active-stimulus.md +85 -0
  53. package/lib/mcp-skill/references/avalanche-detector.md +731 -0
  54. package/lib/mcp-skill/references/bdd-router.md +310 -0
  55. package/lib/mcp-skill/references/browser-runtime-api.md +193 -0
  56. package/lib/mcp-skill/references/command-output-formats.md +1085 -0
  57. package/lib/mcp-skill/references/command-surface.md +183 -0
  58. package/lib/mcp-skill/references/cynefin.md +99 -0
  59. package/lib/mcp-skill/references/debug-hook.md +161 -0
  60. package/lib/mcp-skill/references/fixing-performance.md +490 -0
  61. package/lib/mcp-skill/references/hook-metrics.md +199 -0
  62. package/lib/mcp-skill/references/hooks-inspection.md +61 -0
  63. package/lib/mcp-skill/references/jira-taxonomy.md +81 -0
  64. package/lib/mcp-skill/references/mcp.md +122 -0
  65. package/lib/mcp-skill/references/mode-a-injection.md +102 -0
  66. package/lib/mcp-skill/references/operating-model.md +128 -0
  67. package/lib/mcp-skill/references/playwright-cli-setup.md +105 -0
  68. package/lib/mcp-skill/references/playwright-probes.md +205 -0
  69. package/lib/mcp-skill/references/procedures.md +545 -0
  70. package/lib/mcp-skill/references/recipes.txt +114 -0
  71. package/lib/mcp-skill/references/stability-render.md +428 -0
  72. package/lib/mcp-skill/references/test-mode-playbook.md +194 -0
  73. package/lib/mcp-skill/references/troubleshooting.md +59 -0
  74. package/lib/mcp-skill/scripts/avalanche-analyze.cjs +495 -0
  75. package/lib/mcp-skill/scripts/build-avalanche-command.js +34 -0
  76. package/lib/mcp-skill/scripts/build-fiber-state-command.js +19 -0
  77. package/lib/mcp-skill/scripts/chippy-helper-server.js +1768 -0
  78. package/lib/mcp-skill/scripts/chippy-mcp.cjs +273 -0
  79. package/lib/mcp-skill/scripts/chippy.sh +1252 -0
  80. package/lib/mcp-skill/scripts/format-probe-result.js +34 -0
  81. package/lib/mcp-skill/scripts/helper-access.js +158 -0
  82. package/lib/mcp-skill/scripts/helper-proxy.js +87 -0
  83. package/lib/mcp-skill/scripts/page-socket-trust.js +81 -0
  84. package/lib/mcp-skill/scripts/probe-annotation-channel.js +116 -0
  85. package/lib/mcp-skill/scripts/search-recipes.js +248 -0
  86. package/lib/mcp-skill/snippets/README.md +89 -0
  87. package/lib/mcp-skill/snippets/count-context-consumers.js +40 -0
  88. package/lib/mcp-skill/snippets/find-context-providers.js +38 -0
  89. package/lib/mcp-skill/snippets/find-legacy-context.js +47 -0
  90. package/lib/mcp-skill/snippets/find-prop.js +83 -0
  91. package/lib/mcp-skill/snippets/hook-metrics-sample.js +69 -0
  92. package/lib/mcp-skill/snippets/hook-metrics.js +60 -0
  93. package/lib/mcp-skill/snippets/hook-tracker.js +198 -0
  94. package/lib/mcp-skill/snippets/stability-nudge.js +101 -0
  95. package/lib/package.json +1 -0
  96. package/lib/plugin.js +119 -0
  97. package/lib/plugin.js.map +7 -0
  98. package/lib/storybook/avalanche-panel-model.js +79 -0
  99. package/lib/storybook/brand.jsx +6 -0
  100. package/lib/storybook/connection-fallback.jsx +47 -0
  101. package/lib/storybook/constants.js +15 -0
  102. package/lib/storybook/context-card.jsx +171 -0
  103. package/lib/storybook/manager-owner.js +42 -0
  104. package/lib/storybook/manager.jsx +425 -0
  105. package/lib/storybook/preset.js +7 -0
  106. package/lib/storybook/preview.js +298 -0
  107. package/lib/storybook/probe-annotation-editor.jsx +52 -0
  108. package/lib/storybook/probe-intent.js +23 -0
  109. package/lib/storybook/setup.js +104 -0
  110. package/lib/types/avalanche/commit-metrics-adapter.d.ts +76 -0
  111. package/lib/types/avalanche/commit-stats-indices.d.ts +41 -0
  112. package/lib/types/avalanche/commit-surface-ownership.d.ts +9 -0
  113. package/lib/types/avalanche/detector.d.ts +183 -0
  114. package/lib/types/avalanche/interaction-capture.d.ts +25 -0
  115. package/lib/types/avalanche/internals.d.ts +189 -0
  116. package/lib/types/avalanche/report-serializer.d.ts +283 -0
  117. package/lib/types/avalanche/reporter.d.ts +610 -0
  118. package/lib/types/chippy-bridge/fiber-source.d.ts +48 -0
  119. package/lib/types/chippy-bridge/react-renderer.d.ts +74 -0
  120. package/lib/types/chippy-bridge/recorded-source.d.ts +44 -0
  121. package/lib/types/chippy-bridge/source-map.d.ts +30 -0
  122. package/lib/types/debug-render/core.d.ts +78 -0
  123. package/lib/types/layout-lab/fiber-boundaries.d.ts +51 -0
  124. package/lib/types/layout-lab/fiber-walk.d.ts +131 -0
  125. package/lib/types/layout-lab/marker-context.d.ts +94 -0
  126. package/lib/types/package/avalanche.d.ts +6 -0
  127. package/lib/types/package/browser.d.ts +10 -0
  128. package/lib/types/package/plugin.d.ts +15 -0
  129. package/lib/types/plugins/atl/commit-metrics-adapter.d.ts +65 -0
  130. package/lib/types/plugins/atl/metrics-slot.d.ts +37 -0
  131. package/lib/types/plugins/index.d.ts +49 -0
  132. package/lib/types/plugins/jira/context-provider.d.ts +36 -0
  133. package/package.json +106 -4
@@ -0,0 +1,194 @@
1
+ # Test mode playbook
2
+
3
+ Chippy can work without a human driving the browser. In test mode, Playwright performs the interaction while Chippy reads live page state, traces source, and verifies the result. Playwright is a contract here: open/navigate, inject scripts, interact, wait/poll, and evaluate page state.
4
+
5
+ Use this mode when:
6
+ - you already know the page URL
7
+ - probes can be placed by coordinates or replaced with snippets / eval-page
8
+ - you need repeatable before/after verification
9
+ - you want to save avalanche captures and analyze offline
10
+
11
+ ## Job in test mode
12
+
13
+ The job is the same as interactive mode:
14
+ 1. understand what the page rendered
15
+ 2. find where it comes from
16
+ 3. change source if needed
17
+ 4. verify the result
18
+
19
+ The difference is orchestration. A test harness performs the clicks, typing, reloads, and waits.
20
+
21
+ ## Two automation shapes
22
+
23
+ ### 1. Sidecar mode
24
+ Use a real browser page plus Chippy helper sidecar.
25
+
26
+ Best when:
27
+ - extension is already installed
28
+ - page is a real app page
29
+ - you want the same runtime as a human user
30
+
31
+ Flow:
32
+ 1. open page with Playwright or manually
33
+ 2. ensure origin is enabled in extension
34
+ 3. wait for page to appear in `chippy.sh pages`
35
+ 4. use `chippy.sh` commands to read state, arm reload, or run snippets
36
+
37
+ ### 2. Playwright-controlled mode
38
+ Inject the Chippy bundle directly into a Playwright-controlled page.
39
+
40
+ Best when:
41
+ - running against a disposable local page or Playwright-controlled target
42
+ - you want a fully scripted loop
43
+ - you do not need extension popup/origin enable flows
44
+
45
+ Follow the complete [Mode A injection contract](mode-a-injection.md): DevTools hook shim before navigation, one supported runtime loader, wait for a new page client, then explicit `avalanche-install <clientId>` and `avalanche-clear <clientId>` before the post-install trigger. Mode A does not auto-install the detector and cannot recover boot commits that occurred before installation.
46
+
47
+ ## Stable loop
48
+
49
+ Use this loop for repeatable automation:
50
+
51
+ 1. **Prepare the runtime path**
52
+ - sidecar mode: no harness bootstrap is required
53
+ - direct injection mode: before navigation, install the DevTools hook shim and register the packaged init loader; for the ad-hoc variant, install the shim now and defer the two post-navigation runtime loads
54
+
55
+ 2. **Open page**
56
+ - navigate to the target page URL
57
+ - wait for `document.readyState === "complete"`
58
+
59
+ 3. **Connect runtime**
60
+ - sidecar mode: wait until `chippy.sh pages` lists the page
61
+ - direct injection mode: load the ad-hoc runtimes now if using that variant, select the new client from `pages`, run `avalanche-install`, then `avalanche-clear`
62
+
63
+ 4. **Drive interaction**
64
+ - click, type, drag, or reload
65
+ - sidecar/extension load capture: use `reload-with-avalanche`
66
+ - Mode A: trigger only after explicit install; after any reload, reacquire the new client and repeat install because pre-install boot commits are unobservable
67
+
68
+ 5. **Poll for stable state**
69
+ - after interaction, do not read once and assume done
70
+ - poll until one of these holds:
71
+ - snapshot timestamp changes and then stops changing
72
+ - expected marker becomes non-null with acceptable confidence
73
+ - expected count / text / prop value appears
74
+ - avalanche commit count stops increasing for the settle window
75
+
76
+ 6. **Read structured output**
77
+ - probes: `pages`, `page`, `probe-dom`, `probe-owners`, `probe-props`, `probe-prop-value`
78
+ - performance: `avalanche-status`, `avalanche-hot-sources`, `avalanche-commit-list`, `avalanche-commit-peek`
79
+ - special cases: `eval-page` snippets
80
+ - for unknown data flow, start at an always-used seam; log the full shape first, then narrow after the signal is observed
81
+
82
+ 7. **Change code**
83
+ - proceed only when user intent permits the change and the P-15/P-16 Apply gate passes
84
+ - edit the proven failing layer, not the most convenient visible layer
85
+ - treat harnesses, serializers, navigation/parameter transport, fixtures, mocks, and page objects as foundation until observation shows that foundation is the failing layer
86
+ - edit source in workspace
87
+ - let HMR or reload apply the change
88
+
89
+ 8. **Verify again**
90
+ - same action, same timing window
91
+ - compare visible result and structured output
92
+
93
+ ## Polling contract
94
+
95
+ Polling beats guessing.
96
+
97
+ Recommended defaults:
98
+ - interval: `100ms` to `250ms`
99
+ - short UI wait budget: `5s`
100
+ - heavy reload wait budget: `15s`
101
+ - extra settle after reload avalanche: `3s` to `5s`
102
+
103
+ Treat state as ready only when the thing you need is present and stable.
104
+
105
+ Examples:
106
+ - probe target ready when `resolved` is non-null and confidence is acceptable
107
+ - owner chain ready when `probe-owners` returns the expected source file/name
108
+ - performance capture ready when `commitCount` stops increasing and hot sources are non-empty
109
+
110
+ ## What to use when
111
+
112
+ ### Use probes when:
113
+ - a specific visible element matters
114
+ - you need exact owner or prop origin
115
+ - you need to trace source for one render path
116
+
117
+ ### Use snippets / `eval-page` when:
118
+ - the question is cross-cutting
119
+ - you need to count providers/consumers
120
+ - you need to search many fibers for one condition
121
+ - a built-in command would be too narrow
122
+
123
+ ### Use avalanche when:
124
+ - problem is re-render spread, lag, churn, or restart-heavy commits
125
+ - you need commit-level ranking
126
+ - you need before/after performance verification
127
+
128
+ ## Minimal examples
129
+
130
+ ### Sidecar avalanche loop
131
+ ```bash
132
+ ./scripts/chippy.sh pages
133
+ # Select the page whose URL, title, integration identity, and recency match the target.
134
+ CLIENT_ID=<confirmed-clientId>
135
+ ORIGIN=<that page's origin>
136
+ ./scripts/chippy.sh reload-with-avalanche "$CLIENT_ID" "$ORIGIN" 0 15000 5000
137
+ ./scripts/chippy.sh avalanche-status "$CLIENT_ID"
138
+ ./scripts/chippy.sh avalanche-hot-sources "$CLIENT_ID" 10
139
+ ./scripts/chippy.sh avalanche-commit-list "$CLIENT_ID" 10 collateral
140
+ ```
141
+
142
+ ### Mode A post-install loop
143
+
144
+ Complete the bootstrap in [Mode A injection](mode-a-injection.md), then:
145
+
146
+ ```bash
147
+ ./scripts/chippy.sh pages
148
+ CLIENT_ID=<confirmed-new-clientId>
149
+ ./scripts/chippy.sh avalanche-install "$CLIENT_ID" full
150
+ ./scripts/chippy.sh avalanche-clear "$CLIENT_ID"
151
+ # Use Playwright to trigger the measured behavior now, after installation.
152
+ ./scripts/chippy.sh avalanche-status "$CLIENT_ID"
153
+ ./scripts/chippy.sh avalanche-commit-list "$CLIENT_ID" 10 collateral
154
+ ```
155
+
156
+ For another navigation or reload, repeat client selection, install, clear, and the post-install trigger. Do not use `reload-with-avalanche` to claim Mode A boot coverage.
157
+
158
+ ### Snippet loop
159
+ ```bash
160
+ ./scripts/chippy.sh eval-snippets
161
+ ./scripts/chippy.sh eval-page "$CLIENT_ID" find-context-providers --name Jira
162
+ ```
163
+
164
+ ### Save once, analyze many times
165
+ ```bash
166
+ ./scripts/chippy.sh avalanche-save "$CLIENT_ID" .chippy-captures/run.json
167
+ ./scripts/chippy.sh avalanche-offline .chippy-captures/run.json summary
168
+ ./scripts/chippy.sh avalanche-offline .chippy-captures/run.json commit-peek 8 stats,sources,atl 3 20
169
+ ```
170
+
171
+ ## Failure handling
172
+
173
+ If automation fails:
174
+ - page missing from `pages` → reconnect or reload page
175
+ - marker unresolved → re-place probe or wait longer
176
+ - `__AVALANCHE__` present but no data → confirm live API shape and startup path
177
+ - `report()` unavailable → you may be reading module namespace, not installed instance
178
+ - duplicate install warning → same bundle loaded twice; fix startup order before trusting output
179
+
180
+ ## What to save as artifacts
181
+
182
+ Prefer structured artifacts over screenshots:
183
+ - snapshot JSON
184
+ - probe output JSON
185
+ - avalanche export JSON
186
+ - commit list / commit peek slices
187
+
188
+ Screenshots help verify appearance. They do not replace runtime data.
189
+
190
+ ## Read next
191
+
192
+ - Chippy skill: [../SKILL.md](../SKILL.md)
193
+ - Avalanche reference: [./avalanche-detector.md](./avalanche-detector.md)
194
+ - Performance reasoning: [./fixing-performance.md](./fixing-performance.md)
@@ -0,0 +1,59 @@
1
+ # Troubleshooting
2
+
3
+ ## Helper is down
4
+ - `/__chippy/health` fails
5
+ - no pages in `/__chippy/api/pages`
6
+ - the Storybook Chippy and Avalanche panels conditionally offer `npx skills add atlassian-labs/chippy --skill chippy -g` while their connection state is `failed` or `reconnecting`
7
+ - Chippy must run outside the agent sandbox; the agent owns this, not the user
8
+ - sandbox failure mode: the helper can look alive inside the agent environment, but the browser cannot reach its isolated Node server/port
9
+ - fix: agent runs `./scripts/chippy.sh start` using outside-sandbox / escalated execution, then verifies with `./scripts/chippy.sh health` and `./scripts/chippy.sh pages` (also outside-sandbox)
10
+ - do not ask the user to open a terminal to start the helper; that is a last-resort fallback only if outside-sandbox execution is genuinely unavailable
11
+ - do not try helper-contacting commands inside the sandbox first; `start`, `stop`, `health`, `pages`, `page`, snapshots, probes, fiber inspection, live avalanche commands, `eval-page`, page reload/wait, and proxy commands all need access to the real `127.0.0.1:7823`
12
+ - allowlisting the Chippy wrapper in any agent runner that supports it is helpful but not enough; helper-contacting `chippy.sh` commands must still run outside the sandbox on every attempt that needs `127.0.0.1:7823`
13
+ - allowlist the absolute install path of `chippy.sh` on this machine if the runner supports it
14
+
15
+ ## Helper returns 401 or 403
16
+ - 401: command routes require the helper's access token; `chippy.sh`, MCP, and the Playwright probes send it automatically
17
+ - the running helper writes its token to `~/.chippy/helper-7823.token` (or `$CHIPPY_STATE_DIR`); a missing or stale file usually means another process holds the port or the file was removed
18
+ - fix: `./scripts/chippy.sh stop`, then `./scripts/chippy.sh start` (outside the sandbox), so the new helper writes a fresh token
19
+ - custom HTTP clients send the token as the `X-Chippy-Token` header
20
+ - 403: the request's `Host` is not a loopback name; use `127.0.0.1` or `localhost`, or start the helper with `CHIPPY_HELPER_ALLOWED_HOSTS` set to the forwarded name
21
+ - browser on another machine (remote dev environment, container): the helper binds `127.0.0.1` by default; use an SSH tunnel, or ask for a wide bind with `./scripts/chippy.sh stop` then `./scripts/chippy.sh start --host 0.0.0.0`
22
+
23
+ ## No connected pages
24
+ - extension may not be installed
25
+ - origin may not be enabled
26
+ - page may not have been reloaded after enabling
27
+ - page may have failed to load `/__chippy/inject.js`
28
+ - do not search Chippy's own source code to answer live questions like "where is p1?"
29
+ - instead, explain that there is no live probe state yet and help the user connect or reload the target page
30
+
31
+ ## Bundle failed to load
32
+ - page exists but helper status or page status shows `load-error`
33
+ - check the helper URL configured in the extension
34
+ - check the page network tab for `inject.js`
35
+
36
+ ## Page reloaded and probes disappeared
37
+ - expected after full reload/navigation
38
+ - if the origin is still enabled, Chippy should reappear automatically after reload completes
39
+
40
+ ## Production page
41
+ - neither React <=18 `_debugSource` nor React 19 `_debugStack` source evidence is available
42
+ - rely on component names, stacks, notes, and cross-source hints
43
+ - be explicit with the user that source precision is weaker
44
+
45
+ ## React 19 source stays on a served-module URL
46
+ - `_debugStack` produced a project frame, but the page could not fetch the module or its source map
47
+ - the served URL and generated line remain as a bounded fallback; do not present them as a mapped repository position
48
+ - check that the page can fetch its own module URL and that the dev server emits an inline or external Source Map v3 payload
49
+
50
+ ## React <=18 source line is offset from the file
51
+ - `_debugSource` records the line the JSX transform saw; a transform that ran earlier and added lines shifts it
52
+ - Chippy corrects the line when it can fetch the module the page loaded for that file and the module's source map maps the recorded literal back into the same file
53
+ - if the line still looks offset, check that the page loaded the module from its own origin and that the dev server emits a source map
54
+
55
+ ## Multiple pages on same URL
56
+ - use `clientId`, title, `latestSnapshotAt`, and `lastMessageAt` to identify the right page
57
+ - usually prefer the most recently updated page when one candidate is clearly newer than the rest
58
+ - if the time gap is narrow, treat the target as ambiguous and ask rather than guessing
59
+ - after choosing a likely page, request a fresh snapshot to confirm it is the intended one