@agentshouse/kit 0.2.1-cca9e1f43de44 → 0.2.1-ccb257fa8a318
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/README.md +42 -40
- package/dist/acp.js +92 -115
- package/dist/agents.js +112 -24
- package/dist/api.js +10 -6
- package/dist/app-git.js +10 -26
- package/dist/authority-main.js +2 -2
- package/dist/bridge.js +11 -25
- package/dist/building.js +46 -0
- package/dist/calls.js +71 -0
- package/dist/chatgpt.js +32 -0
- package/dist/clis-main.js +2 -2
- package/dist/clis.js +131 -27
- package/dist/codex-main.js +58 -0
- package/dist/connection.js +116 -0
- package/dist/conversations.js +523 -202
- package/dist/copies.js +185 -123
- package/dist/end.js +24 -5
- package/dist/enrol-main.js +7 -1
- package/dist/events.js +16 -78
- package/dist/files.js +139 -31
- package/dist/git.js +13 -11
- package/dist/home.js +96 -7
- package/dist/house-cli.js +299 -0
- package/dist/house-main.js +7 -177
- package/dist/instructions.js +8 -10
- package/dist/kit-cli.js +68 -0
- package/dist/kit-main.js +8 -22
- package/dist/login.js +118 -107
- package/dist/logout.js +14 -16
- package/dist/mcp.js +6 -2
- package/dist/parts.js +34 -16
- package/dist/placement.js +39 -0
- package/dist/relay.js +33 -2
- package/dist/resident.js +118 -51
- package/dist/scope.js +206 -0
- package/dist/scripts.js +255 -0
- package/dist/service-main.js +9 -0
- package/dist/service.js +55 -0
- package/dist/sign-in.js +23 -40
- package/dist/silence.js +28 -0
- package/dist/skills.js +49 -35
- package/dist/transcription.js +85 -45
- package/dist/translate.js +2 -8
- package/dist/update.js +115 -53
- package/dist/wire.js +22 -0
- package/dist/work.js +346 -0
- package/package.json +20 -20
- package/dist/bootstrap.json +0 -24
- package/dist/stream.js +0 -72
- package/how-we-work.md +0 -23
- package/skills/ask-matt/LICENSE +0 -21
- package/skills/ask-matt/PHASE-BOUNDARIES.md +0 -55
- package/skills/ask-matt/SKILL.md +0 -91
- package/skills/ask-matt/agents/openai.yaml +0 -4
- package/skills/code-review/LICENSE +0 -21
- package/skills/code-review/SKILL.md +0 -89
- package/skills/code-review/agents/openai.yaml +0 -3
- package/skills/codebase-design/DEEPENING.md +0 -37
- package/skills/codebase-design/DESIGN-IT-TWICE.md +0 -44
- package/skills/codebase-design/LICENSE +0 -21
- package/skills/codebase-design/SKILL.md +0 -116
- package/skills/codebase-design/agents/openai.yaml +0 -3
- package/skills/diagnosing-bugs/LICENSE +0 -21
- package/skills/diagnosing-bugs/SKILL.md +0 -140
- package/skills/diagnosing-bugs/agents/openai.yaml +0 -3
- package/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -44
- package/skills/domain-modeling/ADR-FORMAT.md +0 -47
- package/skills/domain-modeling/CONTEXT-FORMAT.md +0 -60
- package/skills/domain-modeling/LICENSE +0 -21
- package/skills/domain-modeling/SKILL.md +0 -76
- package/skills/domain-modeling/agents/openai.yaml +0 -3
- package/skills/grill-me/LICENSE +0 -21
- package/skills/grill-me/SKILL.md +0 -8
- package/skills/grill-me/agents/openai.yaml +0 -4
- package/skills/grill-with-docs/LICENSE +0 -21
- package/skills/grill-with-docs/SKILL.md +0 -8
- package/skills/grill-with-docs/agents/openai.yaml +0 -4
- package/skills/grilling/LICENSE +0 -21
- package/skills/grilling/SKILL.md +0 -30
- package/skills/grilling/agents/openai.yaml +0 -3
- package/skills/handoff/LICENSE +0 -21
- package/skills/handoff/SKILL.md +0 -17
- package/skills/handoff/agents/openai.yaml +0 -4
- package/skills/implement/LICENSE +0 -21
- package/skills/implement/SKILL.md +0 -16
- package/skills/implement/agents/openai.yaml +0 -4
- package/skills/improve-codebase-architecture/HTML-REPORT.md +0 -123
- package/skills/improve-codebase-architecture/LICENSE +0 -21
- package/skills/improve-codebase-architecture/SKILL.md +0 -72
- package/skills/improve-codebase-architecture/agents/openai.yaml +0 -4
- package/skills/prototype/LICENSE +0 -21
- package/skills/prototype/LOGIC.md +0 -67
- package/skills/prototype/SKILL.md +0 -28
- package/skills/prototype/UI.md +0 -112
- package/skills/prototype/agents/openai.yaml +0 -3
- package/skills/research/LICENSE +0 -21
- package/skills/research/SKILL.md +0 -14
- package/skills/research/agents/openai.yaml +0 -3
- package/skills/resolving-merge-conflicts/LICENSE +0 -21
- package/skills/resolving-merge-conflicts/SKILL.md +0 -16
- package/skills/resolving-merge-conflicts/agents/openai.yaml +0 -3
- package/skills/tdd/LICENSE +0 -21
- package/skills/tdd/SKILL.md +0 -40
- package/skills/tdd/agents/openai.yaml +0 -3
- package/skills/tdd/mocking.md +0 -59
- package/skills/tdd/tests.md +0 -77
- package/skills/teach/GLOSSARY-FORMAT.md +0 -35
- package/skills/teach/LEARNING-RECORD-FORMAT.md +0 -46
- package/skills/teach/LICENSE +0 -21
- package/skills/teach/MISSION-FORMAT.md +0 -31
- package/skills/teach/RESOURCES-FORMAT.md +0 -32
- package/skills/teach/SKILL.md +0 -141
- package/skills/teach/agents/openai.yaml +0 -4
- package/skills/to-questionnaire/LICENSE +0 -21
- package/skills/to-questionnaire/SKILL.md +0 -55
- package/skills/to-questionnaire/agents/openai.yaml +0 -4
- package/skills/to-spec/LICENSE +0 -21
- package/skills/to-spec/SKILL.md +0 -76
- package/skills/to-spec/agents/openai.yaml +0 -4
- package/skills/to-tickets/LICENSE +0 -21
- package/skills/to-tickets/SKILL.md +0 -106
- package/skills/to-tickets/agents/openai.yaml +0 -4
- package/skills/wait-what/LICENSE +0 -21
- package/skills/wait-what/SKILL.md +0 -8
- package/skills/wait-what/agents/openai.yaml +0 -4
- package/skills/wayfinder/LICENSE +0 -21
- package/skills/wayfinder/SKILL.md +0 -129
- package/skills/wayfinder/agents/openai.yaml +0 -4
- package/skills/writing-for-agents/LICENSE +0 -21
- package/skills/writing-for-agents/SKILL-MECHANICS.md +0 -22
- package/skills/writing-for-agents/SKILL.md +0 -83
- package/skills/writing-for-agents/agents/openai.yaml +0 -3
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { connect } from 'node:net';
|
|
4
|
+
const KIT_ANSWER = '"house-kit-';
|
|
5
|
+
const SYNC = 'house-kit/sync';
|
|
6
|
+
function lines(each) {
|
|
7
|
+
let buffer = '';
|
|
8
|
+
return (chunk) => {
|
|
9
|
+
buffer += chunk;
|
|
10
|
+
for (let index = buffer.indexOf('\n'); index >= 0; index = buffer.indexOf('\n')) {
|
|
11
|
+
each(buffer.slice(0, index + 1));
|
|
12
|
+
buffer = buffer.slice(index + 1);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function answersKit(line) {
|
|
17
|
+
if (!line.includes(KIT_ANSWER))
|
|
18
|
+
return false;
|
|
19
|
+
try {
|
|
20
|
+
const message = JSON.parse(line);
|
|
21
|
+
return message.method === undefined && typeof message.id === 'string' && message.id.startsWith(KIT_ANSWER.slice(1));
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const args = process.argv.slice(2);
|
|
28
|
+
const serving = args[0] === 'app-server';
|
|
29
|
+
if (process.env.HOUSE_KIT_SANDBOX === '1' && serving)
|
|
30
|
+
args.push('--disable', 'memories');
|
|
31
|
+
const codex = spawn(process.env.HOUSE_KIT_CODEX, args, { stdio: ['pipe', 'pipe', 'inherit'] });
|
|
32
|
+
const stream = serving ? connect(process.env.HOUSE_KIT_CODEX_STREAM) : null;
|
|
33
|
+
stream?.on('error', () => undefined);
|
|
34
|
+
process.stdin.setEncoding('utf8').on('data', lines((line) => codex.stdin.write(line)));
|
|
35
|
+
process.stdin.on('end', () => codex.stdin.end());
|
|
36
|
+
stream?.setEncoding('utf8').on('data', lines((line) => {
|
|
37
|
+
const message = JSON.parse(line);
|
|
38
|
+
if (message.method === SYNC)
|
|
39
|
+
stream.write(`${JSON.stringify({ jsonrpc: '2.0', id: message.id, result: {} })}\n`);
|
|
40
|
+
else
|
|
41
|
+
codex.stdin.write(line);
|
|
42
|
+
}));
|
|
43
|
+
codex.stdout.setEncoding('utf8').on('data', lines((line) => {
|
|
44
|
+
stream?.write(line);
|
|
45
|
+
if (answersKit(line) || process.stdout.write(line))
|
|
46
|
+
return;
|
|
47
|
+
codex.stdout.pause();
|
|
48
|
+
process.stdout.once('drain', () => codex.stdout.resume());
|
|
49
|
+
}));
|
|
50
|
+
codex.stdin.on('error', () => undefined);
|
|
51
|
+
for (const signal of ['SIGTERM', 'SIGINT', 'SIGHUP'])
|
|
52
|
+
process.on(signal, () => codex.kill(signal));
|
|
53
|
+
codex.on('exit', (code, signal) => {
|
|
54
|
+
if (signal === null)
|
|
55
|
+
process.exit(code ?? 1);
|
|
56
|
+
process.removeAllListeners(signal);
|
|
57
|
+
process.kill(process.pid, signal);
|
|
58
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { subscribe } from 'node:diagnostics_channel';
|
|
2
|
+
import { HouseRefusal, retryDelay } from './api.js';
|
|
3
|
+
import { end, REPLACED, signInAgain } from './end.js';
|
|
4
|
+
import { readEnrolment } from './home.js';
|
|
5
|
+
import { relayed } from './relay.js';
|
|
6
|
+
import { Silence } from './silence.js';
|
|
7
|
+
import { endUnserved, KIT_WIRE } from './wire.js';
|
|
8
|
+
const PATH = '/kit/stream';
|
|
9
|
+
const SUBPROTOCOL = `house.kit.stream.${KIT_WIRE}`;
|
|
10
|
+
const REFUSAL_HEADER = 'x-house-refusal';
|
|
11
|
+
// House beats each Kit connection every thirty seconds, so two silent beats mean this Kit process cannot hear House.
|
|
12
|
+
export const CONNECTION_SILENCE_MS = 60_000;
|
|
13
|
+
function connectionUrl(house) {
|
|
14
|
+
const url = new URL(PATH, house);
|
|
15
|
+
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
16
|
+
return url;
|
|
17
|
+
}
|
|
18
|
+
function header(headers, name) {
|
|
19
|
+
for (let index = 0; index < headers.length; index += 2) {
|
|
20
|
+
if (headers[index].toString('latin1').toLowerCase() === name)
|
|
21
|
+
return headers[index + 1].toString('latin1');
|
|
22
|
+
}
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
let refused = null;
|
|
26
|
+
subscribe('undici:request:headers', (message) => {
|
|
27
|
+
const { request, response } = message;
|
|
28
|
+
if (!request.path.endsWith(PATH))
|
|
29
|
+
return;
|
|
30
|
+
refused = new HouseRefusal(PATH, response.statusCode, header(response.headers, REFUSAL_HEADER) || response.statusText);
|
|
31
|
+
});
|
|
32
|
+
export function holdConnection(handlers) {
|
|
33
|
+
let connection = null;
|
|
34
|
+
let socket = null;
|
|
35
|
+
let paused = false;
|
|
36
|
+
let failures = 0;
|
|
37
|
+
const connect = async () => {
|
|
38
|
+
const { house, credential } = (await readEnrolment());
|
|
39
|
+
if (paused || socket !== null)
|
|
40
|
+
return;
|
|
41
|
+
refused = null;
|
|
42
|
+
const opening = new WebSocket(relayed(connectionUrl(house)), {
|
|
43
|
+
protocols: [SUBPROTOCOL],
|
|
44
|
+
headers: { authorization: `Bearer ${credential}` },
|
|
45
|
+
});
|
|
46
|
+
socket = opening;
|
|
47
|
+
let opened = false;
|
|
48
|
+
let silence = null;
|
|
49
|
+
const closed = (event) => {
|
|
50
|
+
silence?.stop();
|
|
51
|
+
silence = null;
|
|
52
|
+
if (socket === opening)
|
|
53
|
+
socket = null;
|
|
54
|
+
if (connection === opening)
|
|
55
|
+
connection = null;
|
|
56
|
+
handlers.closed();
|
|
57
|
+
process.stderr.write(`kit: connection closed ${event.code} ${event.reason}\n`);
|
|
58
|
+
if (event.reason === 'replaced')
|
|
59
|
+
end(REPLACED);
|
|
60
|
+
if (event.reason === 'credential_rejected' || refused?.status === 401) {
|
|
61
|
+
void signInAgain(credential);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (refused !== null)
|
|
65
|
+
endUnserved(refused.text);
|
|
66
|
+
if (!opened && refused !== null)
|
|
67
|
+
process.stderr.write(`kit: ${refused.message}\n`);
|
|
68
|
+
if (paused)
|
|
69
|
+
return;
|
|
70
|
+
// A closed connection reopens in one to three seconds, spread so Kit processes one restart closed return apart; an opening House refused or left unanswered backs off on the jittered curve, retryable or not, since a resident outlives a House deploy.
|
|
71
|
+
setTimeout(() => void connect(), opened ? 1000 + Math.random() * 2000 : retryDelay(failures++));
|
|
72
|
+
};
|
|
73
|
+
opening.onopen = () => {
|
|
74
|
+
opened = true;
|
|
75
|
+
failures = 0;
|
|
76
|
+
connection = opening;
|
|
77
|
+
silence = new Silence(CONNECTION_SILENCE_MS, () => {
|
|
78
|
+
if (connection !== opening)
|
|
79
|
+
return;
|
|
80
|
+
connection = null;
|
|
81
|
+
opening.onclose = null;
|
|
82
|
+
opening.close();
|
|
83
|
+
closed(new CloseEvent('close', { code: 1006, reason: 'heartbeat_missed' }));
|
|
84
|
+
});
|
|
85
|
+
silence.heard();
|
|
86
|
+
handlers.opened();
|
|
87
|
+
};
|
|
88
|
+
opening.onmessage = (event) => {
|
|
89
|
+
silence?.heard();
|
|
90
|
+
const arrived = JSON.parse(String(event.data));
|
|
91
|
+
if (arrived.type === 'input')
|
|
92
|
+
handlers.call(arrived);
|
|
93
|
+
else if (arrived.type !== 'beat')
|
|
94
|
+
handlers.notification(arrived);
|
|
95
|
+
};
|
|
96
|
+
opening.onerror = () => undefined;
|
|
97
|
+
opening.onclose = closed;
|
|
98
|
+
};
|
|
99
|
+
void connect();
|
|
100
|
+
return {
|
|
101
|
+
send(notification) {
|
|
102
|
+
if (connection === null || connection.readyState !== WebSocket.OPEN)
|
|
103
|
+
return false;
|
|
104
|
+
connection.send(JSON.stringify(notification));
|
|
105
|
+
return true;
|
|
106
|
+
},
|
|
107
|
+
pause() {
|
|
108
|
+
paused = true;
|
|
109
|
+
socket?.close();
|
|
110
|
+
return () => {
|
|
111
|
+
paused = false;
|
|
112
|
+
void connect();
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|