@agentshouse/kit 0.2.1-ce145e9aadbf6 → 0.2.1-ce46b2b55463f

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 (146) hide show
  1. package/README.md +46 -49
  2. package/dist/acp.js +101 -108
  3. package/dist/afk.js +17 -0
  4. package/dist/agents.js +252 -73
  5. package/dist/api.js +43 -6
  6. package/dist/app-git.js +48 -0
  7. package/dist/binaries.js +79 -0
  8. package/dist/bridge.js +62 -79
  9. package/dist/building.js +50 -0
  10. package/dist/calls.js +88 -0
  11. package/dist/chunks.js +49 -0
  12. package/dist/clis.js +171 -102
  13. package/dist/codex-main.js +58 -0
  14. package/dist/connect.js +108 -0
  15. package/dist/connection.js +120 -0
  16. package/dist/content.js +106 -0
  17. package/dist/conversations.js +816 -335
  18. package/dist/copies.js +842 -309
  19. package/dist/earlier.js +263 -0
  20. package/dist/end.js +26 -0
  21. package/dist/events.js +793 -0
  22. package/dist/files.js +206 -18
  23. package/dist/git-main.js +24 -29
  24. package/dist/git.js +95 -18
  25. package/dist/grok.js +39 -0
  26. package/dist/home.js +134 -9
  27. package/dist/house-cli.js +282 -0
  28. package/dist/house-main.js +7 -159
  29. package/dist/instructions.js +7 -11
  30. package/dist/keys.js +238 -0
  31. package/dist/kit-cli.js +78 -0
  32. package/dist/kit-main.js +8 -19
  33. package/dist/login.js +133 -104
  34. package/dist/logout.js +15 -14
  35. package/dist/mcp.js +42 -3
  36. package/dist/owner.js +46 -0
  37. package/dist/placement.js +25 -0
  38. package/dist/refusals.js +43 -15
  39. package/dist/relay.js +33 -2
  40. package/dist/resident.js +161 -61
  41. package/dist/scope.js +214 -0
  42. package/dist/scripts.js +303 -0
  43. package/dist/secret-input.js +4 -3
  44. package/dist/settings.js +188 -0
  45. package/dist/shell.js +3 -0
  46. package/dist/sign-in.js +85 -33
  47. package/dist/silence.js +28 -0
  48. package/dist/skills.js +49 -35
  49. package/dist/supervisor.js +163 -0
  50. package/dist/transcription.js +131 -40
  51. package/dist/translate.js +19 -16
  52. package/dist/update.js +119 -100
  53. package/dist/wire.js +32 -0
  54. package/dist/work.js +353 -0
  55. package/dist/workspace.js +103 -0
  56. package/package.json +26 -21
  57. package/dist/authority-main.js +0 -22
  58. package/dist/blocks.js +0 -51
  59. package/dist/bootstrap.json +0 -24
  60. package/dist/clis-main.js +0 -23
  61. package/dist/configure-main.js +0 -6
  62. package/dist/enrol-main.js +0 -4
  63. package/dist/stream.js +0 -47
  64. package/how-we-work.md +0 -23
  65. package/skills/ask-matt/LICENSE +0 -21
  66. package/skills/ask-matt/PHASE-BOUNDARIES.md +0 -55
  67. package/skills/ask-matt/SKILL.md +0 -91
  68. package/skills/ask-matt/agents/openai.yaml +0 -4
  69. package/skills/code-review/LICENSE +0 -21
  70. package/skills/code-review/SKILL.md +0 -89
  71. package/skills/code-review/agents/openai.yaml +0 -3
  72. package/skills/codebase-design/DEEPENING.md +0 -37
  73. package/skills/codebase-design/DESIGN-IT-TWICE.md +0 -44
  74. package/skills/codebase-design/LICENSE +0 -21
  75. package/skills/codebase-design/SKILL.md +0 -116
  76. package/skills/codebase-design/agents/openai.yaml +0 -3
  77. package/skills/diagnosing-bugs/LICENSE +0 -21
  78. package/skills/diagnosing-bugs/SKILL.md +0 -140
  79. package/skills/diagnosing-bugs/agents/openai.yaml +0 -3
  80. package/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -44
  81. package/skills/domain-modeling/ADR-FORMAT.md +0 -47
  82. package/skills/domain-modeling/CONTEXT-FORMAT.md +0 -60
  83. package/skills/domain-modeling/LICENSE +0 -21
  84. package/skills/domain-modeling/SKILL.md +0 -76
  85. package/skills/domain-modeling/agents/openai.yaml +0 -3
  86. package/skills/grill-me/LICENSE +0 -21
  87. package/skills/grill-me/SKILL.md +0 -8
  88. package/skills/grill-me/agents/openai.yaml +0 -4
  89. package/skills/grill-with-docs/LICENSE +0 -21
  90. package/skills/grill-with-docs/SKILL.md +0 -8
  91. package/skills/grill-with-docs/agents/openai.yaml +0 -4
  92. package/skills/grilling/LICENSE +0 -21
  93. package/skills/grilling/SKILL.md +0 -30
  94. package/skills/grilling/agents/openai.yaml +0 -3
  95. package/skills/handoff/LICENSE +0 -21
  96. package/skills/handoff/SKILL.md +0 -17
  97. package/skills/handoff/agents/openai.yaml +0 -4
  98. package/skills/implement/LICENSE +0 -21
  99. package/skills/implement/SKILL.md +0 -16
  100. package/skills/implement/agents/openai.yaml +0 -4
  101. package/skills/improve-codebase-architecture/HTML-REPORT.md +0 -123
  102. package/skills/improve-codebase-architecture/LICENSE +0 -21
  103. package/skills/improve-codebase-architecture/SKILL.md +0 -72
  104. package/skills/improve-codebase-architecture/agents/openai.yaml +0 -4
  105. package/skills/prototype/LICENSE +0 -21
  106. package/skills/prototype/LOGIC.md +0 -67
  107. package/skills/prototype/SKILL.md +0 -28
  108. package/skills/prototype/UI.md +0 -112
  109. package/skills/prototype/agents/openai.yaml +0 -3
  110. package/skills/research/LICENSE +0 -21
  111. package/skills/research/SKILL.md +0 -14
  112. package/skills/research/agents/openai.yaml +0 -3
  113. package/skills/resolving-merge-conflicts/LICENSE +0 -21
  114. package/skills/resolving-merge-conflicts/SKILL.md +0 -16
  115. package/skills/resolving-merge-conflicts/agents/openai.yaml +0 -3
  116. package/skills/tdd/LICENSE +0 -21
  117. package/skills/tdd/SKILL.md +0 -40
  118. package/skills/tdd/agents/openai.yaml +0 -3
  119. package/skills/tdd/mocking.md +0 -59
  120. package/skills/tdd/tests.md +0 -77
  121. package/skills/teach/GLOSSARY-FORMAT.md +0 -35
  122. package/skills/teach/LEARNING-RECORD-FORMAT.md +0 -46
  123. package/skills/teach/LICENSE +0 -21
  124. package/skills/teach/MISSION-FORMAT.md +0 -31
  125. package/skills/teach/RESOURCES-FORMAT.md +0 -32
  126. package/skills/teach/SKILL.md +0 -141
  127. package/skills/teach/agents/openai.yaml +0 -4
  128. package/skills/to-questionnaire/LICENSE +0 -21
  129. package/skills/to-questionnaire/SKILL.md +0 -55
  130. package/skills/to-questionnaire/agents/openai.yaml +0 -4
  131. package/skills/to-spec/LICENSE +0 -21
  132. package/skills/to-spec/SKILL.md +0 -76
  133. package/skills/to-spec/agents/openai.yaml +0 -4
  134. package/skills/to-tickets/LICENSE +0 -21
  135. package/skills/to-tickets/SKILL.md +0 -106
  136. package/skills/to-tickets/agents/openai.yaml +0 -4
  137. package/skills/wait-what/LICENSE +0 -21
  138. package/skills/wait-what/SKILL.md +0 -8
  139. package/skills/wait-what/agents/openai.yaml +0 -4
  140. package/skills/wayfinder/LICENSE +0 -21
  141. package/skills/wayfinder/SKILL.md +0 -129
  142. package/skills/wayfinder/agents/openai.yaml +0 -4
  143. package/skills/writing-for-agents/LICENSE +0 -21
  144. package/skills/writing-for-agents/SKILL-MECHANICS.md +0 -22
  145. package/skills/writing-for-agents/SKILL.md +0 -83
  146. package/skills/writing-for-agents/agents/openai.yaml +0 -3
