@bigmistqke/workpad 0.18.0 → 0.19.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.
- package/bin/workpad.ts +238 -17
- package/dist/bin/workpad.js +191 -13
- package/dist/plugins/badge/README.md +59 -10
- package/dist/plugins/badge/index.js +130 -8
- package/dist/plugins/badge/public/style.css +132 -12
- package/dist/plugins/chat/index.js +7 -1
- package/dist/plugins/claude/README.md +13 -5
- package/dist/plugins/claude/channel.js +25 -2
- package/dist/plugins/claude/doctor.js +43 -47
- package/dist/plugins/claude/index.js +24 -8
- package/dist/plugins/claude/session.js +46 -1
- package/dist/plugins/opencode/channel.js +42 -7
- package/dist/plugins/opencode/index.js +2 -0
- package/dist/src/agents.js +7 -2
- package/dist/src/client/page/main.js +23 -0
- package/dist/src/events.js +6 -5
- package/dist/src/help.js +18 -4
- package/dist/src/hub.js +62 -2
- package/dist/src/listen.js +36 -4
- package/dist/src/listeners.js +14 -4
- package/dist/src/pages/board.js +9 -4
- package/dist/src/pages/index.js +2 -4
- package/dist/src/pages/markdown.js +47 -16
- package/dist/src/pages/render.js +128 -32
- package/dist/src/server.js +69 -6
- package/dist/src/state.js +2 -1
- package/dist/src/status.js +11 -2
- package/dist/src/turns.js +41 -0
- package/package.json +6 -1
- package/plugins/badge/README.md +59 -10
- package/plugins/badge/index.ts +141 -8
- package/plugins/badge/public/style.css +132 -12
- package/plugins/chat/index.ts +9 -1
- package/plugins/claude/README.md +13 -5
- package/plugins/claude/channel.ts +26 -2
- package/plugins/claude/doctor.ts +58 -39
- package/plugins/claude/index.ts +30 -8
- package/plugins/claude/session.ts +32 -0
- package/plugins/opencode/channel.ts +42 -7
- package/plugins/opencode/index.ts +4 -0
- package/skills/workpad/SKILL.md +30 -6
- package/src/agents.ts +9 -1
- package/src/client/page/board.ts +29 -0
- package/src/define.ts +28 -1
- package/src/events.ts +23 -2
- package/src/help.ts +18 -4
- package/src/hub.ts +80 -2
- package/src/listen.ts +47 -4
- package/src/listeners.ts +22 -1
- package/src/pages/board.ts +10 -3
- package/src/pages/index.ts +8 -10
- package/src/pages/markdown.ts +55 -8
- package/src/pages/render.ts +132 -35
- package/src/server.ts +84 -6
- package/src/state.ts +3 -0
- package/src/status.ts +15 -1
- package/src/turns.ts +56 -0
package/plugins/badge/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
A status as a
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
`blocked no bad error` red; any other word is grey.
|
|
1
|
+
A status as a word, small and inline wherever text goes: in a heading, a
|
|
2
|
+
table cell, a list item, a sentence. A grey dot before it, unless it says
|
|
3
|
+
otherwise.
|
|
5
4
|
|
|
6
5
|
```markdown
|
|
7
6
|
### Parser :badge[done]
|
|
@@ -15,12 +14,6 @@ green, `active new info` blue, `open todo maybe warning` amber,
|
|
|
15
14
|
The release is :badge[blocked] on review.
|
|
16
15
|
```
|
|
17
16
|
|
|
18
|
-
A badge that ends a heading sits at its right edge: a page's heading, a grid
|
|
19
|
-
card's, a timeline step's. A block of your own can have the same for a title
|
|
20
|
-
that isn't a heading, with a `data-wp-title` attribute on it. A badge is not
|
|
21
|
-
in a heading's anchor, nor in an item's: `### Parser :badge[done]` is
|
|
22
|
-
`#parser`, so a link to it holds while the badge changes.
|
|
23
|
-
|
|
24
17
|
### Parser :badge[done]
|
|
25
18
|
|
|
26
19
|
| step | state |
|
|
@@ -30,3 +23,59 @@ in a heading's anchor, nor in an item's: `### Parser :badge[done]` is
|
|
|
30
23
|
| docs | :badge[todo] |
|
|
31
24
|
|
|
32
25
|
The release is :badge[blocked] on review.
|
|
26
|
+
|
|
27
|
+
Its look, each attribute off unless set, each colour a name from the
|
|
28
|
+
palette `red orange yellow green blue violet pink grey` (tuned per theme, so
|
|
29
|
+
the text reads on the page and on a fill):
|
|
30
|
+
|
|
31
|
+
- `color`: the dot and the text.
|
|
32
|
+
- `background`: a fill behind them; the text takes the palette's readable
|
|
33
|
+
shade for it, so `{background=red}` alone is a red pill.
|
|
34
|
+
- `border`: an outline.
|
|
35
|
+
- `live`: the dot pulses (still for a reader who asks for less motion).
|
|
36
|
+
|
|
37
|
+
A fill or an outline stands without the dot, unless it is `live`.
|
|
38
|
+
|
|
39
|
+
```markdown
|
|
40
|
+
:badge[busy]{color=green live} :badge[you]{background=red} :badge[on hold]{color=orange border=orange}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
:badge[busy]{color=green live} :badge[you]{background=red} :badge[on hold]{color=orange border=orange}
|
|
44
|
+
|
|
45
|
+
**Presets** name looks, in the config: a badge whose word is the name takes
|
|
46
|
+
its preset (`:badge[you]`, the word as its text lowercased, other characters
|
|
47
|
+
a `-`), and so does one that names it (`:badge[Jonathan]{preset=person}`). A
|
|
48
|
+
preset sets any of the badge's own attributes, and nothing else.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
// .workpad/config.ts
|
|
52
|
+
import badge from '@bigmistqke/workpad/badge'
|
|
53
|
+
|
|
54
|
+
export default defineConfig({
|
|
55
|
+
plugins: [
|
|
56
|
+
badge({
|
|
57
|
+
presets: {
|
|
58
|
+
you: { background: 'red' },
|
|
59
|
+
'on hold': { color: 'orange', border: 'orange' },
|
|
60
|
+
busy: { color: 'green', live: true },
|
|
61
|
+
person: { color: 'violet' },
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The built-in words are presets too: `done ok yes good` green,
|
|
69
|
+
`active new info` blue, `open todo maybe warning` orange,
|
|
70
|
+
`blocked no bad error` red. A project's preset of the same word replaces one.
|
|
71
|
+
|
|
72
|
+
Most specific wins, attribute by attribute: the badge's own attributes, then
|
|
73
|
+
its `preset=`, then its word's preset. An unknown colour, preset or attribute
|
|
74
|
+
is listed by `workpad check` and shown above the page; a bad preset stops the
|
|
75
|
+
config from loading, saying which.
|
|
76
|
+
|
|
77
|
+
A badge that ends a heading sits at its right edge: a page's heading, a grid
|
|
78
|
+
card's, a timeline step's. A block of your own can have the same for a title
|
|
79
|
+
that isn't a heading, with a `data-wp-title` attribute on it. A badge is not
|
|
80
|
+
in a heading's anchor, nor in an item's: `### Parser :badge[done]` is
|
|
81
|
+
`#parser`, so a link to it holds while the badge changes.
|
package/plugins/badge/index.ts
CHANGED
|
@@ -4,7 +4,43 @@ import { definePlugin, type Plugin } from '@bigmistqke/workpad'
|
|
|
4
4
|
import { html, raw, type DirectiveContext } from '@bigmistqke/workpad'
|
|
5
5
|
import { builtinPublic } from '../../src/package.ts'
|
|
6
6
|
|
|
7
|
-
/** The
|
|
7
|
+
/** The colours a badge takes, by name; each tuned per theme for readable text (style.css). */
|
|
8
|
+
export const PALETTE = ['red', 'orange', 'yellow', 'green', 'blue', 'violet', 'pink', 'grey'] as const
|
|
9
|
+
export type Colour = (typeof PALETTE)[number]
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* How a badge looks, each part off unless set: `color` the dot and the text, `background` a fill
|
|
13
|
+
* (its text then the palette's readable shade for it), `border` an outline, `live` a pulsing dot.
|
|
14
|
+
* What a badge's attributes say, and what a preset sets.
|
|
15
|
+
*/
|
|
16
|
+
export interface Look {
|
|
17
|
+
color?: Colour
|
|
18
|
+
background?: Colour
|
|
19
|
+
border?: Colour
|
|
20
|
+
live?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface BadgeOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Looks by name: a badge whose word is the name takes it (`:badge[you]`), and so does one that
|
|
26
|
+
* names it (`:badge[Jonathan]{preset=person}`). They replace the built-in words of the same name.
|
|
27
|
+
*/
|
|
28
|
+
presets?: Record<string, Look>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const COLOURED = ['color', 'background', 'border'] as const
|
|
32
|
+
const KEYS = [...COLOURED, 'live']
|
|
33
|
+
const palette = PALETTE.join(', ')
|
|
34
|
+
|
|
35
|
+
/** The built-in words: default presets, which a project's presets replace word by word. */
|
|
36
|
+
export const BUILTIN_PRESETS: Record<string, Look> = Object.fromEntries([
|
|
37
|
+
...['done', 'ok', 'yes', 'good'].map(w => [w, { color: 'green' }]),
|
|
38
|
+
...['active', 'new', 'info'].map(w => [w, { color: 'blue' }]),
|
|
39
|
+
...['open', 'todo', 'maybe', 'warning'].map(w => [w, { color: 'orange' }]),
|
|
40
|
+
...['blocked', 'no', 'bad', 'error'].map(w => [w, { color: 'red' }]),
|
|
41
|
+
])
|
|
42
|
+
|
|
43
|
+
/** The word a badge's preset is found by: its text, lowercased, runs of other characters a `-`. */
|
|
8
44
|
export const tone = (s: string) =>
|
|
9
45
|
s
|
|
10
46
|
.toLowerCase()
|
|
@@ -12,25 +48,122 @@ export const tone = (s: string) =>
|
|
|
12
48
|
.replace(/[^a-z0-9]+/g, '-')
|
|
13
49
|
.replace(/^-|-$/g, '')
|
|
14
50
|
|
|
15
|
-
|
|
16
|
-
|
|
51
|
+
const isColour = (v: unknown): v is Colour => typeof v === 'string' && (PALETTE as readonly string[]).includes(v)
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A config's presets, checked, by their words (tone()), over the built-in words: what is wrong
|
|
55
|
+
* throws, so the config fails to load and says why.
|
|
56
|
+
*/
|
|
57
|
+
export function presetsOf(given: Record<string, Look> = {}): Record<string, Look> {
|
|
58
|
+
if (typeof given !== 'object' || given === null || Array.isArray(given))
|
|
59
|
+
throw new Error('badge: `presets` is an object of looks by name: `{ you: { background: "red" } }`')
|
|
60
|
+
const own: Record<string, Look> = {}
|
|
61
|
+
const named: Record<string, string> = {}
|
|
62
|
+
for (const [name, look] of Object.entries(given)) {
|
|
63
|
+
const word = tone(name)
|
|
64
|
+
const where = `badge: preset "${name}"`
|
|
65
|
+
if (!word) throw new Error(`${where} has no letter or digit: a badge's word couldn't reach it`)
|
|
66
|
+
if (word in named) throw new Error(`${where} is the same word as "${named[word]}" (${word})`)
|
|
67
|
+
named[word] = name
|
|
68
|
+
if (typeof look !== 'object' || look === null || Array.isArray(look))
|
|
69
|
+
throw new Error(`${where} is a look: an object such as \`{ color: 'green' }\``)
|
|
70
|
+
for (const [k, v] of Object.entries(look)) {
|
|
71
|
+
if (!KEYS.includes(k))
|
|
72
|
+
throw new Error(`${where} sets \`${k}\`, which a badge hasn't: a preset sets ${KEYS.join(', ')}`)
|
|
73
|
+
if (k === 'live' ? typeof v !== 'boolean' : !isColour(v))
|
|
74
|
+
throw new Error(
|
|
75
|
+
k === 'live'
|
|
76
|
+
? `${where} has \`live: ${JSON.stringify(v)}\`: it is true or false`
|
|
77
|
+
: `${where} has no colour ${JSON.stringify(v)} for \`${k}\`: the palette is ${palette}`,
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
own[word] = { ...look }
|
|
81
|
+
}
|
|
82
|
+
return { ...BUILTIN_PRESETS, ...own }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The look of a badge of `text` with `attrs`, attribute by attribute the most specific: its own
|
|
87
|
+
* attributes, then the preset it names (`preset=`), then its word's preset (the built-in words
|
|
88
|
+
* among them). A value it doesn't know is reported, and the next one down holds.
|
|
89
|
+
*/
|
|
90
|
+
export function lookOf(
|
|
91
|
+
text: string,
|
|
92
|
+
attrs: Record<string, string>,
|
|
93
|
+
presets: Record<string, Look>,
|
|
94
|
+
report: (problem: string) => void = () => {},
|
|
95
|
+
): Look {
|
|
96
|
+
const written = `\`:badge[${text}]\``
|
|
97
|
+
const own: Look = {}
|
|
98
|
+
for (const k of COLOURED) {
|
|
99
|
+
const v = attrs[k]
|
|
100
|
+
if (v === undefined) continue
|
|
101
|
+
if (isColour(v)) own[k] = v
|
|
102
|
+
else report(`${written} has no colour \`${v}\` for \`${k}\`: the palette is ${palette}`)
|
|
103
|
+
}
|
|
104
|
+
if (attrs.live !== undefined) {
|
|
105
|
+
if (attrs.live === '' || attrs.live === 'true') own.live = true
|
|
106
|
+
else if (attrs.live === 'false') own.live = false
|
|
107
|
+
else report(`${written} has \`live=${attrs.live}\`: it is \`{live}\` or \`{live=false}\``)
|
|
108
|
+
}
|
|
109
|
+
let named: Look = {}
|
|
110
|
+
if (attrs.preset !== undefined) {
|
|
111
|
+
const found = presets[tone(attrs.preset)]
|
|
112
|
+
if (found) named = found
|
|
113
|
+
else
|
|
114
|
+
report(
|
|
115
|
+
`${written} names no preset \`${attrs.preset}\`: there are ${Object.keys(presets)
|
|
116
|
+
.map(p => `\`${p}\``)
|
|
117
|
+
.join(', ')}`,
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
const look: Look = {}
|
|
121
|
+
for (const layer of [presets[tone(text)] ?? {}, named, own])
|
|
122
|
+
for (const [k, v] of Object.entries(layer)) if (v !== undefined) (look as any)[k] = v
|
|
123
|
+
return look
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** `:badge[done]`: a word, with a coloured dot, a fill or an outline, inline wherever text goes. */
|
|
127
|
+
export function render(ctx: DirectiveContext, presets: Record<string, Look> = BUILTIN_PRESETS) {
|
|
17
128
|
const text = ctx.labelText?.trim()
|
|
18
129
|
if (!text) return html``
|
|
19
|
-
|
|
20
|
-
|
|
130
|
+
const look = lookOf(text, ctx.attrs, presets, p => ctx.problem(p))
|
|
131
|
+
// a built-in word's colour is its dot's only, its text stays grey; a colour written on the
|
|
132
|
+
// badge, or by a preset of the project's, colours the text too
|
|
133
|
+
const word = tone(text)
|
|
134
|
+
const builtin =
|
|
135
|
+
presets[word] !== undefined &&
|
|
136
|
+
presets[word] === BUILTIN_PRESETS[word] &&
|
|
137
|
+
ctx.attrs.color === undefined &&
|
|
138
|
+
(ctx.attrs.preset === undefined || presets[tone(ctx.attrs.preset)]?.color === undefined)
|
|
139
|
+
// what it shows, as data-* the stylesheet reads: only what is set
|
|
140
|
+
const shows = html`${COLOURED.map(k => look[k] && html` data-${k}="${look[k]}"`)}${look.live && html` data-live`}${builtin && look.color && html` data-dot`}`
|
|
141
|
+
// the label is HTML already; its plain text picks the preset
|
|
142
|
+
const label = raw(ctx.label ?? '')
|
|
143
|
+
// unformatted: prettier would put a space before ${shows}, which brings its own
|
|
144
|
+
// prettier-ignore
|
|
145
|
+
return html`<span class="wp-badge" data-badge="${tone(text)}"${shows}>${label}</span>`
|
|
21
146
|
}
|
|
22
147
|
|
|
23
|
-
export default function badge(): Plugin {
|
|
148
|
+
export default function badge(options: BadgeOptions = {}): Plugin {
|
|
149
|
+
const presets = presetsOf(options.presets)
|
|
150
|
+
const own = Object.keys(options.presets ?? {})
|
|
24
151
|
return definePlugin({
|
|
25
152
|
name: 'badge',
|
|
26
153
|
public: builtinPublic('badge'),
|
|
27
154
|
blocks: {
|
|
28
155
|
badge: {
|
|
29
156
|
menu: { group: 'mark', summary: 'a status in a word: done, todo, waiting' },
|
|
30
|
-
|
|
157
|
+
attrs: ['color', 'background', 'border', 'live', 'preset'],
|
|
158
|
+
html: ctx => render(ctx as DirectiveContext, presets),
|
|
31
159
|
style: 'style.css',
|
|
32
160
|
},
|
|
33
161
|
},
|
|
34
|
-
docs: () =>
|
|
162
|
+
docs: () => {
|
|
163
|
+
const readme = fs.readFileSync(new URL('./README.md', import.meta.url), 'utf8')
|
|
164
|
+
if (!own.length) return readme
|
|
165
|
+
const list = own.map(name => `- \`${name}\`: ${JSON.stringify(options.presets![name])}`).join('\n')
|
|
166
|
+
return `${readme}\nThis project's presets:\n\n${list}\n`
|
|
167
|
+
},
|
|
35
168
|
})
|
|
36
169
|
}
|
|
@@ -1,30 +1,150 @@
|
|
|
1
|
-
/* a
|
|
1
|
+
/* A word, small, with a dot before it; a colour, a fill, an outline and a pulse when it says so
|
|
2
|
+
(data-color, data-background, data-border, data-live, from its attributes and presets).
|
|
3
|
+
|
|
4
|
+
The palette, per theme: each colour (--wp-badge-<name>) as text and dot at least 4.5:1 on the
|
|
5
|
+
page and the surfaces a badge sits on (cards, tables, code), and as a fill under its readable
|
|
6
|
+
text (--wp-badge-ink) at least 4.5:1 (test/browser/badge.test.ts measures both). A project can
|
|
7
|
+
retune one in its own stylesheet, both themes at once: `--wp-badge-orange: light-dark(#9a4a06, #ffa462)`. */
|
|
8
|
+
:root {
|
|
9
|
+
--wp-badge-red: light-dark(#c4352b, #ff6f66);
|
|
10
|
+
--wp-badge-orange: light-dark(#a84d08, #ff9a4d);
|
|
11
|
+
--wp-badge-yellow: light-dark(#8a6500, #e8c547);
|
|
12
|
+
--wp-badge-green: light-dark(#1a7a49, #57c48c);
|
|
13
|
+
--wp-badge-blue: light-dark(#1d5bbf, #82aaff);
|
|
14
|
+
--wp-badge-violet: light-dark(#6b4fc0, #b4a0ff);
|
|
15
|
+
--wp-badge-pink: light-dark(#be185d, #f78fc0);
|
|
16
|
+
--wp-badge-grey: light-dark(#696e76, #979ca5);
|
|
17
|
+
/* a fill is the colour itself; the text on it this: white on the light theme's dark shades,
|
|
18
|
+
near-black on the dark theme's light ones */
|
|
19
|
+
--wp-badge-ink: light-dark(#ffffff, #131417);
|
|
20
|
+
}
|
|
21
|
+
|
|
2
22
|
.wp-badge {
|
|
3
|
-
--c: var(--muted);
|
|
4
23
|
display: inline-flex;
|
|
5
24
|
align-items: center;
|
|
6
25
|
gap: var(--space-sm);
|
|
7
26
|
font: 500 var(--ui-tiny)/1 var(--sans);
|
|
8
|
-
|
|
27
|
+
/* on a fill, its ink; else the colour; else as text beside the page's */
|
|
28
|
+
color: var(--wp-badge-on, var(--wp-badge-c, var(--muted)));
|
|
29
|
+
background: var(--wp-badge-fill, none);
|
|
9
30
|
white-space: nowrap;
|
|
10
31
|
vertical-align: 0.1em;
|
|
11
32
|
}
|
|
12
33
|
.wp-badge::before {
|
|
13
34
|
content: '';
|
|
35
|
+
flex: none;
|
|
14
36
|
width: 7px;
|
|
15
37
|
height: 7px;
|
|
16
38
|
border-radius: 50%;
|
|
17
|
-
|
|
39
|
+
--wp-badge-dot: var(--wp-badge-c, var(--wp-badge-on, var(--muted)));
|
|
40
|
+
background: var(--wp-badge-dot);
|
|
41
|
+
}
|
|
42
|
+
/* a built-in word (done, todo, …): the colour is its dot's, the text stays grey */
|
|
43
|
+
.wp-badge[data-dot]:not([data-background]) {
|
|
44
|
+
color: var(--muted);
|
|
45
|
+
}
|
|
46
|
+
/* a fill or an outline makes it a pill, which stands without a dot, unless the dot is live */
|
|
47
|
+
.wp-badge:is([data-background], [data-border]) {
|
|
48
|
+
padding: 2px 7px;
|
|
49
|
+
border: var(--hairline) solid var(--wp-badge-line, transparent);
|
|
50
|
+
border-radius: var(--radius-pill);
|
|
51
|
+
}
|
|
52
|
+
.wp-badge:is([data-background], [data-border]):not([data-live])::before {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.wp-badge[data-color='red'] {
|
|
57
|
+
--wp-badge-c: var(--wp-badge-red);
|
|
58
|
+
}
|
|
59
|
+
.wp-badge[data-color='orange'] {
|
|
60
|
+
--wp-badge-c: var(--wp-badge-orange);
|
|
61
|
+
}
|
|
62
|
+
.wp-badge[data-color='yellow'] {
|
|
63
|
+
--wp-badge-c: var(--wp-badge-yellow);
|
|
64
|
+
}
|
|
65
|
+
.wp-badge[data-color='green'] {
|
|
66
|
+
--wp-badge-c: var(--wp-badge-green);
|
|
67
|
+
}
|
|
68
|
+
.wp-badge[data-color='blue'] {
|
|
69
|
+
--wp-badge-c: var(--wp-badge-blue);
|
|
70
|
+
}
|
|
71
|
+
.wp-badge[data-color='violet'] {
|
|
72
|
+
--wp-badge-c: var(--wp-badge-violet);
|
|
73
|
+
}
|
|
74
|
+
.wp-badge[data-color='pink'] {
|
|
75
|
+
--wp-badge-c: var(--wp-badge-pink);
|
|
76
|
+
}
|
|
77
|
+
.wp-badge[data-color='grey'] {
|
|
78
|
+
--wp-badge-c: var(--wp-badge-grey);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.wp-badge[data-background] {
|
|
82
|
+
--wp-badge-on: var(--wp-badge-ink);
|
|
83
|
+
}
|
|
84
|
+
.wp-badge[data-background='red'] {
|
|
85
|
+
--wp-badge-fill: var(--wp-badge-red);
|
|
86
|
+
}
|
|
87
|
+
.wp-badge[data-background='orange'] {
|
|
88
|
+
--wp-badge-fill: var(--wp-badge-orange);
|
|
89
|
+
}
|
|
90
|
+
.wp-badge[data-background='yellow'] {
|
|
91
|
+
--wp-badge-fill: var(--wp-badge-yellow);
|
|
92
|
+
}
|
|
93
|
+
.wp-badge[data-background='green'] {
|
|
94
|
+
--wp-badge-fill: var(--wp-badge-green);
|
|
95
|
+
}
|
|
96
|
+
.wp-badge[data-background='blue'] {
|
|
97
|
+
--wp-badge-fill: var(--wp-badge-blue);
|
|
98
|
+
}
|
|
99
|
+
.wp-badge[data-background='violet'] {
|
|
100
|
+
--wp-badge-fill: var(--wp-badge-violet);
|
|
101
|
+
}
|
|
102
|
+
.wp-badge[data-background='pink'] {
|
|
103
|
+
--wp-badge-fill: var(--wp-badge-pink);
|
|
104
|
+
}
|
|
105
|
+
.wp-badge[data-background='grey'] {
|
|
106
|
+
--wp-badge-fill: var(--wp-badge-grey);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.wp-badge[data-border='red'] {
|
|
110
|
+
--wp-badge-line: var(--wp-badge-red);
|
|
111
|
+
}
|
|
112
|
+
.wp-badge[data-border='orange'] {
|
|
113
|
+
--wp-badge-line: var(--wp-badge-orange);
|
|
114
|
+
}
|
|
115
|
+
.wp-badge[data-border='yellow'] {
|
|
116
|
+
--wp-badge-line: var(--wp-badge-yellow);
|
|
117
|
+
}
|
|
118
|
+
.wp-badge[data-border='green'] {
|
|
119
|
+
--wp-badge-line: var(--wp-badge-green);
|
|
120
|
+
}
|
|
121
|
+
.wp-badge[data-border='blue'] {
|
|
122
|
+
--wp-badge-line: var(--wp-badge-blue);
|
|
123
|
+
}
|
|
124
|
+
.wp-badge[data-border='violet'] {
|
|
125
|
+
--wp-badge-line: var(--wp-badge-violet);
|
|
126
|
+
}
|
|
127
|
+
.wp-badge[data-border='pink'] {
|
|
128
|
+
--wp-badge-line: var(--wp-badge-pink);
|
|
18
129
|
}
|
|
19
|
-
.wp-badge
|
|
20
|
-
--
|
|
130
|
+
.wp-badge[data-border='grey'] {
|
|
131
|
+
--wp-badge-line: var(--wp-badge-grey);
|
|
21
132
|
}
|
|
22
|
-
|
|
23
|
-
|
|
133
|
+
|
|
134
|
+
/* live: the dot pulses, a ring growing out of it and fading; still under reduced motion */
|
|
135
|
+
.wp-badge[data-live]::before {
|
|
136
|
+
animation: wp-badge-pulse 1.6s ease-out infinite;
|
|
24
137
|
}
|
|
25
|
-
|
|
26
|
-
|
|
138
|
+
@keyframes wp-badge-pulse {
|
|
139
|
+
0% {
|
|
140
|
+
box-shadow: 0 0 0 0 color-mix(in srgb, var(--wp-badge-dot) 55%, transparent);
|
|
141
|
+
}
|
|
142
|
+
100% {
|
|
143
|
+
box-shadow: 0 0 0 5px transparent;
|
|
144
|
+
}
|
|
27
145
|
}
|
|
28
|
-
|
|
29
|
-
|
|
146
|
+
@media (prefers-reduced-motion: reduce) {
|
|
147
|
+
.wp-badge[data-live]::before {
|
|
148
|
+
animation: none;
|
|
149
|
+
}
|
|
30
150
|
}
|
package/plugins/chat/index.ts
CHANGED
|
@@ -69,6 +69,14 @@ const chat: Block = {
|
|
|
69
69
|
/** The chat at the bottom of every page (see `end`): for what is about none of its questions. */
|
|
70
70
|
export const PAGE_CHAT = 'page'
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Whether a page's text could name a chat (or a form, whose chat it is) `name`: a `name=` or `id=`
|
|
74
|
+
* of it, or `#name`. Without one it names none, and the page needs no parse to say so: most pages,
|
|
75
|
+
* whose status asks this for every page.
|
|
76
|
+
*/
|
|
77
|
+
const mayName = (body: string, name: string) =>
|
|
78
|
+
new RegExp(`(?:\\bname|\\bid)\\s*=\\s*["']?${name}(?![\\w-])|#${name}(?![\\w-])`).test(body)
|
|
79
|
+
|
|
72
80
|
/** `page: false`: no chat at the bottom of every page. */
|
|
73
81
|
export interface ChatOptions {
|
|
74
82
|
page?: boolean
|
|
@@ -83,7 +91,7 @@ export default function chatPlugin({ page: pageChat = true }: ChatOptions = {}):
|
|
|
83
91
|
end(page) {
|
|
84
92
|
if (!pageChat || page.id.startsWith('-/')) return null
|
|
85
93
|
const own = (page.frontmatter.plugins as Record<string, unknown> | undefined)?.chat
|
|
86
|
-
if (own === false || chatNames(page.body).includes(PAGE_CHAT)) return null
|
|
94
|
+
if (own === false || (mayName(page.body, PAGE_CHAT) && chatNames(page.body).includes(PAGE_CHAT))) return null
|
|
87
95
|
return `:::chat{name=${PAGE_CHAT}}\nQuestions or remarks about this page:\n:::`
|
|
88
96
|
},
|
|
89
97
|
public: builtinPublic('chat'),
|
package/plugins/claude/README.md
CHANGED
|
@@ -97,11 +97,19 @@ command answers; the server approved and disabled in no settings file
|
|
|
97
97
|
(`.claude/settings.json`, `settings.local.json`, `~/.claude/settings.json`,
|
|
98
98
|
the project in `~/.claude.json`, and in a git worktree without its own
|
|
99
99
|
`settings.local.json`, the main checkout's, where Claude Code writes an Esc
|
|
100
|
-
on "New MCP server found"); the session started with the flag above
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
on "New MCP server found"); the session started with the flag above; the
|
|
101
|
+
server up at the project's version; a channel for this session; and its
|
|
102
|
+
ping confirmed. `/mcp` doesn't list a disabled server at all, so this is
|
|
103
|
+
where to look. It changes nothing, and exits 1 when something is to fix.
|
|
104
|
+
|
|
105
|
+
`.mcp.json` and the settings are read where Claude Code runs, which need
|
|
106
|
+
not be the pages' project: a wrapper can start a session in one folder (a
|
|
107
|
+
git worktree) with the pages of another. That folder is
|
|
108
|
+
`CLAUDE_PROJECT_DIR` when set, else the one the session's claude process
|
|
109
|
+
runs in, else the project's. When it differs, the doctor names both
|
|
110
|
+
(`pages: …; Claude's project: …`), and its fixes point at Claude's:
|
|
111
|
+
`workpad claude install --claude-dir <folder>` writes `.mcp.json` and the
|
|
112
|
+
hooks there.
|
|
105
113
|
|
|
106
114
|
## The turn-end check
|
|
107
115
|
|
|
@@ -23,8 +23,8 @@ import fs from 'node:fs'
|
|
|
23
23
|
import path from 'node:path'
|
|
24
24
|
import readline from 'node:readline'
|
|
25
25
|
import type { CommandContext, WpEvent } from '../../src/define.ts'
|
|
26
|
-
import { ANSWERS_NOTE, answerLine, identity, pong } from '../../src/agents.ts'
|
|
27
|
-
import { channelSince, read } from '../../src/events.ts'
|
|
26
|
+
import { ANSWERS_NOTE, answerLine, identity, pong, unfollowedLine } from '../../src/agents.ts'
|
|
27
|
+
import { channelSince, read, takesUnfollowed } from '../../src/events.ts'
|
|
28
28
|
import { claudeProcess, recordedSession } from './session.ts'
|
|
29
29
|
|
|
30
30
|
const INSTRUCTIONS = [
|
|
@@ -82,10 +82,34 @@ export async function channel(ctx: CommandContext) {
|
|
|
82
82
|
|
|
83
83
|
// Each page followed on its own, so another session's answers are never handed out here.
|
|
84
84
|
const followed = new Set<string>()
|
|
85
|
+
// the pages no one follows, when the session took them on (`workpad listen --unfollowed --channel`)
|
|
86
|
+
let unfollowed: { session: string; stop: AbortController } | null = null
|
|
87
|
+
const takeUnfollowed = (session: string) => {
|
|
88
|
+
const wanted = takesUnfollowed(read(ctx.eventsFile).events, session)
|
|
89
|
+
if (unfollowed && (!wanted || unfollowed.session !== session)) {
|
|
90
|
+
unfollowed.stop.abort()
|
|
91
|
+
unfollowed = null
|
|
92
|
+
}
|
|
93
|
+
if (!wanted || unfollowed) return
|
|
94
|
+
unfollowed = { session, stop: new AbortController() }
|
|
95
|
+
void ctx
|
|
96
|
+
.unfollowed(
|
|
97
|
+
(e, again, from) =>
|
|
98
|
+
notify(unfollowedLine(e, again, from), {
|
|
99
|
+
page: e.page,
|
|
100
|
+
id: e.id,
|
|
101
|
+
type: e.type,
|
|
102
|
+
...(from && { project: from.project }),
|
|
103
|
+
}),
|
|
104
|
+
{ agent: session, signal: unfollowed.stop.signal },
|
|
105
|
+
)
|
|
106
|
+
.catch(err => problem('taking the unfollowed pages failed', String(err)))
|
|
107
|
+
}
|
|
85
108
|
const follow = async () => {
|
|
86
109
|
const session = current()
|
|
87
110
|
hold(session)
|
|
88
111
|
if (!confirmed || !session) return
|
|
112
|
+
takeUnfollowed(session)
|
|
89
113
|
const pages = (await ctx.status()).filter(p => p.subscribers.includes(session)).map(p => p.page)
|
|
90
114
|
for (const page of pages) {
|
|
91
115
|
if (followed.has(page)) continue
|