jackherd 1.24.0 → 1.25.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 (68) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +21 -21
  3. package/dist/{chunk-JDO6O3UO.js → chunk-O365KHHP.js} +139 -3
  4. package/dist/config.d.ts +4 -0
  5. package/dist/config.js +4 -1
  6. package/dist/plan-format.d.ts +121 -3
  7. package/dist/plan-format.js +176 -35
  8. package/docs/plan-contract.md +52 -5
  9. package/herdr-plugin/herdr-plugin.toml +1 -1
  10. package/install.sh +1 -1
  11. package/kit/hooks/hooks/approval-gate/index.ts +2 -2
  12. package/kit/hooks/hooks/merge-guard/lane-plan.ts +1 -1
  13. package/kit/hooks/hooks/shared/board-lanes.ts +33 -12
  14. package/kit/hooks/hooks/shared/boards.ts +22 -6
  15. package/kit/workflow/skills/orchestrate/references/herd.md +3 -3
  16. package/kit/workflow/skills/plan/SKILL.md +3 -1
  17. package/kit/workflow/skills/plan/references/template-English.md +2 -0
  18. package/kit/workflow/skills/plan/references/template-German.md +2 -0
  19. package/package.json +1 -1
  20. package/schemas/jackherd.schema.json +7 -0
  21. package/src/brief/command.ts +1 -1
  22. package/src/brief/lane-facts.ts +2 -2
  23. package/src/check/command.ts +2 -1
  24. package/src/check/plan-structure-check.ts +68 -14
  25. package/src/check/settings.ts +6 -1
  26. package/src/check/skill-budget-defaults.ts +6 -3
  27. package/src/config/schema.ts +3 -0
  28. package/src/lane/close-board.ts +4 -4
  29. package/src/lane/close-command.ts +2 -2
  30. package/src/lane/dev-command.ts +1 -1
  31. package/src/lane/port-command.ts +1 -1
  32. package/src/plan-contract/command.ts +2 -1
  33. package/src/plan-contract/contract.ts +30 -9
  34. package/src/plan-format/bare-codes.ts +4 -4
  35. package/src/plan-format/dependencies.ts +5 -5
  36. package/src/plan-format/lanes.ts +3 -4
  37. package/src/plan-format/markdown.ts +125 -10
  38. package/src/plan-format/open-status.ts +15 -0
  39. package/src/plan-format/phases.ts +45 -4
  40. package/src/plan-format/plan-head.ts +31 -9
  41. package/src/plan-format/plan-structure.ts +43 -7
  42. package/src/plan-format/progress.ts +3 -0
  43. package/src/plan-format/sprint-document.ts +4 -4
  44. package/src/plan-format/unrecognized-sections.ts +21 -0
  45. package/src/plan-format/waiting.ts +13 -13
  46. package/src/plans/board-close.ts +25 -16
  47. package/src/plans/board-pick.ts +1 -1
  48. package/src/plans/ensure-panes.ts +2 -2
  49. package/src/plans/layout-summary.ts +8 -1
  50. package/src/plans/layout.ts +14 -5
  51. package/src/plans/live.ts +1 -1
  52. package/src/plans/settings.ts +3 -0
  53. package/src/plans/snapshot.ts +9 -5
  54. package/src/plans/sprint-export.ts +1 -1
  55. package/src/plans/texts.ts +3 -0
  56. package/src/plans/view.ts +1 -0
  57. package/src/resume/coordinator-read.ts +2 -2
  58. package/src/settled/command.ts +1 -1
  59. package/src/settled/settle.ts +5 -5
  60. package/src/sync/render.ts +20 -5
  61. package/src/sync/sync-plan.ts +6 -2
  62. package/src/sync/sync.ts +3 -2
  63. package/src/vocabulary/index.ts +192 -4
  64. package/src/watch/appointments.ts +13 -20
  65. package/src/watch/command.ts +5 -5
  66. package/src/watch/lane-progress.ts +1 -1
  67. package/src/watch/merge-overlap-read.ts +2 -2
  68. package/src/watch/plan-missing-read.ts +3 -1
