@agentshouse/kit 0.2.1-c5d36e97b0fea → 0.2.1-c681dfca497a8

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 (85) hide show
  1. package/README.md +24 -24
  2. package/dist/agents.js +24 -5
  3. package/dist/api.js +6 -2
  4. package/dist/bootstrap.json +4 -4
  5. package/dist/chatgpt.js +26 -0
  6. package/dist/clis.js +41 -9
  7. package/dist/conversations.js +9 -5
  8. package/dist/copies.js +36 -26
  9. package/dist/end.js +17 -3
  10. package/dist/enrol-main.js +7 -1
  11. package/dist/files.js +7 -1
  12. package/dist/git.js +11 -8
  13. package/dist/home.js +76 -5
  14. package/dist/house-main.js +164 -63
  15. package/dist/instructions.js +5 -4
  16. package/dist/kit-main.js +53 -8
  17. package/dist/login.js +83 -18
  18. package/dist/parts.js +34 -16
  19. package/dist/placement.js +48 -0
  20. package/dist/relay.js +12 -2
  21. package/dist/resident.js +15 -6
  22. package/dist/service-main.js +9 -0
  23. package/dist/service.js +33 -0
  24. package/dist/skills.js +11 -1
  25. package/dist/stream.js +9 -4
  26. package/dist/update.js +28 -6
  27. package/dist/wire.js +6 -0
  28. package/how-we-work.md +11 -3
  29. package/package.json +3 -2
  30. package/skills/ask-matt/SKILL.md +17 -11
  31. package/skills/ask-matt/agents/openai.yaml +1 -0
  32. package/skills/code-review/SKILL.md +5 -5
  33. package/skills/codebase-design/DESIGN-IT-TWICE.md +1 -1
  34. package/skills/codebase-design/SKILL.md +0 -2
  35. package/skills/diagnosing-bugs/SKILL.md +2 -4
  36. package/skills/domain-modeling/{CONTEXT-FORMAT.md → GLOSSARY-FORMAT.md} +10 -10
  37. package/skills/domain-modeling/SKILL.md +12 -14
  38. package/skills/grill-me/SKILL.md +1 -2
  39. package/skills/grill-me/agents/openai.yaml +1 -0
  40. package/skills/grill-with-docs/SKILL.md +1 -2
  41. package/skills/grill-with-docs/agents/openai.yaml +1 -0
  42. package/skills/grilling/SKILL.md +2 -2
  43. package/skills/handoff/SKILL.md +2 -3
  44. package/skills/handoff/agents/openai.yaml +1 -0
  45. package/skills/implement/SKILL.md +5 -4
  46. package/skills/implement/agents/openai.yaml +1 -0
  47. package/skills/implement-spec/SKILL.md +40 -0
  48. package/skills/implement-spec/agents/openai.yaml +5 -0
  49. package/skills/improve-codebase-architecture/SKILL.md +6 -7
  50. package/skills/improve-codebase-architecture/agents/openai.yaml +1 -0
  51. package/skills/pr/CREDITS.md +3 -0
  52. package/skills/pr/LICENSE +21 -0
  53. package/skills/pr/SKILL.md +170 -0
  54. package/skills/pr/agents/openai.yaml +3 -0
  55. package/skills/prototype/SKILL.md +0 -2
  56. package/skills/research/SKILL.md +0 -2
  57. package/skills/retro/LICENSE +21 -0
  58. package/skills/retro/SKILL.md +44 -0
  59. package/skills/retro/agents/openai.yaml +5 -0
  60. package/skills/tdd/SKILL.md +2 -4
  61. package/skills/teach/SKILL.md +3 -4
  62. package/skills/teach/agents/openai.yaml +1 -0
  63. package/skills/to-questionnaire/SKILL.md +1 -2
  64. package/skills/to-questionnaire/agents/openai.yaml +1 -0
  65. package/skills/to-spec/SKILL.md +1 -2
  66. package/skills/to-spec/agents/openai.yaml +1 -0
  67. package/skills/to-tickets/SKILL.md +3 -4
  68. package/skills/to-tickets/agents/openai.yaml +1 -0
  69. package/skills/triage/AGENT-BRIEF.md +207 -0
  70. package/skills/triage/LICENSE +21 -0
  71. package/skills/triage/OUT-OF-SCOPE.md +105 -0
  72. package/skills/triage/SKILL.md +112 -0
  73. package/skills/triage/agents/openai.yaml +5 -0
  74. package/skills/wait-what/SKILL.md +2 -3
  75. package/skills/wait-what/agents/openai.yaml +1 -0
  76. package/skills/wayfinder/SKILL.md +5 -6
  77. package/skills/wayfinder/agents/openai.yaml +1 -0
  78. package/skills/wizard/LICENSE +21 -0
  79. package/skills/wizard/SKILL.md +44 -0
  80. package/skills/wizard/agents/openai.yaml +3 -0
  81. package/skills/wizard/template.sh +223 -0
  82. package/skills/writing-for-agents/SKILL.md +0 -2
  83. package/skills/resolving-merge-conflicts/SKILL.md +0 -16
  84. package/skills/resolving-merge-conflicts/agents/openai.yaml +0 -3
  85. /package/skills/{resolving-merge-conflicts → implement-spec}/LICENSE +0 -0
