@leavewhite9088/harness-bus 0.2.0 → 0.2.1

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 (104) hide show
  1. package/ARCHITECTURE.md +81 -81
  2. package/LICENSE +21 -21
  3. package/README.md +86 -86
  4. package/SETUP_FOR_AI.md +79 -79
  5. package/package.json +4 -2
  6. package/packages/agentd/agentd.config.json +3 -1
  7. package/packages/agentd/cli/commands.mjs +854 -810
  8. package/packages/agentd/cli/format.mjs +294 -238
  9. package/packages/agentd/cli/hbus.mjs +14 -14
  10. package/packages/agentd/cli/index.mjs +4 -4
  11. package/packages/agentd/cli/skill/SKILL.md +66 -61
  12. package/packages/agentd/cli/skill/references/custom.md +12 -0
  13. package/packages/agentd/cli/skill/references/playbooks.md +89 -86
  14. package/packages/agentd/cli/skill/references/routing.md +43 -35
  15. package/packages/agentd/cli/skill-install.mjs +157 -140
  16. package/packages/agentd/cli/update.mjs +221 -221
  17. package/packages/agentd/client/index.mjs +3 -3
  18. package/packages/agentd/contexts/executor.md +13 -12
  19. package/packages/agentd/contexts/templates/architect.md +12 -12
  20. package/packages/agentd/contexts/templates/coder.md +12 -12
  21. package/packages/agentd/contexts/templates/debugger.md +12 -12
  22. package/packages/agentd/contexts/templates/researcher.md +12 -12
  23. package/packages/agentd/contexts/templates/reviewer.md +12 -12
  24. package/packages/agentd/contexts/templates/tester.md +12 -12
  25. package/packages/agentd/core/base/data-dir.mjs +39 -39
  26. package/packages/agentd/core/base/index.mjs +5 -5
  27. package/packages/agentd/core/base/protocol.mjs +13 -13
  28. package/packages/agentd/core/env/config.mjs +52 -1
  29. package/packages/agentd/core/env/index.mjs +6 -1
  30. package/packages/agentd/core/env/install.mjs +82 -4
  31. package/packages/agentd/core/pi/index.mjs +1 -1
  32. package/packages/agentd/core/pi/rpc.mjs +206 -206
  33. package/packages/agentd/core/pool/acp/client.mjs +7 -9
  34. package/packages/agentd/core/pool/acp/process.mjs +27 -18
  35. package/packages/agentd/core/pool/acp/run-tracker.mjs +293 -293
  36. package/packages/agentd/core/pool/acp/sessions.mjs +465 -465
  37. package/packages/agentd/core/pool/acp/turn-runner.mjs +5 -3
  38. package/packages/agentd/core/pool/index.mjs +2 -2
  39. package/packages/agentd/core/pool/instances.mjs +3 -5
  40. package/packages/agentd/core/pool/probe.mjs +91 -85
  41. package/packages/agentd/core/pool/registry.mjs +45 -1
  42. package/packages/agentd/core/pool/support/compaction.mjs +2 -43
  43. package/packages/agentd/core/pool/support/index.mjs +1 -1
  44. package/packages/agentd/core/prompts/index.mjs +12 -12
  45. package/packages/agentd/core/prompts/rules.mjs +22 -22
  46. package/packages/agentd/core/prompts/templates.mjs +172 -172
  47. package/packages/agentd/core/providers/index.mjs +14 -14
  48. package/packages/agentd/core/providers/store.mjs +206 -206
  49. package/packages/agentd/core/records/cleanup.mjs +51 -51
  50. package/packages/agentd/core/records/index.mjs +8 -8
  51. package/packages/agentd/core/records/metrics.mjs +73 -73
  52. package/packages/agentd/core/records/recovery.mjs +39 -39
  53. package/packages/agentd/core/records/transcripts.mjs +122 -122
  54. package/packages/agentd/core/threads/index.mjs +18 -17
  55. package/packages/agentd/core/threads/manager.mjs +498 -476
  56. package/packages/agentd/core/threads/paths.mjs +78 -78
  57. package/packages/agentd/core/threads/store.mjs +146 -125
  58. package/packages/agentd/daemon/agentd.mjs +58 -58
  59. package/packages/agentd/daemon/events.mjs +126 -126
  60. package/packages/agentd/daemon/guard.mjs +127 -127
  61. package/packages/agentd/daemon/lifecycle.mjs +61 -61
  62. package/packages/agentd/daemon/ops/index.mjs +15 -15
  63. package/packages/agentd/daemon/ops/providers.mjs +46 -46
  64. package/packages/agentd/daemon/ops/run.mjs +413 -400
  65. package/packages/agentd/daemon/ops/system.mjs +76 -69
  66. package/packages/agentd/daemon/ops/threads.mjs +156 -153
  67. package/packages/agentd/daemon/server.mjs +130 -130
  68. package/packages/agentd/package.json +1 -1
  69. package/packages/agentd/pi-adapter/acp-adapter.mjs +501 -501
  70. package/packages/agentd/scripts/restart-daemon.mjs +74 -74
  71. package/packages/agentd/scripts/run-isolated.mjs +42 -42
  72. package/packages/agentd/scripts/run-unit.mjs +28 -28
  73. package/packages/backend/src/daemon.mjs +69 -69
  74. package/packages/backend/src/server.mjs +270 -270
  75. package/packages/drivers/{agy.mjs → agy/index.mjs} +2 -1
  76. package/packages/drivers/{claude.mjs → claude/index.mjs} +23 -1
  77. package/packages/drivers/{codex.mjs → codex/index.mjs} +2 -1
  78. package/packages/drivers/{dsh.mjs → dsh/index.mjs} +3 -2
  79. package/packages/drivers/grok/index.mjs +96 -0
  80. package/packages/drivers/index.mjs +25 -12
  81. package/packages/drivers/{kimi.mjs → kimi/index.mjs} +2 -1
  82. package/packages/drivers/{mcode.mjs → mcode/index.mjs} +2 -1
  83. package/packages/drivers/{opencode.mjs → opencode/index.mjs} +2 -1
  84. package/packages/drivers/{pi.mjs → pi/index.mjs} +3 -2
  85. package/packages/drivers/probes/acp.mjs +109 -109
  86. package/packages/drivers/probes/index.mjs +131 -129
  87. package/packages/drivers/probes/provider.mjs +222 -222
  88. package/packages/drivers/qoder/index.mjs +32 -0
  89. package/packages/drivers/{bin.mjs → shared/bin.mjs} +2 -0
  90. package/packages/drivers/shared/index.mjs +2 -0
  91. package/packages/preflight/bin/preflight.mjs +116 -116
  92. package/packages/preflight/src/index.mjs +5 -5
  93. package/packages/preflight/src/report.mjs +18 -1
  94. package/packages/web/dist/apple-touch-icon.png +0 -0
  95. package/packages/web/dist/assets/index-CT8dIwav.css +2 -0
  96. package/packages/web/dist/assets/index-CypTUMFB.js +79 -0
  97. package/packages/web/dist/favicon-32.png +0 -0
  98. package/packages/web/dist/favicon.svg +19 -15
  99. package/packages/web/dist/index.html +5 -5
  100. package/packages/web/dist/assets/index-B2kdkHNw.js +0 -79
  101. package/packages/web/dist/assets/index-DQTyjC4x.css +0 -2
  102. /package/packages/drivers/{dsh-sessions.mjs → dsh/sessions.mjs} +0 -0
  103. /package/packages/drivers/{pi-catalog.mjs → pi/catalog.mjs} +0 -0
  104. /package/packages/drivers/{lib.mjs → shared/lib.mjs} +0 -0
