@houserules/payload 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@houserules/payload",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "houserules: shared payload libraries, copied into .claude/scripts/lib and executed on bare node with zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -71,12 +71,12 @@
71
71
  "hooks"
72
72
  ],
73
73
  "devDependencies": {
74
- "@types/node": "26.6.3",
74
+ "@types/node": "26.6.5",
75
75
  "publint": "^0.3.25",
76
76
  "type-fest": "^5.10.0",
77
77
  "typescript": "^6.0.3",
78
- "vitest": "^5.0.4",
79
- "wireit": "^0.14.13",
78
+ "vitest": "^5.0.5",
79
+ "wireit": "^0.15.0",
80
80
  "@houserules/test": "0.1.3"
81
81
  },
82
82
  "dependencies": {},
@@ -61,6 +61,8 @@ export interface HouseConfig {
61
61
  enabled?: boolean;
62
62
  stopCheck?: boolean;
63
63
  baseBranch?: string;
64
+ /** Repo-relative path globs the Stop-hook changeset gate never counts. */
65
+ gateIgnore?: string[];
64
66
  };
65
67
  ledger?: {
66
68
  enabled?: boolean;
@@ -82,6 +84,11 @@ export interface HouseConfig {
82
84
  design?: {
83
85
  themeEntry?: string;
84
86
  };
87
+ /** `maxWorkers` is read by `wave-ceiling.mjs`: the per-wave worker ceiling, overriding the machine-derived one. */
88
+ orchestrate?: {
89
+ workerTools?: string[];
90
+ maxWorkers?: number;
91
+ };
85
92
  targets: ConfigTarget[];
86
93
  [key: string]: unknown;
87
94
  }
@@ -9,6 +9,11 @@ export declare const READ_ONLY_TOOLS: ReadonlySet<string>;
9
9
  export interface TurnRecord {
10
10
  type?: string;
11
11
  isMeta?: boolean;
12
+ isCompactSummary?: boolean;
13
+ origin?: {
14
+ kind?: string;
15
+ };
16
+ timestamp?: string;
12
17
  message?: {
13
18
  content?: unknown;
14
19
  };
@@ -33,3 +38,10 @@ export declare function toolUsesSinceLastPrompt(records: readonly TurnRecord[]):
33
38
  * looks. A caller treats `undefined` exactly as it behaved before this gate existed.
34
39
  */
35
40
  export declare function turnTouchedFiles(transcriptPath: string | undefined): boolean | undefined;
41
+ /**
42
+ * When the turn that just ended began, as epoch milliseconds: the `timestamp` of the last
43
+ * human prompt in the transcript at `transcriptPath`. Undefined when there is no path, the
44
+ * file is unreadable, or no prompt carries a parseable timestamp. A lagging transcript can
45
+ * only yield an earlier prompt, which widens the turn rather than narrowing it.
46
+ */
47
+ export declare function turnStartedAt(transcriptPath: string | undefined): number | undefined;
@@ -25,12 +25,17 @@ export const READ_ONLY_TOOLS = new Set([
25
25
  ]);
26
26
  /**
27
27
  * Whether a `user` record carries a human prompt rather than a tool result. A meta record
28
- * (a command caveat the harness inserts) is not a prompt: stopping at one would hide the
29
- * tool uses before it and read an editing turn as read-only.
28
+ * (a command caveat), a task notification, and a compaction summary are inserted by the
29
+ * harness and continue the turn already running. Stopping at one would hide the tool uses
30
+ * before it, such as the dispatch of the background agent that just reported.
30
31
  */
31
32
  function isHumanPrompt(record) {
32
33
  if (record.type !== 'user' || record.isMeta === true)
33
34
  return false;
35
+ if (record.isCompactSummary === true)
36
+ return false;
37
+ if (record.origin?.kind === 'task-notification')
38
+ return false;
34
39
  const content = record.message?.content;
35
40
  if (typeof content === 'string')
36
41
  return true;
@@ -69,6 +74,16 @@ function* reversed(items) {
69
74
  for (let i = items.length - 1; i >= 0; i--)
70
75
  yield items[i];
71
76
  }
77
+ function readTranscriptLines(transcriptPath) {
78
+ if (!transcriptPath)
79
+ return undefined;
80
+ try {
81
+ return readFileSync(transcriptPath, 'utf8').split('\n');
82
+ }
83
+ catch {
84
+ return undefined;
85
+ }
86
+ }
72
87
  function* parsedFromEnd(lines) {
73
88
  for (const line of reversed(lines)) {
74
89
  if (!line.trim())
@@ -103,17 +118,29 @@ export function toolUsesSinceLastPrompt(records) {
103
118
  * looks. A caller treats `undefined` exactly as it behaved before this gate existed.
104
119
  */
105
120
  export function turnTouchedFiles(transcriptPath) {
106
- if (!transcriptPath)
121
+ const lines = readTranscriptLines(transcriptPath);
122
+ if (!lines)
107
123
  return undefined;
108
- let text;
109
- try {
110
- text = readFileSync(transcriptPath, 'utf8');
111
- }
112
- catch {
113
- return undefined;
114
- }
115
- const uses = collectNewestFirst(parsedFromEnd(text.split('\n')));
124
+ const uses = collectNewestFirst(parsedFromEnd(lines));
116
125
  if (uses === null)
117
126
  return undefined;
118
127
  return uses.some((name) => !READ_ONLY_TOOLS.has(name));
119
128
  }
129
+ /**
130
+ * When the turn that just ended began, as epoch milliseconds: the `timestamp` of the last
131
+ * human prompt in the transcript at `transcriptPath`. Undefined when there is no path, the
132
+ * file is unreadable, or no prompt carries a parseable timestamp. A lagging transcript can
133
+ * only yield an earlier prompt, which widens the turn rather than narrowing it.
134
+ */
135
+ export function turnStartedAt(transcriptPath) {
136
+ const lines = readTranscriptLines(transcriptPath);
137
+ if (!lines)
138
+ return undefined;
139
+ for (const record of parsedFromEnd(lines)) {
140
+ if (!isHumanPrompt(record))
141
+ continue;
142
+ const startedAt = Date.parse(record.timestamp ?? '');
143
+ return Number.isNaN(startedAt) ? undefined : startedAt;
144
+ }
145
+ return undefined;
146
+ }