@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.
- package/ARCHITECTURE.md +81 -81
- package/LICENSE +21 -21
- package/README.md +86 -86
- package/SETUP_FOR_AI.md +79 -79
- package/package.json +4 -2
- package/packages/agentd/agentd.config.json +3 -1
- package/packages/agentd/cli/commands.mjs +854 -810
- package/packages/agentd/cli/format.mjs +294 -238
- package/packages/agentd/cli/hbus.mjs +14 -14
- package/packages/agentd/cli/index.mjs +4 -4
- package/packages/agentd/cli/skill/SKILL.md +66 -61
- package/packages/agentd/cli/skill/references/custom.md +12 -0
- package/packages/agentd/cli/skill/references/playbooks.md +89 -86
- package/packages/agentd/cli/skill/references/routing.md +43 -35
- package/packages/agentd/cli/skill-install.mjs +157 -140
- package/packages/agentd/cli/update.mjs +221 -221
- package/packages/agentd/client/index.mjs +3 -3
- package/packages/agentd/contexts/executor.md +13 -12
- package/packages/agentd/contexts/templates/architect.md +12 -12
- package/packages/agentd/contexts/templates/coder.md +12 -12
- package/packages/agentd/contexts/templates/debugger.md +12 -12
- package/packages/agentd/contexts/templates/researcher.md +12 -12
- package/packages/agentd/contexts/templates/reviewer.md +12 -12
- package/packages/agentd/contexts/templates/tester.md +12 -12
- package/packages/agentd/core/base/data-dir.mjs +39 -39
- package/packages/agentd/core/base/index.mjs +5 -5
- package/packages/agentd/core/base/protocol.mjs +13 -13
- package/packages/agentd/core/env/config.mjs +52 -1
- package/packages/agentd/core/env/index.mjs +6 -1
- package/packages/agentd/core/env/install.mjs +82 -4
- package/packages/agentd/core/pi/index.mjs +1 -1
- package/packages/agentd/core/pi/rpc.mjs +206 -206
- package/packages/agentd/core/pool/acp/client.mjs +7 -9
- package/packages/agentd/core/pool/acp/process.mjs +27 -18
- package/packages/agentd/core/pool/acp/run-tracker.mjs +293 -293
- package/packages/agentd/core/pool/acp/sessions.mjs +465 -465
- package/packages/agentd/core/pool/acp/turn-runner.mjs +5 -3
- package/packages/agentd/core/pool/index.mjs +2 -2
- package/packages/agentd/core/pool/instances.mjs +3 -5
- package/packages/agentd/core/pool/probe.mjs +91 -85
- package/packages/agentd/core/pool/registry.mjs +45 -1
- package/packages/agentd/core/pool/support/compaction.mjs +2 -43
- package/packages/agentd/core/pool/support/index.mjs +1 -1
- package/packages/agentd/core/prompts/index.mjs +12 -12
- package/packages/agentd/core/prompts/rules.mjs +22 -22
- package/packages/agentd/core/prompts/templates.mjs +172 -172
- package/packages/agentd/core/providers/index.mjs +14 -14
- package/packages/agentd/core/providers/store.mjs +206 -206
- package/packages/agentd/core/records/cleanup.mjs +51 -51
- package/packages/agentd/core/records/index.mjs +8 -8
- package/packages/agentd/core/records/metrics.mjs +73 -73
- package/packages/agentd/core/records/recovery.mjs +39 -39
- package/packages/agentd/core/records/transcripts.mjs +122 -122
- package/packages/agentd/core/threads/index.mjs +18 -17
- package/packages/agentd/core/threads/manager.mjs +498 -476
- package/packages/agentd/core/threads/paths.mjs +78 -78
- package/packages/agentd/core/threads/store.mjs +146 -125
- package/packages/agentd/daemon/agentd.mjs +58 -58
- package/packages/agentd/daemon/events.mjs +126 -126
- package/packages/agentd/daemon/guard.mjs +127 -127
- package/packages/agentd/daemon/lifecycle.mjs +61 -61
- package/packages/agentd/daemon/ops/index.mjs +15 -15
- package/packages/agentd/daemon/ops/providers.mjs +46 -46
- package/packages/agentd/daemon/ops/run.mjs +413 -400
- package/packages/agentd/daemon/ops/system.mjs +76 -69
- package/packages/agentd/daemon/ops/threads.mjs +156 -153
- package/packages/agentd/daemon/server.mjs +130 -130
- package/packages/agentd/package.json +1 -1
- package/packages/agentd/pi-adapter/acp-adapter.mjs +501 -501
- package/packages/agentd/scripts/restart-daemon.mjs +74 -74
- package/packages/agentd/scripts/run-isolated.mjs +42 -42
- package/packages/agentd/scripts/run-unit.mjs +28 -28
- package/packages/backend/src/daemon.mjs +69 -69
- package/packages/backend/src/server.mjs +270 -270
- package/packages/drivers/{agy.mjs → agy/index.mjs} +2 -1
- package/packages/drivers/{claude.mjs → claude/index.mjs} +23 -1
- package/packages/drivers/{codex.mjs → codex/index.mjs} +2 -1
- package/packages/drivers/{dsh.mjs → dsh/index.mjs} +3 -2
- package/packages/drivers/grok/index.mjs +96 -0
- package/packages/drivers/index.mjs +25 -12
- package/packages/drivers/{kimi.mjs → kimi/index.mjs} +2 -1
- package/packages/drivers/{mcode.mjs → mcode/index.mjs} +2 -1
- package/packages/drivers/{opencode.mjs → opencode/index.mjs} +2 -1
- package/packages/drivers/{pi.mjs → pi/index.mjs} +3 -2
- package/packages/drivers/probes/acp.mjs +109 -109
- package/packages/drivers/probes/index.mjs +131 -129
- package/packages/drivers/probes/provider.mjs +222 -222
- package/packages/drivers/qoder/index.mjs +32 -0
- package/packages/drivers/{bin.mjs → shared/bin.mjs} +2 -0
- package/packages/drivers/shared/index.mjs +2 -0
- package/packages/preflight/bin/preflight.mjs +116 -116
- package/packages/preflight/src/index.mjs +5 -5
- package/packages/preflight/src/report.mjs +18 -1
- package/packages/web/dist/apple-touch-icon.png +0 -0
- package/packages/web/dist/assets/index-CT8dIwav.css +2 -0
- package/packages/web/dist/assets/index-CypTUMFB.js +79 -0
- package/packages/web/dist/favicon-32.png +0 -0
- package/packages/web/dist/favicon.svg +19 -15
- package/packages/web/dist/index.html +5 -5
- package/packages/web/dist/assets/index-B2kdkHNw.js +0 -79
- package/packages/web/dist/assets/index-DQTyjC4x.css +0 -2
- /package/packages/drivers/{dsh-sessions.mjs → dsh/sessions.mjs} +0 -0
- /package/packages/drivers/{pi-catalog.mjs → pi/catalog.mjs} +0 -0
- /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
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
mk('
|
|
34
|
-
mk('
|
|
35
|
-
mk('
|
|
36
|
-
mk('
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
+
}
|