@@ -1,140 +1,157 @@
1
- import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
2
- import { homedir } from 'node:os';
3
- import { dirname, join } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
-
6
- const HERE = dirname(fileURLToPath(import.meta.url));
7
- export const SKILL_SOURCE = join(HERE, 'skill', 'SKILL.md');
8
- export const ROUTING_SOURCE = join(HERE, 'skill', 'references', 'routing.md');
9
- export const PLAYBOOKS_SOURCE = join(HERE, 'skill', 'references', 'playbooks.md');
10
- export const SKILL_NAME = 'harness-bus';
11
-
12
- function atomicWrite(file, content) {
13
- mkdirSync(dirname(file), { recursive: true });
14
- const tmp = `${file}.hbus-tmp-${process.pid}`;
15
- writeFileSync(tmp, content, 'utf8');
16
- renameSync(tmp, file);
17
- }
18
-
19
- export function skillTargets(home = homedir()) {
20
- const mk = (id, label, detectDir, skillDir, extra = {}) => ({
21
- id,
22
- label,
23
- detectDir,
24
- skillDir,
25
- skillFile: join(skillDir, 'SKILL.md'),
26
- routingFile: join(skillDir, 'references', 'routing.md'),
27
- playbooksFile: join(skillDir, 'references', 'playbooks.md'),
28
- ...extra,
29
- });
30
- return [
31
- mk('shared', 'Shared Agents (.agents)', join(home, '.agents'), join(home, '.agents', 'skills', SKILL_NAME), { alwaysInstall: true }),
32
- mk('agy', 'Antigravity', join(home, '.gemini'), join(home, '.gemini', 'antigravity', 'skills', SKILL_NAME)),
33
- mk('claude', 'Claude Code', join(home, '.claude'), join(home, '.claude', 'skills', SKILL_NAME)),
34
- mk('codex', 'OpenAI Codex', join(home, '.codex'), join(home, '.codex', 'skills', SKILL_NAME)),
35
- mk('kimi', 'Kimi Code', join(home, '.kimi-code'), join(home, '.kimi-code', 'skills', SKILL_NAME)),
36
- mk('opencode', 'OpenCode', join(home, '.config', 'opencode'), join(home, '.config', 'opencode', 'skills', SKILL_NAME), {
37
- fallbackDetectDir: join(home, '.local', 'share', 'opencode'),
38
- }),
39
- mk('pi', 'Pi Coding Agent', join(home, '.pi'), join(home, '.pi', 'agent', 'skills', SKILL_NAME)),
40
- ];
41
- }
42
-
43
- function isDetected(t) {
44
- return Boolean(
45
- t.alwaysInstall ||
46
- (t.detectDir && existsSync(t.detectDir)) ||
47
- (t.fallbackDetectDir && existsSync(t.fallbackDetectDir)) ||
48
- existsSync(t.skillFile),
49
- );
50
- }
51
-
52
- export function statusSkills({ homeDir = homedir(), onlyTargets = null } = {}) {
53
- const allow = onlyTargets?.length ? new Set(onlyTargets) : null;
54
- return skillTargets(homeDir)
55
- .filter((t) => !allow || allow.has(t.id))
56
- .map((t) => ({
57
- id: t.id,
58
- label: t.label,
59
- present: isDetected(t),
60
- installed: existsSync(t.skillFile),
61
- routingInstalled: existsSync(t.routingFile),
62
- playbooksInstalled: existsSync(t.playbooksFile),
63
- skillFile: t.skillFile,
64
- routingFile: t.routingFile,
65
- playbooksFile: t.playbooksFile,
66
- }));
67
- }
68
-
69
- export function installSkills({ homeDir = homedir(), onlyTargets = null, all = false, resetRouting = false } = {}) {
70
- const allow = onlyTargets?.length ? new Set(onlyTargets) : null;
71
- const content = readFileSync(SKILL_SOURCE, 'utf8');
72
- const routingContent = existsSync(ROUTING_SOURCE) ? readFileSync(ROUTING_SOURCE, 'utf8') : null;
73
- const playbooksContent = existsSync(PLAYBOOKS_SOURCE) ? readFileSync(PLAYBOOKS_SOURCE, 'utf8') : null;
74
- const rows = [];
75
-
76
- for (const t of skillTargets(homeDir)) {
77
- if (allow && !allow.has(t.id)) continue;
78
- const present = isDetected(t);
79
- if (!present && !all && !allow?.has(t.id)) {
80
- rows.push({
81
- id: t.id,
82
- label: t.label,
83
- present: false,
84
- installed: false,
85
- action: 'skipped',
86
- skillFile: t.skillFile,
87
- routingFile: t.routingFile,
88
- playbooksFile: t.playbooksFile,
89
- });
90
- continue;
91
- }
92
- const existed = existsSync(t.skillFile);
93
- atomicWrite(t.skillFile, content);
94
- let playbooksAction = 'none';
95
- if (playbooksContent) {
96
- const pbExisted = existsSync(t.playbooksFile);
97
- atomicWrite(t.playbooksFile, playbooksContent);
98
- playbooksAction = pbExisted ? 'updated' : 'installed';
99
- }
100
- let routingAction = 'none';
101
- if (routingContent) {
102
- const routingExisted = existsSync(t.routingFile);
103
- if (!routingExisted || resetRouting) {
104
- atomicWrite(t.routingFile, routingContent);
105
- routingAction = routingExisted ? 'reset' : 'installed';
106
- } else {
107
- routingAction = 'kept';
108
- }
109
- }
110
- rows.push({
111
- id: t.id,
112
- label: t.label,
113
- present: true,
114
- installed: true,
115
- action: existed ? 'updated' : 'installed',
116
- playbooksAction,
117
- routingAction,
118
- skillFile: t.skillFile,
119
- routingFile: t.routingFile,
120
- playbooksFile: t.playbooksFile,
121
- });
122
- }
123
- return rows;
124
- }
125
-
126
- export function uninstallSkills({ homeDir = homedir(), onlyTargets = null } = {}) {
127
- const allow = onlyTargets?.length ? new Set(onlyTargets) : null;
128
- const rows = [];
129
-
130
- for (const t of skillTargets(homeDir)) {
131
- if (allow && !allow.has(t.id)) continue;
132
- if (!existsSync(t.skillFile) && !existsSync(t.skillDir)) {
133
- rows.push({ id: t.id, label: t.label, removed: false, action: 'not installed', skillFile: t.skillFile });
134
- continue;
135
- }
136
- rmSync(t.skillDir, { recursive: true, force: true });
137
- rows.push({ id: t.id, label: t.label, removed: true, action: 'removed', skillFile: t.skillFile });
138
- }
139
- return rows;
140
- }
1
+ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { dirname, join } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const HERE = dirname(fileURLToPath(import.meta.url));
7
+ export const SKILL_SOURCE = join(HERE, 'skill', 'SKILL.md');
8
+ export const ROUTING_SOURCE = join(HERE, 'skill', 'references', 'routing.md');
9
+ export const PLAYBOOKS_SOURCE = join(HERE, 'skill', 'references', 'playbooks.md');
10
+ export const CUSTOM_SOURCE = join(HERE, 'skill', 'references', 'custom.md');
11
+ export const SKILL_NAME = 'harness-bus';
12
+
13
+ function atomicWrite(file, content) {
14
+ mkdirSync(dirname(file), { recursive: true });
15
+ const tmp = `${file}.hbus-tmp-${process.pid}`;
16
+ writeFileSync(tmp, content, 'utf8');
17
+ renameSync(tmp, file);
18
+ }
19
+
20
+ export function skillTargets(home = homedir()) {
21
+ const mk = (id, label, detectDir, skillDir, extra = {}) => ({
22
+ id,
23
+ label,
24
+ detectDir,
25
+ skillDir,
26
+ skillFile: join(skillDir, 'SKILL.md'),
27
+ routingFile: join(skillDir, 'references', 'routing.md'),
28
+ playbooksFile: join(skillDir, 'references', 'playbooks.md'),
29
+ customFile: join(skillDir, 'references', 'custom.md'),
30
+ ...extra,
31
+ });
32
+ return [
33
+ mk('shared', 'Shared Agents (.agents)', join(home, '.agents'), join(home, '.agents', 'skills', SKILL_NAME), { alwaysInstall: true }),
34
+ mk('agy', 'Antigravity', join(home, '.gemini'), join(home, '.gemini', 'antigravity', 'skills', SKILL_NAME)),
35
+ mk('claude', 'Claude Code', join(home, '.claude'), join(home, '.claude', 'skills', SKILL_NAME)),
36
+ mk('codex', 'OpenAI Codex', join(home, '.codex'), join(home, '.codex', 'skills', SKILL_NAME)),
37
+ mk('kimi', 'Kimi Code', join(home, '.kimi-code'), join(home, '.kimi-code', 'skills', SKILL_NAME)),
38
+ mk('opencode', 'OpenCode', join(home, '.config', 'opencode'), join(home, '.config', 'opencode', 'skills', SKILL_NAME), {
39
+ fallbackDetectDir: join(home, '.local', 'share', 'opencode'),
40
+ }),
41
+ mk('pi', 'Pi Coding Agent', join(home, '.pi'), join(home, '.pi', 'agent', 'skills', SKILL_NAME)),
42
+ mk('qoder', 'Qoder', join(home, '.qoder'), join(home, '.qoder', 'skills', SKILL_NAME)),
43
+ mk('grok', 'Grok Build', join(home, '.grok'), join(home, '.grok', 'skills', SKILL_NAME)),
44
+ ];
45
+ }
46
+
47
+ function isDetected(t) {
48
+ return Boolean(
49
+ t.alwaysInstall ||
50
+ (t.detectDir && existsSync(t.detectDir)) ||
51
+ (t.fallbackDetectDir && existsSync(t.fallbackDetectDir)) ||
52
+ existsSync(t.skillFile),
53
+ );
54
+ }
55
+
56
+ export function statusSkills({ homeDir = homedir(), onlyTargets = null } = {}) {
57
+ const allow = onlyTargets?.length ? new Set(onlyTargets) : null;
58
+ return skillTargets(homeDir)
59
+ .filter((t) => !allow || allow.has(t.id))
60
+ .map((t) => ({
61
+ id: t.id,
62
+ label: t.label,
63
+ present: isDetected(t),
64
+ installed: existsSync(t.skillFile),
65
+ routingInstalled: existsSync(t.routingFile),
66
+ playbooksInstalled: existsSync(t.playbooksFile),
67
+ customInstalled: existsSync(t.customFile),
68
+ skillFile: t.skillFile,
69
+ routingFile: t.routingFile,
70
+ playbooksFile: t.playbooksFile,
71
+ customFile: t.customFile,
72
+ }));
73
+ }
74
+
75
+ export function installSkills({ homeDir = homedir(), onlyTargets = null, all = false, resetCustom = false, resetRouting = false } = {}) {
76
+ const allow = onlyTargets?.length ? new Set(onlyTargets) : null;
77
+ const content = readFileSync(SKILL_SOURCE, 'utf8');
78
+ const routingContent = existsSync(ROUTING_SOURCE) ? readFileSync(ROUTING_SOURCE, 'utf8') : null;
79
+ const playbooksContent = existsSync(PLAYBOOKS_SOURCE) ? readFileSync(PLAYBOOKS_SOURCE, 'utf8') : null;
80
+ const customContent = existsSync(CUSTOM_SOURCE) ? readFileSync(CUSTOM_SOURCE, 'utf8') : null;
81
+ const shouldResetCustom = Boolean(resetCustom || resetRouting);
82
+ const rows = [];
83
+
84
+ for (const t of skillTargets(homeDir)) {
85
+ if (allow && !allow.has(t.id)) continue;
86
+ const present = isDetected(t);
87
+ if (!present && !all && !allow?.has(t.id)) {
88
+ rows.push({
89
+ id: t.id,
90
+ label: t.label,
91
+ present: false,
92
+ installed: false,
93
+ action: 'skipped',
94
+ skillFile: t.skillFile,
95
+ routingFile: t.routingFile,
96
+ playbooksFile: t.playbooksFile,
97
+ customFile: t.customFile,
98
+ });
99
+ continue;
100
+ }
101
+ const existed = existsSync(t.skillFile);
102
+ atomicWrite(t.skillFile, content);
103
+ let playbooksAction = 'none';
104
+ if (playbooksContent) {
105
+ const pbExisted = existsSync(t.playbooksFile);
106
+ atomicWrite(t.playbooksFile, playbooksContent);
107
+ playbooksAction = pbExisted ? 'updated' : 'installed';
108
+ }
109
+ let routingAction = 'none';
110
+ if (routingContent) {
111
+ const routingExisted = existsSync(t.routingFile);
112
+ atomicWrite(t.routingFile, routingContent);
113
+ routingAction = routingExisted ? 'updated' : 'installed';
114
+ }
115
+ let customAction = 'none';
116
+ if (customContent) {
117
+ const customExisted = existsSync(t.customFile);
118
+ if (!customExisted || shouldResetCustom) {
119
+ atomicWrite(t.customFile, customContent);
120
+ customAction = customExisted ? 'reset' : 'installed';
121
+ } else {
122
+ customAction = 'kept';
123
+ }
124
+ }
125
+ rows.push({
126
+ id: t.id,
127
+ label: t.label,
128
+ present: true,
129
+ installed: true,
130
+ action: existed ? 'updated' : 'installed',
131
+ playbooksAction,
132
+ routingAction,
133
+ customAction,
134
+ skillFile: t.skillFile,
135
+ routingFile: t.routingFile,
136
+ playbooksFile: t.playbooksFile,
137
+ customFile: t.customFile,
138
+ });
139
+ }
140
+ return rows;
141
+ }
142
+
143
+ export function uninstallSkills({ homeDir = homedir(), onlyTargets = null } = {}) {
144
+ const allow = onlyTargets?.length ? new Set(onlyTargets) : null;
145
+ const rows = [];
146
+
147
+ for (const t of skillTargets(homeDir)) {
148
+ if (allow && !allow.has(t.id)) continue;
149
+ if (!existsSync(t.skillFile) && !existsSync(t.skillDir)) {
150
+ rows.push({ id: t.id, label: t.label, removed: false, action: 'not installed', skillFile: t.skillFile });
151
+ continue;
152
+ }
153
+ rmSync(t.skillDir, { recursive: true, force: true });
154
+ rows.push({ id: t.id, label: t.label, removed: true, action: 'removed', skillFile: t.skillFile });
155
+ }
156
+ return rows;
157
+ }