@agentshouse/kit 0.2.1-cd9cbd8b6428c → 0.2.1-cdc381ebf021f
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 -49
- package/dist/acp.js +102 -108
- package/dist/afk.js +17 -0
- package/dist/agents.js +256 -69
- package/dist/api.js +43 -6
- package/dist/app-git.js +48 -0
- package/dist/bridge.js +42 -62
- package/dist/building.js +50 -0
- package/dist/calls.js +88 -0
- package/dist/chunks.js +49 -0
- package/dist/clis.js +169 -95
- package/dist/codex-main.js +58 -0
- package/dist/connect.js +108 -0
- package/dist/connection.js +120 -0
- package/dist/content.js +106 -0
- package/dist/conversations.js +817 -333
- package/dist/copies.js +450 -251
- package/dist/earlier.js +263 -0
- package/dist/end.js +26 -0
- package/dist/events.js +793 -0
- package/dist/files.js +139 -17
- package/dist/git.js +57 -21
- package/dist/grok.js +39 -0
- package/dist/home.js +122 -8
- package/dist/house-cli.js +359 -0
- package/dist/house-main.js +7 -159
- package/dist/instructions.js +7 -11
- package/dist/kit-cli.js +78 -0
- package/dist/kit-main.js +8 -19
- package/dist/login.js +133 -104
- package/dist/logout.js +15 -14
- package/dist/mcp.js +6 -2
- package/dist/owner.js +46 -0
- package/dist/placement.js +25 -0
- package/dist/refusals.js +12 -0
- package/dist/relay.js +33 -2
- package/dist/resident.js +161 -61
- package/dist/scope.js +214 -0
- package/dist/scripts.js +303 -0
- package/dist/secret-input.js +5 -2
- package/dist/settings.js +188 -0
- package/dist/shell.js +3 -0
- package/dist/sign-in.js +40 -32
- package/dist/silence.js +28 -0
- package/dist/skills.js +49 -35
- package/dist/supervisor.js +163 -0
- package/dist/transcription.js +131 -40
- package/dist/translate.js +19 -16
- package/dist/update.js +119 -100
- package/dist/wire.js +32 -0
- package/dist/work.js +353 -0
- package/dist/workspace.js +103 -0
- package/package.json +25 -21
- package/dist/authority-main.js +0 -22
- package/dist/blocks.js +0 -51
- package/dist/bootstrap.json +0 -24
- package/dist/clis-main.js +0 -23
- package/dist/configure-main.js +0 -6
- package/dist/enrol-main.js +0 -4
- package/dist/stream.js +0 -47
- 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
package/README.md
CHANGED
|
@@ -1,59 +1,52 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Kit
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
through the agent CLIs you chose and gives each Agent the `house` command.
|
|
3
|
+
Kit connects an Environment, a Linux computer or server, to [agents.house](https://agents.house). It runs
|
|
4
|
+
your Agents' conversations through the agent CLIs you chose and gives each Agent the `house` command.
|
|
6
5
|
|
|
7
6
|
## Install
|
|
8
7
|
|
|
9
|
-
Run `curl -fsSL
|
|
10
|
-
Windows, and again to update;
|
|
11
|
-
installs
|
|
12
|
-
|
|
13
|
-
your
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
House Kit runs the agent CLIs your login shell finds and installs a missing one
|
|
28
|
-
through that CLI's own installer. Running the command again offers to update
|
|
29
|
-
each CLI older than House Kit needs; add `--update-clis` to update every one to
|
|
30
|
-
its latest release without asking. House Kit also gives every Agent on the
|
|
31
|
-
Environment a set of agent skills. Add `--no-skills` to the command to leave
|
|
32
|
-
them out; running it again without the flag brings them back.
|
|
8
|
+
Run `sh -c 'kit=$(curl -fsSL "$0") || { echo "Kit could not be downloaded; run this command again." >&2; exit 1; }; eval "$kit"' agents.house/kit`,
|
|
9
|
+
or `& { try { $kit = irm agents.house/kit.ps1 } catch { throw 'Kit could not be downloaded; run this command again.' }; & ([scriptblock]::Create($kit)) @args }` on Windows, which run nothing of a failed download, and again to update; `--code <code>` follows `agents.house/kit` to connect with a login code.
|
|
10
|
+
On macOS and Linux, a server included, it installs Kit natively under your own account, without an admin password, in one folder, `~/.agents/house`: Kit's own files at its top, its releases and their Node.js in `kit`, `kit` and `house` in `bin`, which it adds to your login shell's `PATH`, and your workspace, the Agents' folders in `agents` and the Rooms' copies in `local-copies`. It stops, changing nothing, where `~/.agents/house` holds something that is not Kit's. On Linux it adds a missing `ca-certificates`, `curl` or `git` through apt. Then `kit connect` keeps the Environment you connected, redeems the login code or prints a link you confirm, writes Kit's settings where `kit.json` has none, places House's Skills and starts Kit: as a systemd user unit that starts at boot through lingering on Linux, and as a LaunchAgent on macOS. On a Linux without systemd it starts nothing: run the `kit resident` command it prints under your own service manager, restarting it whenever it ends with a failure. One account runs one Kit for one Building; to move it to another, run `kit logout` and then the other Building's command.
|
|
11
|
+
|
|
12
|
+
Every run places the Kit release your Building serves, with the Node.js and agent adapters it runs on, in a directory of its own beside the one that runs, then starts it; the earlier one stays until the next release. Kit also updates itself: when your Building takes another release, Kit places it the same way and, once no turn is open, ends so its service starts it. When House no longer serves the wire of the Kit that runs, Kit places your Building's release at once, ending any running turn, and ends the same way; while it cannot, it stays offline, prints why with the command that installs it again, and tries again regularly.
|
|
13
|
+
|
|
14
|
+
A Kit installed before moves itself into `~/.agents/house` on its next update, a Mac's or a Linux desktop's and one running as root; one in a container or under a system unit of another account asks you, on its Environment's page, to run the install command again on that computer, which moves it and removes the container or the unit, keeping its Environment.
|
|
15
|
+
|
|
16
|
+
On Windows the command, run in PowerShell, installs WSL where it is absent, asking you to restart only where Windows needs that and to run the command again after, and Ubuntu where WSL has none, with a default user named after yours; it turns on WSL's Keep WSL running, starts Ubuntu, with no window, when you sign in, and installs Kit inside Ubuntu as on Linux. The Linux command run in a WSL terminal recommends the Windows command instead and installs and starts Kit there only once you agree that it then runs only while a WSL terminal is open, and not after a restart; with no terminal to ask in, it installs nothing and names the Windows command. A Kit that ran in Docker Desktop's `house-kit` container moves into Ubuntu as the same Environment, its workspace kept where it was, and the command removes the container, keeping its volume.
|
|
17
|
+
|
|
18
|
+
Kit is built for macOS 27 on Apple silicon, Ubuntu 26.04 LTS on amd64 and Windows 11 on amd64. On another release, distribution or architecture the command prints one warning line, such as `Warning: macOS 26.7.1 is outdated; update to macOS 27.`, and installs anyway. It refuses only an architecture other than amd64 and arm64, a macOS older than 13.5 and a Linux without glibc 2.28 or newer.
|
|
19
|
+
|
|
20
|
+
Kit runs each agent CLI through the link your login shell finds and installs a missing one through that CLI's own
|
|
21
|
+
installer. When it starts and regularly after, Kit runs each CLI's own update command, such as `claude update`, beside
|
|
22
|
+
your conversations: a running conversation keeps its version and the next one runs the new release. A CLI older than
|
|
23
|
+
the oldest release Kit is built for still runs, though its conversations may fail: Kit tells House its version, that
|
|
24
|
+
oldest release and its update command. Kit also gives every Agent on the Environment the agent skills of
|
|
25
|
+
`@agentshouse/skills`, at the version each Kit release installs, unless its `skills` setting is off.
|
|
33
26
|
|
|
34
27
|
## Commands
|
|
35
28
|
|
|
36
|
-
`kit login` opens a link you confirm in
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
and
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
`kit resident` keeps the Environment connected, and keeps the Rooms you chose
|
|
46
|
-
for this Environment as Git repositories under `local-copies` in the
|
|
47
|
-
workspace. Commit in one and run `house push --owner` there to send the
|
|
48
|
-
commit to House; in the container, run it through the install command from the
|
|
49
|
-
copy's directory. Inside an Agent conversation the Agent runs `house push`.
|
|
50
|
-
|
|
51
|
-
House Kit turns each audio file of your message to an Agent into text on this
|
|
52
|
-
computer before the Agent reads the message. The first audio file downloads the
|
|
53
|
-
speech engine and model, about 425 MB, into `~/.house-kit`.
|
|
29
|
+
`kit login` opens or prints a link you confirm in any browser, on this computer or another, continues on its own and keeps the Environment's credential in `~/.agents/house`. `--environment <id>` reconnects an Environment you already have, which keeps its Rooms: its page in House changes them. A new Environment takes `--rooms <ref>[,<ref>...]` for only those Rooms and `--no-private` for every Room but your Private Room; `--code <code>` connects immediately without a link.
|
|
30
|
+
A login also connects your own agent: outside an Agent conversation, `house <tool>` calls
|
|
31
|
+
House as you and `git` clones and pushes your Apps at `<house>/app/` as you, each through the Kit
|
|
32
|
+
home of the account it runs as, until you revoke that connection on Connections. `house help` lists the Tools and `house help <tool>` one Tool's arguments. Codex sessions started after a
|
|
33
|
+
login run a lone `house` command outside their sandbox. `kit logout` disconnects this
|
|
34
|
+
computer, stops the Kit process and ends your own agent's connection, so `house` and `git` no
|
|
35
|
+
longer act as you here; a later `kit login` reconnects the same Environment, or connects
|
|
36
|
+
this computer as a new one when House no longer holds it.
|
|
54
37
|
|
|
55
|
-
|
|
38
|
+
`kit settings` prints Kit's two settings, which every update and every rerun of the install keep: `skills`, whether Kit places House's Skills, and `workspace`, the folder that holds `agents` and `local-copies`. `kit settings skills on|off` and `kit settings workspace <absolute path>` change one, as the Environment's page in House does.
|
|
39
|
+
A new workspace must hold no `agents` or `local-copies` folder, and none is taken while an Agent works; Kit then ends its conversations' processes, moves both folders there, across filesystems copying and checking them before it deletes the old ones, and ends so its service starts it there.
|
|
40
|
+
|
|
41
|
+
`kit resident` keeps the Environment connected and, as it connects, copies the text of each Room you chose for it as a
|
|
42
|
+
Git repository in the workspace's `local-copies`, and keeps a Room's copy as it is, no longer refreshing it, once the
|
|
43
|
+
Room may no longer be copied here. `house fetch` does the same and records House's changes on each copy's
|
|
44
|
+
`refs/house/received`; rebase onto it, commit and run `house push --owner` in the copy. An Agent runs both, without `--owner`. `house upload` and `house download` move a Room's other files straight between disk and House's store, and a broken upload resumes on its own.
|
|
45
|
+
|
|
46
|
+
Kit turns each audio file your message to an Agent links into text on this computer before the Agent reads it, and keeps a message whose audio it cannot turn into text from starting. While transcription is on, the speech engine and model use about 425 MB beside the Environment's credential; turning it off deletes them.
|
|
56
47
|
|
|
57
|
-
|
|
48
|
+
When you press Run on a Web Wizard's page, Kit runs its script with `bash` in a terminal on this computer, as you, in the home and directory it runs agent CLIs from, with your login shell's `PATH`; the page shows that terminal and takes your typing, and closing the page, or Kit losing its connection to House, ends the script and its child processes. Kit keeps nothing the script prints or you type. A script you keep as a function from a Web Wizard runs as you, from the same home, directory and `PATH`, when a Trigger of your Private Room or your agent runs it, with no terminal and nothing on its standard input, and when you press Run now on its page, in a terminal you can type into. Kit writes the run's input as JSON to a file only you can read, whose path is in `HOUSE_INPUT`, and deletes it when the run ends; it ends the script and its child processes at the run's time limit or when it loses its connection to House, and sends House the end of what the script printed, up to the run's output limit, without any line that holds a line you typed.
|
|
49
|
+
|
|
50
|
+
## License
|
|
58
51
|
|
|
59
|
-
|
|
52
|
+
MIT.
|
package/dist/acp.js
CHANGED
|
@@ -1,48 +1,113 @@
|
|
|
1
|
-
import { ndJsonStream, PROTOCOL_VERSION, } from '@agentclientprotocol/sdk';
|
|
2
|
-
import {
|
|
3
|
-
import { readdirSync, readFileSync } from 'node:fs';
|
|
1
|
+
import { ndJsonStream, PROTOCOL_VERSION, RequestError, } from '@agentclientprotocol/sdk';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
4
3
|
import { Readable, Writable } from 'node:stream';
|
|
5
|
-
import { CLIS,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { CLIS, KIT_RELEASE, adapterCommand } from './clis.js';
|
|
5
|
+
import { childEnvironment } from './relay.js';
|
|
6
|
+
import { killTree } from './scope.js';
|
|
7
|
+
import { Silence } from './silence.js';
|
|
8
|
+
const RETIRED = 'the CLI was retired';
|
|
9
|
+
const SIGNED_OUT = RequestError.authRequired().code;
|
|
10
|
+
export function signedOut(error) {
|
|
11
|
+
return typeof error === 'object' && error !== null && error.code === SIGNED_OUT;
|
|
12
|
+
}
|
|
13
|
+
// Claude Code ends a shell command or a model request after ten minutes, so a CLI that owes the Kit an answer and sends nothing for half an hour has hung.
|
|
14
|
+
export const CLI_SILENCE_MS = 30 * 60_000;
|
|
15
|
+
const SILENT = `the CLI sent nothing for ${CLI_SILENCE_MS / 60_000} minutes`;
|
|
16
|
+
export async function startAdapter(kind, cli, cwd, app, events = () => undefined, added = {}, signal, scope = null) {
|
|
9
17
|
const adapter = CLIS[kind].adapter;
|
|
10
|
-
const
|
|
18
|
+
const started = [adapter === null ? cli : adapterCommand(kind), CLIS[kind].args];
|
|
19
|
+
const [command, args] = scope?.command(...started) ?? started;
|
|
20
|
+
const child = spawn(command, args, {
|
|
11
21
|
cwd,
|
|
12
|
-
env: { ...
|
|
22
|
+
env: { ...childEnvironment(), ...(adapter === null ? {} : { ...adapter.env, [adapter.executable]: cli }), ...added },
|
|
13
23
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
14
24
|
detached: true,
|
|
15
25
|
});
|
|
26
|
+
let owned = true;
|
|
27
|
+
let retired = false;
|
|
28
|
+
let silent = false;
|
|
29
|
+
let over = false;
|
|
30
|
+
let open = false;
|
|
16
31
|
let stderr = '';
|
|
32
|
+
const owed = new Set();
|
|
33
|
+
const asked = new Set();
|
|
34
|
+
const silence = new Silence(CLI_SILENCE_MS, () => {
|
|
35
|
+
silent = true;
|
|
36
|
+
connection.close(new Error(SILENT));
|
|
37
|
+
if (child.pid !== undefined)
|
|
38
|
+
killTree(child);
|
|
39
|
+
});
|
|
40
|
+
const watch = () => (!over && (owed.size > 0 || open) && asked.size === 0 ? silence.heard() : silence.stop());
|
|
17
41
|
child.stderr.on('data', (chunk) => {
|
|
18
42
|
stderr = (stderr + chunk.toString('utf8')).slice(-4000);
|
|
19
43
|
});
|
|
20
|
-
const exited = new Promise((resolve) => {
|
|
21
|
-
child.on('error', (error) => resolve(`the CLI did not start: ${error.message}`));
|
|
22
|
-
child.on('exit', (code, signal) => {
|
|
23
|
-
const last = stderr.trim().split('\n').at(-1);
|
|
24
|
-
resolve(`the CLI exited with ${code ?? signal}${last ? `: ${last}` : ''}`);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
44
|
const stream = ndJsonStream(Writable.toWeb(child.stdin), Readable.toWeb(child.stdout));
|
|
45
|
+
const output = stream.writable.getWriter();
|
|
28
46
|
const connection = app.connect({
|
|
29
|
-
writable:
|
|
47
|
+
writable: new WritableStream({
|
|
48
|
+
write(message) {
|
|
49
|
+
const sent = message;
|
|
50
|
+
if (sent.id !== undefined) {
|
|
51
|
+
if (sent.method === undefined)
|
|
52
|
+
asked.delete(sent.id);
|
|
53
|
+
else
|
|
54
|
+
owed.add(sent.id);
|
|
55
|
+
watch();
|
|
56
|
+
}
|
|
57
|
+
return output.write(message);
|
|
58
|
+
},
|
|
59
|
+
close: () => output.close(),
|
|
60
|
+
abort: (reason) => output.abort(reason),
|
|
61
|
+
}),
|
|
30
62
|
readable: stream.readable.pipeThrough(new TransformStream({
|
|
31
63
|
transform(message, controller) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
64
|
+
const read = message;
|
|
65
|
+
if (read.id !== undefined) {
|
|
66
|
+
if (read.method === undefined)
|
|
67
|
+
owed.delete(read.id);
|
|
68
|
+
else
|
|
69
|
+
asked.add(read.id);
|
|
70
|
+
}
|
|
71
|
+
watch();
|
|
72
|
+
if (owned)
|
|
73
|
+
events(read);
|
|
74
|
+
if (read.id !== undefined || (read.method !== 'session/update' && !read.method.startsWith('_'))) {
|
|
37
75
|
controller.enqueue(message);
|
|
38
|
-
|
|
39
|
-
controller.enqueue({ jsonrpc: '2.0', method: TURN_STARTED });
|
|
40
|
-
if (CLIS[kind].turnEnded(notice))
|
|
41
|
-
controller.enqueue({ jsonrpc: '2.0', method: TURN_ENDED });
|
|
76
|
+
}
|
|
42
77
|
},
|
|
43
78
|
})),
|
|
44
79
|
});
|
|
45
|
-
|
|
80
|
+
const { promise: lost, resolve: lose } = Promise.withResolvers();
|
|
81
|
+
const exited = new Promise((resolve) => {
|
|
82
|
+
const end = (cause) => {
|
|
83
|
+
over = true;
|
|
84
|
+
silence.stop();
|
|
85
|
+
if (owned)
|
|
86
|
+
lose(cause);
|
|
87
|
+
owned = false;
|
|
88
|
+
connection.close(new Error(cause));
|
|
89
|
+
resolve(cause);
|
|
90
|
+
};
|
|
91
|
+
child.on('error', (error) => end(`the CLI did not start: ${error.message}`));
|
|
92
|
+
child.on('exit', (code, signal) => {
|
|
93
|
+
const last = stderr.trim().split('\n').at(-1);
|
|
94
|
+
end(silent ? SILENT : `the CLI exited with ${code ?? signal}${last ? `: ${last}` : ''}`);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
const retire = () => {
|
|
98
|
+
owned = false;
|
|
99
|
+
over = true;
|
|
100
|
+
silence.stop();
|
|
101
|
+
if (retired)
|
|
102
|
+
return;
|
|
103
|
+
retired = true;
|
|
104
|
+
if (child.pid !== undefined)
|
|
105
|
+
killTree(child);
|
|
106
|
+
scope?.kill();
|
|
107
|
+
connection.close(new Error(RETIRED));
|
|
108
|
+
};
|
|
109
|
+
signal?.addEventListener('abort', retire, { once: true });
|
|
110
|
+
child.on('exit', () => signal?.removeEventListener('abort', retire));
|
|
46
111
|
try {
|
|
47
112
|
const initialized = await connection.agent.request('initialize', {
|
|
48
113
|
protocolVersion: PROTOCOL_VERSION,
|
|
@@ -50,91 +115,20 @@ export async function startAdapter(kind, cli, cwd, app, jobs = () => undefined,
|
|
|
50
115
|
fs: { readTextFile: false, writeTextFile: false },
|
|
51
116
|
terminal: false,
|
|
52
117
|
elicitation: { form: {} },
|
|
53
|
-
|
|
118
|
+
session: { compaction: {}, notices: {} },
|
|
119
|
+
_meta: { jetbrains: { air: { version: 1, capabilities: CLIS[kind].air } } },
|
|
54
120
|
},
|
|
55
|
-
clientInfo: { name: '@agentshouse/kit', version:
|
|
121
|
+
clientInfo: { name: '@agentshouse/kit', version: KIT_RELEASE },
|
|
56
122
|
});
|
|
57
|
-
|
|
123
|
+
scope?.entered(child.pid);
|
|
124
|
+
const turn = (opened) => {
|
|
125
|
+
open = opened;
|
|
126
|
+
watch();
|
|
127
|
+
};
|
|
128
|
+
return { connection, initialized, exited, lost, silent: () => silent, turn, retire };
|
|
58
129
|
}
|
|
59
130
|
catch (error) {
|
|
60
|
-
|
|
131
|
+
retire();
|
|
61
132
|
throw error;
|
|
62
133
|
}
|
|
63
134
|
}
|
|
64
|
-
const LISTING_BYTES = 1 << 28;
|
|
65
|
-
function listed(options) {
|
|
66
|
-
return execFileSync('ps', [options, '-o', 'pid=,ppid=,command='], { encoding: 'utf8', maxBuffer: LISTING_BYTES })
|
|
67
|
-
.split('\n')
|
|
68
|
-
.flatMap((line) => {
|
|
69
|
-
const fields = /^\s*(\d+)\s+(\d+)\s?(.*)$/.exec(line);
|
|
70
|
-
return fields === null ? [] : [[Number(fields[1]), Number(fields[2]), fields[3]]];
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
function parents() {
|
|
74
|
-
const children = new Map();
|
|
75
|
-
const adopt = (pid, parent) => children.set(parent, [...(children.get(parent) ?? []), pid]);
|
|
76
|
-
if (process.platform === 'darwin') {
|
|
77
|
-
for (const [pid, parent] of listed('-Aww'))
|
|
78
|
-
adopt(pid, parent);
|
|
79
|
-
return children;
|
|
80
|
-
}
|
|
81
|
-
for (const entry of readdirSync('/proc')) {
|
|
82
|
-
if (!/^\d+$/.test(entry))
|
|
83
|
-
continue;
|
|
84
|
-
try {
|
|
85
|
-
const stat = readFileSync(`/proc/${entry}/stat`, 'utf8');
|
|
86
|
-
adopt(Number(entry), Number(stat.slice(stat.lastIndexOf(')') + 2).split(' ')[1]));
|
|
87
|
-
}
|
|
88
|
-
catch { }
|
|
89
|
-
}
|
|
90
|
-
return children;
|
|
91
|
-
}
|
|
92
|
-
function descendants(roots) {
|
|
93
|
-
const children = parents();
|
|
94
|
-
const tree = [];
|
|
95
|
-
const pending = roots.flatMap((root) => children.get(root) ?? []);
|
|
96
|
-
while (pending.length > 0) {
|
|
97
|
-
const pid = pending.pop();
|
|
98
|
-
tree.push(pid);
|
|
99
|
-
pending.push(...(children.get(pid) ?? []));
|
|
100
|
-
}
|
|
101
|
-
return tree;
|
|
102
|
-
}
|
|
103
|
-
function killAll(pids) {
|
|
104
|
-
for (const pid of pids) {
|
|
105
|
-
for (const target of [-pid, pid]) {
|
|
106
|
-
try {
|
|
107
|
-
process.kill(target, 'SIGKILL');
|
|
108
|
-
}
|
|
109
|
-
catch { }
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function marked(marker) {
|
|
114
|
-
if (process.platform === 'darwin') {
|
|
115
|
-
return listed('-AEww')
|
|
116
|
-
.filter(([, , command]) => ` ${command} `.includes(` ${marker} `))
|
|
117
|
-
.map(([pid]) => pid);
|
|
118
|
-
}
|
|
119
|
-
return readdirSync('/proc')
|
|
120
|
-
.filter((entry) => {
|
|
121
|
-
try {
|
|
122
|
-
return /^\d+$/.test(entry) && readFileSync(`/proc/${entry}/environ`, 'utf8').split('\0').includes(marker);
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
})
|
|
128
|
-
.map(Number);
|
|
129
|
-
}
|
|
130
|
-
export function killTree(child) {
|
|
131
|
-
killAll([child.pid, ...descendants([child.pid])]);
|
|
132
|
-
}
|
|
133
|
-
export function killMarked(marker) {
|
|
134
|
-
const pids = marked(marker);
|
|
135
|
-
killAll([...pids, ...descendants(pids)]);
|
|
136
|
-
}
|
|
137
|
-
export function killDescendants() {
|
|
138
|
-
const pids = marked(`HOUSE_KIT_RESIDENT=${process.pid}`);
|
|
139
|
-
killAll([...pids, ...descendants([process.pid, ...pids])]);
|
|
140
|
-
}
|
package/dist/afk.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CLIS } from './clis.js';
|
|
2
|
+
const NOBODY_THERE = 'Nobody is there to answer. Decide for yourself and go on.';
|
|
3
|
+
export const PLAN_APPROVED = { outcome: 'approved' };
|
|
4
|
+
function told(fields) {
|
|
5
|
+
return Object.fromEntries(fields.map((field) => [field, NOBODY_THERE]));
|
|
6
|
+
}
|
|
7
|
+
export function permissionAllowed({ options }) {
|
|
8
|
+
const option = options.find(({ kind }) => kind === 'allow_once') ?? options.find(({ kind }) => kind === 'allow_always');
|
|
9
|
+
return { outcome: { outcome: 'selected', optionId: option.optionId } };
|
|
10
|
+
}
|
|
11
|
+
export function formAnswered(kind, request) {
|
|
12
|
+
const fields = CLIS[kind].questionFields(request);
|
|
13
|
+
return fields.length === 0 ? { action: 'decline' } : { action: 'accept', content: told(fields) };
|
|
14
|
+
}
|
|
15
|
+
export function grokQuestionAnswered({ questions }) {
|
|
16
|
+
return { outcome: 'accepted', answers: told(questions.map(({ question }) => question)) };
|
|
17
|
+
}
|