@agentshouse/kit 0.2.1-cb0bd1cadcfed → 0.2.1-cd646adba3f64

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 CHANGED
@@ -37,10 +37,11 @@ them out; running it again without the flag brings them back.
37
37
  Environment's credential in `~/.house-kit`, or in `$HOUSE_KIT_HOME` when it is
38
38
  set. Pass `--manual` to paste the code by hand on a machine without a browser,
39
39
  and `--environment <id>` to reconnect an Environment you already have. It also
40
- connects your own agent: `house <tool>` run outside an Agent conversation calls
41
- House as you, until you revoke that connection on Connections. `house help`
42
- lists the Tools. `kit logout` disconnects this computer and stops House Kit; a
43
- later `kit login` reconnects the same Environment.
40
+ connects your own agent: outside an Agent conversation, `house <tool>` calls
41
+ House as you and `git` clones and pushes your Apps at `<house>/app/` as you,
42
+ until you revoke that connection on Connections. `house help` lists the Tools.
43
+ `kit logout` disconnects this computer, stops House Kit and ends that Git
44
+ access; a later `kit login` reconnects the same Environment.
44
45
 
45
46
  `kit resident` keeps the Environment connected, and keeps the Rooms you chose
46
47
  for this Environment as Git repositories under `local-copies` in the
@@ -54,6 +55,4 @@ engine and model use about 425 MB in `~/.house-kit`; turning it off deletes them
54
55
 
55
56
  ## License
56
57
 
