buddy-agent-harness 0.5.0 → 0.7.0
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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/bin/buddy-agent-harness.mjs +8 -3
- package/dist/cli-Bvnq8zOL.mjs +2122 -0
- package/dist/cli-Bvnq8zOL.mjs.map +1 -0
- package/dist/cli.d.mts +13 -2
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +2 -20
- package/dist/index.d.mts +491 -40
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/package.json +3 -2
- package/plugin.json +1 -1
- package/skills/doctor/SKILL.md +27 -23
- package/skills/doctor/references/bridges.md +23 -0
- package/skills/doctor/references/configuration.md +12 -0
- package/skills/doctor/references/harnesses/claude-code.md +39 -0
- package/skills/doctor/references/harnesses/codex.md +37 -0
- package/skills/doctor/references/harnesses/copilot-cli.md +39 -0
- package/skills/doctor/references/harnesses/cursor.md +40 -0
- package/skills/doctor/references/harnesses/devin-desktop.md +20 -0
- package/skills/doctor/references/harnesses/gemini-cli.md +38 -0
- package/skills/doctor/references/harnesses/windsurf.md +27 -0
- package/skills/doctor/references/instructions.md +14 -0
- package/skills/doctor/references/mcp.md +31 -0
- package/skills/doctor/references/nonstandard.md +27 -0
- package/skills/doctor/scripts/doctor.mjs +7 -3
- package/skills/enhance/SKILL.md +4 -0
- package/skills/init/README.md +1 -1
- package/skills/init/SKILL.md +24 -10
- package/skills/init/references/detection.md +5 -3
- package/skills/init/references/harnesses/claude-code.md +2 -0
- package/skills/init/references/harnesses/cursor.md +9 -2
- package/skills/init/references/harnesses/gemini-cli.md +6 -9
- package/skills/init/scripts/doctor.mjs +14 -0
- package/skills/init/scripts/init.mjs +7 -3
- package/skills/repair/README.md +21 -0
- package/skills/repair/SKILL.md +74 -0
- package/skills/repair/references/classes.md +49 -0
- package/skills/repair/scripts/doctor.mjs +14 -0
- package/src/cli.ts +40 -7
- package/src/command-output/command-output.ts +1 -4
- package/src/diagnose-bridges/agents-files.ts +34 -0
- package/src/diagnose-bridges/diagnose-bridges.ts +39 -21
- package/src/diagnose-bridges/diagnose-instructions.ts +145 -0
- package/src/diagnose-bridges/doctor-guidance.ts +683 -69
- package/src/diagnose-bridges/doctor.command.ts +63 -30
- package/src/diagnose-bridges/git-bridge-state.ts +30 -0
- package/src/diagnose-bridges/json-with-comments.ts +60 -0
- package/src/diagnose-bridges/locator.ts +36 -0
- package/src/diagnose-configuration/diagnose-configuration.ts +99 -0
- package/src/diagnose-mcp/diagnose-mcp.ts +135 -0
- package/src/diagnose-mcp/mcp-baseline.ts +122 -0
- package/src/diagnose-mcp/mcp-model.ts +88 -0
- package/src/diagnose-mcp/mcp-secrets.ts +101 -0
- package/src/diagnose-mcp/mcp-sources.ts +131 -0
- package/src/diagnose-nonstandard/diagnose-nonstandard.ts +109 -0
- package/src/harness-registry/harness-registry.ts +164 -14
- package/src/harness-registry/instruction-bridge.ts +31 -0
- package/src/harness-registry/mcp-config.ts +37 -0
- package/src/harness-registry/nonstandard-artifact.ts +39 -0
- package/src/index.ts +33 -4
- package/src/initialize-harnesses/init.command.ts +13 -18
- package/src/initialize-harnesses/initialize-harnesses.ts +7 -4
- package/src/is-record/is-record.ts +12 -0
- package/src/skill-projection/skill-projection.ts +104 -18
- package/dist/cli.mjs.map +0 -1
- package/dist/init.command-c0fBv15T.mjs +0 -714
- package/dist/init.command-c0fBv15T.mjs.map +0 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where one harness keeps its MCP server configuration at one scope, as that harness's own vendor
|
|
3
|
+
* documents it.
|
|
4
|
+
*
|
|
5
|
+
* Recorded per scope like everything else in a `HarnessScope`, and populated at **project** scope
|
|
6
|
+
* only. Much of the world's MCP configuration lives at user scope — `~/.codex/config.toml`,
|
|
7
|
+
* `~/.claude.json`, `claude_desktop_config.json` — and the registry records user scope as
|
|
8
|
+
* described and diagnosable, never written. Reading a user's home directory into output that
|
|
9
|
+
* lands in every session's transcript is a wider blast radius than diagnosis needs, so those paths
|
|
10
|
+
* stay out until something needs them.
|
|
11
|
+
*
|
|
12
|
+
* A harness with no documented project-scope MCP file gets no entry. Copilot CLI is the case that
|
|
13
|
+
* matters: its own documentation states that `.vscode/mcp.json` "is not read by Copilot CLI", and
|
|
14
|
+
* names `~/.copilot/mcp-config.json` instead. That is a documented absence, not a gap — see
|
|
15
|
+
* `.research/mcp-canonical-location/` (E-MCP-11).
|
|
16
|
+
*/
|
|
17
|
+
export type McpConfig = {
|
|
18
|
+
/** Repository-relative path of the file, as the vendor documents it. */
|
|
19
|
+
path: string
|
|
20
|
+
/**
|
|
21
|
+
* The key the servers sit under. Not one key across hosts: `mcpServers` for Claude Code, Cursor,
|
|
22
|
+
* and Gemini CLI, `mcp_servers` for Codex, `servers` for VS Code. Reading the wrong one finds
|
|
23
|
+
* nothing and reports a repository as unconfigured.
|
|
24
|
+
*/
|
|
25
|
+
key: string
|
|
26
|
+
/**
|
|
27
|
+
* How the file is serialized. It decides the parser, and it is also why comparison is semantic:
|
|
28
|
+
* the same server in TOML and in JSON shares no bytes.
|
|
29
|
+
*/
|
|
30
|
+
format: 'json' | 'toml'
|
|
31
|
+
/**
|
|
32
|
+
* Set when the file holds far more than MCP configuration. `.gemini/settings.json` also carries
|
|
33
|
+
* the instruction bridge, so anything reading it must take its key and leave the rest alone —
|
|
34
|
+
* and anything writing it must never rewrite the file wholesale.
|
|
35
|
+
*/
|
|
36
|
+
shared?: true
|
|
37
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration a harness reads that no other harness can, declared per harness beside the paths
|
|
3
|
+
* `doctor` already knows about it.
|
|
4
|
+
*
|
|
5
|
+
* These are not faults. Every one of them works — for exactly one harness — which is the whole
|
|
6
|
+
* problem: the guidance in a Cursor rule reaches Cursor and nothing else, and nobody finds out
|
|
7
|
+
* except by noticing an agent behaving differently in another tool. `doctor` surfaces them so they
|
|
8
|
+
* can be converted, one at a time, toward a repository whose agent configuration is canonical and
|
|
9
|
+
* whose harness files are generated from it. Zero of these is the north star, not a release gate.
|
|
10
|
+
*
|
|
11
|
+
* `kind` carries the conversion, because the canonical form differs per kind and nothing else about
|
|
12
|
+
* the artifact does. It is what a finding routes on.
|
|
13
|
+
*/
|
|
14
|
+
export type NonstandardKind =
|
|
15
|
+
/** Prose an `AGENTS.md` can hold verbatim. The harness file becomes a generated bridge. */
|
|
16
|
+
| 'instructions'
|
|
17
|
+
/**
|
|
18
|
+
* A rule scoped to paths. A skill is the portable form *where the scoping is incidental* — a
|
|
19
|
+
* skill is loaded on relevance rather than by glob, so guidance whose whole point is "these
|
|
20
|
+
* files and no others" has no equivalent yet, and converting it would lose the scoping.
|
|
21
|
+
*/
|
|
22
|
+
| 'rule'
|
|
23
|
+
/** A harness command. Claude Code merged commands into skills, so a skill is the portable form. */
|
|
24
|
+
| 'command'
|
|
25
|
+
/** A skill kept under a harness directory rather than the canonical one. */
|
|
26
|
+
| 'skill'
|
|
27
|
+
/** A subagent. No cross-harness format exists, so surfacing it *is* reporting that gap. */
|
|
28
|
+
| 'subagent'
|
|
29
|
+
|
|
30
|
+
export type NonstandardArtifact = {
|
|
31
|
+
/**
|
|
32
|
+
* Repository-relative path. A file is reported as itself; a directory is reported per file
|
|
33
|
+
* below it, so each one can be converted on its own rather than as an all-or-nothing batch.
|
|
34
|
+
*/
|
|
35
|
+
path: string
|
|
36
|
+
/** Whether `path` names one file or a directory to walk. */
|
|
37
|
+
shape: 'file' | 'directory'
|
|
38
|
+
kind: NonstandardKind
|
|
39
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { run } from './cli.ts'
|
|
1
2
|
export type {
|
|
2
3
|
BridgeFinding,
|
|
3
4
|
BridgeKind,
|
|
@@ -8,12 +9,40 @@ export type {
|
|
|
8
9
|
DivergenceReport,
|
|
9
10
|
} from './diagnose-bridges/diagnose-bridges.ts'
|
|
10
11
|
export { diagnoseBridges } from './diagnose-bridges/diagnose-bridges.ts'
|
|
11
|
-
export {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
export type {
|
|
13
|
+
InstructionKind,
|
|
14
|
+
InstructionReport,
|
|
15
|
+
InstructionStatus,
|
|
16
|
+
} from './diagnose-bridges/diagnose-instructions.ts'
|
|
17
|
+
export { diagnoseInstructions } from './diagnose-bridges/diagnose-instructions.ts'
|
|
18
|
+
export type { DoctorReport } from './diagnose-bridges/doctor.command.ts'
|
|
19
|
+
export { buildDoctorReport, doctorCommand } from './diagnose-bridges/doctor.command.ts'
|
|
20
|
+
export type {
|
|
21
|
+
BridgeProblem,
|
|
22
|
+
ConfigurationFault,
|
|
23
|
+
ConfigurationProblem,
|
|
24
|
+
DoctorProblem,
|
|
25
|
+
InstructionProblem,
|
|
26
|
+
McpProblem,
|
|
27
|
+
Repair,
|
|
28
|
+
} from './diagnose-bridges/doctor-guidance.ts'
|
|
29
|
+
export {
|
|
30
|
+
bridgeRepairs,
|
|
31
|
+
doctorRepairs,
|
|
32
|
+
doctorSkill,
|
|
33
|
+
instructionRepairs,
|
|
34
|
+
renderDoctorSkill,
|
|
35
|
+
} from './diagnose-bridges/doctor-guidance.ts'
|
|
14
36
|
export type { DivergenceDirection } from './diagnose-bridges/git-bridge-state.ts'
|
|
15
|
-
export type {
|
|
37
|
+
export type { DiagnoseMcpOptions } from './diagnose-mcp/diagnose-mcp.ts'
|
|
38
|
+
export { diagnoseMcp } from './diagnose-mcp/diagnose-mcp.ts'
|
|
39
|
+
export type { McpDirection } from './diagnose-mcp/mcp-baseline.ts'
|
|
40
|
+
export type { McpField, McpServer, McpTransport } from './diagnose-mcp/mcp-model.ts'
|
|
41
|
+
export { goldenSetPath } from './diagnose-mcp/mcp-sources.ts'
|
|
42
|
+
export type { Harness, HarnessName, HarnessScope, HarnessScopeName } from './harness-registry/harness-registry.ts'
|
|
16
43
|
export { harnessRegistry } from './harness-registry/harness-registry.ts'
|
|
44
|
+
export type { InstructionBridge } from './harness-registry/instruction-bridge.ts'
|
|
45
|
+
export type { McpConfig } from './harness-registry/mcp-config.ts'
|
|
17
46
|
export { activate, harnessCommand, initCommand } from './initialize-harnesses/init.command.ts'
|
|
18
47
|
export type { InitializeOptions, InitializeResult } from './initialize-harnesses/initialize-harnesses.ts'
|
|
19
48
|
export { initializeHarnesses } from './initialize-harnesses/initialize-harnesses.ts'
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { cli } from 'clibuilder'
|
|
2
|
-
import { command, z } from 'clibuilder'
|
|
2
|
+
import { command, exitCodes, z } from 'clibuilder'
|
|
3
3
|
import { parseFormat, writeResult } from '../command-output/command-output.ts'
|
|
4
4
|
import { doctorCommand } from '../diagnose-bridges/doctor.command.ts'
|
|
5
|
-
import {
|
|
5
|
+
import { parseHarnesses } from '../harness-registry/harness-registry.ts'
|
|
6
|
+
import { parseForce } from '../skill-projection/skill-projection.ts'
|
|
6
7
|
import { initializeHarnesses } from './initialize-harnesses.ts'
|
|
7
8
|
|
|
8
9
|
export const initCommand: cli.Command = command({
|
|
@@ -22,8 +23,9 @@ export const initCommand: cli.Command = command({
|
|
|
22
23
|
type: z.optional(z.boolean()),
|
|
23
24
|
},
|
|
24
25
|
force: {
|
|
25
|
-
description:
|
|
26
|
-
|
|
26
|
+
description:
|
|
27
|
+
'Replace conflicting target skill directories. Names the targets to replace, comma-separated (e.g. .claude/skills); given alone it replaces every conflicting target.',
|
|
28
|
+
type: z.optional(z.string()),
|
|
27
29
|
},
|
|
28
30
|
format: {
|
|
29
31
|
description: 'Output format: toon (default), json, or text for a human-readable report.',
|
|
@@ -34,29 +36,22 @@ export const initCommand: cli.Command = command({
|
|
|
34
36
|
run(args) {
|
|
35
37
|
try {
|
|
36
38
|
const format = parseFormat(args.format)
|
|
37
|
-
const
|
|
38
|
-
?.split(',')
|
|
39
|
-
.map((name) => name.trim())
|
|
40
|
-
.filter(Boolean)
|
|
41
|
-
const unsupported = requested?.filter((name) => !harnessRegistry.some((harness) => harness.name === name))
|
|
42
|
-
if (unsupported?.length)
|
|
43
|
-
throw new Error(
|
|
44
|
-
`Unsupported harness: ${unsupported.join(', ')}. Supported: ${harnessRegistry
|
|
45
|
-
.map((harness) => harness.name)
|
|
46
|
-
.join(', ')}.`,
|
|
47
|
-
)
|
|
39
|
+
const harnesses = parseHarnesses(args.harness)
|
|
48
40
|
writeResult(
|
|
49
41
|
initializeHarnesses({
|
|
50
42
|
root: args.root ?? process.cwd(),
|
|
51
|
-
...(
|
|
43
|
+
...(harnesses.length ? { harnesses } : {}),
|
|
52
44
|
...(args.copy === undefined ? {} : { copy: args.copy }),
|
|
53
|
-
...(args.force === undefined ? {} : { force: args.force }),
|
|
45
|
+
...(args.force === undefined ? {} : { force: parseForce(args.force) }),
|
|
54
46
|
}),
|
|
55
47
|
format,
|
|
56
48
|
)
|
|
49
|
+
return exitCodes.success
|
|
57
50
|
} catch (error) {
|
|
58
51
|
process.stderr.write(`error: ${error instanceof Error ? error.message : 'Harness initialization failed.'}\n`)
|
|
59
|
-
|
|
52
|
+
// Returned, not written: a command that writes the code reports its failure past `run`
|
|
53
|
+
// rather than to it, leaving a caller that is not the process no way to learn of it.
|
|
54
|
+
return exitCodes.error
|
|
60
55
|
}
|
|
61
56
|
},
|
|
62
57
|
})
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { join } from 'node:path'
|
|
2
2
|
import { type HarnessName, selectHarnesses } from '../harness-registry/harness-registry.ts'
|
|
3
|
-
import { countSkills, projectSkills } from '../skill-projection/skill-projection.ts'
|
|
3
|
+
import { countSkills, type ForceSelection, projectSkills } from '../skill-projection/skill-projection.ts'
|
|
4
4
|
|
|
5
5
|
export type InitializeOptions = {
|
|
6
6
|
root: string
|
|
7
7
|
harnesses?: HarnessName[]
|
|
8
8
|
copy?: boolean
|
|
9
|
-
force?:
|
|
9
|
+
force?: ForceSelection
|
|
10
10
|
}
|
|
11
11
|
export type InitializeResult = {
|
|
12
12
|
root: string
|
|
13
13
|
harnesses: HarnessName[]
|
|
14
14
|
native: HarnessName[]
|
|
15
15
|
linked: HarnessName[]
|
|
16
|
+
/** Enabled harnesses left untouched because their target conflicts and `--force` did not name it. */
|
|
17
|
+
skipped: HarnessName[]
|
|
16
18
|
/** Enabled harnesses whose name has been superseded, as `{ name, replacedBy }`. */
|
|
17
19
|
deprecated: { name: HarnessName; replacedBy: HarnessName }[]
|
|
18
20
|
skills: number
|
|
@@ -28,13 +30,14 @@ export function initializeHarnesses({
|
|
|
28
30
|
const canonicalSkills = join(root, '.agents', 'skills')
|
|
29
31
|
const skills = countSkills(canonicalSkills)
|
|
30
32
|
const harnesses = selectHarnesses(root, preferred)
|
|
31
|
-
const linked = projectSkills({ root, canonicalSkills, harnesses, copy, force })
|
|
33
|
+
const { linked, skipped } = projectSkills({ root, canonicalSkills, harnesses, copy, force })
|
|
32
34
|
|
|
33
35
|
return {
|
|
34
36
|
root,
|
|
35
37
|
harnesses: harnesses.map((harness) => harness.name),
|
|
36
|
-
native: harnesses.filter((harness) => !harness.skillsDirectory).map((harness) => harness.name),
|
|
38
|
+
native: harnesses.filter((harness) => !harness.project.skillsDirectory).map((harness) => harness.name),
|
|
37
39
|
linked,
|
|
40
|
+
skipped,
|
|
38
41
|
deprecated: harnesses
|
|
39
42
|
.filter((harness) => harness.deprecated)
|
|
40
43
|
.map((harness) => ({ name: harness.name, replacedBy: harness.deprecated as HarnessName })),
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a value is a record: an object with named keys, and not an array.
|
|
3
|
+
*
|
|
4
|
+
* Everything this package reads is a file someone else wrote — a golden MCP set, a harness config,
|
|
5
|
+
* a projection record — so every parse lands on `unknown` and every reader narrows it here before
|
|
6
|
+
* asking for a key. Four modules had their own copy of the same three clauses; a predicate that
|
|
7
|
+
* decides what counts as a parsed object is one fact, and a copy of it that drifts changes what a
|
|
8
|
+
* file is read to say.
|
|
9
|
+
*/
|
|
10
|
+
export function isRecord(value: unknown): value is Record<string, unknown> {
|
|
11
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
12
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { cpSync, lstatSync, mkdirSync, readdirSync,
|
|
2
|
-
import {
|
|
1
|
+
import { cpSync, lstatSync, mkdirSync, readdirSync, realpathSync, rmSync, symlinkSync } from 'node:fs'
|
|
2
|
+
import { platform } from 'node:os'
|
|
3
|
+
import { dirname, join, relative, resolve } from 'node:path'
|
|
3
4
|
import type { Harness, HarnessName } from '../harness-registry/harness-registry.ts'
|
|
4
5
|
|
|
5
6
|
function skillNames(skillsDirectory: string): string[] {
|
|
@@ -18,8 +19,19 @@ function pathOccupied(path: string): boolean {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Whether `target` is a symbolic link that resolves to `canonical`. Resolved paths are compared
|
|
24
|
+
* rather than link text, so a link a user wrote as an absolute path, one this tool wrote as a
|
|
25
|
+
* Windows junction, and one reached through a symbolic link in a parent directory all read as the
|
|
26
|
+
* correct bridge. A link that no longer resolves is not.
|
|
27
|
+
*/
|
|
28
|
+
export function linksTo(target: string, canonical: string): boolean {
|
|
29
|
+
try {
|
|
30
|
+
if (!lstatSync(target).isSymbolicLink()) return false
|
|
31
|
+
return realpathSync(target) === realpathSync(canonical)
|
|
32
|
+
} catch {
|
|
33
|
+
return false
|
|
34
|
+
}
|
|
23
35
|
}
|
|
24
36
|
|
|
25
37
|
/** Creates the canonical directory when absent, so a fresh repository reports zero skills. */
|
|
@@ -28,51 +40,125 @@ export function countSkills(canonicalSkills: string): number {
|
|
|
28
40
|
return skillNames(canonicalSkills).length
|
|
29
41
|
}
|
|
30
42
|
|
|
43
|
+
/**
|
|
44
|
+
* A junction is the only link Windows grants an unprivileged process, and Node resolves a relative
|
|
45
|
+
* junction target against the process directory rather than the link's own, so Windows is given the
|
|
46
|
+
* absolute path. Every other platform keeps the link relative, so it survives the repository moving.
|
|
47
|
+
*/
|
|
48
|
+
function linkTarget(target: string, canonicalSkills: string): string {
|
|
49
|
+
return platform() === 'win32' ? resolve(canonicalSkills) : relative(dirname(target), canonicalSkills)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Which conflicting targets a run may replace. `true` is every one of them; a list names them
|
|
54
|
+
* individually, so a run invoked to fix one bridge cannot reach past it to another. `false` and an
|
|
55
|
+
* empty list both mean none, which is what makes a conflict stop the run.
|
|
56
|
+
*/
|
|
57
|
+
export type ForceSelection = boolean | readonly string[]
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Translates what the option parser hands back into a selection. A valueless `--force` arrives as
|
|
61
|
+
* the literal string `true` — that is how the parser encodes a flag given no value — and means
|
|
62
|
+
* every conflicting target, which is what keeps an existing `init --force` doing what it always did.
|
|
63
|
+
* Anything else is a comma-separated list of targets.
|
|
64
|
+
*/
|
|
65
|
+
export function parseForce(value: string): ForceSelection {
|
|
66
|
+
if (value === 'true') return true
|
|
67
|
+
if (value === 'false') return false
|
|
68
|
+
return value
|
|
69
|
+
.split(',')
|
|
70
|
+
.map((target) => target.trim())
|
|
71
|
+
.filter((target) => target.length > 0)
|
|
72
|
+
}
|
|
73
|
+
|
|
31
74
|
export type ProjectSkillsOptions = {
|
|
32
75
|
root: string
|
|
33
76
|
canonicalSkills: string
|
|
34
77
|
harnesses: readonly Harness[]
|
|
35
78
|
copy: boolean
|
|
36
|
-
force:
|
|
79
|
+
force: ForceSelection
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type ProjectSkillsResult = {
|
|
83
|
+
/** Harnesses whose target now points at the canonical directory. */
|
|
84
|
+
linked: HarnessName[]
|
|
85
|
+
/** Harnesses left untouched because their target conflicts and `--force` did not name it. */
|
|
86
|
+
skipped: HarnessName[]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Targets are matched against what the caller typed, resolved against the repository root, so the
|
|
91
|
+
* repo-relative form the conflict message prints is the form that selects it back — and an absolute
|
|
92
|
+
* path naming the same directory selects it too.
|
|
93
|
+
*/
|
|
94
|
+
function namesTarget(root: string, target: string, given: string): boolean {
|
|
95
|
+
return resolve(root, given) === resolve(target)
|
|
37
96
|
}
|
|
38
97
|
|
|
39
98
|
/**
|
|
40
99
|
* Points every harness that cannot read `.agents/skills` at the canonical directory. Symlinking is
|
|
41
|
-
* preferred; a platform that refuses the link falls back to a copy.
|
|
100
|
+
* preferred; a platform that refuses the link falls back to a copy.
|
|
42
101
|
*/
|
|
43
|
-
export function projectSkills({
|
|
102
|
+
export function projectSkills({
|
|
103
|
+
root,
|
|
104
|
+
canonicalSkills,
|
|
105
|
+
harnesses,
|
|
106
|
+
copy,
|
|
107
|
+
force,
|
|
108
|
+
}: ProjectSkillsOptions): ProjectSkillsResult {
|
|
44
109
|
const projections = harnesses
|
|
45
|
-
.filter((harness) => harness.skillsDirectory)
|
|
110
|
+
.filter((harness) => harness.project.skillsDirectory)
|
|
46
111
|
.map((harness) => ({
|
|
47
112
|
harness,
|
|
48
|
-
target: join(root, harness.skillsDirectory as string),
|
|
113
|
+
target: join(root, harness.project.skillsDirectory as string),
|
|
49
114
|
}))
|
|
50
115
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
116
|
+
const named = Array.isArray(force) ? force : []
|
|
117
|
+
// A name matching no projection target at all is a typo, not a narrower run: silently forcing
|
|
118
|
+
// nothing would surface as the conflict error the flag was reached for, blaming the wrong thing.
|
|
119
|
+
const unknown = named.filter((given) => !projections.some(({ target }) => namesTarget(root, target, given)))
|
|
120
|
+
if (unknown.length) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
`No skill target matches:\n${unknown.map((given) => `- ${given}`).join('\n')}\n` +
|
|
123
|
+
`Targets for the enabled harnesses:\n${projections.map(({ target }) => `- ${relative(root, target)}`).join('\n')}`,
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const forces = (target: string): boolean => force === true || named.some((given) => namesTarget(root, target, given))
|
|
54
128
|
|
|
55
|
-
|
|
129
|
+
const conflicts = projections.filter(({ target }) => pathOccupied(target) && !linksTo(target, canonicalSkills))
|
|
130
|
+
const blocked = conflicts.filter(({ target }) => !forces(target))
|
|
131
|
+
|
|
132
|
+
// Nothing was named, so nothing distinguishes one conflict from another: stop before writing.
|
|
133
|
+
// Once a target IS named, the unnamed conflicts are the ones this run was told to leave alone,
|
|
134
|
+
// so they are skipped and reported rather than turned into a refusal that writes nothing at all.
|
|
135
|
+
if (blocked.length && named.length === 0) {
|
|
56
136
|
throw new Error(
|
|
57
|
-
`Refusing to replace existing skill targets:\n${
|
|
137
|
+
`Refusing to replace existing skill targets:\n${blocked.map(({ target }) => `- ${relative(root, target)}`).join('\n')}`,
|
|
58
138
|
)
|
|
59
139
|
}
|
|
60
140
|
|
|
61
|
-
|
|
141
|
+
const skipped = new Set(blocked.map(({ harness }) => harness.name))
|
|
142
|
+
|
|
143
|
+
for (const { harness, target } of projections) {
|
|
144
|
+
if (skipped.has(harness.name)) continue
|
|
62
145
|
mkdirSync(dirname(target), { recursive: true })
|
|
63
|
-
if (
|
|
146
|
+
if (linksTo(target, canonicalSkills)) continue
|
|
64
147
|
if (pathOccupied(target)) rmSync(target, { recursive: true, force: true })
|
|
65
148
|
if (copy) {
|
|
66
149
|
cpSync(canonicalSkills, target, { recursive: true })
|
|
67
150
|
continue
|
|
68
151
|
}
|
|
69
152
|
try {
|
|
70
|
-
symlinkSync(
|
|
153
|
+
symlinkSync(linkTarget(target, canonicalSkills), target, platform() === 'win32' ? 'junction' : undefined)
|
|
71
154
|
} catch (error) {
|
|
72
155
|
if (pathOccupied(target)) throw error
|
|
73
156
|
cpSync(canonicalSkills, target, { recursive: true })
|
|
74
157
|
}
|
|
75
158
|
}
|
|
76
159
|
|
|
77
|
-
return
|
|
160
|
+
return {
|
|
161
|
+
linked: projections.filter(({ harness }) => !skipped.has(harness.name)).map(({ harness }) => harness.name),
|
|
162
|
+
skipped: projections.filter(({ harness }) => skipped.has(harness.name)).map(({ harness }) => harness.name),
|
|
163
|
+
}
|
|
78
164
|
}
|
package/dist/cli.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["import { cli } from 'clibuilder'\nimport { doctorCommand } from './diagnose-bridges/doctor.command.ts'\nimport { initCommand } from './initialize-harnesses/init.command.ts'\n\nexport async function main(): Promise<void> {\n\tconst app = cli({\n\t\tname: 'buddy-agent-harness',\n\t\tversion: '0.1.0',\n\t\tdescription: 'Initialize agent harness skill compatibility in consumer repositories.',\n\t})\n\ttry {\n\t\tawait app.command(initCommand).command(doctorCommand).parse(process.argv)\n\t} catch (error) {\n\t\tprocess.stdout.write(`error: ${error instanceof Error ? error.message : 'Invalid command.'}\\n`)\n\t\tprocess.exitCode = 2\n\t}\n}\n"],"mappings":";;;AAIA,eAAsB,OAAsB;CAC3C,MAAM,MAAM,IAAI;EACf,MAAM;EACN,SAAS;EACT,aAAa;CACd,CAAC;CACD,IAAI;EACH,MAAM,IAAI,QAAQ,WAAW,CAAC,CAAC,QAAQ,aAAa,CAAC,CAAC,MAAM,QAAQ,IAAI;CACzE,SAAS,OAAO;EACf,QAAQ,OAAO,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,mBAAmB,GAAG;EAC9F,QAAQ,WAAW;CACpB;AACD"}
|