@zfdx123/dsh-superpowers 1.0.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 (59) hide show
  1. package/LICENSE +27 -0
  2. package/LICENSE.superpowers +21 -0
  3. package/README.md +109 -0
  4. package/README.zh.md +109 -0
  5. package/cordis.patch.yml +16 -0
  6. package/index.js +395 -0
  7. package/package.json +68 -0
  8. package/skills/brainstorming/SKILL.md +250 -0
  9. package/skills/brainstorming/scripts/frame-template.html +213 -0
  10. package/skills/brainstorming/scripts/helper.js +179 -0
  11. package/skills/brainstorming/scripts/server.cjs +781 -0
  12. package/skills/brainstorming/scripts/start-server.sh +209 -0
  13. package/skills/brainstorming/scripts/stop-server.sh +120 -0
  14. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  15. package/skills/brainstorming/visual-companion.md +299 -0
  16. package/skills/dispatching-parallel-agents/SKILL.md +167 -0
  17. package/skills/executing-plans/SKILL.md +64 -0
  18. package/skills/finishing-a-development-branch/SKILL.md +225 -0
  19. package/skills/receiving-code-review/SKILL.md +205 -0
  20. package/skills/requesting-code-review/SKILL.md +95 -0
  21. package/skills/requesting-code-review/code-reviewer.md +181 -0
  22. package/skills/subagent-driven-development/SKILL.md +568 -0
  23. package/skills/subagent-driven-development/implementer-prompt.md +154 -0
  24. package/skills/subagent-driven-development/re-review-prompt.md +115 -0
  25. package/skills/subagent-driven-development/scripts/review-package +46 -0
  26. package/skills/subagent-driven-development/scripts/sdd-workspace +40 -0
  27. package/skills/subagent-driven-development/scripts/task-brief +41 -0
  28. package/skills/subagent-driven-development/task-reviewer-prompt.md +207 -0
  29. package/skills/systematic-debugging/CREATION-LOG.md +119 -0
  30. package/skills/systematic-debugging/SKILL.md +283 -0
  31. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  32. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  33. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  34. package/skills/systematic-debugging/find-polluter.sh +72 -0
  35. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  36. package/skills/systematic-debugging/test-academic.md +14 -0
  37. package/skills/systematic-debugging/test-pressure-1.md +58 -0
  38. package/skills/systematic-debugging/test-pressure-2.md +68 -0
  39. package/skills/systematic-debugging/test-pressure-3.md +69 -0
  40. package/skills/test-driven-development/SKILL.md +320 -0
  41. package/skills/test-driven-development/writing-good-tests.md +198 -0
  42. package/skills/using-git-worktrees/SKILL.md +167 -0
  43. package/skills/using-superpowers/SKILL.md +63 -0
  44. package/skills/using-superpowers/references/antigravity-tools.md +23 -0
  45. package/skills/using-superpowers/references/codex-tools.md +108 -0
  46. package/skills/using-superpowers/references/gemini-tools.md +63 -0
  47. package/skills/using-superpowers/references/hermes-tools.md +56 -0
  48. package/skills/using-superpowers/references/pi-tools.md +16 -0
  49. package/skills/verification-before-completion/SKILL.md +120 -0
  50. package/skills/writing-plans/SKILL.md +171 -0
  51. package/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  52. package/skills/writing-skills/SKILL.md +679 -0
  53. package/skills/writing-skills/anthropic-best-practices.md +1150 -0
  54. package/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  55. package/skills/writing-skills/graphviz-conventions.dot +172 -0
  56. package/skills/writing-skills/persuasion-principles.md +187 -0
  57. package/skills/writing-skills/render-graphs.js +172 -0
  58. package/skills/writing-skills/testing-skills-with-subagents.md +384 -0
  59. package/test/index.test.js +332 -0