57
- MIT
58
-
59
- The skills come from [mattpocock/skills](https://github.com/mattpocock/skills); thank you, Matt Pocock.
58
+ MIT. The skills come from [mattpocock/skills](https://github.com/mattpocock/skills); thank you, Matt Pocock.
@@ -0,0 +1,64 @@
1
+ import { extname, resolve } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { run } from './git.js';
4
+ import { kitHome, readOwnAgent } from './home.js';
5
+ import { quoted } from './shell.js';
6
+ function section(house) {
7
+ return `credential.${new URL('/app/', house).href}`;
8
+ }
9
+ function helper() {
10
+ const main = fileURLToPath(new URL(`./kit-main${extname(fileURLToPath(import.meta.url))}`, import.meta.url));
11
+ return `!HOUSE_KIT_HOME=${quoted(resolve(kitHome()))} ${quoted(process.execPath)} ${quoted(main)} git-credential`;
12
+ }
13
+ async function configured(args) {
14
+ try {
15
+ return await run(kitHome(), ['config', '--global', ...args]);
16
+ }
17
+ catch (error) {
18
+ if (error.code === 'ENOENT')
19
+ return null;
20
+ throw error;
21
+ }
22
+ }
23
+ async function forget(house) {
24
+ await configured(['--remove-section', section(house)]);
25
+ }
26
+ async function register(house) {
27
+ await forget(house);
28
+ for (const value of ['', helper()]) {
29
+ const ran = await configured(['--add', `${section(house)}.helper`, value]);
30
+ if (ran === null)
31
+ return;
32
+ if (ran.status !== 0)
33
+ throw new Error(`git config failed: ${ran.stderr.trim()}`);
34
+ }
35
+ }
36
+ export async function placeAppGit(before, after) {
37
+ if (before !== null && before.house !== after?.house)
38
+ await forget(before.house);
39
+ if (after !== null)
40
+ await register(after.house);
41
+ }
42
+ export async function forgetAppGit() {
43
+ const ownAgent = await readOwnAgent();
44
+ if (ownAgent !== null)
45
+ await forget(ownAgent.house);
46
+ }
47
+ export async function answerGitCredential(operation) {
48
+ let asked = '';
49
+ for await (const chunk of process.stdin)
50
+ asked += String(chunk);
51
+ if (operation !== 'get')
52
+ return;
53
+ const attributes = new Map(asked
54
+ .split('\n')
55
+ .filter((line) => line.includes('='))
56
+ .map((line) => [line.slice(0, line.indexOf('=')), line.slice(line.indexOf('=') + 1)]));
57
+ const ownAgent = await readOwnAgent();
58
+ if (ownAgent === null)
59
+ return;
60
+ const house = new URL(ownAgent.house);
61
+ if (attributes.get('protocol') !== house.protocol.slice(0, -1) || attributes.get('host') !== house.host)
62
+ return;
63
+ process.stdout.write(`username=house\npassword=${ownAgent.credential}\n`);
64
+ }
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
- "version": "0.2.1-cb0bd1cadcfed",
3
+ "version": "0.2.1-cd646adba3f64",
4
4
  "hosts": {
5
5
  "macos": {
6
6
  "asset": {
7
7
  "name": "connect-linux.sh",
8
- "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-cb0bd1cadcfed/connect-linux.sh"
8
+ "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-cd646adba3f64/connect-linux.sh"
9
9
  }
10
10
  },
11
11
  "linux": {
12
12
  "asset": {
13
13
  "name": "connect-linux.sh",
14
- "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-cb0bd1cadcfed/connect-linux.sh"
14
+ "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-cd646adba3f64/connect-linux.sh"
15
15
  }
16
16
  },
17
17
  "windows": {
18
18
  "asset": {
19
19
  "name": "connect-windows.ps1",
20
- "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-cb0bd1cadcfed/connect-windows.ps1"
20
+ "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-cd646adba3f64/connect-windows.ps1"
21
21
  }
22
22
  }
23
23
  }
package/dist/kit-main.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { setGlobalProxyFromEnv } from 'node:http';
3
+ import { answerGitCredential } from './app-git.js';
3
4
  import { login } from './login.js';
4
5
  import { logout } from './logout.js';
5
6
  import { resident } from './resident.js';
@@ -12,6 +13,8 @@ async function run() {
12
13
  return logout();
13
14
  if (command === 'resident')
14
15
  return resident();
16
+ if (command === 'git-credential')
17
+ return answerGitCredential(argv[0]);
15
18
  process.stderr.write('usage: kit <login|logout|resident>\n');
16
19
  process.exitCode = 2;
17
20
  }
package/dist/login.js CHANGED
@@ -4,6 +4,7 @@ import { hostname } from 'node:os';
4
4
  import { createInterface } from 'node:readline/promises';
5
5
  import { parseArgs } from 'node:util';
6
6
  import { post } from './api.js';
7
+ import { placeAppGit } from './app-git.js';
7
8
  import { forgetOwnAgent, readDisconnected, readEnrolment, readOwnAgent, writeEnrolment, writeOwnAgent } from './home.js';
8
9
  import { callHouse, rpc } from './mcp.js';
9
10
  const DEFAULT_HOUSE = 'https://agents.house';
@@ -104,6 +105,7 @@ export async function login(argv) {
104
105
  process.stdout.write("This computer's own agent was another User's; run kit login again to connect it to you.\n");
105
106
  }
106
107
  };
108
+ const placeGit = async () => placeAppGit(ownAgent, await readOwnAgent());
107
109
  if (values.manual) {
108
110
  const { start_url } = await post(house, '/kit', {
109
111
  ...started,
@@ -111,6 +113,7 @@ export async function login(argv) {
111
113
  });
112
114
  process.stdout.write(`Open this link and confirm: ${start_url}\n`);
113
115
  await exchange(await typed('Code: '));
116
+ await placeGit();
114
117
  return;
115
118
  }
116
119
  const callback = await listen();
@@ -133,4 +136,5 @@ export async function login(argv) {
133
136
  finally {
134
137
  callback.close();
135
138
  }
139
+ await placeGit();
136
140
  }
package/dist/logout.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import { HouseRefusal, post } from './api.js';
2
+ import { forgetAppGit } from './app-git.js';
2
3
  import { forgetEnrolment, readEnrolment } from './home.js';
3
4
  export async function logout() {
4
5
  const enrolled = await readEnrolment();
5
6
  if (enrolled === null) {
7
+ await forgetAppGit();
6
8
  process.stdout.write('This computer is not connected to House.\n');
7
9
  return;
8
10
  }
@@ -14,5 +16,6 @@ export async function logout() {
14
16
  throw error;
15
17
  }
16
18
  await forgetEnrolment(enrolled);
19
+ await forgetAppGit();
17
20
  process.stdout.write(`Environment ${enrolled.environment} is disconnected; kit login reconnects it.\n`);
18
21
  }
package/dist/resident.js CHANGED
@@ -11,6 +11,7 @@ import { received } from './bridge.js';
11
11
  import { Conversations } from './conversations.js';
12
12
  import { LocalCopies } from './copies.js';
13
13
  import { agentBase, enrolled, kitHome } from './home.js';
14
+ import { quoted } from './shell.js';
14
15
  import { SignIns } from './sign-in.js';
15
16
  import { placeSkillSet } from './skills.js';
16
17
  import { holdStream } from './stream.js';
@@ -21,9 +22,6 @@ function report(error) {
21
22
  function logged(work) {
22
23
  work.catch(report);
23
24
  }
24
- function quoted(value) {
25
- return `'${value.replaceAll("'", `'\\''`)}'`;
26
- }
27
25
  async function installShim() {
28
26
  const main = fileURLToPath(new URL(`./git-main${extname(fileURLToPath(import.meta.url))}`, import.meta.url));
29
27
  await mkdir(join(kitHome(), 'shim'), { recursive: true });
package/dist/shell.js ADDED
@@ -0,0 +1,3 @@
1
+ export function quoted(value) {
2
+ return `'${value.replaceAll("'", `'\\''`)}'`;
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/kit",
3
- "version": "0.2.1-cb0bd1cadcfed",
3
+ "version": "0.2.1-cd646adba3f64",
4
4
  "description": "House Kit connects an Environment to agents.house.",
5
5
  "license": "MIT",
6
6
  "repository": {