@@ -0,0 +1,21 @@
1
+ import { isSectionKey, sectionOfHeading } from '../vocabulary'
2
+ import { markedKeyOf, SECTION_HEADING } from './markdown'
3
+
4
+ const isRecognized = (lines: readonly string[], index: number): boolean => {
5
+ const text = SECTION_HEADING.exec(lines[index])?.[1] ?? ''
6
+ const marked = markedKeyOf(lines[index + 1] ?? '')
7
+ return sectionOfHeading(text) !== null || (marked !== null && isSectionKey(marked))
8
+ }
9
+
10
+ /**
11
+ * The 1-based line of the first `##` heading of a board or plan when it has such headings and jh reads none of them,
12
+ * neither by the heading of a known language nor by a marker `<!-- jh: <key> -->` directly under it: a document in a
13
+ * language without vocabulary and without markers, which every reader would take for empty. Null when the document has
14
+ * no `##` heading or reads at least one.
15
+ */
16
+ export const firstUnrecognizedSectionLine = (markdown: string): number | null => {
17
+ const lines = markdown.split('\n')
18
+ const headings = lines.flatMap((line, index) => (SECTION_HEADING.test(line) ? [index] : []))
19
+ if (headings.length === 0 || headings.some((index) => isRecognized(lines, index))) return null
20
+ return headings[0] + 1
21
+ }
@@ -1,5 +1,6 @@
1
- import { type PlanLanguage, WAITING_VOCABULARY } from '../vocabulary'
2
- import { firstTableWithHeader, sectionLines } from './markdown'
1
+ import { COLUMN_KEY, type PlanLanguage, WAITING_VOCABULARY } from '../vocabulary'
2
+ import { columnIndex, firstTableWithHeader, sectionLines } from './markdown'
3
+ import { isOpenStatus } from './open-status'
3
4
  import { terminalSafe } from './terminal-text'
4
5
 
5
6
  /** `file` for a file or an Artifact that was sent, `question` for a dialog that ended unanswered. */
@@ -35,11 +36,9 @@ const namesOf = (cell: string): string[] =>
35
36
  .map((name) => name.replaceAll('`', '').trim())
36
37
  .filter(Boolean)
37
38
 
38
- /** An empty status counts as open: a row nobody closed is not dropped in silence. */
39
- const isOpen = (status: string, language: PlanLanguage): boolean => {
40
- const lower = status.toLowerCase()
41
- return lower === '' || WAITING_VOCABULARY[language].open.some((word) => lower.startsWith(word))
42
- }
39
+ const OPEN_WORDS = Object.values(WAITING_VOCABULARY).flatMap(({ open }) => open)
40
+
41
+ const isOpen = (status: string): boolean => isOpenStatus(status, OPEN_WORDS)
43
42
 
44
43
  /**
45
44
  * The rows of the board's waiting section in `language` (`## Wartet auf dich`, `## Waiting for you`), its columns
@@ -47,14 +46,15 @@ const isOpen = (status: string, language: PlanLanguage): boolean => {
47
46
  * column, a section without a table and a row without an item give nothing.
48
47
  */
