@agentshouse/kit 0.2.1-ccf188e02985d → 0.2.1-cd423aab3dbcc
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 +35 -42
- package/dist/acp.js +66 -12
- package/dist/afk.js +17 -0
- package/dist/agents.js +122 -53
- package/dist/api.js +15 -10
- package/dist/binaries.js +60 -0
- package/dist/bridge.js +100 -45
- package/dist/building.js +50 -0
- package/dist/calls.js +88 -0
- package/dist/chunks.js +54 -0
- package/dist/clis.js +62 -50
- package/dist/connect.js +121 -0
- package/dist/connection.js +120 -0
- package/dist/content.js +106 -0
- package/dist/conversations.js +617 -240
- package/dist/copies.js +1277 -623
- package/dist/earlier.js +273 -0
- package/dist/end.js +12 -5
- package/dist/events.js +549 -281
- package/dist/files.js +206 -38
- package/dist/git.js +2 -72
- package/dist/grok.js +39 -0
- package/dist/home.js +86 -29
- package/dist/house-cli.js +180 -189
- package/dist/house-main.js +3 -3
- package/dist/instructions.js +29 -11
- package/dist/keys.js +238 -0
- package/dist/kit-cli.js +18 -8
- package/dist/kit-main.js +3 -3
- package/dist/login.js +36 -22
- package/dist/logout.js +2 -2
- package/dist/manifest.js +75 -0
- package/dist/mcp.js +47 -7
- package/dist/owner.js +46 -0
- package/dist/placement.js +15 -20
- package/dist/refusals.js +50 -23
- package/dist/relay.js +21 -0
- package/dist/resident.js +141 -90
- package/dist/scope.js +15 -4
- package/dist/scripts.js +319 -0
- package/dist/secret-input.js +1 -1
- package/dist/settings.js +247 -0
- package/dist/sign-in.js +67 -21
- package/dist/silence.js +28 -0
- package/dist/skills.js +42 -97
- package/dist/supervisor.js +163 -0
- package/dist/transcription.js +88 -45
- package/dist/update.js +118 -120
- package/dist/wire.js +30 -4
- package/dist/work.js +27 -2
- package/dist/workspace.js +113 -0
- package/package.json +25 -22
- package/dist/authority-main.js +0 -22
- package/dist/bootstrap.json +0 -24
- package/dist/chatgpt.js +0 -32
- package/dist/clis-main.js +0 -23
- package/dist/configure-main.js +0 -6
- package/dist/enrol-main.js +0 -10
- package/dist/git-main.js +0 -153
- package/dist/inputs.js +0 -37
- package/dist/parts.js +0 -82
- package/dist/service-main.js +0 -9
- package/dist/service.js +0 -55
- package/dist/stream.js +0 -123
- package/dist/translate.js +0 -51
- package/how-we-work.md +0 -33
- package/skills/ask-matt/LICENSE +0 -21
- package/skills/ask-matt/PHASE-BOUNDARIES.md +0 -55
- package/skills/ask-matt/SKILL.md +0 -97
- package/skills/ask-matt/agents/openai.yaml +0 -5
- 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 -114
- package/skills/codebase-design/agents/openai.yaml +0 -3
- package/skills/diagnosing-bugs/LICENSE +0 -21
- package/skills/diagnosing-bugs/SKILL.md +0 -138
- 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/GLOSSARY-FORMAT.md +0 -60
- package/skills/domain-modeling/LICENSE +0 -21
- package/skills/domain-modeling/SKILL.md +0 -74
- package/skills/domain-modeling/agents/openai.yaml +0 -3
- package/skills/grill-me/LICENSE +0 -21
- package/skills/grill-me/SKILL.md +0 -7
- package/skills/grill-me/agents/openai.yaml +0 -5
- package/skills/grill-with-docs/LICENSE +0 -21
- package/skills/grill-with-docs/SKILL.md +0 -7
- package/skills/grill-with-docs/agents/openai.yaml +0 -5
- 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 -16
- package/skills/handoff/agents/openai.yaml +0 -5
- package/skills/implement/LICENSE +0 -21
- package/skills/implement/SKILL.md +0 -17
- package/skills/implement/agents/openai.yaml +0 -5
- package/skills/implement-spec/LICENSE +0 -21
- package/skills/implement-spec/SKILL.md +0 -40
- package/skills/implement-spec/agents/openai.yaml +0 -5
- 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 -71
- package/skills/improve-codebase-architecture/agents/openai.yaml +0 -5
- package/skills/pr/CREDITS.md +0 -3
- package/skills/pr/LICENSE +0 -21
- package/skills/pr/SKILL.md +0 -170
- package/skills/pr/agents/openai.yaml +0 -3
- package/skills/prototype/LICENSE +0 -21
- package/skills/prototype/LOGIC.md +0 -67
- package/skills/prototype/SKILL.md +0 -26
- 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 -12
- package/skills/research/agents/openai.yaml +0 -3
- package/skills/retro/LICENSE +0 -21
- package/skills/retro/SKILL.md +0 -44
- package/skills/retro/agents/openai.yaml +0 -5
- package/skills/tdd/LICENSE +0 -21
- package/skills/tdd/SKILL.md +0 -38
- 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 -140
- package/skills/teach/agents/openai.yaml +0 -5
- package/skills/to-questionnaire/LICENSE +0 -21
- package/skills/to-questionnaire/SKILL.md +0 -54
- package/skills/to-questionnaire/agents/openai.yaml +0 -5
- package/skills/to-spec/LICENSE +0 -21
- package/skills/to-spec/SKILL.md +0 -75
- package/skills/to-spec/agents/openai.yaml +0 -5
- package/skills/to-tickets/LICENSE +0 -21
- package/skills/to-tickets/SKILL.md +0 -105
- package/skills/to-tickets/agents/openai.yaml +0 -5
- package/skills/triage/AGENT-BRIEF.md +0 -207
- package/skills/triage/LICENSE +0 -21
- package/skills/triage/OUT-OF-SCOPE.md +0 -105
- package/skills/triage/SKILL.md +0 -112
- package/skills/triage/agents/openai.yaml +0 -5
- package/skills/wait-what/LICENSE +0 -21
- package/skills/wait-what/SKILL.md +0 -7
- package/skills/wait-what/agents/openai.yaml +0 -5
- package/skills/wayfinder/LICENSE +0 -21
- package/skills/wayfinder/SKILL.md +0 -128
- package/skills/wayfinder/agents/openai.yaml +0 -5
- package/skills/wizard/LICENSE +0 -21
- package/skills/wizard/SKILL.md +0 -44
- package/skills/wizard/agents/openai.yaml +0 -3
- package/skills/wizard/template.sh +0 -223
- 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 -81
- package/skills/writing-for-agents/agents/openai.yaml +0 -3
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
export 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 keptName(path) {
|
|
47
|
+
for (let count = 1;; count++) {
|
|
48
|
+
const name = `${path} (kept)${count === 1 ? '' : ` ${count}`}`;
|
|
49
|
+
if ((await present(name)) === null)
|
|
50
|
+
return name;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export async function merged(from, to, placed = () => 'moves') {
|
|
54
|
+
const found = await present(from);
|
|
55
|
+
if (found === null || !found.isDirectory())
|
|
56
|
+
return;
|
|
57
|
+
await mkdir(to, { recursive: true, mode: 0o700 });
|
|
58
|
+
for (const entry of await readdir(from, { withFileTypes: true })) {
|
|
59
|
+
const source = join(from, entry.name);
|
|
60
|
+
const placement = placed(source, entry);
|
|
61
|
+
if (placement === 'stays')
|
|
62
|
+
continue;
|
|
63
|
+
const target = join(to, entry.name);
|
|
64
|
+
const held = await present(target);
|
|
65
|
+
if (held === null && placement === 'moves')
|
|
66
|
+
await moved(source, target);
|
|
67
|
+
else if (entry.isDirectory() && (held === null || held.isDirectory()))
|
|
68
|
+
await merged(source, target, placed);
|
|
69
|
+
else
|
|
70
|
+
await rm(source, { recursive: true, force: true });
|
|
71
|
+
}
|
|
72
|
+
await removeFolder(from);
|
|
73
|
+
}
|
|
74
|
+
export async function removeFolder(path) {
|
|
75
|
+
await rmdir(path).catch((error) => {
|
|
76
|
+
if (error.code !== 'ENOTEMPTY' && error.code !== 'ENOENT')
|
|
77
|
+
throw error;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export function within(path, folder) {
|
|
81
|
+
return path === folder || path.startsWith(`${folder}/`);
|
|
82
|
+
}
|
|
83
|
+
function rewritten(value, from, to, kept) {
|
|
84
|
+
if (typeof value === 'string') {
|
|
85
|
+
if (kept.some((folder) => within(value, folder)) || (within(to, from) && within(value, to)) || !within(value, from))
|
|
86
|
+
return value;
|
|
87
|
+
return `${to}${value.slice(from.length)}`;
|
|
88
|
+
}
|
|
89
|
+
if (Array.isArray(value))
|
|
90
|
+
return value.map((item) => rewritten(item, from, to, kept));
|
|
91
|
+
if (typeof value === 'object' && value !== null) {
|
|
92
|
+
return Object.fromEntries(Object.entries(value).map(([name, held]) => [name, rewritten(held, from, to, kept)]));
|
|
93
|
+
}
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
export function rerooted(value, from, to) {
|
|
97
|
+
return rewritten(value, from, to, []);
|
|
98
|
+
}
|
|
99
|
+
export async function followRoot(records, from, to, kept = []) {
|
|
100
|
+
if (from === to)
|
|
101
|
+
return;
|
|
102
|
+
for (const name of await readdir(records).catch(() => [])) {
|
|
103
|
+
if (!name.endsWith('.json'))
|
|
104
|
+
continue;
|
|
105
|
+
const path = join(records, name);
|
|
106
|
+
const text = await readFile(path, 'utf8');
|
|
107
|
+
const next = `${JSON.stringify(rewritten(JSON.parse(text), from, to, kept))}\n`;
|
|
108
|
+
if (next.trim() === text.trim())
|
|
109
|
+
continue;
|
|
110
|
+
await writeFile(`${path}.new`, next, { mode: 0o600 });
|
|
111
|
+
await rename(`${path}.new`, path);
|
|
112
|
+
}
|
|
113
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/kit",
|
|
3
|
-
"version": "0.2.1-
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.1-cd423aab3dbcc",
|
|
4
|
+
"description": "Kit connects an Environment to agents.house.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -12,28 +12,30 @@
|
|
|
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
|
-
"
|
|
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",
|
|
26
|
-
"
|
|
22
|
+
"follow-skills-and-kit-wire": "node scripts/follow-skills-and-kit-wire.mjs",
|
|
23
|
+
"release-files": "node scripts/release-files.mjs",
|
|
27
24
|
"test": "tsc -p tsconfig.json && vitest run"
|
|
28
25
|
},
|
|
29
26
|
"dependencies": {
|
|
30
|
-
"@agentclientprotocol/sdk": "
|
|
31
|
-
"@agentshouse/
|
|
27
|
+
"@agentclientprotocol/sdk": "2.4.0",
|
|
28
|
+
"@agentshouse/kit-wire": "0.1.0-ceea7707b3282",
|
|
29
|
+
"@agentshouse/session-content": "0.1.0-c560e48c9bea3",
|
|
30
|
+
"@agentshouse/skills": "0.1.0-cbfeca43f4f64",
|
|
31
|
+
"@lydell/node-pty": "1.2.0-beta.15",
|
|
32
|
+
"micromark": "4.0.2",
|
|
33
|
+
"smol-toml": "1.9.1",
|
|
32
34
|
"yaml": "2.9.1"
|
|
33
35
|
},
|
|
34
36
|
"peerDependencies": {
|
|
35
|
-
"@agentclientprotocol/claude-agent-acp": "0.
|
|
36
|
-
"@agentclientprotocol/codex-acp": "2.
|
|
37
|
+
"@agentclientprotocol/claude-agent-acp": "0.100.0",
|
|
38
|
+
"@agentclientprotocol/codex-acp": "2.5.0"
|
|
37
39
|
},
|
|
38
40
|
"peerDependenciesMeta": {
|
|
39
41
|
"@agentclientprotocol/claude-agent-acp": {
|
|
@@ -44,26 +46,27 @@
|
|
|
44
46
|
}
|
|
45
47
|
},
|
|
46
48
|
"devDependencies": {
|
|
47
|
-
"@types/node": "24.
|
|
49
|
+
"@types/node": "24.19.2",
|
|
48
50
|
"@types/ws": "8.18.2",
|
|
49
51
|
"typescript": "7.0.2",
|
|
50
|
-
"vitest": "5.0.
|
|
51
|
-
"ws": "8.22.0"
|
|
52
|
+
"vitest": "5.0.5",
|
|
53
|
+
"ws": "8.22.0",
|
|
54
|
+
"zod": "4.6.7"
|
|
52
55
|
},
|
|
53
|
-
"packageManager": "npm@11.19.
|
|
56
|
+
"packageManager": "npm@11.19.1",
|
|
54
57
|
"engines": {
|
|
55
|
-
"node": "24.
|
|
56
|
-
"npm": "11.19.
|
|
58
|
+
"node": "24.22.1",
|
|
59
|
+
"npm": "11.19.1"
|
|
57
60
|
},
|
|
58
61
|
"devEngines": {
|
|
59
62
|
"runtime": {
|
|
60
63
|
"name": "node",
|
|
61
|
-
"version": "24.
|
|
64
|
+
"version": "24.22.1",
|
|
62
65
|
"onFail": "error"
|
|
63
66
|
},
|
|
64
67
|
"packageManager": {
|
|
65
68
|
"name": "npm",
|
|
66
|
-
"version": "11.19.
|
|
69
|
+
"version": "11.19.1",
|
|
67
70
|
"onFail": "error"
|
|
68
71
|
}
|
|
69
72
|
}
|
package/dist/authority-main.js
DELETED
|
@@ -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/bootstrap.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"schemaVersion": 2,
|
|
3
|
-
"version": "0.2.1-ccf188e02985d",
|
|
4
|
-
"hosts": {
|
|
5
|
-
"macos": {
|
|
6
|
-
"asset": {
|
|
7
|
-
"name": "connect-linux.sh",
|
|
8
|
-
"url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-ccf188e02985d/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-ccf188e02985d/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-ccf188e02985d/connect-windows.ps1"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
package/dist/chatgpt.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { parseArgs } from 'node:util';
|
|
2
|
-
import { placeAppGit } from './app-git.js';
|
|
3
|
-
import { kitHome, readOwnAgent, writeOwnAgent } from './home.js';
|
|
4
|
-
import { accepted, DEFAULT_HOUSE } from './login.js';
|
|
5
|
-
const KEY_SOURCE = 'New key for a script on Connections';
|
|
6
|
-
const USAGE = `usage: kit chatgpt --key <key> [--house <origin>]
|
|
7
|
-
--key <key> a key from ${KEY_SOURCE}
|
|
8
|
-
--house <origin> the House of the key, ${DEFAULT_HOUSE} unless one is stored
|
|
9
|
-
`;
|
|
10
|
-
export async function chatgpt(argv) {
|
|
11
|
-
const { values } = parseArgs({
|
|
12
|
-
args: argv,
|
|
13
|
-
options: { key: { type: 'string' }, house: { type: 'string' }, help: { type: 'boolean', default: false } },
|
|
14
|
-
});
|
|
15
|
-
if (values.help) {
|
|
16
|
-
process.stdout.write(USAGE);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (values.key === undefined)
|
|
20
|
-
throw new Error(`pass --key with a key from ${KEY_SOURCE}`);
|
|
21
|
-
const before = await readOwnAgent();
|
|
22
|
-
const house = values.house ?? before?.house ?? DEFAULT_HOUSE;
|
|
23
|
-
if (!(await accepted(house, values.key)))
|
|
24
|
-
throw new Error(`${house} does not accept this key; pass one from ${KEY_SOURCE}`);
|
|
25
|
-
const relay = process.env.HOUSE_KIT_RELAY || undefined;
|
|
26
|
-
await writeOwnAgent({ house, ...(relay === undefined ? {} : { relay }), credential: values.key });
|
|
27
|
-
await placeAppGit(await readOwnAgent()).catch((error) => process.stderr.write(`kit: ${error.message}\n`));
|
|
28
|
-
if (before !== null && before.credential !== values.key) {
|
|
29
|
-
process.stdout.write('This replaced the key this Kit home held; give each session its own HOUSE_KIT_HOME to keep its own key.\n');
|
|
30
|
-
}
|
|
31
|
-
process.stdout.write(`house now calls ${house} as you, with the key kept in ${kitHome()}.\n`);
|
|
32
|
-
}
|
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
|
-
}
|
package/dist/configure-main.js
DELETED
|
@@ -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');
|
package/dist/enrol-main.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { writeEnrolment } from './home.js';
|
|
3
|
-
const [house, environment] = process.argv.slice(2);
|
|
4
|
-
const relay = process.env.HOUSE_KIT_RELAY || undefined;
|
|
5
|
-
await writeEnrolment({
|
|
6
|
-
house: house,
|
|
7
|
-
...(relay === undefined ? {} : { relay }),
|
|
8
|
-
environment: environment,
|
|
9
|
-
credential: readFileSync(0, 'utf8').trim(),
|
|
10
|
-
});
|
package/dist/git-main.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { spawn, spawnSync } from 'node:child_process';
|
|
3
|
-
import { accessSync, constants, realpathSync, statSync } from 'node:fs';
|
|
4
|
-
import { request } from 'node:http';
|
|
5
|
-
import { constants as system } from 'node:os';
|
|
6
|
-
import { delimiter, dirname, join } from 'node:path';
|
|
7
|
-
import { localCopies } from './git.js';
|
|
8
|
-
import { kitHome } from './home.js';
|
|
9
|
-
const VALUED = new Set(['-C', '-c', '--git-dir', '--work-tree', '--namespace', '--config-env', '--attr-source', '--super-prefix']);
|
|
10
|
-
const READS = new Set([
|
|
11
|
-
'blame',
|
|
12
|
-
'branch',
|
|
13
|
-
'cat-file',
|
|
14
|
-
'check-ignore',
|
|
15
|
-
'config',
|
|
16
|
-
'describe',
|
|
17
|
-
'diff',
|
|
18
|
-
'fetch',
|
|
19
|
-
'for-each-ref',
|
|
20
|
-
'grep',
|
|
21
|
-
'help',
|
|
22
|
-
'log',
|
|
23
|
-
'ls-files',
|
|
24
|
-
'ls-tree',
|
|
25
|
-
'reflog',
|
|
26
|
-
'remote',
|
|
27
|
-
'rev-list',
|
|
28
|
-
'rev-parse',
|
|
29
|
-
'shortlog',
|
|
30
|
-
'show',
|
|
31
|
-
'show-ref',
|
|
32
|
-
'status',
|
|
33
|
-
'tag',
|
|
34
|
-
'version',
|
|
35
|
-
]);
|
|
36
|
-
const RELAYED = ['SIGINT', 'SIGTERM', 'SIGHUP', 'SIGQUIT'];
|
|
37
|
-
function nativeGit() {
|
|
38
|
-
const shim = join(kitHome(), 'shim');
|
|
39
|
-
for (const directory of (process.env.PATH ?? '').split(delimiter)) {
|
|
40
|
-
if (directory === '')
|
|
41
|
-
continue;
|
|
42
|
-
try {
|
|
43
|
-
if (realpathSync(directory) === realpathSync(shim))
|
|
44
|
-
continue;
|
|
45
|
-
const candidate = join(directory, 'git');
|
|
46
|
-
if (!statSync(candidate).isFile())
|
|
47
|
-
continue;
|
|
48
|
-
accessSync(candidate, constants.X_OK);
|
|
49
|
-
return candidate;
|
|
50
|
-
}
|
|
51
|
-
catch { }
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
function captured(git, args) {
|
|
56
|
-
const ran = spawnSync(git, args, {
|
|
57
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
58
|
-
maxBuffer: Infinity,
|
|
59
|
-
env: { ...process.env, LC_ALL: 'C' },
|
|
60
|
-
});
|
|
61
|
-
return ran.status === 0 ? ran.stdout.toString('utf8') : null;
|
|
62
|
-
}
|
|
63
|
-
function delegated(git, args) {
|
|
64
|
-
return new Promise((resolve) => {
|
|
65
|
-
const child = spawn(git, args, { stdio: 'inherit' });
|
|
66
|
-
const relay = (signal) => child.kill(signal);
|
|
67
|
-
for (const signal of RELAYED)
|
|
68
|
-
process.on(signal, relay);
|
|
69
|
-
const settle = (outcome) => {
|
|
70
|
-
for (const signal of RELAYED)
|
|
71
|
-
process.off(signal, relay);
|
|
72
|
-
resolve(outcome);
|
|
73
|
-
};
|
|
74
|
-
child.once('error', (error) => {
|
|
75
|
-
process.stderr.write(`git: ${error.message}\n`);
|
|
76
|
-
settle({ status: 127, signal: null });
|
|
77
|
-
});
|
|
78
|
-
child.once('close', (status, signal) => settle({ status, signal }));
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
function staged(listing) {
|
|
82
|
-
const entries = new Map();
|
|
83
|
-
for (const record of (listing ?? '').split('\0')) {
|
|
84
|
-
const tab = record.indexOf('\t');
|
|
85
|
-
if (tab >= 0)
|
|
86
|
-
entries.set(record.slice(tab + 1), record.slice(0, tab).split(' ')[1]);
|
|
87
|
-
}
|
|
88
|
-
return entries;
|
|
89
|
-
}
|
|
90
|
-
function moved(planned, before, after) {
|
|
91
|
-
const moves = [];
|
|
92
|
-
for (const line of planned.split('\n')) {
|
|
93
|
-
if (!line.startsWith('Renaming '))
|
|
94
|
-
continue;
|
|
95
|
-
const renaming = line.slice('Renaming '.length);
|
|
96
|
-
for (let at = renaming.indexOf(' to '); at >= 0; at = renaming.indexOf(' to ', at + 1)) {
|
|
97
|
-
const from = renaming.slice(0, at);
|
|
98
|
-
const to = renaming.slice(at + 4);
|
|
99
|
-
if (before.has(from) && !after.has(from) && after.get(to) === before.get(from)) {
|
|
100
|
-
moves.push({ from, to });
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return moves;
|
|
106
|
-
}
|
|
107
|
-
function reported(socketPath, body) {
|
|
108
|
-
return new Promise((resolve) => {
|
|
109
|
-
const sent = request({ socketPath, path: '/git/observed', method: 'POST' }, (answer) => {
|
|
110
|
-
answer.resume();
|
|
111
|
-
answer.on('end', resolve);
|
|
112
|
-
});
|
|
113
|
-
sent.on('error', () => resolve());
|
|
114
|
-
sent.end(JSON.stringify(body));
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
async function observed(git, args) {
|
|
118
|
-
let index = 0;
|
|
119
|
-
while (index < args.length && args[index].startsWith('-'))
|
|
120
|
-
index += VALUED.has(args[index]) ? 2 : 1;
|
|
121
|
-
const globals = args.slice(0, index);
|
|
122
|
-
const name = args[index];
|
|
123
|
-
const bridge = process.env.HOUSE_BRIDGE;
|
|
124
|
-
if (bridge === undefined || name === undefined || READS.has(name))
|
|
125
|
-
return delegated(git, args);
|
|
126
|
-
const located = captured(git, [...globals, 'rev-parse', '--path-format=absolute', '--git-common-dir', '--show-toplevel']);
|
|
127
|
-
const [common, worktree] = located?.split('\n') ?? [];
|
|
128
|
-
if (common === undefined || worktree === undefined || !dirname(common).startsWith(`${localCopies()}/`)) {
|
|
129
|
-
return delegated(git, args);
|
|
130
|
-
}
|
|
131
|
-
const listing = [...globals, '-C', worktree, 'ls-files', '--stage', '-z'];
|
|
132
|
-
const before = name === 'mv' ? staged(captured(git, listing)) : null;
|
|
133
|
-
const planned = name === 'mv' ? (captured(git, [...globals, 'mv', '--dry-run', ...args.slice(index + 1)]) ?? '') : '';
|
|
134
|
-
const outcome = await delegated(git, args);
|
|
135
|
-
const moves = before !== null && outcome.status === 0 ? moved(planned, before, staged(captured(git, listing))) : [];
|
|
136
|
-
await reported(bridge, { common, worktree, moves });
|
|
137
|
-
return outcome;
|
|
138
|
-
}
|
|
139
|
-
const git = nativeGit();
|
|
140
|
-
if (git === null) {
|
|
141
|
-
process.stderr.write('git: no installed Git found on PATH\n');
|
|
142
|
-
process.exitCode = 127;
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
observed(git, process.argv.slice(2)).then(({ status, signal }) => {
|
|
146
|
-
if (signal === null) {
|
|
147
|
-
process.exitCode = status ?? 1;
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
process.exitCode = 128 + system.signals[signal];
|
|
151
|
-
process.kill(process.pid, signal);
|
|
152
|
-
});
|
|
153
|
-
}
|
package/dist/inputs.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
function logged(error) {
|
|
2
|
-
process.stderr.write(`kit: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
3
|
-
}
|
|
4
|
-
export class Inputs {
|
|
5
|
-
house;
|
|
6
|
-
changed;
|
|
7
|
-
carried = new Map();
|
|
8
|
-
open = 0;
|
|
9
|
-
constructor(house, changed) {
|
|
10
|
-
this.house = house;
|
|
11
|
-
this.changed = changed;
|
|
12
|
-
}
|
|
13
|
-
idle() {
|
|
14
|
-
return this.open === 0;
|
|
15
|
-
}
|
|
16
|
-
carry(inputId, work) {
|
|
17
|
-
const known = this.carried.get(inputId);
|
|
18
|
-
const carried = known ?? work();
|
|
19
|
-
if (known === undefined) {
|
|
20
|
-
this.carried.set(inputId, carried);
|
|
21
|
-
carried.catch(() => this.carried.delete(inputId));
|
|
22
|
-
}
|
|
23
|
-
this.open++;
|
|
24
|
-
this.changed();
|
|
25
|
-
return carried
|
|
26
|
-
.then(async ({ ack, acknowledged }) => {
|
|
27
|
-
await this.house.deliver(`/kit/inputs/${inputId}/ack`, ack);
|
|
28
|
-
if (known === undefined)
|
|
29
|
-
await acknowledged?.();
|
|
30
|
-
})
|
|
31
|
-
.catch(logged)
|
|
32
|
-
.finally(() => {
|
|
33
|
-
this.open--;
|
|
34
|
-
this.changed();
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
package/dist/parts.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
export class Parts {
|
|
2
|
-
parts = [];
|
|
3
|
-
context = null;
|
|
4
|
-
emit;
|
|
5
|
-
made = [];
|
|
6
|
-
events = 0;
|
|
7
|
-
writing = null;
|
|
8
|
-
counting = null;
|
|
9
|
-
planned = null;
|
|
10
|
-
constructor(emit) {
|
|
11
|
-
this.emit = emit;
|
|
12
|
-
}
|
|
13
|
-
write(type, id, text) {
|
|
14
|
-
if (text === '')
|
|
15
|
-
return;
|
|
16
|
-
if (this.writing?.type === type && this.writing.id === id) {
|
|
17
|
-
this.parts[this.writing.index].text += text;
|
|
18
|
-
this.emit({ op: 'append', index: this.writing.index, text });
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
this.writing = { type, id, index: this.start({ type, text }) };
|
|
22
|
-
}
|
|
23
|
-
command() {
|
|
24
|
-
if (this.counting === null) {
|
|
25
|
-
this.counting = this.start({ type: 'commands', count: 1 });
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const part = this.parts[this.counting];
|
|
29
|
-
part.count++;
|
|
30
|
-
this.emit({ op: 'count', index: this.counting, count: part.count });
|
|
31
|
-
}
|
|
32
|
-
start(part) {
|
|
33
|
-
this.writing = null;
|
|
34
|
-
this.counting = null;
|
|
35
|
-
return this.add(part, ++this.events);
|
|
36
|
-
}
|
|
37
|
-
reserve() {
|
|
38
|
-
this.writing = null;
|
|
39
|
-
this.counting = null;
|
|
40
|
-
return ++this.events;
|
|
41
|
-
}
|
|
42
|
-
arrive(part, reserved) {
|
|
43
|
-
this.add(part, reserved);
|
|
44
|
-
}
|
|
45
|
-
done(index, result) {
|
|
46
|
-
const part = this.parts[index];
|
|
47
|
-
part.status = 'done';
|
|
48
|
-
part.result = result;
|
|
49
|
-
this.emit({ op: 'status', index, status: 'done', result });
|
|
50
|
-
}
|
|
51
|
-
plan(entries) {
|
|
52
|
-
if (this.planned === null) {
|
|
53
|
-
this.planned = this.start({ type: 'plan', entries });
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
this.parts[this.planned].entries = entries;
|
|
57
|
-
this.emit({ op: 'plan', index: this.planned, entries });
|
|
58
|
-
}
|
|
59
|
-
measure(context) {
|
|
60
|
-
this.context = context;
|
|
61
|
-
this.emit({ op: 'context', ...context });
|
|
62
|
-
}
|
|
63
|
-
saved() {
|
|
64
|
-
return this.parts
|
|
65
|
-
.map((part, index) => ({ part, made: this.made[index] }))
|
|
66
|
-
.sort((a, b) => a.made - b.made)
|
|
67
|
-
.map(({ part }) => part);
|
|
68
|
-
}
|
|
69
|
-
operations() {
|
|
70
|
-
return [
|
|
71
|
-
...this.parts.map((part, index) => ({ op: 'start', index, part })),
|
|
72
|
-
...(this.context === null ? [] : [{ op: 'context', ...this.context }]),
|
|
73
|
-
];
|
|
74
|
-
}
|
|
75
|
-
add(part, made) {
|
|
76
|
-
this.parts.push(part);
|
|
77
|
-
this.made.push(made);
|
|
78
|
-
const index = this.parts.length - 1;
|
|
79
|
-
this.emit({ op: 'start', index, part });
|
|
80
|
-
return index;
|
|
81
|
-
}
|
|
82
|
-
}
|
package/dist/service-main.js
DELETED
package/dist/service.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { existsSync, realpathSync } from 'node:fs';
|
|
3
|
-
import { resolve } from 'node:path';
|
|
4
|
-
import { kitHome } from './home.js';
|
|
5
|
-
const UNIT = 'house-kit.service';
|
|
6
|
-
// launchctl and systemctl answer at once, so ten seconds only bounds a stuck service manager.
|
|
7
|
-
const MANAGER_MS = 10_000;
|
|
8
|
-
function manage(command, args) {
|
|
9
|
-
return spawnSync(command, args, { encoding: 'utf8', timeout: MANAGER_MS });
|
|
10
|
-
}
|
|
11
|
-
function start(command, args) {
|
|
12
|
-
const started = manage(command, args);
|
|
13
|
-
if (started.status === 0)
|
|
14
|
-
return;
|
|
15
|
-
const cause = started.error?.message ?? (started.stderr.trim() || `${command} exited with ${started.status ?? 'a signal'}`);
|
|
16
|
-
throw new Error(`the House Kit service could not be started: ${cause}`);
|
|
17
|
-
}
|
|
18
|
-
function physical(path) {
|
|
19
|
-
return existsSync(path) ? realpathSync(path) : resolve(path);
|
|
20
|
-
}
|
|
21
|
-
function systemdHome(environment) {
|
|
22
|
-
for (const [, quoted, bare] of environment.matchAll(/"((?:[^"\\]|\\.)*)"|(\S+)/g)) {
|
|
23
|
-
const assignment = bare ?? quoted.replace(/\\(.)/g, '$1');
|
|
24
|
-
if (assignment.startsWith('HOUSE_KIT_HOME='))
|
|
25
|
-
return assignment.slice('HOUSE_KIT_HOME='.length);
|
|
26
|
-
}
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
function runsThisHome(served) {
|
|
30
|
-
return served !== undefined && physical(served) === physical(kitHome());
|
|
31
|
-
}
|
|
32
|
-
export function startService() {
|
|
33
|
-
if (process.platform === 'darwin') {
|
|
34
|
-
const service = `gui/${process.getuid()}/house-kit`;
|
|
35
|
-
const printed = manage('launchctl', ['print', service]);
|
|
36
|
-
if (printed.status !== 0 || /^\tstate = running$/m.test(printed.stdout))
|
|
37
|
-
return false;
|
|
38
|
-
if (!runsThisHome(/^\t+HOUSE_KIT_HOME => (.+)$/m.exec(printed.stdout)?.[1]))
|
|
39
|
-
return false;
|
|
40
|
-
start('launchctl', ['kickstart', service]);
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
for (const scope of [['--user'], []]) {
|
|
44
|
-
if (manage('systemctl', [...scope, 'is-enabled', '--quiet', UNIT]).status !== 0)
|
|
45
|
-
continue;
|
|
46
|
-
const environment = manage('systemctl', [...scope, 'show', '--property=Environment', '--value', UNIT]).stdout;
|
|
47
|
-
if (!runsThisHome(systemdHome(environment)))
|
|
48
|
-
continue;
|
|
49
|
-
if (manage('systemctl', [...scope, 'is-active', '--quiet', UNIT]).status === 0)
|
|
50
|
-
return false;
|
|
51
|
-
start('systemctl', [...scope, 'start', UNIT]);
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
}
|