package/dist/login.js CHANGED
@@ -4,9 +4,13 @@ import { hostname } from 'node:os';
4
4
  import { parseArgs } from 'node:util';
5
5
  import { post, retrying } from './api.js';
6
6
  import { placeAppGit } from './app-git.js';
7
+ import { writeCodexRule } from './clis.js';
7
8
  import { forgetOwnAgent, readDisconnected, readEnrolment, readOwnAgent, writeEnrolment, writeOwnAgent } from './home.js';
8
9
  import { callHouse, rpc } from './mcp.js';
9
- const DEFAULT_HOUSE = 'https://agents.house';
10
+ import { selectRelay } from './relay.js';
11
+ import { startService } from './service.js';
12
+ import { placeSkillSet } from './skills.js';
13
+ export const DEFAULT_HOUSE = 'https://agents.house';
10
14
  const OPENER = process.platform === 'darwin' ? 'open' : 'xdg-open';
11
15
  // Polling every two seconds brings the User's confirmation to the waiting Kit moments after they give it.
12
16
  const POLL_INTERVAL_MS = 2000;
@@ -15,7 +19,7 @@ function open(link) {
15
19
  .on('error', () => undefined)
16
20
  .unref();
17
21
  }
18
- async function accepted(house, credential) {
22
+ export async function accepted(house, credential) {
19
23
  const checked = await callHouse(house, credential, rpc('tools/list', {}));
20
24
  if (checked.status === 200)
21
25
  return true;
@@ -23,39 +27,100 @@ async function accepted(house, credential) {
23
27
  return false;
24
28
  throw new Error(`House answered ${checked.status} when Kit checked this computer's own agent's connection: ${checked.text}`);
25
29
  }
30
+ const USAGE = `usage: kit login [--house <origin>] [--environment <id>] [--rooms <ref>[,<ref>...] | --no-private]
31
+ kit login [--house <origin>] --code <code>
32
+ --house <origin> the House to connect to, ${DEFAULT_HOUSE} unless one is stored
33
+ --environment <id> reconnect this Environment
34
+ --rooms <ref>[,<ref>...] give this Environment only these Rooms
35
+ --no-private give this Environment every Room but your Private Room
36
+ --code <code> connect this machine with a login code
37
+ `;
38
+ function chosenRooms(rooms, noPrivate) {
39
+ if (rooms !== undefined && noPrivate)
40
+ throw new Error('--rooms and --no-private are two choices of Rooms; pass one');
41
+ if (rooms !== undefined)
42
+ return { rooms: { reach: 'selected', refs: rooms.split(',') } };
43
+ return noPrivate ? { rooms: { reach: 'all_but_private' } } : {};
44
+ }
26
45
  export async function login(argv) {
27
46
  const { values } = parseArgs({
28
47
  args: argv,
29
48
  options: {
30
49
  house: { type: 'string' },
31
50
  environment: { type: 'string' },
51
+ rooms: { type: 'string' },
52
+ 'no-private': { type: 'boolean', default: false },
53
+ code: { type: 'string' },
54
+ help: { type: 'boolean', default: false },
32
55
  },
33
56
  });
57
+ if (values.help) {
58
+ process.stdout.write(USAGE);
59
+ return;
60
+ }
61
+ if (values.code !== undefined && values.rooms !== undefined)
62
+ throw new Error('--code cannot be used with --rooms');
63
+ if (values.code !== undefined && values['no-private'])
64
+ throw new Error('--code cannot be used with --no-private');
65
+ if (values.code !== undefined && values.environment !== undefined)
66
+ throw new Error('--code cannot be used with --environment');
67
+ const rooms = chosenRooms(values.rooms, values['no-private']);
34
68
  const enrolled = (await readEnrolment()) ?? (await readDisconnected());
69
+ if (values.code !== undefined && enrolled !== null) {
70
+ throw new Error(`--code connects a new machine; this Kit home records Environment ${enrolled.environment}, so run kit login to reconnect it`);
71
+ }
72
+ const relay = process.env.HOUSE_KIT_RELAY || undefined;
73
+ selectRelay(relay);
35
74
  const house = values.house ?? enrolled?.house ?? DEFAULT_HOUSE;
36
75
  const replaces = process.env.HOUSE_KIT_REPLACES;
37
76
  const environment = replaces === undefined ? (values.environment ?? (enrolled?.house === house ? enrolled.environment : undefined)) : undefined;
38
77
  const ownAgent = await readOwnAgent();
39
- const held = ownAgent !== null && ownAgent.house === house && (await accepted(house, ownAgent.credential));
40
- const verifier = randomBytes(32).toString('base64url');
41
- const started = await retrying(() => post(house, '/kit', {
42
- ...(environment === undefined
43
- ? { act: 'new_environment', label: hostname(), ...(replaces === undefined ? {} : { replaces }) }
44
- : { act: 'existing_environment', environment_id: environment }),
45
- code_challenge: createHash('sha256').update(verifier).digest('base64url'),
46
- ...(held ? {} : { headless: true }),
47
- }));
48
- process.stdout.write(`Open this link and confirm: ${started.start_url}\n`);
49
- open(started.start_url);
50
- const exchanged = await retrying(() => post(house, '/kit/token', { login: started.login, code_verifier: verifier }), undefined, () => POLL_INTERVAL_MS);
51
- await writeEnrolment({ house, environment: exchanged.environment, credential: exchanged.credential });
78
+ let held = false;
79
+ let exchanged;
80
+ if (values.code !== undefined) {
81
+ exchanged = await post(house, '/kit/token', { code: values.code, label: hostname() });
82
+ }
83
+ else {
84
+ held = ownAgent !== null && ownAgent.house === house && (await accepted(house, ownAgent.credential));
85
+ const verifier = randomBytes(32).toString('base64url');
86
+ const started = await retrying(() => post(house, '/kit', {
87
+ label: hostname(),
88
+ ...(environment === undefined
89
+ ? { act: 'new_environment', ...(replaces === undefined ? {} : { replaces }) }
90
+ : { act: 'existing_environment', environment_id: environment }),
91
+ ...rooms,
92
+ code_challenge: createHash('sha256').update(verifier).digest('base64url'),
93
+ ...(held ? {} : { headless: true }),
94
+ }));
95
+ process.stdout.write(`Open this link and confirm: ${started.start_url}\n`);
96
+ open(started.start_url);
97
+ exchanged = await retrying(() => post(house, '/kit/token', { login: started.login, code_verifier: verifier }), undefined, () => POLL_INTERVAL_MS);
98
+ }
99
+ await placeSkillSet();
100
+ await writeCodexRule().catch((error) => process.stderr.write(`kit: ${error.message}\n`));
101
+ const relayRecord = relay === undefined ? {} : { relay };
102
+ await writeEnrolment({
103
+ house,
104
+ ...relayRecord,
105
+ environment: exchanged.environment,
106
+ credential: exchanged.credential,
107
+ });
52
108
  process.stdout.write(`Environment ${exchanged.environment} is connected to ${house}.\n`);
53
109
  if (exchanged.headless_credential !== undefined) {
54
- await writeOwnAgent({ house, user: exchanged.user, credential: exchanged.headless_credential });
110
+ await writeOwnAgent({ house, ...relayRecord, user: exchanged.user, credential: exchanged.headless_credential });
55
111
  }
56
- else if (held && ownAgent.user !== exchanged.user) {
112
+ else if (held && ownAgent !== null && ownAgent.user !== exchanged.user) {
57
113
  await forgetOwnAgent();
58
114
  process.stdout.write("This computer's own agent was another User's; run kit login again to connect it to you.\n");
59
115
  }
60
- await placeAppGit(ownAgent, await readOwnAgent());
116
+ else if (held && ownAgent !== null) {
117
+ await writeOwnAgent({ house, ...relayRecord, user: ownAgent.user, credential: ownAgent.credential });
118
+ }
119
+ await placeAppGit(ownAgent, await readOwnAgent()).catch((error) => process.stderr.write(`kit: ${error.message}\n`));
120
+ try {
121
+ startService();
122
+ }
123
+ catch (error) {
124
+ process.stderr.write(`kit: ${error.message}\n`);
125
+ }
61
126
  }
package/dist/parts.js CHANGED
@@ -2,7 +2,10 @@ export class Parts {
2
2
  parts = [];
3
3
  context = null;
4
4
  emit;
5
+ made = [];
6
+ events = 0;
5
7
  writing = null;
8
+ counting = null;
6
9
  planned = null;
7
10
  constructor(emit) {
8
11
  this.emit = emit;
@@ -10,32 +13,34 @@ export class Parts {
10
13
  write(type, id, text) {
11
14
  if (text === '')
12
15
  return;
13
- const last = this.parts.length - 1;
14
- const part = this.parts[last];
15
- if (this.writing?.type === type && this.writing.id === id && part?.type === type) {
16
- part.text += text;
17
- this.emit({ op: 'append', index: last, text });
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 });
18
19
  return;
19
20
  }
20
- this.start({ type, text });
21
- this.writing = { type, id };
21
+ this.writing = { type, id, index: this.start({ type, text }) };
22
22
  }
23
23
  command() {
24
- const last = this.parts.length - 1;
25
- const part = this.parts[last];
26
- if (part?.type !== 'commands') {
27
- this.start({ type: 'commands', count: 1 });
24
+ if (this.counting === null) {
25
+ this.counting = this.start({ type: 'commands', count: 1 });
28
26
  return;
29
27
  }
28
+ const part = this.parts[this.counting];
30
29
  part.count++;
31
- this.emit({ op: 'count', index: last, count: part.count });
30
+ this.emit({ op: 'count', index: this.counting, count: part.count });
32
31
  }
33
32
  start(part) {
34
33
  this.writing = null;
35
- this.parts.push(part);
36
- const index = this.parts.length - 1;
37
- this.emit({ op: 'start', index, part });
38
- return index;
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);
39
44
  }
40
45
  done(index, result) {
41
46
  const part = this.parts[index];
@@ -55,10 +60,23 @@ export class Parts {
55
60
  this.context = context;
56
61
  this.emit({ op: 'context', ...context });
57
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
+ }
58
69
  operations() {
59
70
  return [
60
71
  ...this.parts.map((part, index) => ({ op: 'start', index, part })),
61
72
  ...(this.context === null ? [] : [{ op: 'context', ...this.context }]),
62
73
  ];
63
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
+ }
64
82
  }
@@ -0,0 +1,48 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { run } from './clis.js';
4
+ import { kitHome } from './home.js';
5
+ import { relayOrigin } from './relay.js';
6
+ export function service() {
7
+ if (process.platform !== 'linux' || !process.env.INVOCATION_ID)
8
+ return null;
9
+ return process.env.MANAGERPID ? 'user' : 'system';
10
+ }
11
+ export function throughSudo() {
12
+ return service() === 'system' && process.getuid() !== 0;
13
+ }
14
+ export async function updatesItself() {
15
+ if (service() === null)
16
+ return false;
17
+ if (!throughSudo())
18
+ return true;
19
+ // sudo answers at once, so ten seconds only bounds a stuck sudo.
20
+ return (await run('sudo', ['-n', 'true'], 10_000)).status === 0;
21
+ }
22
+ function installed() {
23
+ try {
24
+ return readFileSync(join(kitHome(), 'placement'), 'utf8').trim();
25
+ }
26
+ catch (error) {
27
+ if (error.code === 'ENOENT')
28
+ return null;
29
+ throw error;
30
+ }
31
+ }
32
+ function entries(house) {
33
+ const host = new URL(house).host;
34
+ const relay = relayOrigin();
35
+ if (relay === undefined)
36
+ return [`curl -fsSL ${host}/kit | sh`, `irm ${host}/kit.ps1 | iex`];
37
+ const entry = `${relay}/${host}/kit`;
38
+ return [`curl -fsSL ${entry} | HOUSE_KIT_RELAY=${relay} sh`, `$env:HOUSE_KIT_RELAY='${relay}'; irm ${entry}.ps1 | iex`];
39
+ }
40
+ export function installCommand(house) {
41
+ const [shell, windows] = entries(house);
42
+ const placement = installed();
43
+ if (placement === 'native')
44
+ return shell;
45
+ if (placement === 'server')
46
+ return `${shell} -s -- --linux`;
47
+ return `${shell} -s -- --container, or ${windows} on Windows`;
48
+ }
package/dist/relay.js CHANGED
@@ -1,7 +1,17 @@
1
+ let selected;
2
+ export function selectRelay(relay) {
3
+ selected = relay === undefined || relay === '' ? null : relay;
4
+ }
5
+ export function relayOrigin() {
6
+ if (selected !== undefined)
7
+ return selected ?? undefined;
8
+ const ambient = process.env.HOUSE_KIT_RELAY;
9
+ return ambient === undefined || ambient === '' ? undefined : ambient;
10
+ }
1
11
  export function relayed(target) {
2
12
  const url = new URL(target);
3
- const relay = process.env.HOUSE_KIT_RELAY;
4
- if (relay === undefined || relay === '')
13
+ const relay = relayOrigin();
14
+ if (relay === undefined)
5
15
  return url;
6
16
  const through = new URL(`${url.host}${url.pathname}${url.search}`, `${relay}/`);
7
17
  if (url.protocol === 'wss:' || url.protocol === 'ws:')
package/dist/resident.js CHANGED
@@ -7,9 +7,10 @@ import { fileURLToPath } from 'node:url';
7
7
  import { Agents } from './agents.js';
8
8
  import { house } from './api.js';
9
9
  import { received } from './bridge.js';
10
- import { Conversations } from './conversations.js';
10
+ import { CONVERSATION_INPUTS, Conversations } from './conversations.js';
11
11
  import { LocalCopies } from './copies.js';
12
- import { agentBase, enrolled, kitHome } from './home.js';
12
+ import { restart } from './end.js';
13
+ import { agentBase, enrolled, forgetRestart, kitHome, restartAsked } from './home.js';
13
14
  import { killDescendants } from './scope.js';
14
15
  import { quoted } from './shell.js';
15
16
  import { SignIns } from './sign-in.js';
@@ -73,6 +74,7 @@ function connected() {
73
74
  }
74
75
  export async function resident() {
75
76
  await connected();
77
+ await forgetRestart();
76
78
  watch(kitHome(), () => {
77
79
  if (enrolled())
78
80
  return;
@@ -82,7 +84,7 @@ export async function resident() {
82
84
  await placeSkillSet();
83
85
  await mkdir(agentBase(), { recursive: true });
84
86
  process.env.HOUSE_KIT_RESIDENT = String(process.pid);
85
- const agents = new Agents(house);
87
+ const agents = new Agents(house, () => changed());
86
88
  const copies = new LocalCopies(house);
87
89
  await copies.load();
88
90
  await installShim(join(kitHome(), 'shim', 'git'), 'git-main');
@@ -90,11 +92,14 @@ export async function resident() {
90
92
  await serveOwner(copies);
91
93
  let stream = null;
92
94
  let reported = false;
93
- const idle = () => conversations.idle() && signIns.idle();
95
+ const idle = () => conversations.idle() && signIns.idle() && agents.idle();
94
96
  const changed = () => {
95
97
  if (!idle()) {
96
98
  reported = false;
97
99
  }
100
+ else if (restartAsked() && conversations.quiet()) {
101
+ restart('restarting for an updated CLI');
102
+ }
98
103
  else if (!reported) {
99
104
  reported = true;
100
105
  logged(house.deliver('/kit/idle', {}, idle));
@@ -122,7 +127,7 @@ export async function resident() {
122
127
  opened: () => {
123
128
  conversations.opened();
124
129
  changed();
125
- logged(copies.select());
130
+ logged(copies.connected());
126
131
  },
127
132
  frame: (arrived) => {
128
133
  if (arrived.type === 'watching')
@@ -135,8 +140,12 @@ export async function resident() {
135
140
  signIns.start(arrived);
136
141
  else if (arrived.kind === 'update')
137
142
  updates.start(arrived);
138
- else
143
+ else if (CONVERSATION_INPUTS.has(arrived.kind))
139
144
  conversations.input(arrived);
145
+ else {
146
+ const refused = { refused: `This Kit does not know ${arrived.kind}; update the Kit` };
147
+ logged(house.deliver(`/kit/inputs/${arrived.input_id}/ack`, refused).finally(changed));
148
+ }
140
149
  }
141
150
  },
142
151
  });
@@ -0,0 +1,9 @@
1
+ import { startService } from './service.js';
2
+ try {
3
+ if (startService())
4
+ process.stdout.write('started\n');
5
+ }
6
+ catch (error) {
7
+ process.stderr.write(`kit: ${error.message}\n`);
8
+ process.exitCode = 1;
9
+ }
@@ -0,0 +1,33 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ const UNIT = 'house-kit.service';
3
+ // launchctl and systemctl answer at once, so ten seconds only bounds a stuck service manager.
4
+ const MANAGER_MS = 10_000;
5
+ function manage(command, args) {
6
+ return spawnSync(command, args, { encoding: 'utf8', timeout: MANAGER_MS });
7
+ }
8
+ function start(command, args) {
9
+ const started = manage(command, args);
10
+ if (started.status === 0)
11
+ return;
12
+ const cause = started.error?.message ?? (started.stderr.trim() || `${command} exited with ${started.status ?? 'a signal'}`);
13
+ throw new Error(`the House Kit service could not be started: ${cause}`);
14
+ }
15
+ export function startService() {
16
+ if (process.platform === 'darwin') {
17
+ const service = `gui/${process.getuid()}/house-kit`;
18
+ const printed = manage('launchctl', ['print', service]);
19
+ if (printed.status !== 0 || /^\tstate = running$/m.test(printed.stdout))
20
+ return false;
21
+ start('launchctl', ['kickstart', service]);
22
+ return true;
23
+ }
24
+ for (const scope of [['--user'], []]) {
25
+ if (manage('systemctl', [...scope, 'is-enabled', '--quiet', UNIT]).status !== 0)
26
+ continue;
27
+ if (manage('systemctl', [...scope, 'is-active', '--quiet', UNIT]).status === 0)
28
+ return false;
29
+ start('systemctl', [...scope, 'start', UNIT]);
30
+ return true;
31
+ }
32
+ return false;
33
+ }
package/dist/skills.js CHANGED
@@ -49,6 +49,14 @@ async function install() {
49
49
  await writeHome(RECORD, { version: KIT_VERSION, names });
50
50
  }
51
51
  export async function placeSkillSet() {
52
+ try {
53
+ await replaceSkillSet();
54
+ }
55
+ catch (error) {
56
+ process.stderr.write(`kit: the skills could not be placed: ${error.message}\n`);
57
+ }
58
+ }
59
+ async function replaceSkillSet() {
52
60
  const accepted = (await readConfiguration()).skills;
53
61
  const installed = await readHome(RECORD);
54
62
  if (accepted && installed?.version === KIT_VERSION)
@@ -63,7 +71,9 @@ export async function placeSkillSet() {
63
71
  await rm(join(kitHome(), RECORD), { force: true });
64
72
  }
65
73
  export async function createHowWeWork(bridge) {
66
- if ((await readHome(RECORD)) === null || (await present(join(kitHome(), CREATED))))
74
+ if (!(await readConfiguration()).skills || (await readHome(RECORD))?.version === undefined)
75
+ return;
76
+ if (await present(join(kitHome(), CREATED)))
67
77
  return;
68
78
  const created = await bridge.tool('edit', { changes: [{ op: 'create', path: HOW_WE_WORK, content: HOW_WE_WORK_TEXT }] });
69
79
  if (created.isError === true) {
package/dist/stream.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { subscribe } from 'node:diagnostics_channel';
2
2
  import { finalRefusal, HouseRefusal, retryDelay } from './api.js';
3
- import { end, REPLACED, SIGN_IN_AGAIN } from './end.js';
3
+ import { end, REPLACED, signInAgain, updateRequired } from './end.js';
4
4
  import { readEnrolment } from './home.js';
5
5
  import { relayed } from './relay.js';
6
+ import { KIT_WIRE, tooOld } from './wire.js';
6
7
  const PATH = '/kit/stream';
7
- const SUBPROTOCOL = 'house.kit.stream.1';
8
+ const SUBPROTOCOL = `house.kit.stream.${KIT_WIRE}`;
8
9
  const REFUSAL_HEADER = 'x-house-refusal';
9
10
  function streamUrl(house) {
10
11
  const url = new URL(PATH, house);
@@ -52,8 +53,12 @@ export function holdStream(handlers) {
52
53
  process.stderr.write(`kit: control stream closed ${event.code} ${event.reason}\n`);
53
54
  if (event.reason === 'replaced')
54
55
  end(REPLACED);
55
- if (event.reason === 'credential_rejected' || refused?.status === 401)
56
- end(SIGN_IN_AGAIN);
56
+ if (event.reason === 'credential_rejected' || refused?.status === 401) {
57
+ void signInAgain(credential);
58
+ return;
59
+ }
60
+ if (refused !== null && tooOld(refused.text))
61
+ updateRequired(house);
57
62
  if (finalRefusal(refused))
58
63
  end(refused.message);
59
64
  // A closed socket reopens in one to three seconds, spread so Kits one restart closed return apart; an opening House refused as retryable or left unanswered backs off on the jittered curve.
package/dist/update.js CHANGED
@@ -4,8 +4,8 @@ import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
4
4
  import { homedir } from 'node:os';
5
5
  import { join } from 'node:path';
6
6
  import { run } from './clis.js';
7
- import { kitHome } from './home.js';
8
- const RECORD = 'outcome=$1; shift; bash "$0" --linux "$@"; printf %s "$?" > "$outcome"; systemctl start house-kit.service';
7
+ import { kitHome, workspaceRoot } from './home.js';
8
+ import { service, throughSudo } from './placement.js';
9
9
  function logged(error) {
10
10
  process.stderr.write(`kit: ${error instanceof Error ? error.message : String(error)}\n`);
11
11
  }
@@ -21,6 +21,21 @@ function outcome() {
21
21
  function unit(inputId) {
22
22
  return `house-kit-update-${inputId}`;
23
23
  }
24
+ function manager() {
25
+ return service() === 'user' ? ['--user'] : [];
26
+ }
27
+ function elevated() {
28
+ return throughSudo() ? ['sudo', '-n'] : [];
29
+ }
30
+ function account() {
31
+ return throughSudo() ? [`--uid=${process.getuid()}`, `--gid=${process.getgid()}`] : [];
32
+ }
33
+ function placement() {
34
+ return service() === 'user' ? ['--workspace', workspaceRoot()] : ['--linux'];
35
+ }
36
+ function record() {
37
+ return `outcome=$1; shift; bash "$0" "$@"; printf %s "$?" > "$outcome"; ${[...elevated(), 'systemctl', ...manager(), 'start', 'house-kit.service'].join(' ')}`;
38
+ }
24
39
  async function pendingInput() {
25
40
  try {
26
41
  return JSON.parse(await readFile(pending(), 'utf8')).input_id;
@@ -41,7 +56,7 @@ async function finished(inputId) {
41
56
  if (ack !== null)
42
57
  return ack;
43
58
  // systemctl answers at once, so ten seconds only bounds a stuck service manager.
44
- if ((await run('systemctl', ['is-active', '--quiet', unit(inputId)], 10_000)).status !== 0) {
59
+ if ((await run('systemctl', [...manager(), 'is-active', '--quiet', unit(inputId)], 10_000)).status !== 0) {
45
60
  return (await recorded()) ?? { refused: 'the Kit bootstrap did not finish' };
46
61
  }
47
62
  // The bootstrap runs for minutes, so checking each second sees its outcome within a second at little cost.
@@ -50,19 +65,26 @@ async function finished(inputId) {
50
65
  }
51
66
  function rerun(script, inputId, flags) {
52
67
  return new Promise((resolve) => {
53
- const child = spawn('systemd-run', [
68
+ const [command, ...args] = [
69
+ ...elevated(),
70
+ 'systemd-run',
71
+ ...manager(),
72
+ ...account(),
54
73
  '--wait',
55
74
  '--collect',
56
75
  '--quiet',
57
76
  `--unit=${unit(inputId)}`,
58
77
  `--setenv=HOME=${homedir()}`,
78
+ `--setenv=HOUSE_KIT_HOME=${kitHome()}`,
59
79
  '/bin/sh',
60
80
  '-c',
61
- RECORD,
81
+ record(),
62
82
  script,
63
83
  outcome(),
84
+ ...placement(),
64
85
  ...flags,
65
- ], { stdio: ['ignore', 'ignore', 'inherit'] });
86
+ ];
87
+ const child = spawn(command, args, { stdio: ['ignore', 'ignore', 'inherit'] });
66
88
  child.on('error', () => resolve({ refused: 'no service manager runs this Kit' }));
67
89
  child.on('close', () => resolve(null));
68
90
  });
package/dist/wire.js ADDED
@@ -0,0 +1,6 @@
1
+ import { refusalOf } from './refusals.js';
2
+ export const KIT_WIRE = 1;
3
+ export const KIT_WIRE_HEADER = 'x-house-kit-wire';
4
+ export function tooOld(text) {
5
+ return refusalOf(text)?.code === 'kit_update_required';
6
+ }
package/how-we-work.md CHANGED
@@ -8,16 +8,24 @@ The skills are already set up; never run `setup-matt-pocock-skills`.
8
8
 
9
9
  ## Where skill output goes
10
10
 
11
- - Glossary (`CONTEXT.md`): `glossary.md`
11
+ - Glossary (`GLOSSARY.md`): `glossary.md`
12
12
  - Decisions (ADRs): `decisions/NNNN-<slug>.md`
13
13
  - Plan (spec): `projects/<name>/plan.md`
14
14
  - Tasks (tickets): `projects/<name>/tasks/NN-<slug>.md`, with a
15
15
  `Status:` line (`needs-triage`, `needs-info`, `ready-for-agent`,
16
- `ready-for-human`, `wontfix`), a `Blocked by:` line and comments under
17
- `## Comments`
16
+ `ready-for-human`, `wontfix`, or `done` once implemented), a
17
+ `Category:` line (`bug`, `enhancement`), a `Blocked by:` line and comments
18
+ under `## Comments`; triage takes no pull requests
19
+ - Rejected requests (triage): `out-of-scope/<concept>.md`
20
+ - Implementation notes (implement-spec): `projects/<name>/notes/`
21
+ - PR bodies (pr): `projects/<name>/prs/<branch>.md`
18
22
  - Map (Wayfinding): `projects/<name>/map.md`, its tasks under
19
23
  `tasks/` with `Type:`, `Status: claimed|resolved` and `Blocked by:` lines
20
24
  - Research: `research/<slug>.md`
25
+ - Architecture reports (improve-codebase-architecture): `architecture/<slug>.html`
26
+ - Handoffs: `handoffs/<slug>.md`
21
27
  - Questionnaires: `questionnaires/<slug>.md`
28
+ - Retrospectives (retro): `retros/<date>-<slug>.md`
29
+ - Wizards: `wizards/<slug>.sh`; the values they capture stay out of the Room
22
30
  - Learning: `learning/<topic>/`
23
31
  - Prototype: one HTML file with every variant on one page.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/kit",
3
- "version": "0.2.1-c5d36e97b0fea",
3
+ "version": "0.2.1-c681dfca497a8",
4
4
  "description": "House Kit connects an Environment to agents.house.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -23,11 +23,12 @@
23
23
  "scripts": {
24
24
  "build": "tsc -p tsconfig.build.json && node scripts/bootstrap-manifest.mjs",
25
25
  "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
+ "sync-skills": "node scripts/sync-skills.mjs",
26
27
  "test": "tsc -p tsconfig.json && vitest run"
27
28
  },
28
29
  "dependencies": {
29
30
  "@agentclientprotocol/sdk": "1.7.0",
30
- "@agentshouse/mdmodel": "0.1.0-alpha.19",
31
+ "@agentshouse/mdmodel": "0.1.0-c68e2039f1ca8",
31
32
  "yaml": "2.9.1"
32
33
  },
33
34
  "peerDependencies": {