49
48
  export const readWaitingItems = (board: string, language: PlanLanguage): WaitingItem[] => {
50
- const { heading, columns, statusAlso } = WAITING_VOCABULARY[language]
49
+ const { heading } = WAITING_VOCABULARY[language]
51
50
  const { header, rows } = firstTableWithHeader(sectionLines(board, heading))
52
- const statusName = [columns.status, ...statusAlso].find((name) => header.includes(name)) ?? columns.status
53
- const positions = [columns.since, columns.item, statusName].map((name) => header.indexOf(name))
51
+ const positions = [COLUMN_KEY.since, COLUMN_KEY.item, COLUMN_KEY.status].map((key) =>
52
+ columnIndex(header, key, language),
53
+ )
54
54
  if (positions.includes(-1)) return []
55
55
  const [since, item, status] = positions
56
- const originPosition = header.indexOf(columns.origin)
57
- const unblocksPosition = header.indexOf(columns.unblocks)
56
+ const originPosition = columnIndex(header, COLUMN_KEY.origin, language)
57
+ const unblocksPosition = columnIndex(header, COLUMN_KEY.unblocks, language)
58
58
  return rows.flatMap((cells) => {
59
59
  const text = oneLine(cells[item] ?? '')
60
60
  const origin = oneLine(cells[originPosition] ?? '')
@@ -65,7 +65,7 @@ export const readWaitingItems = (board: string, language: PlanLanguage): Waiting
65
65
  {
66
66
  since: oneLine(cells[since] ?? ''),
67
67
  item: text,
68
- open: isOpen(cells[status] ?? '', language),
68
+ open: isOpen(cells[status] ?? ''),
69
69
  ...(origin === '' ? {} : { origin }),
70
70
  ...(unblocks.length === 0 ? {} : { unblocks }),
71
71
  },
@@ -1,12 +1,19 @@
1
1
  import { twoDigits } from '../plan-format/clock'
2
- import { firstTableRows, sectionLines, sectionStart } from '../plan-format/markdown'
3
- import { APPOINTMENT_VOCABULARY, PLAN_LANGUAGE, type PlanLanguage, WAITING_VOCABULARY } from '../vocabulary'
2
+ import { columnIndex, firstTableRows, sectionLines, sectionStart } from '../plan-format/markdown'
3
+ import {
4
+ APPOINTMENT_VOCABULARY,
5
+ COLUMN_KEY,
6
+ type ColumnKey,
7
+ PLAN_LANGUAGE,
8
+ type PlanLanguage,
9
+ WAITING_VOCABULARY,
10
+ } from '../vocabulary'
4
11
 
5
12
  type SectionColumns = {
6
13
  heading: string
7
- /** The header names of the two cells that identify a row, then the names that count as the status column. */
8
- keys: readonly [string, string]
9
- status: readonly string[]
14
+ /** The columns of the two cells that identify a row; the status column is found beside them. */
15
+ keys: readonly [ColumnKey, ColumnKey]
16
+ language: PlanLanguage
10
17
  }
11
18
 
12
19
  const DONE_WORD: Record<PlanLanguage, string> = { [PLAN_LANGUAGE.de]: 'erledigt', [PLAN_LANGUAGE.en]: 'done' }
@@ -17,15 +24,17 @@ export const doneStatus = (language: PlanLanguage, now: Date): string =>
17
24
 
18
25
  const squeezed = (text: string): string => text.replace(/\s+/g, ' ').trim()
19
26
 
20
- const waitingColumns = (language: PlanLanguage): SectionColumns => {
21
- const { heading, columns, statusAlso } = WAITING_VOCABULARY[language]
22
- return { heading, keys: [columns.since, columns.item], status: [columns.status, ...statusAlso] }
23
- }
27
+ const waitingColumns = (language: PlanLanguage): SectionColumns => ({
28
+ heading: WAITING_VOCABULARY[language].heading,
29
+ keys: [COLUMN_KEY.since, COLUMN_KEY.item],
30
+ language,
31
+ })
24
32
 
25
- const appointmentColumns = (language: PlanLanguage): SectionColumns => {
26
- const { heading, columns, statusAlso } = APPOINTMENT_VOCABULARY[language]
27
- return { heading, keys: [columns.when, columns.action], status: [columns.status, ...statusAlso] }
28
- }
33
+ const appointmentColumns = (language: PlanLanguage): SectionColumns => ({
34
+ heading: APPOINTMENT_VOCABULARY[language].heading,
35
+ keys: [COLUMN_KEY.when, COLUMN_KEY.action],
36
+ language,
37
+ })
29
38
 
30
39
  /** The line with the status cell (the `index`th between the bars) replaced; the other cells keep their text as written. */
31
40
  const withStatus = (line: string, index: number, status: string): string => {
@@ -42,7 +51,7 @@ const withStatus = (line: string, index: number, status: string): string => {
42
51
  */
43
52
  const closeRow = (
44
53
  board: string,
45
- { heading, keys: keyNames, status: statusNames }: SectionColumns,
54
+ { heading, keys: keyColumns, language }: SectionColumns,
46
55
  keys: readonly [string, string],
47
56
  status: string,
48
57
  ): string | null => {
@@ -55,8 +64,8 @@ const closeRow = (
55
64
  .slice(1, header.endsWith('|') ? -1 : undefined)
56
65
  .split('|')
57
66
  .map((cell) => cell.trim())
58
- const positions = keyNames.map((name) => names.indexOf(name))
59
- const statusAt = names.findIndex((name) => statusNames.includes(name))
67
+ const positions = keyColumns.map((key) => columnIndex(names, key, language))
68
+ const statusAt = columnIndex(names, COLUMN_KEY.status, language)
60
69
  if (positions.includes(-1) || statusAt === -1) return null
61
70
  const row = firstTableRows(lines).find(({ cells }) =>
62
71
  positions.every((position, index) => squeezed(cells[position] ?? '') === squeezed(keys[index])),
@@ -20,7 +20,7 @@ const changedAtOf = (root: string, settings: PlansSettings, file: string): numbe
20
20
 
21
21
  const candidateOf = (root: string, settings: PlansSettings, file: string): BoardCandidate => ({
22
22
  path: relative(root, file),
23
- lanes: parseSprintLanes(readFileSync(file, 'utf8'), settings.planLanguage).map((lane) => lane.name),
23
+ lanes: parseSprintLanes(readFileSync(file, 'utf8'), settings.boardLanguage).map((lane) => lane.name),
24
24
  changedAt: changedAtOf(root, settings, file),
25
25
  })
26
26
 
@@ -21,7 +21,7 @@ import {
21
21
  withAgentPanes,
22
22
  withForeground,
23
23
  } from './plan-panes'
24
- import type { PlansSettings } from './settings'
24
+ import { type PlansSettings } from './settings'
25
25
 
26
26
  const panesWithForeground = (agentPanes: readonly string[]): { panes: PaneState[]; notes: string[] } =>
27
27
  withForeground(withAgentPanes(paneListOf(runHerdr(['pane', 'list'])), agentPanes), (pane) =>
@@ -30,7 +30,7 @@ const panesWithForeground = (agentPanes: readonly string[]): { panes: PaneState[
30
30
 
31
31
  /** The board's lanes that have a worktree, closed ones left out. */
32
32
  const lanesOf = (root: string, settings: PlansSettings, boardFile: string) =>
33
- parseSprintLanes(readFileSync(boardFile, 'utf8'), settings.planLanguage)
33
+ parseSprintLanes(readFileSync(boardFile, 'utf8'), settings.boardLanguage)
34
34
  .filter((lane) => !lane.closed)
35
35
  .map((lane) => ({ name: lane.name, cwd: join(root, settings.worktreeDirectory, lane.name) }))
36
36
  .filter((lane) => existsSync(lane.cwd))
@@ -170,6 +170,10 @@ const checklistFrames = (
170
170
  return [...folder, ...frames, ...(open ? deferredFrames(active.phase, context.width) : [])]
171
171
  }
172
172
 
173
+ /** The phase's purpose sentence, dim, on one row cut at `width`; no row for a phase without one. */
174
+ const purposeFrame = (purpose: string | undefined, width: number): Frame =>
175
+ purpose ? textFrame([fit(paint.dim(plain(purpose)), width)]) : textFrame([])
176
+
173
177
  /**
174
178
  * A phase the lane works on: its head with the bar, no row of its own; under it the checklist of its tasks in the
175
179
  * plan's order, the running one marked (`checklistFrames`). `laneRuns` is false for a phase that only waits.
@@ -184,7 +188,10 @@ const activeFrame = (context: SummaryContext, active: ActivePhase, laneRuns = tr
184
188
  const running = runningTasks(active, laneRuns)
185
189
  return joinFrames([
186
190
  textFrame([phaseHead(active, current, context, model)]),
187
- indented(joinFrames(checklistFrames(inner, key, active, running)), TASK_INDENT),
191
+ indented(
192
+ joinFrames([purposeFrame(active.phase.purpose, inner.width), ...checklistFrames(inner, key, active, running)]),
193
+ TASK_INDENT,
194
+ ),
188
195
  ])
189
196
  }
190
197
 
@@ -182,6 +182,8 @@ export type OverviewView = {
182
182
  awaiting?: WaitingItem[]
183
183
  /** What is the user's turn, in a block under the title; absent for a herd without a board. */
184
184
  yourTurn?: YourTurnBlock
185
+ /** True when the board has `##` headings and jh reads none of them: an empty "Your turn" then says so instead of that nothing waits. */
186
+ boardUnread?: true
185
187
  /** The sources the watcher runs that are not tickets, in a block of their own under "Your turn". */
186
188
  sourceBlock?: SourceBlock
187
189
  /** Whole days since the board was groomed (`groomedDaysAgo`), beside the clock; null or absent when unknown. */
@@ -1403,9 +1405,9 @@ const turnMarkPaint = (mark: string): string => {
1403
1405
  }
1404
1406
 
1405
1407
  /** "Your turn" without a point: one line that cannot be opened, its name in the column of the other block names. */
1406
- const emptyTurnLines = (): BlockLines => ({
1408
+ const emptyTurnLines = (emptyText: string): BlockLines => ({
1407
1409
  open: false,
1408
- lines: [`${blockBar()} ${TEXTS.yourTurnHeading} ${paint.dim(`${ITEM_SEPARATOR} ${TEXTS.yourTurnEmpty}`)}`],
1410
+ lines: [`${blockBar()} ${TEXTS.yourTurnHeading} ${paint.dim(`${ITEM_SEPARATOR} ${emptyText}`)}`],
1409
1411
  hit: { rows: [], moreKey: null },
1410
1412
  })
1411
1413
 
@@ -1413,9 +1415,14 @@ const emptyTurnLines = (): BlockLines => ({
1413
1415
  * What is the user's turn, on top of the herd: the head `Your turn · <n>` with its balance, folded until the user opens
1414
1416
  * it; open, the now rows and the planned rows (`turnRows`), told apart by their mark alone.
1415
1417
  */
1416
- const yourTurnLines = ({ turn, now }: YourTurnBlock, state: Selection, width: number): BlockLines => {
1418
+ const yourTurnLines = (
1419
+ { turn, now }: YourTurnBlock,
1420
+ state: Selection,
1421
+ width: number,
1422
+ emptyText: string,
1423
+ ): BlockLines => {
1417
1424
  const count = turn.now.length + turn.planned.length
1418
- if (count === 0) return emptyTurnLines()
1425
+ if (count === 0) return emptyTurnLines(emptyText)
1419
1426
  const opened = { allNow: state.expanded.has(YOUR_TURN_MORE_KEY), allPlanned: state.expanded.has(YOUR_TURN_LATER_KEY) }
1420
1427
  const clock = new Date(now)
1421
1428
  const block: TopBlock = {
@@ -1702,6 +1709,7 @@ export const renderScreen = (
1702
1709
  watchesTickets,
1703
1710
  awaiting = [],
1704
1711
  yourTurn,
1712
+ boardUnread,
1705
1713
  sourceBlock,
1706
1714
  groomedDays,
1707
1715
  unplaced = [],
@@ -1719,7 +1727,8 @@ export const renderScreen = (
1719
1727
  const notice = watchNotice({ lanes: active, watch, watchesTickets }, badgeTexts)
1720
1728
  const status = [notice ? paint.yellow(notice) : '', groomedCell(groomedDays)].filter(Boolean).join(COLUMN_SEPARATOR)
1721
1729
  const titleLine = spread(`${HEADER_MARK} ${paint.bold(title)}`, status, width)
1722
- const turn = yourTurn ? yourTurnLines(yourTurn, state, width) : null
1730
+ const emptyTurnText = boardUnread ? TEXTS.boardUnread : TEXTS.yourTurnEmpty
1731
+ const turn = yourTurn ? yourTurnLines(yourTurn, state, width, emptyTurnText) : null
1723
1732
  const nowLines = unplaced.map((task) => nowLine(task, width, taskStyle))
1724
1733
  const above = nowLines.length > 0 ? [titleLine, rule(width), ...nowLines] : [titleLine]
1725
1734
  const listed = sourceLinesOf(sourceBlock, awaiting, state, width)
package/src/plans/live.ts CHANGED
@@ -511,7 +511,7 @@ const applyBlockClick = (live: Live, outcome: BlockClick): void => {
511
511
  if ('done' in outcome) {
512
512
  const { closed, notice } = closeRow(outcome.done, {
513
513
  sprintFile: live.source.sprintFile,
514
- language: live.source.settings.planLanguage,
514
+ language: live.source.settings.boardLanguage,
515
515
  now: new Date(),
516
516
  closeRecords: (ids) => closeWaiting(live.source.root, ids, Date.now()),
517
517
  })
@@ -16,6 +16,8 @@ export type PlansSettings = Pick<
16
16
  JackherdConfig,
17
17
  'planDirectory' | 'board' | 'worktreeDirectory' | 'baseBranch' | 'planLanguage' | 'responseLanguage' | 'skillPrefix'
18
18
  > & {
19
+ /** The language jh writes the board in: the config's `boardLanguage`, or its `planLanguage` when it sets none. */
20
+ boardLanguage: JackherdConfig['planLanguage']
19
21
  adapter: JackherdConfig['terminal']['adapter']
20
22
  /** Free gigabytes a new lane needs on the disk (`lanes.minFreeGb`). */
21
23
  minFreeGb: number
@@ -65,6 +67,7 @@ export const plansSettingsOf = (config: JackherdConfig): PlansSettings => ({
65
67
  worktreeDirectory: config.worktreeDirectory,
66
68
  baseBranch: config.baseBranch,
67
69
  planLanguage: config.planLanguage,
70
+ boardLanguage: config.boardLanguage ?? config.planLanguage,
68
71
  responseLanguage: config.responseLanguage,
69
72
  skillPrefix: config.skillPrefix,
70
73
  adapter: config.terminal.adapter,
@@ -15,6 +15,7 @@ import {
15
15
  shortTitle,
16
16
  sprintTitleOf,
17
17
  } from '../plan-format'
18
+ import { firstUnrecognizedSectionLine } from '../plan-format/unrecognized-sections'
18
19
  import type { WaitingItem } from '../plan-format/waiting'
19
20
  import { dropUnused } from '../shared/stat-cache'
20
21
  import type { TaskSignal } from '../task-signals/types'
@@ -140,6 +141,8 @@ export type Snapshot = {
140
141
  groomedDays?: number | null
141
142
  /** What is the user's turn: `waiting`, the board's open appointments and its next section, one row per topic. */
142
143
  yourTurn?: YourTurnBlock
144
+ /** True when the board has `##` headings and jh reads none of them (`firstUnrecognizedSectionLine`). */
145
+ boardUnread?: true
143
146
  /** The sources of `watch.sources` not marked `ticket`, from the watcher's state, for the block under "Your turn". */
144
147
  sourceBlock?: SourceBlock
145
148
  /** The tone of each role, from the config, which `renderSnapshot` sets before it draws. */
@@ -535,7 +538,7 @@ const readBoardLanes = async (
535
538
  const atBase = textAtBase(base, boardPath)
536
539
  const markdown = atBase ?? (await readFallback(boardPath, sprintFile, fallbacks)) ?? ''
537
540
  const liveMarkdown = atBase !== null && existsSync(sprintFile) ? await Bun.file(sprintFile).text() : markdown
538
- return { markdown, liveMarkdown, lanes: rowsOf(markdown, liveMarkdown, settings.planLanguage).lanes }
541
+ return { markdown, liveMarkdown, lanes: rowsOf(markdown, liveMarkdown, settings.boardLanguage).lanes }
539
542
  }
540
543
 
541
544
  /** The plans the sprint's plans tables name, read at the base ref, by link; lanes read theirs themselves. */
@@ -547,7 +550,7 @@ const readListedPlans = async (
547
550
  fallbacks: Fallbacks,
548
551
  ): Promise<Record<string, string>> => {
549
552
  const hrefs = new Set(
550
- readSprintDocument(markdown, source.settings.planLanguage).planTables.flatMap(({ rows }) =>
553
+ readSprintDocument(markdown, source.settings.boardLanguage).planTables.flatMap(({ rows }) =>
551
554
  rows.flatMap((row) => (row.href ? [row.href] : [])),
552
555
  ),
553
556
  )
@@ -757,7 +760,7 @@ export const loadSnapshot = async (
757
760
  await gate.pass()
758
761
  const waitingRecords = readWaitingRecords(root)
759
762
  const waiting = withSourcePrefix(
760
- waitingItemsOf(liveBoard, settings.planLanguage, waitingRecords, now),
763
+ waitingItemsOf(liveBoard, settings.boardLanguage, waitingRecords, now),
761
764
  sourceSettings.sourceLabels,
762
765
  )
763
766
  const sentChips = sentChipsByLane(waitingRecords.sent, worktrees, now)
@@ -810,8 +813,9 @@ export const loadSnapshot = async (
810
813
  errors: [...laneSet.errors, ...pullRequests.errors, ...(notice ? [notice] : [])],
811
814
  watch: reading?.health,
812
815
  waiting,
813
- groomedDays: groomedDaysAgo(liveBoard, settings.planLanguage, new Date(now)),
814
- yourTurn: yourTurnOfBoard(liveBoard, settings.planLanguage, waiting, now),
816
+ groomedDays: groomedDaysAgo(liveBoard, settings.boardLanguage, new Date(now)),
817
+ yourTurn: yourTurnOfBoard(liveBoard, settings.boardLanguage, waiting, now),
818
+ ...(firstUnrecognizedSectionLine(liveBoard) === null ? {} : { boardUnread: true as const }),
815
819
  ...(reading?.sources ? { sourceBlock: { sources: withSourceStyle(reading.sources, sourceSettings), now } } : {}),
816
820
  tones: settings.tones,
817
821
  ...(coordinator ? { coordinator: coordinator.view } : {}),
@@ -37,7 +37,7 @@ const pageOf = ({ root, sprintFile, settings }: Source, snapshot: Snapshot, envi
37
37
  baseRef: baseRefInfo(root, baseRefOf(settings)),
38
38
  repoBlobBase: remoteBlobBase(root, settings.baseBranch),
39
39
  sprintDirectory: dirname(boardRepoPathOf(root, settings, sprintFile)),
40
- language: settings.planLanguage,
40
+ language: settings.boardLanguage,
41
41
  linkKinds: settings.linkKinds,
42
42
  })
43
43
 
@@ -84,6 +84,8 @@ export type PlanTexts = {
84
84
  hintDonePhases: string
85
85
  /** After the head of "Your turn" when nothing waits for the user and nothing is planned. */
86
86
  yourTurnEmpty: string
87
+ /** After the head of "Your turn" when the board has `##` headings and jh reads none of them, so nothing can be said to wait. */
88
+ boardUnread: string
87
89
  notInPlan: string
88
90
  /** Before a task an agent reports that no task of the plan names. */
89
91
  now: string
@@ -189,6 +191,7 @@ export const TEXTS: PlanTexts = {
189
191
  hintNextPhases: 'the next phases',
190
192
  hintDonePhases: 'the done phases',
191
193
  yourTurnEmpty: 'nothing waits for you',
194
+ boardUnread: 'board: no section recognised',
192
195
  notInPlan: 'not in the plan',
193
196
  now: 'now:',
194
197
  subagent: 'Subagent:',
package/src/plans/view.ts CHANGED
@@ -47,6 +47,7 @@ const overviewOf = (snapshot: Snapshot, shimmer: boolean): OverviewView => {
47
47
  awaiting: snapshot.waiting,
48
48
  groomedDays: snapshot.groomedDays,
49
49
  yourTurn: snapshot.yourTurn,
50
+ boardUnread: snapshot.boardUnread,
50
51
  sourceBlock: snapshot.sourceBlock,
51
52
  unplaced: snapshot.unplaced,
52
53
  coordinator: snapshot.coordinator,
@@ -103,7 +103,7 @@ const lanesOf = ({ root, settings }: Place, board: string | null, agents: readon
103
103
  discoverLanes({
104
104
  worktrees: worktreeNames(join(root, settings.worktreeDirectory)),
105
105
  agentNames: (agents ?? []).flatMap((agent) => agent.name ?? []),
106
- sprintLanes: board === null ? [] : parseSprintLanes(board, settings.planLanguage).map((lane) => lane.name),
106
+ sprintLanes: board === null ? [] : parseSprintLanes(board, settings.boardLanguage).map((lane) => lane.name),
107
107
  })
108
108
 
109
109
  /** `jh resume --coordinator`: prints what a cleared coordinator takes up, then the reference on it. Reads only. */
@@ -117,7 +117,7 @@ export const printCoordinatorState = async (boardPath: string | null): Promise<v
117
117
  const lines = coordinatorStateLines({
118
118
  boardPath: relative(root, boardFile),
119
119
  board,
120
- language: settings.planLanguage,
120
+ language: settings.boardLanguage,
121
121
  lanes: lanes.map((lane) => laneFactsOf(place, agents, lane)),
122
122
  herdrAnswered: agents !== null,
123
123
  pullRequests: await readPullRequestsSafely(place, lanes),
@@ -54,7 +54,7 @@ export const run = async (args: string[]): Promise<number> => {
54
54
  foundLanesOf(root, settings, () => terminal.listAgents().map((agent) => agent.name)),
55
55
  )
56
56
  if (board.notice) console.error(board.notice)
57
- const context = { now: new Date(), planLanguage: settings.planLanguage }
57
+ const context = { now: new Date(), boardLanguage: settings.boardLanguage }
58
58
  const outcome = settle(request, context, portsFor(checkout, board.file, settings.adapter))
59
59
  printOutcome(outcome)
60
60
  return outcome.exitCode
@@ -15,7 +15,7 @@ export type SettlePorts = {
15
15
  }
16
16
 
17
17
  /** When it runs and in which language the board is written; the lane is told in English. */
18
- export type SettleContext = { now: Date; planLanguage: PlanLanguage }
18
+ export type SettleContext = { now: Date; boardLanguage: PlanLanguage }
19
19
 
20
20
  export const SETTLE_EXIT = { settled: 0, refused: 1, notSent: 2 } as const
21
21
 
@@ -48,10 +48,10 @@ const chatLine = (request: CheckedRequest): string =>
48
48
  * not be written, or null; the send has failed either way, so a board error must not turn exit 2 into exit 1.
49
49
  */
50
50
  const noteFailure = (entry: SettledEntry, error: string, context: SettleContext, ports: SettlePorts): string | null => {
51
- const row = settledRow(entry, context.planLanguage)
52
- const noted = settledRow(withSendFailure(entry, error, context.planLanguage), context.planLanguage)
51
+ const row = settledRow(entry, context.boardLanguage)
52
+ const noted = settledRow(withSendFailure(entry, error, context.boardLanguage), context.boardLanguage)
53
53
  try {
54
- ports.writeBoard(withReplacedRow(ports.readBoard(), row, noted, context.planLanguage))
54
+ ports.writeBoard(withReplacedRow(ports.readBoard(), row, noted, context.boardLanguage))
55
55
  return null
56
56
  } catch (noteError) {
57
57
  return errorText(noteError)
@@ -80,7 +80,7 @@ export const settle = (request: SettledRequest, context: SettleContext, ports: S
80
80
  }
81
81
  const { checked } = result
82
82
  const entry = entryOf(checked, context.now, ports.evidenceVersion(checked.evidence.path))
83
- ports.writeBoard(withSettledRow(ports.readBoard(), settledRow(entry, context.planLanguage), context.planLanguage))
83
+ ports.writeBoard(withSettledRow(ports.readBoard(), settledRow(entry, context.boardLanguage), context.boardLanguage))
84
84
  const error = ports.send(checked.lane, laneMessageOf(checked))
85
85
  if (error === null) return { exitCode: SETTLE_EXIT.settled, stdout: [chatLine(checked)], stderr: [] }
86
86
  return notSent(checked, error, noteFailure(entry, error, context, ports))
@@ -5,7 +5,9 @@ import {
5
5
  APPROVAL_TEXTS,
6
6
  CARD_FIELDS,
7
7
  LANGUAGE_NAME,
8
+ PLAN_LANGUAGE,
8
9
  PLAN_VOCABULARY,
10
+ type PlanLanguage,
9
11
  RECOMMENDED_MARK,
10
12
  REPORT_FIELDS,
11
13
  SELF_MERGE_LABEL,
@@ -35,9 +37,20 @@ const checkFreeList = (patterns: readonly string[]): string =>
35
37
  const prefixed = (prefix: string, values: Record<string, string>): [string, string][] =>
36
38
  Object.entries(values).map(([key, value]) => [`kit.${prefix}.${key}`, value])
37
39
 
38
- /** Every placeholder a kit file may use, with its value for this project. */
39
- const placeholderValues = (config: JackherdConfig): Map<string, string> => {
40
- const { header, sections, columns, phase, laneClosed, openSubagents } = PLAN_VOCABULARY[config.planLanguage]
40
+ const TEMPLATE_FILE = /(?:^|\/)template-([A-Za-z]+)\.md$/
41
+
42
+ /**
43
+ * The language a plan template file is written in, from its name (`template-English.md` is English); undefined for any
44
+ * other path. Such a file renders with the vocabulary of that language, never with the project's plan language.
45
+ */
46
+ export const templateLanguageOf = (path: string): PlanLanguage | undefined => {
47
+ const name = TEMPLATE_FILE.exec(path)?.[1]
48
+ return Object.values(PLAN_LANGUAGE).find((language) => LANGUAGE_NAME[language] === name)
49
+ }
50
+
51
+ /** Every placeholder a kit file may use, with its value for this project; the plan words follow `vocabularyLanguage`. */
52
+ const placeholderValues = (config: JackherdConfig, vocabularyLanguage: PlanLanguage): Map<string, string> => {
53
+ const { header, sections, columns, phase, laneClosed, openSubagents } = PLAN_VOCABULARY[vocabularyLanguage]
41
54
  return new Map([
42
55
  ['kit.responseLanguage', LANGUAGE_NAME[config.responseLanguage]],
43
56
  ['kit.responseAddress', ADDRESS_FORM[config.responseLanguage][config.responseAddress]],
@@ -74,15 +87,17 @@ export const listPlaceholders = (template: string): string[] =>
74
87
  * vocabulary, the two languages, `{{kit.responseAddress}}`, the plan and worktree directory and the base branch. A
75
88
  * command or lock file the config leaves unset renders as `unsetValueText`, never as a guessed default. Other
76
89
  * `{{…}}` text is left alone; an unknown `kit.` placeholder throws rather than reaching a project
77
- * file unrendered. `overrides` win over the config: a global kit renders what each repository decides as
90
+ * file unrendered. `templateLanguage` (`templateLanguageOf` of the file) fills the plan words from that language's
91
+ * vocabulary instead of the project's plan language. `overrides` win over the config: a global kit renders what each repository decides as
78
92
  * `<name>` (`REPOSITORY_TOKENS`).
79
93
  */
80
94
  export const renderTemplate = (
81
95
  template: string,
82
96
  config: JackherdConfig,
83
97
  overrides: ReadonlyMap<string, string> = new Map(),
98
+ templateLanguage?: PlanLanguage,
84
99
  ): string => {
85
- const values = placeholderValues(config)
100
+ const values = placeholderValues(config, templateLanguage ?? config.planLanguage)
86
101
  return template.replace(PLACEHOLDER, (_match, name: string) => {
87
102
  const value = overrides.get(name) ?? values.get(name)
88
103
  if (value === undefined) throw new Error(`Unknown kit placeholder {{${name}}}`)
@@ -77,13 +77,17 @@ export const assertOutsideWorktrees = (paths: Iterable<string>, config: Jackherd
77
77
  }
78
78
  }
79
79
 
80
- export const renderKitFiles = (kit: KitSource, render: (template: string) => string): Map<string, RenderedFile> => {
80
+ /** `render` gets the kit path too, so a `template-<Language>.md` can be filled in its own language. */
81
+ export const renderKitFiles = (
82
+ kit: KitSource,
83
+ render: (template: string, path: string) => string,
84
+ ): Map<string, RenderedFile> => {
81
85
  const rendered = new Map<string, RenderedFile>()
82
86
  for (const file of kit.files) {
83
87
  const parsed = parseKitPath(file.path)
84
88
  if (!parsed.ok) throw new Error(`Kit file ${file.path} ${parsed.reason}`)
85
89
  if (rendered.has(parsed.path)) throw new Error(`Kit file ${parsed.path} appears twice`)
86
- const content = render(file.template)
90
+ const content = render(file.template, parsed.path)
87
91
  const mode = file.executable ? FILE_MODE.executable : FILE_MODE.regular
88
92
  rendered.set(parsed.path, { content, checksum: checksum(content), mode })
89
93
  }
package/src/sync/sync.ts CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  removeFileSafely,
30
30
  writeFileSafely,
31
31
  } from './project-fs'
32
- import { renderTemplate } from './render'
32
+ import { renderTemplate, templateLanguageOf } from './render'
33
33
  import { parseSettings, type Settings } from './settings-hooks'
34
34
  import {
35
35
  type AcceptRequest,
@@ -184,7 +184,8 @@ const buildPlan = async ({
184
184
  }: PlanInput): Promise<SyncPlan> => {
185
185
  const { manifest, text: manifestText } = await readManifest(toolDirectory)
186
186
  const accept = parseAcceptPaths(acceptPaths)
187
- const render = (template: string) => renderTemplate(template, config, overrides)
187
+ const render = (template: string, path: string) =>
188
+ renderTemplate(template, config, overrides, templateLanguageOf(path))
188
189
  const rendered = renderKitFiles(kit, render)
189
190
  assertOutsideWorktrees([...rendered.keys(), ...Object.keys(manifest.files), ...accept.files], config)
190
191
  const files = await planFiles(locate, rendered, manifest, accept)