@@ -0,0 +1,179 @@
1
+ ;(function () {
2
+ const MIN_RECONNECT_MS = 500
3
+ const MAX_RECONNECT_MS = 30000
4
+ const TOMBSTONE_AFTER_MS = 15000 // show the "paused" overlay after this long disconnected
5
+
6
+ // Pure: next backoff delay (doubles, capped). Exported for unit tests.
7
+ function nextReconnectDelay(current, max) {
8
+ return Math.min(current * 2, max)
9
+ }
10
+ if (typeof module !== 'undefined' && module.exports) {
11
+ module.exports = { nextReconnectDelay, MIN_RECONNECT_MS, MAX_RECONNECT_MS, TOMBSTONE_AFTER_MS }
12
+ }
13
+
14
+ // Everything below is browser-only; bail out when loaded in Node (tests).
15
+ if (typeof window === 'undefined') return
16
+
17
+ let ws = null
18
+ let eventQueue = []
19
+ let reconnectDelay = MIN_RECONNECT_MS
20
+ let reconnectTimer = null
21
+ let disconnectedSince = null
22
+ let everConnected = false
23
+ let tombstoneShown = false
24
+
25
+ function sessionKey() {
26
+ try {
27
+ return window.sessionStorage && window.sessionStorage.getItem('brainstorm-session-key')
28
+ } catch (e) {}
29
+ return null
30
+ }
31
+
32
+ function websocketUrl() {
33
+ const key = sessionKey()
34
+ return 'ws://' + window.location.host + (key ? '/?key=' + encodeURIComponent(key) : '')
35
+ }
36
+
37
+ function reloadAfterRecovery() {
38
+ const key = sessionKey()
39
+ if (key) {
40
+ window.location.replace('/?key=' + encodeURIComponent(key))
41
+ } else {
42
+ window.location.reload()
43
+ }
44
+ }
45
+
46
+ // Reflect connection state in the frame's status pill (absent on full-doc screens).
47
+ function setStatus(state) {
48
+ const el = document.querySelector('.status')
49
+ if (!el) return
50
+ const map = {
51
+ connecting: ['Connecting…', 'var(--text-tertiary)'],
52
+ connected: ['Connected', 'var(--success)'],
53
+ reconnecting: ['Reconnecting…', 'var(--warning)'],
54
+ disconnected: ['Disconnected', 'var(--error)'],
55
+ }
56
+ const [text, color] = map[state] || map.disconnected
57
+ el.textContent = text
58
+ el.style.setProperty('--status-color', color)
59
+ }
60
+
61
+ // Self-styled so it works on framed and full-document screens alike.
62
+ function showTombstone() {
63
+ if (tombstoneShown) return
64
+ tombstoneShown = true
65
+ const el = document.createElement('div')
66
+ el.id = 'bs-tombstone'
67
+ el.style.cssText =
68
+ 'position:fixed;inset:0;z-index:99999;display:flex;' +
69
+ 'align-items:center;justify-content:center;padding:2rem;text-align:center;' +
70
+ 'background:rgba(20,20,22,0.92);color:#f5f5f7;font-family:system-ui,sans-serif'
71
+ el.innerHTML =
72
+ '<div style="max-width:480px">' +
73
+ '<h2 style="margin:0 0 .5rem;font-weight:600">Companion paused</h2>' +
74
+ '<p style="margin:0;opacity:.85">This brainstorm companion has stopped. ' +
75
+ 'Ask your coding agent to bring it back — this page reconnects automatically.</p></div>'
76
+ if (document.body) document.body.appendChild(el)
77
+ }
78
+
79
+ function connect() {
80
+ if (reconnectTimer) {
81
+ clearTimeout(reconnectTimer)
82
+ reconnectTimer = null
83
+ }
84
+ setStatus(everConnected ? 'reconnecting' : 'connecting')
85
+ ws = new WebSocket(websocketUrl())
86
+
87
+ ws.onopen = () => {
88
+ const recovered = tombstoneShown
89
+ everConnected = true
90
+ disconnectedSince = null
91
+ reconnectDelay = MIN_RECONNECT_MS
92
+ tombstoneShown = false
93
+ setStatus('connected')
94
+ eventQueue.forEach((e) => ws.send(JSON.stringify(e)))
95
+ eventQueue = []
96
+ // Recovered from a tombstoned outage (e.g. the server restarted on the same
97
+ // port) — reload through the keyed bootstrap when possible so the cookie is
98
+ // refreshed before the visible URL returns to bare /.
99
+ if (recovered) reloadAfterRecovery()
100
+ }
101
+
102
+ ws.onmessage = (msg) => {
103
+ let data
104
+ try {
105
+ data = JSON.parse(msg.data)
106
+ } catch (e) {
107
+ return
108
+ }
109
+ if (data.type === 'reload') window.location.reload()
110
+ }
111
+
112
+ ws.onclose = () => {
113
+ ws = null
114
+ if (disconnectedSince === null) disconnectedSince = Date.now()
115
+ if (Date.now() - disconnectedSince >= TOMBSTONE_AFTER_MS) {
116
+ setStatus('disconnected')
117
+ showTombstone()
118
+ } else {
119
+ setStatus('reconnecting')
120
+ }
121
+ reconnectTimer = setTimeout(connect, reconnectDelay)
122
+ reconnectDelay = nextReconnectDelay(reconnectDelay, MAX_RECONNECT_MS)
123
+ }
124
+
125
+ // Let onclose own reconnection so we don't schedule it twice.
126
+ ws.onerror = () => {
127
+ try {
128
+ ws.close()
129
+ } catch (e) {}
130
+ }
131
+ }
132
+
133
+ function sendEvent(event) {
134
+ event.timestamp = Date.now()
135
+ if (ws && ws.readyState === WebSocket.OPEN) {
136
+ ws.send(JSON.stringify(event))
137
+ } else {
138
+ eventQueue.push(event)
139
+ }
140
+ }
141
+
142
+ // Capture clicks on choice elements
143
+ document.addEventListener('click', (e) => {
144
+ const target = e.target.closest('[data-choice]')
145
+ if (!target) return
146
+
147
+ sendEvent({
148
+ type: 'click',
149
+ text: target.textContent.trim(),
150
+ choice: target.dataset.choice,
151
+ id: target.id || null,
152
+ })
153
+ })
154
+
155
+ // Frame UI: selection tracking
156
+ window.selectedChoice = null
157
+
158
+ window.toggleSelect = function (el) {
159
+ const container = el.closest('.options') || el.closest('.cards')
160
+ const multi = container && container.dataset.multiselect !== undefined
161
+ if (container && !multi) {
162
+ container.querySelectorAll('.option, .card').forEach((o) => o.classList.remove('selected'))
163
+ }
164
+ if (multi) {
165
+ el.classList.toggle('selected')
166
+ } else {
167
+ el.classList.add('selected')
168
+ }
169
+ window.selectedChoice = el.dataset.choice
170
+ }
171
+
172
+ // Expose API for explicit use
173
+ window.brainstorm = {
174
+ send: sendEvent,
175
+ choice: (value, metadata = {}) => sendEvent({ type: 'choice', value, ...metadata }),
176
+ }
177
+
178
+ connect()
179
+ })()