package/dist/work.js ADDED
@@ -0,0 +1,353 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { once } from 'node:events';
3
+ import { readFileSync } from 'node:fs';
4
+ import { rm } from 'node:fs/promises';
5
+ import { createServer } from 'node:net';
6
+ import { join } from 'node:path';
7
+ import { RUNNING_JOB } from './events.js';
8
+ import { kitHome, socketDirectory } from './home.js';
9
+ const ENDED_TASK = new Set(['completed', 'failed', 'killed']);
10
+ const SCHEDULING = new Set(['CronCreate', 'CronDelete', 'ScheduleWakeup']);
11
+ const QUEUE_LIST = 'house-kit-queue-';
12
+ const SYNC = 'house-kit-sync-';
13
+ const WAKEUP = /Next wakeup scheduled for (\d\d):(\d\d):(\d\d) \(in (\d+)s\)/;
14
+ const HALF_DAY = 12 * 60 * 60 * 1000;
15
+ export function codexLauncher() {
16
+ return join(kitHome(), 'launchers', 'codex');
17
+ }
18
+ export class Work {
19
+ changed;
20
+ jobs = new Set();
21
+ constructor(changed) {
22
+ this.changed = changed;
23
+ }
24
+ async open(_cli) {
25
+ return {};
26
+ }
27
+ async settled() { }
28
+ read(message) {
29
+ this.take(message);
30
+ this.changed();
31
+ }
32
+ take(message) {
33
+ const update = message.params?.update;
34
+ if (message.method !== 'session/update' || update?.asyncTaskId === undefined)
35
+ return;
36
+ if (update.sessionUpdate === 'async_task_spawned')
37
+ this.jobs.add(update.asyncTaskId);
38
+ if (update.sessionUpdate === 'async_task_state_update' && !RUNNING_JOB.has(update.state))
39
+ this.jobs.delete(update.asyncTaskId);
40
+ }
41
+ busy() {
42
+ return this.jobs.size > 0;
43
+ }
44
+ close() { }
45
+ }
46
+ class ClaudeWork extends Work {
47
+ cwd;
48
+ level = new Set();
49
+ listed = new Set();
50
+ started = new Set();
51
+ running = false;
52
+ hooks = new Set();
53
+ calls = new Map();
54
+ crons = new Map();
55
+ wakeups = [];
56
+ goal = false;
57
+ constructor(cwd, changed) {
58
+ super(changed);
59
+ this.cwd = cwd;
60
+ }
61
+ take(message) {
62
+ super.take(message);
63
+ if (message.method === '_claude/sdkMessage')
64
+ this.sdk(message.params.message);
65
+ if (message.method === 'session/update')
66
+ this.update(message.params.update);
67
+ }
68
+ busy() {
69
+ return (super.busy() ||
70
+ this.level.size > 0 ||
71
+ this.started.size > 0 ||
72
+ this.running ||
73
+ this.hooks.size > 0 ||
74
+ this.crons.size > 0 ||
75
+ this.wakeups.length > 0 ||
76
+ this.goal ||
77
+ this.durable());
78
+ }
79
+ sdk(message) {
80
+ switch (message.subtype) {
81
+ case 'background_tasks_changed':
82
+ this.level = new Set(message.tasks.map((task) => task.task_id));
83
+ for (const id of this.level) {
84
+ this.listed.add(id);
85
+ this.started.delete(id);
86
+ }
87
+ break;
88
+ case 'task_started':
89
+ if (!this.listed.has(message.task_id))
90
+ this.started.add(message.task_id);
91
+ break;
92
+ case 'task_updated':
93
+ if (ENDED_TASK.has(message.patch.status))
94
+ this.started.delete(message.task_id);
95
+ break;
96
+ case 'task_notification':
97
+ this.started.delete(message.task_id);
98
+ break;
99
+ case 'session_state_changed':
100
+ if (message.state === 'running' && !this.running)
101
+ this.wakeups = this.wakeups.filter((due) => due > Date.now());
102
+ this.running = message.state === 'running';
103
+ break;
104
+ case 'hook_started':
105
+ this.hooks.add(message.hook_id);
106
+ break;
107
+ case 'hook_response':
108
+ this.hooks.delete(message.hook_id);
109
+ break;
110
+ }
111
+ }
112
+ update(update) {
113
+ const air = update._meta?.jetbrains?.air;
114
+ if (update.sessionUpdate === 'session_info_update' && air !== undefined && 'goal' in air) {
115
+ this.goal = air.goal?.status === 'active';
116
+ }
117
+ if (update.sessionUpdate !== 'tool_call' && update.sessionUpdate !== 'tool_call_update')
118
+ return;
119
+ const tool = update._meta?.claudeCode?.toolName;
120
+ if (update.sessionUpdate === 'tool_call' && SCHEDULING.has(tool ?? ''))
121
+ this.calls.set(update.toolCallId, { tool });
122
+ const call = this.calls.get(update.toolCallId);
123
+ if (call === undefined)
124
+ return;
125
+ if (update.rawInput !== undefined)
126
+ call.input = update.rawInput;
127
+ if (update.content !== undefined)
128
+ call.content = update.content;
129
+ if (update.status === 'failed')
130
+ this.calls.delete(update.toolCallId);
131
+ if (update.status !== 'completed')
132
+ return;
133
+ this.calls.delete(update.toolCallId);
134
+ if (call.tool === 'CronCreate')
135
+ this.crons.set(update.toolCallId, JSON.stringify(call.content ?? []));
136
+ if (call.tool === 'ScheduleWakeup')
137
+ this.wakeup(call);
138
+ if (call.tool !== 'CronDelete')
139
+ return;
140
+ for (const [id, text] of this.crons)
141
+ if (text.includes(String(call.input?.id)))
142
+ this.crons.delete(id);
143
+ }
144
+ wakeup(call) {
145
+ if (call.input?.stop === true) {
146
+ this.wakeups = [];
147
+ return;
148
+ }
149
+ const time = WAKEUP.exec(JSON.stringify(call.content ?? []));
150
+ if (time === null) {
151
+ this.wakeups.push(Infinity);
152
+ return;
153
+ }
154
+ const fires = Date.now() + Number(time[4]) * 1000;
155
+ const due = new Date(fires);
156
+ due.setHours(Number(time[1]), Number(time[2]), Number(time[3]), 0);
157
+ if (due.getTime() - fires > HALF_DAY)
158
+ due.setDate(due.getDate() - 1);
159
+ if (fires - due.getTime() > HALF_DAY)
160
+ due.setDate(due.getDate() + 1);
161
+ this.wakeups.push(due.getTime());
162
+ }
163
+ durable() {
164
+ let text;
165
+ try {
166
+ text = readFileSync(join(this.cwd, '.claude', 'scheduled_tasks.json'), 'utf8');
167
+ }
168
+ catch (error) {
169
+ return error.code !== 'ENOENT';
170
+ }
171
+ try {
172
+ return JSON.parse(text).tasks?.length !== 0;
173
+ }
174
+ catch {
175
+ return true;
176
+ }
177
+ }
178
+ }
179
+ class CodexWork extends Work {
180
+ tapped;
181
+ threads = new Map();
182
+ queues = new Map();
183
+ goals = new Set();
184
+ items = new Set();
185
+ hooks = new Set();
186
+ starting = new Set();
187
+ settling = [];
188
+ memories = null;
189
+ lost = false;
190
+ server = null;
191
+ path = null;
192
+ socket = null;
193
+ asked = 0;
194
+ heard = 0;
195
+ proving = -1;
196
+ proven = -1;
197
+ constructor(changed, tapped) {
198
+ super(changed);
199
+ this.tapped = tapped;
200
+ }
201
+ async open(cli) {
202
+ this.path = join(socketDirectory(), `${randomUUID()}.sock`);
203
+ this.server = createServer((socket) => this.connected(socket));
204
+ this.server.listen(this.path);
205
+ await once(this.server, 'listening');
206
+ return { CODEX_PATH: codexLauncher(), HOUSE_KIT_CODEX: cli, HOUSE_KIT_CODEX_STREAM: this.path };
207
+ }
208
+ settled() {
209
+ return new Promise((resolve) => {
210
+ this.settling.push(resolve);
211
+ this.settle();
212
+ });
213
+ }
214
+ take(message) {
215
+ super.take(message);
216
+ this.heard++;
217
+ }
218
+ busy() {
219
+ if (super.busy() ||
220
+ this.lost ||
221
+ this.memories !== false ||
222
+ [...this.threads.values()].some(Boolean) ||
223
+ this.queues.size > 0 ||
224
+ this.goals.size > 0 ||
225
+ this.items.size > 0 ||
226
+ this.hooks.size > 0) {
227
+ return true;
228
+ }
229
+ if (this.proven === this.heard)
230
+ return false;
231
+ this.prove();
232
+ return true;
233
+ }
234
+ close() {
235
+ this.server?.close();
236
+ if (this.path !== null)
237
+ void rm(this.path, { force: true });
238
+ }
239
+ connected(socket) {
240
+ this.socket = socket;
241
+ let buffer = '';
242
+ socket.on('error', () => this.lose());
243
+ socket.on('close', () => this.lose());
244
+ socket.setEncoding('utf8').on('data', (chunk) => {
245
+ buffer += chunk;
246
+ for (let index = buffer.indexOf('\n'); index >= 0; index = buffer.indexOf('\n')) {
247
+ const message = this.parsed(buffer.slice(0, index));
248
+ buffer = buffer.slice(index + 1);
249
+ if (message !== null)
250
+ this.stream(message, socket);
251
+ }
252
+ this.settle();
253
+ this.changed();
254
+ });
255
+ }
256
+ parsed(line) {
257
+ try {
258
+ return JSON.parse(line);
259
+ }
260
+ catch {
261
+ this.lost = true;
262
+ return null;
263
+ }
264
+ }
265
+ lose() {
266
+ this.lost = true;
267
+ this.changed();
268
+ }
269
+ prove() {
270
+ if (this.proving === this.heard)
271
+ return;
272
+ this.proving = this.heard;
273
+ this.socket.write(`${JSON.stringify({ jsonrpc: '2.0', id: `${SYNC}${this.heard}`, method: 'house-kit/sync' })}\n`);
274
+ }
275
+ settle() {
276
+ if (this.starting.size === 0)
277
+ for (const resolve of this.settling.splice(0))
278
+ resolve();
279
+ }
280
+ stream(message, socket) {
281
+ const params = message.params;
282
+ if (message.method !== undefined)
283
+ this.tapped(message);
284
+ switch (message.method) {
285
+ case 'thread/status/changed':
286
+ this.threads.set(params.threadId, params.status.type === 'active' && params.status.activeFlags.length === 0);
287
+ break;
288
+ case 'thread/closed':
289
+ this.threads.delete(params.threadId);
290
+ break;
291
+ case 'thread/queue/changed':
292
+ this.queues.set(params.threadId, ++this.asked);
293
+ socket.write(`${JSON.stringify({ jsonrpc: '2.0', id: `${QUEUE_LIST}${this.asked}`, method: 'thread/queue/list', params: { threadId: params.threadId } })}\n`);
294
+ break;
295
+ case 'thread/goal/updated':
296
+ if (params.goal.status === 'active')
297
+ this.goals.add(params.threadId);
298
+ else
299
+ this.goals.delete(params.threadId);
300
+ break;
301
+ case 'thread/goal/cleared':
302
+ this.goals.delete(params.threadId);
303
+ break;
304
+ case 'item/started':
305
+ this.items.add(`${params.threadId} ${params.item.id}`);
306
+ break;
307
+ case 'item/completed':
308
+ this.items.delete(`${params.threadId} ${params.item.id}`);
309
+ break;
310
+ case 'hook/started':
311
+ this.hooks.add(params.run.id);
312
+ break;
313
+ case 'hook/completed':
314
+ this.hooks.delete(params.run.id);
315
+ break;
316
+ case 'mcpServer/startupStatus/updated':
317
+ if (params.status === 'starting')
318
+ this.starting.add(`${params.threadId} ${params.name}`);
319
+ else
320
+ this.starting.delete(`${params.threadId} ${params.name}`);
321
+ break;
322
+ case undefined:
323
+ this.answered(message);
324
+ }
325
+ }
326
+ answered(message) {
327
+ if (typeof message.id === 'string' && message.id.startsWith(SYNC)) {
328
+ this.proven = Number(message.id.slice(SYNC.length));
329
+ }
330
+ else if (typeof message.id === 'string' && message.id.startsWith(QUEUE_LIST)) {
331
+ const asked = Number(message.id.slice(QUEUE_LIST.length));
332
+ for (const [thread, latest] of this.queues) {
333
+ if (latest === asked && message.result?.data?.length === 0)
334
+ this.queues.delete(thread);
335
+ }
336
+ }
337
+ else if (message.result?.config?.features !== undefined) {
338
+ this.memories = message.result.config.features.memories !== false;
339
+ }
340
+ }
341
+ }
342
+ class GrokWork extends Work {
343
+ busy() {
344
+ return true;
345
+ }
346
+ }
347
+ export function workFor(kind, cwd, changed, tapped) {
348
+ if (kind === 'claude-agent-acp')
349
+ return new ClaudeWork(cwd, changed);
350
+ if (kind === 'codex-acp')
351
+ return new CodexWork(changed, tapped);
352
+ return new GrokWork(changed);
353
+ }
@@ -0,0 +1,103 @@
1
+ import { cp, lstat, mkdir, readdir, readFile, rename, rm, rmdir, writeFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ export async function present(path) {
4
+ try {
5
+ return await lstat(path);
6
+ }
7
+ catch (error) {
8
+ if (error.code === 'ENOENT')
9
+ return null;
10
+ throw error;
11
+ }
12
+ }
13
+ async function listed(path) {
14
+ const entries = await readdir(path, { recursive: true, withFileTypes: true });
15
+ const shown = await Promise.all(entries.map(async (entry) => {
16
+ const at = join(entry.parentPath, entry.name);
17
+ return `${at.slice(path.length)} ${entry.isFile() ? (await lstat(at)).size : entry.isDirectory() ? 'folder' : 'link'}`;
18
+ }));
19
+ return shown.sort();
20
+ }
21
+ async function moved(source, target) {
22
+ try {
23
+ await rename(source, target);
24
+ return;
25
+ }
26
+ catch (error) {
27
+ if (error.code !== 'EXDEV')
28
+ throw error;
29
+ }
30
+ const copy = `${target}.moving`;
31
+ await rm(copy, { recursive: true, force: true });
32
+ try {
33
+ await cp(source, copy, { recursive: true, preserveTimestamps: true, verbatimSymlinks: true });
34
+ const folder = (await lstat(source)).isDirectory();
35
+ if (folder && JSON.stringify(await listed(source)) !== JSON.stringify(await listed(copy))) {
36
+ throw new Error(`${source} could not be copied to ${target} whole`);
37
+ }
38
+ }
39
+ catch (error) {
40
+ await rm(copy, { recursive: true, force: true });
41
+ throw error;
42
+ }
43
+ await rename(copy, target);
44
+ await rm(source, { recursive: true, force: true });
45
+ }
46
+ export async function merged(from, to, placed = () => 'moves') {
47
+ const found = await present(from);
48
+ if (found === null || !found.isDirectory())
49
+ return;
50
+ await mkdir(to, { recursive: true, mode: 0o700 });
51
+ for (const entry of await readdir(from, { withFileTypes: true })) {
52
+ const source = join(from, entry.name);
53
+ const placement = placed(source, entry);
54
+ if (placement === 'stays')
55
+ continue;
56
+ const target = join(to, entry.name);
57
+ const held = await present(target);
58
+ if (held === null && placement === 'moves')
59
+ await moved(source, target);
60
+ else if (entry.isDirectory() && (held === null || held.isDirectory()))
61
+ await merged(source, target, placed);
62
+ else
63
+ await rm(source, { recursive: true, force: true });
64
+ }
65
+ await removeFolder(from);
66
+ }
67
+ export async function removeFolder(path) {
68
+ await rmdir(path).catch((error) => {
69
+ if (error.code !== 'ENOTEMPTY' && error.code !== 'ENOENT')
70
+ throw error;
71
+ });
72
+ }
73
+ export function within(path, folder) {
74
+ return path === folder || path.startsWith(`${folder}/`);
75
+ }
76
+ function rewritten(value, from, to, kept) {
77
+ if (typeof value === 'string') {
78
+ if (kept.some((folder) => within(value, folder)) || (within(to, from) && within(value, to)) || !within(value, from))
79
+ return value;
80
+ return `${to}${value.slice(from.length)}`;
81
+ }
82
+ if (Array.isArray(value))
83
+ return value.map((item) => rewritten(item, from, to, kept));
84
+ if (typeof value === 'object' && value !== null) {
85
+ return Object.fromEntries(Object.entries(value).map(([name, held]) => [name, rewritten(held, from, to, kept)]));
86
+ }
87
+ return value;
88
+ }
89
+ export async function followRoot(records, from, to, kept = []) {
90
+ if (from === to)
91
+ return;
92
+ for (const name of await readdir(records).catch(() => [])) {
93
+ if (!name.endsWith('.json'))
94
+ continue;
95
+ const path = join(records, name);
96
+ const text = await readFile(path, 'utf8');
97
+ const next = `${JSON.stringify(rewritten(JSON.parse(text), from, to, kept))}\n`;
98
+ if (next.trim() === text.trim())
99
+ continue;
100
+ await writeFile(`${path}.new`, next, { mode: 0o600 });
101
+ await rename(`${path}.new`, path);
102
+ }
103
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agentshouse/kit",
3
- "version": "0.2.1-ce145e9aadbf6",
4
- "description": "House Kit connects an Environment to agents.house.",
3
+ "version": "0.2.1-ce46b2b55463f",
4
+ "description": "Kit connects an Environment to agents.house.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -12,27 +12,31 @@
12
12
  "kit": "dist/kit-main.js",
13
13
  "house": "dist/house-main.js"
14
14
  },
15
- "exports": {
16
- "./bootstrap": "./dist/bootstrap.json"
17
- },
18
15
  "files": [
19
- "dist",
20
- "how-we-work.md",
21
- "skills"
16
+ "dist"
22
17
  ],
23
18
  "scripts": {
24
- "build": "tsc -p tsconfig.build.json && node scripts/bootstrap-manifest.mjs",
19
+ "bootstrap-manifest": "node scripts/bootstrap-manifest.mjs",
20
+ "build": "tsc -p tsconfig.build.json",
25
21
  "engine": "mkdir -p tmp/engine && docker run --rm -v \"$PWD:/kit\" -w /kit alpine:3.24@sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6 sh scripts/engine.sh tmp/engine",
22
+ "follow-skills-and-kit-wire": "node scripts/follow-skills-and-kit-wire.mjs",
23
+ "release-files": "node scripts/release-files.mjs",
26
24
  "test": "tsc -p tsconfig.json && vitest run"
27
25
  },
28
26
  "dependencies": {
29
- "@agentclientprotocol/sdk": "1.7.0",
30
- "@agentshouse/mdmodel": "0.1.0-alpha.19",
27
+ "@agentclientprotocol/sdk": "2.4.0",
28
+ "@agentshouse/kit-wire": "0.1.0-cc6eaf0c9a296",
29
+ "@agentshouse/mdmodel": "0.1.0-cd6a8e5bc7efc",
30
+ "@agentshouse/session-content": "0.1.0-c560e48c9bea3",
31
+ "@agentshouse/skills": "0.1.0-c0286f9b00d01",
32
+ "@lydell/node-pty": "1.2.0-beta.15",
33
+ "micromark": "4.0.2",
34
+ "smol-toml": "1.9.1",
31
35
  "yaml": "2.9.1"
32
36
  },
33
37
  "peerDependencies": {
34
- "@agentclientprotocol/claude-agent-acp": "0.85.1",
35
- "@agentclientprotocol/codex-acp": "2.1.1"
38
+ "@agentclientprotocol/claude-agent-acp": "0.100.0",
39
+ "@agentclientprotocol/codex-acp": "2.5.0"
36
40
  },
37
41
  "peerDependenciesMeta": {
38
42
  "@agentclientprotocol/claude-agent-acp": {
@@ -43,26 +47,27 @@
43
47
  }
44
48
  },
45
49
  "devDependencies": {
46
- "@types/node": "24.13.6",
50
+ "@types/node": "24.19.2",
47
51
  "@types/ws": "8.18.2",
48
52
  "typescript": "7.0.2",
49
- "vitest": "5.0.1",
50
- "ws": "8.22.0"
53
+ "vitest": "5.0.5",
54
+ "ws": "8.22.0",
55
+ "zod": "4.6.7"
51
56
  },
52
- "packageManager": "npm@11.19.0",
57
+ "packageManager": "npm@11.19.1",
53
58
  "engines": {
54
- "node": "24.21.0",
55
- "npm": "11.19.0"
59
+ "node": "24.22.1",
60
+ "npm": "11.19.1"
56
61
  },
57
62
  "devEngines": {
58
63
  "runtime": {
59
64
  "name": "node",
60
- "version": "24.21.0",
65
+ "version": "24.22.1",
61
66
  "onFail": "error"
62
67
  },
63
68
  "packageManager": {
64
69
  "name": "npm",
65
- "version": "11.19.0",
70
+ "version": "11.19.1",
66
71
  "onFail": "error"
67
72
  }
68
73
  }
@@ -1,22 +0,0 @@
1
- import { setGlobalProxyFromEnv } from 'node:http';
2
- import { HouseRefusal, post } from './api.js';
3
- import { readEnrolment } from './home.js';
4
- function unanswered(error) {
5
- return error instanceof HouseRefusal ? error.status >= 500 : error instanceof TypeError && error.message === 'fetch failed';
6
- }
7
- setGlobalProxyFromEnv();
8
- try {
9
- const { house, credential } = (await readEnrolment());
10
- try {
11
- await post(house, '/kit/agents/desired', {}, credential);
12
- }
13
- catch (error) {
14
- if (!unanswered(error))
15
- throw error;
16
- process.stderr.write(`kit: House did not answer, so the stored credential stands: ${error.message}\n`);
17
- }
18
- }
19
- catch (error) {
20
- process.stderr.write(`kit: ${error.message}\n`);
21
- process.exitCode = 1;
22
- }
package/dist/blocks.js DELETED
@@ -1,51 +0,0 @@
1
- const FENCE = /^\s*(`{3,}|~{3,})\s*(\S*)/;
2
- export function blocksOf(text) {
3
- const blocks = [];
4
- let paragraph = [];
5
- let fence = null;
6
- const closeParagraph = () => {
7
- const joined = paragraph.join('\n').trim();
8
- if (joined.length > 0)
9
- blocks.push({ type: 'paragraph', text: joined });
10
- paragraph = [];
11
- };
12
- const closeFence = () => {
13
- const joined = fence.lines.join('\n');
14
- if (joined.length > 0)
15
- blocks.push({ type: 'code', language: fence.language, text: joined });
16
- fence = null;
17
- };
18
- for (const line of text.split('\n')) {
19
- if (fence !== null) {
20
- if (line.trim().startsWith(fence.marker))
21
- closeFence();
22
- else
23
- fence.lines.push(line);
24
- continue;
25
- }
26
- const opening = FENCE.exec(line);
27
- if (opening !== null) {
28
- closeParagraph();
29
- fence = { marker: opening[1], language: opening[2] || null, lines: [] };
30
- }
31
- else if (line.trim().length === 0) {
32
- closeParagraph();
33
- }
34
- else {
35
- paragraph.push(line);
36
- }
37
- }
38
- if (fence !== null)
39
- closeFence();
40
- closeParagraph();
41
- return blocks;
42
- }
43
- export function firstChange(before, after) {
44
- let index = 0;
45
- while (index < before.length &&
46
- index < after.length &&
47
- JSON.stringify(before[index]) === JSON.stringify(after[index])) {
48
- index++;
49
- }
50
- return index;
51
- }
@@ -1,24 +0,0 @@
1
- {
2
- "schemaVersion": 2,
3
- "version": "0.2.1-ce145e9aadbf6",
4
- "hosts": {
5
- "macos": {
6
- "asset": {
7
- "name": "connect-linux.sh",
8
- "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-ce145e9aadbf6/connect-linux.sh"
9
- }
10
- },
11
- "linux": {
12
- "asset": {
13
- "name": "connect-linux.sh",
14
- "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-ce145e9aadbf6/connect-linux.sh"
15
- }
16
- },
17
- "windows": {
18
- "asset": {
19
- "name": "connect-windows.ps1",
20
- "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-ce145e9aadbf6/connect-windows.ps1"
21
- }
22
- }
23
- }
24
- }
package/dist/clis-main.js DELETED
@@ -1,23 +0,0 @@
1
- import { setGlobalProxyFromEnv } from 'node:http';
2
- import { post } from './api.js';
3
- import { CLIS, below, locate, versionOf } from './clis.js';
4
- import { readEnrolment } from './home.js';
5
- setGlobalProxyFromEnv();
6
- try {
7
- const { house, credential } = (await readEnrolment());
8
- const { agents } = await post(house, '/kit/agents/desired', {}, credential);
9
- for (const kind of agents) {
10
- const cli = await locate(kind);
11
- if (cli === null)
12
- continue;
13
- const release = await versionOf(cli);
14
- if (release === null)
15
- continue;
16
- const { bin, minimum } = CLIS[kind];
17
- process.stdout.write(`${[bin, cli, release, minimum, below(release, minimum) ? 'old' : 'current'].join('\t')}\n`);
18
- }
19
- }
20
- catch (error) {
21
- process.stderr.write(`kit: ${error.message}\n`);
22
- process.exitCode = 1;
23
- }
@@ -1,6 +0,0 @@
1
- import { readConfiguration, writeConfiguration } from './home.js';
2
- const skills = !process.argv.slice(2).includes('--no-skills');
3
- const stored = await readConfiguration();
4
- await writeConfiguration({ skills });
5
- if (stored.skills !== skills)
6
- process.stdout.write('changed\n');
@@ -1,4 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { writeEnrolment } from './home.js';
3
- const [house, environment] = process.argv.slice(2);
4
- await writeEnrolment({ house: house, environment: environment, credential: readFileSync(0, 'utf8').trim() });