Agent Harness · VibeGit
Agent Harness Публичная копия обвязки агентной разработки: гейты, journeys, скиллы и шаблоны. Без ключей и личных данных.
agent-harness / tools / doctor.mjs 140 строк · изменён 6 нояб., 03:45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
import fs from 'node:fs' ;
import path from 'node:path' ;
import { spawnSync } from 'node:child_process' ;
import { HARNESS_ROOT , homeDir, parseArgs, readJsonc, readJson, sha256 } from './lib.mjs' ;
import { loadManifest, validateSkillsDir, parity } from './skills.mjs' ;
import { scanFiles } from './policy.mjs' ;
const { flags } = parseArgs ( process. argv
home
results
results level area message
name args
res name args process
res res
res res
nodeMajor process
nodeMajor
name level why
version name name
version level name version
pms pm
pms pms
manifest
skillIssues
path manifest
path manifest
manifest
i skillIssues i
skillIssues i
installed path home
installed
drift installed fs f f f
drift drift
installed manifest
fs path home fs path home
fs path home
ocConfig path home f fs f
ocConfig
cfg ocConfig
mcp cfg
mcp
entries mcp mcp
name server entries
server
cmd server server
viaShell cmd cmd a
substFields server viaShell cmd
substFields
names entries n
lacking names n
lacking
cfg
error
leaks ocConfig
leaks
piSettings path home
fs piSettings
s piSettings
missing s p
missing missing
piMcp path home
piServers piMcp
piMissing piServers n
piMissing fs piMcp piMissing
error
error
name why process name
templatesDir path
fs path templatesDir fs templatesDir
chrome b
chrome chrome
sshConfig path home
fs sshConfig
hosts fs sshConfig l
hosts
res url
res
searx flags flags flags
status
status status
flags
out process
out out
line out l line line
flags results
icon
r results
errors results r
warns results r
process results r
.
slice
(
2
)
)
;
const
FRONTEND_MCP
=
[
'playwright'
,
'chrome-devtools'
,
'context7'
]
;
const
=
homeDir
(
)
;
const
=
[
]
;
const
add
=
(
level, area, message
)
=>
.
push
(
{
,
,
}
)
;
function
bin
(
,
=
[
'--version'
]
)
{
const
=
spawnSync
(
,
,
{
encoding
:
'utf8'
,
shell
:
.
platform
===
'win32'
,
timeout
:
15000
}
)
;
if
(
.
error
||
.
status
!==
0
)
return
null
;
return
(
.
stdout
||
.
stderr
)
.
trim
(
)
.
split
(
'\n'
)
[
0
]
;
}
const
=
Number
(
.
versions
.
node
.
split
(
'.'
)
[
0
]
)
;
add
(
>=
20
?
'ok'
:
'error'
,
'node'
,
` v ${ process. versions . node } ${ nodeMajor >= 20 ? '' : ' (need >= 20)' } `
)
;
for
(
const
[
,
,
]
of
[
[
'git'
,
'error'
,
'worktrees, review diff, release gate'
]
,
[
'ssh'
,
'warn'
,
'VPS tasks'
]
,
[
'npx'
,
'warn'
,
'MCP servers (searxng, playwright)'
]
,
[
'uvx'
,
'warn'
,
'mcp-server-fetch'
]
,
[
'pi'
,
'warn'
,
'Pi agent'
]
,
[
'opencode'
,
'warn'
,
'OpenCode agent'
]
,
]
)
{
const
=
bin
(
,
===
'ssh'
?
[
'-V'
]
:
[
'--version'
]
)
;
add
(
?
'ok'
:
,
,
??
` not found ( ${ why} ) `
)
;
}
const
=
[
'pnpm'
,
'npm'
,
'yarn'
,
'bun'
]
.
filter
(
(
pm
)
=>
bin
(
)
)
;
add
(
.
length
?
'ok'
:
'error'
,
'package-managers'
,
.
join
(
', '
)
||
'none found'
)
;
const
=
loadManifest
(
)
;
const
=
[
...
validateSkillsDir
(
.
join
(
HARNESS_ROOT
,
.
paths
.
piSkills
)
)
,
...
validateSkillsDir
(
.
join
(
HARNESS_ROOT
,
.
paths
.
opencodeSkills
)
)
,
...
parity
(
)
,
]
;
for
(
const
of
)
add
(
.
level
,
'skills'
,
` ${ i. where } : ${ i. message } `
)
;
if
(
!
.
some
(
(
i
)
=>
.
level
===
'error'
)
)
add
(
'ok'
,
'skills'
,
'frontmatter + Pi/OpenCode parity'
)
;
const
=
readJson
(
.
join
(
,
'.agent-harness'
,
'installed.json'
)
,
null
)
;
if
(
!
)
add
(
'warn'
,
'install'
,
'harness not installed in home (node tools/install.mjs)'
)
;
else
{
const
=
.
files
.
filter
(
(
f
)
=>
!
.
existsSync
(
.
path
)
||
sha256
(
.
path
)
!==
.
sha256
)
;
add
(
.
length
?
'warn'
:
'ok'
,
'install'
,
.
length
?
` ${ drift. length } installed file(s) changed since install: ${ drift. slice ( 0 , 3 ) . map ( ( d ) => d. path ) . join ( ', ' ) } `
:
` v ${ installed. version } , ${ installed. files . length } files intact `
)
;
if
(
.
version
!==
.
version
)
add
(
'warn'
,
'install'
,
` installed ${ installed. version } , harness is ${ manifest. version } : reinstall `
)
;
}
add
(
.
existsSync
(
.
join
(
,
'AGENTS.md'
)
)
?
'ok'
:
'warn'
,
'memory'
,
.
existsSync
(
.
join
(
,
'AGENTS.md'
)
)
?
'~/AGENTS.md present'
:
'~/AGENTS.md missing'
)
;
if
(
.
existsSync
(
.
join
(
,
'AGENTS.md.harness-new'
)
)
)
add
(
'warn'
,
'memory'
,
'~/AGENTS.md.harness-new waits for a manual merge'
)
;
const
=
[
'opencode.jsonc'
,
'opencode.json'
]
.
map
(
(
f
)
=>
.
join
(
,
'.config'
,
'opencode'
,
)
)
.
find
(
(
f
)
=>
.
existsSync
(
)
)
;
if
(
!
)
add
(
'warn'
,
'opencode-config'
,
'no ~/.config/opencode/opencode.json(c)'
)
;
else
{
try
{
const
=
readJsonc
(
)
;
const
=
.
mcp
??
{
}
;
if
(
.
servers
)
add
(
'warn'
,
'opencode-config'
,
'uses "mcp.servers": the official schema expects mcp.<name> directly. Confirm with `opencode mcp list` on your build.'
)
;
const
=
Object
.
entries
(
.
servers
??
)
;
for
(
const
[
,
]
of
)
{
if
(
.
disabled
!==
undefined
)
add
(
'warn'
,
'opencode-config'
,
` mcp ${ name} : "disabled" is not in the official schema, use "enabled": false `
)
;
const
=
Array
.
isArray
(
.
command
)
?
.
command
:
[
]
;
const
=
/ ^ ( bash| sh| zsh| cmd| powershell| pwsh) ( \. exe) ? $ / i
.
test
(
String
(
[
0
]
??
''
)
)
&&
.
some
(
(
a
)
=>
/ ^ -\w * c$ /
.
test
(
String
(
)
)
)
;
const
=
[
.
environment
??
{
}
,
...
(
?
[
]
:
.
slice
(
1
)
)
]
;
if
(
JSON
.
stringify
(
)
.
includes
(
'${'
)
)
add
(
'warn'
,
'opencode-config'
,
` mcp ${ name} : "\${VAR}" is not expanded by OpenCode, use "{env:VAR}" `
)
;
}
add
(
'ok'
,
'opencode-config'
,
` ${ path. basename ( ocConfig) } parsed, ${ entries. length } MCP server(s) `
)
;
const
=
.
map
(
(
[ n]
)
=>
)
;
const
=
FRONTEND_MCP
.
filter
(
(
n
)
=>
!
.
includes
(
)
)
;
if
(
.
length
)
add
(
'warn'
,
'opencode-config'
,
` frontend MCP missing: ${ lacking. join ( ', ' ) } (see opencode/opencode.jsonc.example) `
)
;
if
(
!
.
permission
)
add
(
'warn'
,
'opencode-config'
,
'no "permission" block: dangerous commands run without approval (node tools/policy.mjs opencode-permission)'
)
;
}
catch
(
)
{
add
(
'error'
,
'opencode-config'
,
` ${ ocConfig} : ${ error. message } `
)
;
}
const
=
scanFiles
(
[
]
)
;
if
(
.
length
)
add
(
'error'
,
'secrets'
,
` ${ ocConfig} contains ${ leaks. length } plaintext secret(s); move them to env and reference {env:VAR} `
)
;
}
const
=
.
join
(
,
'.pi'
,
'agent'
,
'settings.json'
)
;
if
(
.
existsSync
(
)
)
{
try
{
const
=
readJson
(
)
;
const
=
[
'npm:pi-subagents'
,
'npm:pi-mcp-adapter'
,
'npm:pi-web-access'
]
.
filter
(
(
p
)
=>
!
(
.
packages
??
[
]
)
.
includes
(
)
)
;
add
(
.
length
?
'warn'
:
'ok'
,
'pi-config'
,
.
length
?
` missing packages: ${ missing. join ( ', ' ) } `
:
'required packages listed'
)
;
const
=
.
join
(
,
'.config'
,
'mcp'
,
'mcp.json'
)
;
const
=
Object
.
keys
(
readJson
(
,
{
}
)
.
mcpServers
??
{
}
)
;
const
=
FRONTEND_MCP
.
filter
(
(
n
)
=>
!
.
includes
(
)
)
;
add
(
.
length
?
'warn'
:
'ok'
,
'pi-mcp'
,
.
existsSync
(
)
?
(
.
length
?
` ~/.config/mcp/mcp.json lacks: ${ piMissing. join ( ', ' ) } `
:
` ${ piServers. length } server(s) incl. frontend set `
)
:
'no ~/.config/mcp/mcp.json (pi-mcp-adapter has no servers)'
)
;
}
catch
(
)
{
add
(
'error'
,
'pi-config'
,
.
message
)
;
}
}
else
add
(
'warn'
,
'pi-config'
,
'no ~/.pi/agent/settings.json'
)
;
for
(
const
[
,
]
of
[
[
'TAVILY_API_KEY'
,
'tavily MCP stays off'
]
,
[
'CONTEXT7_API_KEY'
,
'context7 works with lower rate limits'
]
]
)
add
(
.
env
[
]
?
'ok'
:
'warn'
,
'env'
,
` ${ name} ${ process. env [ name] ? 'set' : ` not set ( ${ why} ) ` } `
)
;
const
=
.
join
(
HARNESS_ROOT
,
'templates'
,
'frontend'
)
;
add
(
.
existsSync
(
.
join
(
,
'playwright.config.ts'
)
)
?
'ok'
:
'error'
,
'templates'
,
.
existsSync
(
)
?
'frontend templates present'
:
` missing ${ templatesDir} `
)
;
const
=
[
'google-chrome'
,
'google-chrome-stable'
,
'chromium'
,
'chromium-browser'
]
.
map
(
(
b
)
=>
bin
(
)
)
.
find
(
Boolean
)
;
add
(
?
'ok'
:
'warn'
,
'chrome'
,
??
'no Chrome/Chromium in PATH (chrome-devtools MCP, lhci need one; playwright installs its own)'
)
;
const
=
.
join
(
,
'.ssh'
,
'config'
)
;
if
(
.
existsSync
(
)
)
{
const
=
.
readFileSync
(
,
'utf8'
)
.
split
(
'\n'
)
.
filter
(
(
l
)
=>
/ ^ \s * Host\s + (?! \* ) /
.
test
(
)
)
.
length
;
add
(
?
'ok'
:
'warn'
,
'ssh'
,
` ${ hosts} host alias(es) in ~/.ssh/config `
)
;
}
else
add
(
'warn'
,
'ssh'
,
'no ~/.ssh/config (VPS work needs host aliases + keys)'
)
;
async
function
probe
(
url
)
{
try
{
const
=
await
fetch
(
,
{
signal
:
AbortSignal
.
timeout
(
2500
)
}
)
;
return
.
status
;
}
catch
{
return
null
;
}
}
const
=
.
searxng
&&
.
searxng
!==
true
?
.
searxng
:
'http://127.0.0.1:8080'
;
const
=
await
probe
(
` ${ searx} /search?q=ping&format=json `
)
;
add
(
===
200
?
'ok'
:
'warn'
,
'searxng'
,
===
200
?
` ${ searx} answers JSON `
:
` ${ searx} ${ status ? ` HTTP ${ status} (enable json format in settings.yml?) ` : 'unreachable' } `
)
;
if
(
.
mcp
)
{
const
=
spawnSync
(
'opencode'
,
[
'mcp'
,
'list'
]
,
{
encoding
:
'utf8'
,
timeout
:
60000
,
shell
:
.
platform
===
'win32'
}
)
;
if
(
.
error
||
.
status
!==
0
)
add
(
'warn'
,
'mcp-live'
,
` opencode mcp list failed: ${ ( out. stderr || out. error ?. message || '' ) . trim ( ) . split ( '\n' ) [ 0 ] } `
)
;
else
for
(
const
of
.
stdout
.
split
(
'\n'
)
.
filter
(
(
l
)
=>
.
trim
(
)
)
)
add
(
/ ✗| fail| error / i
.
test
(
)
?
'error'
:
'ok'
,
'mcp-live'
,
.
trim
(
)
)
;
}
if
(
.
json
)
console
.
log
(
JSON
.
stringify
(
,
null
,
2
)
)
;
else
{
const
=
{
ok
:
'OK '
,
warn
:
'WARN'
,
error
:
'FAIL'
}
;
for
(
const
of
)
console
.
log
(
` ${ icon[ r. level ] } ${ r. area . padEnd ( 16 ) } ${ r. message } `
)
;
const
=
.
filter
(
(
r
)
=>
.
level
===
'error'
)
.
length
;
const
=
.
filter
(
(
r
)
=>
.
level
===
'warn'
)
.
length
;
console
.
log
(
` \n ${ errors} error(s), ${ warns} warning(s). ${ flags. mcp ? '' : ' Add --mcp for a live MCP check.' } `
)
;
}
.
exit
(
.
some
(
(
r
)
=>
.
level
===
'error'
)
?
1
:
0
)
;