jackherd 1.1.0 → 1.2.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/CHANGELOG.md +8 -0
- package/README.md +8 -3
- package/herdr-plugin/herdr-plugin.toml +1 -1
- package/install.sh +1 -1
- package/kit/workflow/skills/orchestrate/SKILL.md +2 -1
- package/package.json +1 -1
- package/src/sync/if-changed.ts +18 -8
- package/src/sync/settings-migration.ts +45 -3
- package/src/sync/settings-offer.ts +8 -2
- package/src/watch/command.ts +7 -1
- package/src/watch/report-questions.ts +16 -2
- package/src/watch/update-available.ts +26 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
What changed for people who use jackherd, newest first.
|
|
4
4
|
|
|
5
|
+
## 1.2.0
|
|
6
|
+
|
|
7
|
+
- **A running session hears about a new release.** The watcher asks npm once a day, on the timestamp of the `SessionStart` hook, and prints `=== update available <old> → <new>` once per version when there is a newer one; with nothing new it prints nothing. The `orchestrate` skill asks you (update now / not now) and runs `jh update` only after a yes.
|
|
8
|
+
- **The hook also runs after `/clear`, `/resume` and compaction.** Its matcher is now `startup|resume|clear|compact`; `jh sync --global` moves a hook that matches `startup` only, exactly as an older install wrote it, and touches no other entry in `~/.claude/settings.json`.
|
|
9
|
+
- **A silent npm is asked again after an hour.** Before, one unanswered question paused the check for a day. Nothing is printed on a failure.
|
|
10
|
+
- **No `questions:` line for an empty section.** A `## Questions` section that only says "Keine." or "None." counts as no question, and the report keeps its full head.
|
|
11
|
+
- **README.** Three badges at the top: npm version, license, dependencies.
|
|
12
|
+
|
|
5
13
|
## 1.1.0
|
|
6
14
|
|
|
7
15
|
- **Questions in a lane's report reach you.** The watcher cut a new report to its first 15 lines, and the questions, which stand at the end, fell away. It now shows a `## Questions` section (also `## Fragen`, any level, any text after the word) whole, wherever it stands, under a `questions: <n>` line, within a budget of 20 lines and 1500 characters (over it, each question keeps the start of its first line and a closing line says how many were left out). A report with such a section gets a shorter head (8 lines, 900 characters: the diff stat and the checks), so the message stays about as long as before. The `orchestrate` skill makes every question a duty in the same wake-up: answered in the lane, or put to you, and a question the lane answered is reported to you in one line.
|
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
<br>
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
|
+
[](https://www.npmjs.com/package/jackherd) [](https://www.npmjs.com/package/jackherd) [](https://www.npmjs.com/package/jackherd?activeTab=dependencies)
|
|
10
|
+
|
|
9
11
|
**Plan. Delegate. Ship.** Your agents do the work. Jack keeps them together.
|
|
10
12
|
|
|
11
13
|
Large tasks outgrow one chat, the context fills up, parallel sessions edit the same files, and
|
|
@@ -260,10 +262,12 @@ A running `plans` view restarts itself with the new code, and a running `watch`
|
|
|
260
262
|
`jh sync --global --if-changed` is meant to run at the start of every session. It syncs `~/.claude` only when the installed package is not the version the global lock was written by, so after `bun add -g jackherd@<version>` the next session brings the skills up to date. Once a day it asks npm for the newest release and, when there is one, prints a single line of this form:
|
|
261
263
|
|
|
262
264
|
```text
|
|
263
|
-
jh 1.
|
|
265
|
+
jh 1.2.0 is on npm, 1.1.0 is installed. Ask the user with AskUserQuestion whether to run `jh update` now (update now / not now), and run it only after a yes.
|
|
264
266
|
```
|
|
265
267
|
|
|
266
|
-
It never installs anything itself: the session asks you, and `jh update` runs only after your yes. With nothing to do it prints nothing and exits 0; without a global install it syncs nothing. The time of the last npm question is kept in `~/.jackherd/update-check.json`.
|
|
268
|
+
It never installs anything itself: the session asks you, and `jh update` runs only after your yes. With nothing to do it prints nothing and exits 0; without a global install it syncs nothing. The time of the last npm question is kept in `~/.jackherd/update-check.json`. If npm does not answer (3 seconds), the question is asked again after an hour, not after a day, and nothing is printed meanwhile.
|
|
269
|
+
|
|
270
|
+
The hook runs when a session starts, resumes, is cleared or is compacted (`startup|resume|clear|compact`), so a hand-over by `/clear` sees the line too; the daily timestamp makes the extra runs free. A session that runs for days is covered by [the watcher](#user-content-the-watcher), which looks at npm once a day on the same timestamp. `jh sync --global` moves a hook that still reads `startup` only, exactly as an older install wrote it, to the new matcher; a hook of your own, or one with another command or extra keys, stays as it is.
|
|
267
271
|
|
|
268
272
|
`init --global` asks once whether to add this hook to `~/.claude/settings.json`, appends it as a group of its own beside your other hooks, and does nothing when it is there already. A file it cannot read or merge into, or a symlink, stays as it is; the entry to add by hand:
|
|
269
273
|
|
|
@@ -271,7 +275,7 @@ It never installs anything itself: the session asks you, and `jh update` runs on
|
|
|
271
275
|
{
|
|
272
276
|
"hooks": {
|
|
273
277
|
"SessionStart": [
|
|
274
|
-
{ "matcher": "startup", "hooks": [{ "type": "command", "command": "jh sync --global --if-changed" }] }
|
|
278
|
+
{ "matcher": "startup|resume|clear|compact", "hooks": [{ "type": "command", "command": "jh sync --global --if-changed" }] }
|
|
275
279
|
]
|
|
276
280
|
}
|
|
277
281
|
}
|
|
@@ -528,6 +532,7 @@ Why it exists: the coordinator is a chat, and it only acts when something arrive
|
|
|
528
532
|
- a deploy preview for a lane's new head commit, with its link (`watch.previews`)
|
|
529
533
|
- a new or changed entry of an external service, such as a ticket comment, read by a command the config names (`watch.sources`)
|
|
530
534
|
- `gh` became unreachable
|
|
535
|
+
- npm has a newer jackherd than the one running: `=== update available <old> → <new>`, one line, once per version. The watcher asks npm once a day on the timestamp the `SessionStart` hook uses (`~/.jackherd/update-check.json`), so the two never ask twice a day or report twice; with nothing newer it prints nothing. The coordinator asks you and runs `jh update` only after your yes
|
|
531
536
|
- a lane's context fill rose to `warn` or `alert` (`=== lane <name> alert 47 %`, with a duty line at `alert`: request the lane's hand-over at its next phase boundary), against the lanes' thresholds in `plans.context`
|
|
532
537
|
- the coordinator's own context fill rose to `warn` or `alert`, so it hands itself over in time
|
|
533
538
|
- `lane added` / `lane removed` when a worktree with an agent or a board row appears or goes
|
package/install.sh
CHANGED
|
@@ -9,7 +9,7 @@ set -eu
|
|
|
9
9
|
|
|
10
10
|
# The default is the version this file ships with. The release bump changes it together with
|
|
11
11
|
# package.json; install.test.ts fails while the two differ. Overridable, but only by a plain release.
|
|
12
|
-
JACKHERD_VERSION="${JACKHERD_VERSION:-1.
|
|
12
|
+
JACKHERD_VERSION="${JACKHERD_VERSION:-1.2.0}"
|
|
13
13
|
|
|
14
14
|
JACKHERD_PACKAGE='jackherd'
|
|
15
15
|
# Test seam: the terminal the wizard asks its questions on.
|
|
@@ -277,7 +277,7 @@ not fire), when a lane's PR merges, its checks turn red or green, the same for o
|
|
|
277
277
|
PRs on a branch no lane has (`=== checks failed #<n> (branch <name>)`, found by `--author @me`: a
|
|
278
278
|
documentation or `chore` PR you opened yourself; act on it like on a lane's, a merge makes every
|
|
279
279
|
lane rebase), a deploy run ends (after such a merge `(push, #<n>)`), the
|
|
280
|
-
heartbeat falls due, `gh` becomes unreachable, the installed kit changes version (`=== kit updated <old> → <new>`, then the watcher ends), or your own fill rises to `warn` or `alert`
|
|
280
|
+
heartbeat falls due, `gh` becomes unreachable, the installed kit changes version (`=== kit updated <old> → <new>`, then the watcher ends), npm names a newer release (`=== update available <old> → <new>`, once a day at most and once per version), or your own fill rises to `warn` or `alert`
|
|
281
281
|
(`=== coordinator <level> <share>`). Every report prints the event blocks, then `status:` with one
|
|
282
282
|
line per lane: its status, its branch, its PR with checks, and its open phase with the starts-after
|
|
283
283
|
entry (or that the plan is finished, or that there is no plan). One more line holds your own fill,
|
|
@@ -370,6 +370,7 @@ On wake-up:
|
|
|
370
370
|
| `lane added: <name>` | Nothing: the lane is watched. Check that it has its row (§ 2 step 5) |
|
|
371
371
|
| `lane removed: <name>` | Nothing after you closed it (§ 7). Otherwise its agent exited or its worktree is gone: read why, then tell the user |
|
|
372
372
|
| `kit updated <old> → <new>` | The kit was updated under the running watcher, which ended. After the `jh update` call has finished, read the change of this skill the next line names (`orchestrate skill: § … changed · diff <path>`; the diff shows the kit's placeholders, not your values), so the new text is the one you follow; read this skill file again (`Read` on the file you were given, no session restart) only when the line says `diff unavailable`; `orchestrate skill unchanged` needs no reading. Then start the stream again |
|
|
373
|
+
| `update available <old> → <new>` | A newer jackherd is on npm. Ask the user with `AskUserQuestion` (update now / not now) and run `jh update` only after a yes; the watcher then ends with `kit updated`, handle it as that row and start the stream again. After a no, nothing: the watcher does not mention this version again |
|
|
373
374
|
| monitor expired | Start the stream again |
|
|
374
375
|
| `superseded by <pid>` / `stopped by SIGTERM` | Nothing for `superseded`: it is no event, the newer watcher runs. After `stopped by SIGTERM` from outside, start it again |
|
|
375
376
|
| `watcher stopped: <reason>` | Tell the user, fix the cause (an unreadable state file, say), then start it again |
|
package/package.json
CHANGED
package/src/sync/if-changed.ts
CHANGED
|
@@ -15,6 +15,9 @@ export type UpdateCheck = { now: () => number; latestVersion: () => Promise<stri
|
|
|
15
15
|
|
|
16
16
|
export const UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000
|
|
17
17
|
|
|
18
|
+
/** How soon npm is asked again after it gave no answer: an hour, so an offline morning does not cost the day. */
|
|
19
|
+
export const UPDATE_RETRY_INTERVAL_MS = 60 * 60 * 1000
|
|
20
|
+
|
|
18
21
|
const REGISTRY_LATEST = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`
|
|
19
22
|
const REGISTRY_TIMEOUT_MS = 3_000
|
|
20
23
|
const UPDATE_STATE_FILE = 'update-check.json'
|
|
@@ -78,22 +81,29 @@ const stampUpdateCheck = async (home: string, now: number): Promise<boolean> =>
|
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
|
|
84
|
+
/** The stamp that makes the check due again after `UPDATE_RETRY_INTERVAL_MS`, as if npm had been asked that long ago. */
|
|
85
|
+
const retryStampFor = (now: number): number => now - UPDATE_CHECK_INTERVAL_MS + UPDATE_RETRY_INTERVAL_MS
|
|
86
|
+
|
|
81
87
|
/**
|
|
82
|
-
* The
|
|
83
|
-
*
|
|
88
|
+
* The newest version npm names, when the daily check is due; null when it is not due or npm gave no answer. The
|
|
89
|
+
* check is stamped before npm is asked, so sessions starting together ask once. An unanswered question is
|
|
90
|
+
* restamped as if it had been asked `UPDATE_RETRY_INTERVAL_MS` before it is due again: the state file keeps its
|
|
91
|
+
* one field, and the hook and the watcher share it.
|
|
84
92
|
*/
|
|
85
|
-
export const
|
|
86
|
-
home: string,
|
|
87
|
-
installed: string,
|
|
88
|
-
check: UpdateCheck,
|
|
89
|
-
): Promise<string | null> => {
|
|
93
|
+
export const latestVersionIfDue = async (home: string, check: UpdateCheck): Promise<string | null> => {
|
|
90
94
|
const path = join(home, TOOL_DIRECTORY, UPDATE_STATE_FILE)
|
|
91
95
|
const now = check.now()
|
|
92
96
|
if (!updateCheckDue(await readUpdateState(path), now)) return null
|
|
93
97
|
if (!(await stampUpdateCheck(home, now))) return null
|
|
94
|
-
|
|
98
|
+
const latest = await check.latestVersion()
|
|
99
|
+
if (latest === null) await stampUpdateCheck(home, retryStampFor(now))
|
|
100
|
+
return latest
|
|
95
101
|
}
|
|
96
102
|
|
|
103
|
+
/** The update line, when the daily check is due and npm has a newer release. */
|
|
104
|
+
export const dailyUpdateNotice = async (home: string, installed: string, check: UpdateCheck): Promise<string | null> =>
|
|
105
|
+
updateNotice(await latestVersionIfDue(home, check), installed)
|
|
106
|
+
|
|
97
107
|
/** Asks the npm registry for the `latest` tag; null on any failure, after a few seconds at most. */
|
|
98
108
|
const registryLatestVersion = async (): Promise<string | null> => {
|
|
99
109
|
try {
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
isObject,
|
|
8
8
|
readSettingsOffer,
|
|
9
9
|
SESSION_HOOK_COMMAND,
|
|
10
|
+
SESSION_HOOK_MATCHER,
|
|
11
|
+
SESSION_START,
|
|
10
12
|
type SettingsObject,
|
|
11
13
|
type SettingsOffer,
|
|
12
14
|
} from './settings-offer'
|
|
@@ -41,7 +43,7 @@ const migrateGroup = (group: unknown): unknown =>
|
|
|
41
43
|
|
|
42
44
|
const sessionStartOf = (settings: SettingsObject): unknown[] | null => {
|
|
43
45
|
const hooks = settings.hooks
|
|
44
|
-
return isObject(hooks) && Array.isArray(hooks
|
|
46
|
+
return isObject(hooks) && Array.isArray(hooks[SESSION_START]) ? hooks[SESSION_START] : null
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
/** Our `SessionStart` hook as the old CLI ran it becomes the `jh` command; every other event, group and handler stays. */
|
|
@@ -53,7 +55,42 @@ export const LEGACY_HOOK_MIGRATION: SettingsOffer = {
|
|
|
53
55
|
if (JSON.stringify(migrated) === JSON.stringify(groups)) return { kind: 'present' }
|
|
54
56
|
return {
|
|
55
57
|
kind: 'add',
|
|
56
|
-
next: { ...settings, hooks: { ...(settings.hooks as SettingsObject),
|
|
58
|
+
next: { ...settings, hooks: { ...(settings.hooks as SettingsObject), [SESSION_START]: migrated } },
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The matcher older installs wrote: the hook ran at `startup` only, so a `/clear` handover never saw its line. */
|
|
64
|
+
export const LEGACY_SESSION_HOOK_MATCHER = 'startup'
|
|
65
|
+
|
|
66
|
+
const sameKeys = (value: SettingsObject, keys: readonly string[]): boolean =>
|
|
67
|
+
Object.keys(value).sort().join() === [...keys].sort().join()
|
|
68
|
+
|
|
69
|
+
/** Exactly the group an older install wrote: the `startup` matcher and our one handler, nothing else on either. */
|
|
70
|
+
const isLegacyMatcherGroup = (group: unknown): boolean => {
|
|
71
|
+
if (!isObject(group) || !sameKeys(group, ['matcher', 'hooks'])) return false
|
|
72
|
+
if (group.matcher !== LEGACY_SESSION_HOOK_MATCHER || !Array.isArray(group.hooks) || group.hooks.length !== 1)
|
|
73
|
+
return false
|
|
74
|
+
const [handler] = group.hooks
|
|
75
|
+
return (
|
|
76
|
+
isObject(handler) &&
|
|
77
|
+
sameKeys(handler, ['type', 'command']) &&
|
|
78
|
+
handler.type === 'command' &&
|
|
79
|
+
handler.command === SESSION_HOOK_COMMAND
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Our `SessionStart` hook written for `startup` only also runs after `resume`, `clear` and `compact`; any other group stays. */
|
|
84
|
+
export const SESSION_MATCHER_MIGRATION: SettingsOffer = {
|
|
85
|
+
find: (settings) => {
|
|
86
|
+
const groups = sessionStartOf(settings)
|
|
87
|
+
if (!groups?.some(isLegacyMatcherGroup)) return { kind: 'present' }
|
|
88
|
+
const widened = groups.map((group) =>
|
|
89
|
+
isLegacyMatcherGroup(group) ? { ...(group as SettingsObject), matcher: SESSION_HOOK_MATCHER } : group,
|
|
90
|
+
)
|
|
91
|
+
return {
|
|
92
|
+
kind: 'add',
|
|
93
|
+
next: { ...settings, hooks: { ...(settings.hooks as SettingsObject), [SESSION_START]: widened } },
|
|
57
94
|
}
|
|
58
95
|
},
|
|
59
96
|
}
|
|
@@ -90,5 +127,10 @@ export const migrateGlobalSettings = async (home: string, cliOnPath: boolean): P
|
|
|
90
127
|
`Changed the SessionStart hook in ${SHOWN_SETTINGS} to \`${SESSION_HOOK_COMMAND}\`.`,
|
|
91
128
|
)
|
|
92
129
|
: HOOK_WAITS
|
|
93
|
-
|
|
130
|
+
const matcher = await migrate(
|
|
131
|
+
path,
|
|
132
|
+
SESSION_MATCHER_MIGRATION,
|
|
133
|
+
`Widened the SessionStart hook in ${SHOWN_SETTINGS} to startup, resume, clear and compact.`,
|
|
134
|
+
)
|
|
135
|
+
return [statusLine, hook, matcher].filter((line): line is string => line !== null)
|
|
94
136
|
}
|
|
@@ -29,9 +29,15 @@ export type SettingsWrite = { kind: 'written' } | { kind: 'notWritten'; reason:
|
|
|
29
29
|
/** What the `SessionStart` hook runs: a global sync only when the installed kit changed. */
|
|
30
30
|
export const SESSION_HOOK_COMMAND = `${CLI_NAME} sync --global --if-changed`
|
|
31
31
|
|
|
32
|
-
const SESSION_START = 'SessionStart'
|
|
32
|
+
export const SESSION_START = 'SessionStart'
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
/** Every way a session starts; the daily timestamp makes the extra runs free. */
|
|
35
|
+
export const SESSION_HOOK_MATCHER = 'startup|resume|clear|compact'
|
|
36
|
+
|
|
37
|
+
const SESSION_HOOK_GROUP = {
|
|
38
|
+
matcher: SESSION_HOOK_MATCHER,
|
|
39
|
+
hooks: [{ type: 'command', command: SESSION_HOOK_COMMAND }],
|
|
40
|
+
}
|
|
35
41
|
|
|
36
42
|
/** Claude Code creates `settings.json` world-readable; an existing file keeps its own mode. */
|
|
37
43
|
const NEW_FILE_MODE = 0o644
|
package/src/watch/command.ts
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* with `watch.sources`), a gh outage, a lane's or the coordinator's own context fill rising to warn or alert, or the
|
|
7
7
|
* heartbeat. A blocked lane adds one duty line, a merge one per lane, a lane at alert one, and every report ends with one status line
|
|
8
8
|
* per lane and one for the coordinator, in the words of `responseLanguage`. When the installed kit changes version
|
|
9
|
-
* it prints `=== kit updated <old> → <new>` and ends
|
|
9
|
+
* it prints `=== kit updated <old> → <new>` and ends; once a day it asks npm and prints `=== update available <old> → <new>`
|
|
10
|
+
* for a newer release, once per version. The coordinator is the agent in the
|
|
10
11
|
* watcher's own herdr pane unless `--coordinator` names it, else `orchestrator-<repository>`. A new start replaces a running watcher of the same
|
|
11
12
|
* repository; one in another repository keeps running.
|
|
12
13
|
*
|
|
@@ -26,6 +27,7 @@
|
|
|
26
27
|
* jh watch source <name|draft.json|-> --dry-run
|
|
27
28
|
*/
|
|
28
29
|
import { readFileSync } from 'node:fs'
|
|
30
|
+
import { homedir } from 'node:os'
|
|
29
31
|
import { basename, dirname, join, relative } from 'node:path'
|
|
30
32
|
import { readResolvedConfig } from '../config/read-config'
|
|
31
33
|
import type { JackherdConfig } from '../config/schema'
|
|
@@ -42,6 +44,7 @@ import { mainCheckout, worktreeNames, worktreeRoot } from '../plans/git'
|
|
|
42
44
|
import { discoverLanes, isUnchanged, laneSetChange, laneSetLines } from '../plans/lane-discovery'
|
|
43
45
|
import { clockLocaleOf, type PlansSettings, plansSettingsOf, worktreeOf } from '../plans/settings'
|
|
44
46
|
import { boardTexts } from '../plans/texts'
|
|
47
|
+
import { defaultUpdateCheck } from '../sync/if-changed'
|
|
45
48
|
import { herdrLaneStatusSource } from '../terminal/herdr'
|
|
46
49
|
import { startedKit } from '../version/started-kit'
|
|
47
50
|
import {
|
|
@@ -135,6 +138,7 @@ import {
|
|
|
135
138
|
} from './sources'
|
|
136
139
|
import { streamHeartbeatLine } from './stream-output'
|
|
137
140
|
import { WATCH_TEXTS, type WatchTexts } from './texts'
|
|
141
|
+
import { updateAnnouncer } from './update-available'
|
|
138
142
|
import {
|
|
139
143
|
coordinatorWatchEvent,
|
|
140
144
|
deployEvents,
|
|
@@ -846,9 +850,11 @@ const watchLanes = async (watch: Watch) => {
|
|
|
846
850
|
const kit = await startedKit()
|
|
847
851
|
const skillSnapshot = kit ? readOrchestrateSkill(kit.packageRoot) : null
|
|
848
852
|
const skillLine = () => skillLineFor(kit, skillSnapshot, dirname(watch.files.state))
|
|
853
|
+
const announceUpdate = kit ? updateAnnouncer(homedir(), kit.version, defaultUpdateCheck(), console.log) : null
|
|
849
854
|
while (await pollOnce(watch, watching)) {
|
|
850
855
|
await Bun.sleep(POLL_MS)
|
|
851
856
|
pollLanes(watch, watching)
|
|
857
|
+
await announceUpdate?.()
|
|
852
858
|
if (endedByKitUpdate(kit, { saveState: () => saveState(watch, watching), log: console.log, skillLine })) return
|
|
853
859
|
}
|
|
854
860
|
}
|
|
@@ -7,6 +7,9 @@ const ANY_HEADING = /^(#{1,6})\s/
|
|
|
7
7
|
const CODE_FENCE = /^\s*(```|~~~)/
|
|
8
8
|
const LIST_ITEM = /^(?:\d+[.)]|[-*])\s/
|
|
9
9
|
const CONTINUATION_LINE = /^\s/
|
|
10
|
+
const LIST_MARKER = /^(?:\d+[.)]|[-*])\s*/
|
|
11
|
+
/** What a section writes when it has nothing to ask: "Keine.", "None.", "Keine offenen Fragen.", a dash. */
|
|
12
|
+
const NO_QUESTIONS = /^(?:(?:keine|none|no|nein)(?:\s+(?:offenen\s+)?(?:fragen?|questions?))?\.?|n\/a|[—–])$/i
|
|
10
13
|
|
|
11
14
|
/** What the questions part of a message may take: whole up to these limits, else cut question by question. */
|
|
12
15
|
const QUESTION_LINES = 20
|
|
@@ -24,13 +27,24 @@ const headings = (lines: readonly string[]): { index: number; level: number; isQ
|
|
|
24
27
|
})
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
/**
|
|
30
|
+
/** True when every line of the body, ignoring blank lines, a list marker and bold, says there is nothing to ask. */
|
|
31
|
+
const asksNothing = (body: readonly string[]): boolean =>
|
|
32
|
+
body
|
|
33
|
+
.map((line) => line.trim().replace(LIST_MARKER, '').replaceAll('**', '').trim())
|
|
34
|
+
.filter((text) => text !== '')
|
|
35
|
+
.every((text) => NO_QUESTIONS.test(text))
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The questions sections of a report, in order: from the heading to the next heading of the same or a higher level.
|
|
39
|
+
* A section that is empty or only says "Keine." / "None." asks nothing and is left out.
|
|
40
|
+
*/
|
|
28
41
|
export const questionSections = (lines: readonly string[]): QuestionSection[] => {
|
|
29
42
|
const all = headings(lines)
|
|
30
43
|
return all.flatMap((heading, position) => {
|
|
31
44
|
if (!heading.isQuestion) return []
|
|
32
45
|
const next = all.slice(position + 1).find((other) => other.level <= heading.level)
|
|
33
|
-
|
|
46
|
+
const end = next?.index ?? lines.length
|
|
47
|
+
return asksNothing(lines.slice(heading.index + 1, end)) ? [] : [{ start: heading.index, end }]
|
|
34
48
|
})
|
|
35
49
|
}
|
|
36
50
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { latestVersionIfDue, type UpdateCheck } from '../sync/if-changed'
|
|
2
|
+
import { isNewerVersion } from '../version/release'
|
|
3
|
+
|
|
4
|
+
/** The one line that wakes the coordinator when npm has a newer release; the orchestrate skill asks the user. */
|
|
5
|
+
export const updateAvailableLine = (installed: string, latest: string): string =>
|
|
6
|
+
`=== update available ${installed} → ${latest}`
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The watcher's daily look at npm, on the hook's timestamp and check, so a day holds one registry question across
|
|
10
|
+
* both. Prints a line only for a newer plain release it has not announced yet; otherwise nothing, so a quiet
|
|
11
|
+
* day costs no tokens. Call it on every poll: the timestamp decides whether npm is asked at all.
|
|
12
|
+
*/
|
|
13
|
+
export const updateAnnouncer = (
|
|
14
|
+
home: string,
|
|
15
|
+
installed: string,
|
|
16
|
+
check: UpdateCheck,
|
|
17
|
+
log: (line: string) => void,
|
|
18
|
+
): (() => Promise<void>) => {
|
|
19
|
+
let announced: string | null = null
|
|
20
|
+
return async () => {
|
|
21
|
+
const latest = await latestVersionIfDue(home, check)
|
|
22
|
+
if (latest === null || latest === announced || !isNewerVersion(latest, installed)) return
|
|
23
|
+
announced = latest
|
|
24
|
+
log(updateAvailableLine(installed, latest))
|
|
25
|
+
}
|
|
26
|
+
}
|