@tacuchi/agent-workflow-cli 4.6.0 → 4.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/dist/application/dsn-reader-service.d.ts +10 -0
- package/dist/application/dsn-reader-service.d.ts.map +1 -0
- package/dist/application/dsn-reader-service.js +26 -0
- package/dist/application/dsn-reader-service.js.map +1 -0
- package/dist/application/graduation-check-service.d.ts +19 -0
- package/dist/application/graduation-check-service.d.ts.map +1 -0
- package/dist/application/graduation-check-service.js +145 -0
- package/dist/application/graduation-check-service.js.map +1 -0
- package/dist/application/hub-init-service.d.ts +47 -0
- package/dist/application/hub-init-service.d.ts.map +1 -0
- package/dist/application/hub-init-service.js +92 -0
- package/dist/application/hub-init-service.js.map +1 -0
- package/dist/application/mcp-doctor-service.d.ts +23 -0
- package/dist/application/mcp-doctor-service.d.ts.map +1 -0
- package/dist/application/mcp-doctor-service.js +123 -0
- package/dist/application/mcp-doctor-service.js.map +1 -0
- package/dist/application/mcp-host-reader.d.ts +13 -0
- package/dist/application/mcp-host-reader.d.ts.map +1 -0
- package/dist/application/mcp-host-reader.js +89 -0
- package/dist/application/mcp-host-reader.js.map +1 -0
- package/dist/application/mcp-host-writer.d.ts +13 -0
- package/dist/application/mcp-host-writer.d.ts.map +1 -0
- package/dist/application/mcp-host-writer.js +196 -0
- package/dist/application/mcp-host-writer.js.map +1 -0
- package/dist/application/mcp-setup-service.d.ts +31 -0
- package/dist/application/mcp-setup-service.d.ts.map +1 -0
- package/dist/application/mcp-setup-service.js +69 -0
- package/dist/application/mcp-setup-service.js.map +1 -0
- package/dist/application/visibility-doctor-service.d.ts +34 -0
- package/dist/application/visibility-doctor-service.d.ts.map +1 -0
- package/dist/application/visibility-doctor-service.js +192 -0
- package/dist/application/visibility-doctor-service.js.map +1 -0
- package/dist/cli/commands/graduation-check.d.ts +3 -0
- package/dist/cli/commands/graduation-check.d.ts.map +1 -0
- package/dist/cli/commands/graduation-check.js +11 -0
- package/dist/cli/commands/graduation-check.js.map +1 -0
- package/dist/cli/commands/hub-init.d.ts +3 -0
- package/dist/cli/commands/hub-init.d.ts.map +1 -0
- package/dist/cli/commands/hub-init.js +95 -0
- package/dist/cli/commands/hub-init.js.map +1 -0
- package/dist/cli/commands/mcp.d.ts.map +1 -1
- package/dist/cli/commands/mcp.js +159 -37
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/visibility.d.ts +3 -0
- package/dist/cli/commands/visibility.d.ts.map +1 -0
- package/dist/cli/commands/visibility.js +42 -0
- package/dist/cli/commands/visibility.js.map +1 -0
- package/dist/cli/main.js +6 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/domain/mcp-entry.d.ts +44 -0
- package/dist/domain/mcp-entry.d.ts.map +1 -0
- package/dist/domain/mcp-entry.js +13 -0
- package/dist/domain/mcp-entry.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { McpInstance } from "../domain/mcp-entry.js";
|
|
2
|
+
import type { PathsService } from "./paths-service.js";
|
|
3
|
+
export interface DsnReadResult {
|
|
4
|
+
path: string;
|
|
5
|
+
exists: boolean;
|
|
6
|
+
values: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export declare function readBootstrapDsn(paths: PathsService): DsnReadResult;
|
|
9
|
+
export declare function dsnKeyForInstance(instance: McpInstance): string;
|
|
10
|
+
//# sourceMappingURL=dsn-reader-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dsn-reader-service.d.ts","sourceRoot":"","sources":["../../src/application/dsn-reader-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,CAiBnE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,GAAG,MAAM,CAE/D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
export function readBootstrapDsn(paths) {
|
|
3
|
+
const path = paths.userDsnFile();
|
|
4
|
+
if (!existsSync(path)) {
|
|
5
|
+
return { path, exists: false, values: {} };
|
|
6
|
+
}
|
|
7
|
+
const text = readFileSync(path, "utf-8");
|
|
8
|
+
const values = {};
|
|
9
|
+
for (const rawLine of text.split("\n")) {
|
|
10
|
+
const line = rawLine.trim();
|
|
11
|
+
if (line.length === 0 || line.startsWith("#"))
|
|
12
|
+
continue;
|
|
13
|
+
const eq = line.indexOf("=");
|
|
14
|
+
if (eq <= 0)
|
|
15
|
+
continue;
|
|
16
|
+
const key = line.slice(0, eq).trim();
|
|
17
|
+
const val = line.slice(eq + 1).trim();
|
|
18
|
+
if (key.length > 0)
|
|
19
|
+
values[key] = val;
|
|
20
|
+
}
|
|
21
|
+
return { path, exists: true, values };
|
|
22
|
+
}
|
|
23
|
+
export function dsnKeyForInstance(instance) {
|
|
24
|
+
return instance === "cert" ? "DB_CERT_DSN" : "DB_PROD_DSN";
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=dsn-reader-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dsn-reader-service.js","sourceRoot":"","sources":["../../src/application/dsn-reader-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAUnD,MAAM,UAAU,gBAAgB,CAAC,KAAmB;IAClD,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IACjC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAC7C,CAAC;IACD,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QACxD,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,EAAE,IAAI,CAAC;YAAE,SAAS;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACtC,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IACxC,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAqB;IACrD,OAAO,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EnvPort } from "../ports/env.js";
|
|
2
|
+
import type { FileSystemPort } from "../ports/file-system.js";
|
|
3
|
+
export interface GraduationCheckFinding {
|
|
4
|
+
level: "warn" | "ok";
|
|
5
|
+
fuente: string;
|
|
6
|
+
categoria: string;
|
|
7
|
+
file: string;
|
|
8
|
+
msg: string;
|
|
9
|
+
}
|
|
10
|
+
export interface GraduationCheckOutput {
|
|
11
|
+
status: "ok" | "warn" | "skipped";
|
|
12
|
+
hub_mode: boolean;
|
|
13
|
+
hub_path: string;
|
|
14
|
+
fuentes_count: number;
|
|
15
|
+
findings: GraduationCheckFinding[];
|
|
16
|
+
reason?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function runGraduationCheck(fs: FileSystemPort, env: EnvPort): Promise<GraduationCheckOutput>;
|
|
19
|
+
//# sourceMappingURL=graduation-check-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graduation-check-service.d.ts","sourceRoot":"","sources":["../../src/application/graduation-check-service.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAK9D,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAOD,wBAAsB,kBAAkB,CACtC,EAAE,EAAE,cAAc,EAClB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,qBAAqB,CAAC,CAkDhC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Graduation routing check — detecta artefactos graduados a fuentes (docs/manuales|rfcs|post-mortems|analisis)
|
|
2
|
+
// sin breadcrumb correspondiente en el hub. Aplica solo en hub mode.
|
|
3
|
+
//
|
|
4
|
+
// Lee CLAUDE.md del cwd (hub workspace), parsea bloque `## Fuentes` para
|
|
5
|
+
// obtener alias + path, y walkea docs/<categoria>/ en cada fuente. Por cada
|
|
6
|
+
// archivo NNN-<slug>.md encontrado en una fuente, busca breadcrumb correspondiente
|
|
7
|
+
// en `<hub>/docs/<categoria>/000-INDEX.md` (regex sobre el filename).
|
|
8
|
+
//
|
|
9
|
+
// Output: lista de findings con level (error/warn/ok) por categoría.
|
|
10
|
+
//
|
|
11
|
+
// Origen: session005-dev-fix-graduacion-docs-hub-fuente, Phase 3.
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
const CATEGORIAS = ["manuales", "rfcs", "post-mortems", "analisis", "refactors"];
|
|
14
|
+
export async function runGraduationCheck(fs, env) {
|
|
15
|
+
const hubPath = env.cwd();
|
|
16
|
+
const claudeMd = await readClaudeMd(fs, hubPath);
|
|
17
|
+
if (!claudeMd) {
|
|
18
|
+
return {
|
|
19
|
+
status: "skipped",
|
|
20
|
+
hub_mode: false,
|
|
21
|
+
hub_path: hubPath,
|
|
22
|
+
fuentes_count: 0,
|
|
23
|
+
findings: [],
|
|
24
|
+
reason: "CLAUDE.md no encontrado en cwd",
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (!isHubMode(claudeMd)) {
|
|
28
|
+
return {
|
|
29
|
+
status: "skipped",
|
|
30
|
+
hub_mode: false,
|
|
31
|
+
hub_path: hubPath,
|
|
32
|
+
fuentes_count: 0,
|
|
33
|
+
findings: [],
|
|
34
|
+
reason: "workspace no está en Mode: hub",
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const fuentes = parseFuentes(claudeMd);
|
|
38
|
+
if (fuentes.length === 0) {
|
|
39
|
+
return {
|
|
40
|
+
status: "skipped",
|
|
41
|
+
hub_mode: true,
|
|
42
|
+
hub_path: hubPath,
|
|
43
|
+
fuentes_count: 0,
|
|
44
|
+
findings: [],
|
|
45
|
+
reason: "no se encontraron fuentes en CLAUDE.md",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const findings = [];
|
|
49
|
+
for (const fuente of fuentes) {
|
|
50
|
+
for (const categoria of CATEGORIAS) {
|
|
51
|
+
const f = await checkFuenteCategoria(fs, hubPath, fuente, categoria);
|
|
52
|
+
findings.push(...f);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const status = findings.some((f) => f.level === "warn") ? "warn" : "ok";
|
|
56
|
+
return {
|
|
57
|
+
status,
|
|
58
|
+
hub_mode: true,
|
|
59
|
+
hub_path: hubPath,
|
|
60
|
+
fuentes_count: fuentes.length,
|
|
61
|
+
findings,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function readClaudeMd(fs, hubPath) {
|
|
65
|
+
const claudePath = join(hubPath, "CLAUDE.md");
|
|
66
|
+
if (!(await fs.exists(claudePath))) {
|
|
67
|
+
const agentsPath = join(hubPath, "AGENTS.md");
|
|
68
|
+
if (!(await fs.exists(agentsPath)))
|
|
69
|
+
return null;
|
|
70
|
+
return fs.readText(agentsPath);
|
|
71
|
+
}
|
|
72
|
+
return fs.readText(claudePath);
|
|
73
|
+
}
|
|
74
|
+
function isHubMode(text) {
|
|
75
|
+
return /^\s*Mode:\s*hub\s*$/m.test(text);
|
|
76
|
+
}
|
|
77
|
+
function parseFuentes(text) {
|
|
78
|
+
const lines = text.split(/\r?\n/);
|
|
79
|
+
const out = [];
|
|
80
|
+
let inFuentes = false;
|
|
81
|
+
for (const line of lines) {
|
|
82
|
+
if (/^##\s+Fuentes\s*$/i.test(line)) {
|
|
83
|
+
inFuentes = true;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (inFuentes && /^##\s+/.test(line))
|
|
87
|
+
break;
|
|
88
|
+
if (!inFuentes)
|
|
89
|
+
continue;
|
|
90
|
+
const m = line.match(/^\|\s*([\w-]+)\s*\|\s*([^\s|]+)\s*\|/);
|
|
91
|
+
if (m?.[1] && m[2] && m[1] !== "Alias" && !m[1].startsWith("---")) {
|
|
92
|
+
out.push({ alias: m[1], path: m[2] });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
async function checkFuenteCategoria(fs, hubPath, fuente, categoria) {
|
|
98
|
+
const fuenteDir = join(fuente.path, "docs", categoria);
|
|
99
|
+
if (!(await fs.exists(fuenteDir)))
|
|
100
|
+
return [];
|
|
101
|
+
let entries;
|
|
102
|
+
try {
|
|
103
|
+
entries = await fs.list(fuenteDir);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
const orphans = [];
|
|
109
|
+
for (const entry of entries) {
|
|
110
|
+
if (entry.type !== "file")
|
|
111
|
+
continue;
|
|
112
|
+
if (!/^\d{3}-.*\.md$/.test(entry.name))
|
|
113
|
+
continue;
|
|
114
|
+
if (entry.name === "000-INDEX.md")
|
|
115
|
+
continue;
|
|
116
|
+
orphans.push(entry.name);
|
|
117
|
+
}
|
|
118
|
+
if (orphans.length === 0)
|
|
119
|
+
return [];
|
|
120
|
+
const indexFile = join(hubPath, "docs", categoria, "000-INDEX.md");
|
|
121
|
+
const indexText = (await fs.exists(indexFile)) ? await fs.readText(indexFile) : "";
|
|
122
|
+
const findings = [];
|
|
123
|
+
for (const orphan of orphans) {
|
|
124
|
+
if (indexText.includes(orphan)) {
|
|
125
|
+
findings.push({
|
|
126
|
+
level: "ok",
|
|
127
|
+
fuente: fuente.alias,
|
|
128
|
+
categoria,
|
|
129
|
+
file: `${fuente.path}/docs/${categoria}/${orphan}`,
|
|
130
|
+
msg: "breadcrumb encontrado en hub",
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
findings.push({
|
|
135
|
+
level: "warn",
|
|
136
|
+
fuente: fuente.alias,
|
|
137
|
+
categoria,
|
|
138
|
+
file: `${fuente.path}/docs/${categoria}/${orphan}`,
|
|
139
|
+
msg: `falta breadcrumb en <hub>/docs/${categoria}/000-INDEX.md (debe mencionar '${orphan}')`,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return findings;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=graduation-check-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graduation-check-service.js","sourceRoot":"","sources":["../../src/application/graduation-check-service.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,qEAAqE;AACrE,EAAE;AACF,yEAAyE;AACzE,4EAA4E;AAC5E,mFAAmF;AACnF,sEAAsE;AACtE,EAAE;AACF,qEAAqE;AACrE,EAAE;AACF,kEAAkE;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,CAAU,CAAC;AAyB1F,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,EAAkB,EAClB,GAAY;IAEZ,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACjD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,OAAO;YACjB,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,EAAE;YACZ,MAAM,EAAE,gCAAgC;SACzC,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,QAAQ,EAAE,KAAK;YACf,QAAQ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AAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,QAAQ,CAAC,IAAI,CAAC;gBACZ,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,MAAM,CAAC,KAAK;gBACpB,SAAS;gBACT,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,SAAS,SAAS,IAAI,MAAM,EAAE;gBAClD,GAAG,EAAE,8BAA8B;aACpC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC;gBACZ,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,MAAM,CAAC,KAAK;gBACpB,SAAS;gBACT,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,SAAS,SAAS,IAAI,MAAM,EAAE;gBAClD,GAAG,EAAE,kCAAkC,SAAS,kCAAkC,MAAM,IAAI;aAC7F,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { EnvPort } from "../ports/env.js";
|
|
2
|
+
import type { FileSystemPort } from "../ports/file-system.js";
|
|
3
|
+
import { type MultirootError, type MultirootResult } from "./multiroot-service.js";
|
|
4
|
+
import type { PathsService } from "./paths-service.js";
|
|
5
|
+
import { type ProjectMdUpsertError, type ProjectMdUpsertOutput } from "./project-md-upsert-service.js";
|
|
6
|
+
export interface HubInitFuente {
|
|
7
|
+
alias: string;
|
|
8
|
+
path: string;
|
|
9
|
+
}
|
|
10
|
+
export interface HubInitInput {
|
|
11
|
+
proyecto: string;
|
|
12
|
+
fuentes: HubInitFuente[];
|
|
13
|
+
workingBranches: Record<string, string>;
|
|
14
|
+
mainBranch?: string;
|
|
15
|
+
workspace?: string;
|
|
16
|
+
skipAttach?: boolean;
|
|
17
|
+
dryRun?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface HubInitProjectMdPreview {
|
|
20
|
+
dry_run_preview: {
|
|
21
|
+
fuentes: number;
|
|
22
|
+
mode: "hub";
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface HubInitAttachSkipped {
|
|
26
|
+
skipped: true;
|
|
27
|
+
reason: string;
|
|
28
|
+
}
|
|
29
|
+
export interface HubInitAttachPreview {
|
|
30
|
+
dry_run_preview: {
|
|
31
|
+
paths: string[];
|
|
32
|
+
workspace: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface HubInitResult {
|
|
36
|
+
ok: boolean;
|
|
37
|
+
dry_run: boolean;
|
|
38
|
+
workspace: string;
|
|
39
|
+
project_md: ProjectMdUpsertOutput | ProjectMdUpsertError | HubInitProjectMdPreview;
|
|
40
|
+
attach_multiroot: MultirootResult | MultirootError | HubInitAttachSkipped | HubInitAttachPreview;
|
|
41
|
+
}
|
|
42
|
+
export interface HubInitInputError {
|
|
43
|
+
error: string;
|
|
44
|
+
hint?: string;
|
|
45
|
+
}
|
|
46
|
+
export declare function runHubInit(fs: FileSystemPort, env: EnvPort, paths: PathsService, input: HubInitInput): Promise<HubInitResult | HubInitInputError>;
|
|
47
|
+
//# sourceMappingURL=hub-init-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hub-init-service.d.ts","sourceRoot":"","sources":["../../src/application/hub-init-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAgB,MAAM,wBAAwB,CAAC;AACjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAE3B,MAAM,gCAAgC,CAAC;AAExC,MAAM,WAAW,aAAa;IAC5B,KAAK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1,92 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { runMultiroot } from "./multiroot-service.js";
|
|
3
|
+
import { runProjectMdUpsertWrite, } from "./project-md-upsert-service.js";
|
|
4
|
+
export async function runHubInit(fs, env, paths, input) {
|
|
5
|
+
const validation = validateInput(input);
|
|
6
|
+
if (validation)
|
|
7
|
+
return validation;
|
|
8
|
+
const workspace = input.workspace ? resolve(input.workspace) : resolve(env.cwd());
|
|
9
|
+
if (input.dryRun) {
|
|
10
|
+
return {
|
|
11
|
+
ok: true,
|
|
12
|
+
dry_run: true,
|
|
13
|
+
workspace,
|
|
14
|
+
project_md: { dry_run_preview: { fuentes: input.fuentes.length, mode: "hub" } },
|
|
15
|
+
attach_multiroot: input.skipAttach
|
|
16
|
+
? { skipped: true, reason: "skip-attach flag" }
|
|
17
|
+
: {
|
|
18
|
+
dry_run_preview: { paths: input.fuentes.map((f) => f.path), workspace },
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const targetEnv = workspace !== resolve(env.cwd()) ? overrideCwd(env, workspace) : env;
|
|
23
|
+
const projectMd = await runProjectMdUpsertWrite(fs, targetEnv, paths, {
|
|
24
|
+
op: "init",
|
|
25
|
+
mode: "hub",
|
|
26
|
+
proyecto: input.proyecto,
|
|
27
|
+
fuentes: input.fuentes.map((f) => ({ alias: f.alias, path: f.path })),
|
|
28
|
+
workingBranches: input.workingBranches,
|
|
29
|
+
...(input.mainBranch !== undefined ? { mainBranch: input.mainBranch } : {}),
|
|
30
|
+
verbose: true,
|
|
31
|
+
});
|
|
32
|
+
if ("error" in projectMd) {
|
|
33
|
+
return {
|
|
34
|
+
ok: false,
|
|
35
|
+
dry_run: false,
|
|
36
|
+
workspace,
|
|
37
|
+
project_md: projectMd,
|
|
38
|
+
attach_multiroot: { skipped: true, reason: "project_md_failed" },
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (input.skipAttach) {
|
|
42
|
+
return {
|
|
43
|
+
ok: projectMd.ok,
|
|
44
|
+
dry_run: false,
|
|
45
|
+
workspace,
|
|
46
|
+
project_md: projectMd,
|
|
47
|
+
attach_multiroot: { skipped: true, reason: "skip-attach flag" },
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const attach = await runMultiroot(fs, targetEnv, paths, "attach", {
|
|
51
|
+
fromSources: true,
|
|
52
|
+
workspace,
|
|
53
|
+
});
|
|
54
|
+
const attachOk = !("error" in attach);
|
|
55
|
+
return {
|
|
56
|
+
ok: projectMd.ok && attachOk,
|
|
57
|
+
dry_run: false,
|
|
58
|
+
workspace,
|
|
59
|
+
project_md: projectMd,
|
|
60
|
+
attach_multiroot: attach,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function overrideCwd(env, cwd) {
|
|
64
|
+
return {
|
|
65
|
+
get: (k) => env.get(k),
|
|
66
|
+
homeDir: () => env.homeDir(),
|
|
67
|
+
cwd: () => cwd,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function validateInput(input) {
|
|
71
|
+
if (!input.proyecto || input.proyecto.trim().length === 0) {
|
|
72
|
+
return { error: "missing_proyecto", hint: "--proyecto es obligatorio" };
|
|
73
|
+
}
|
|
74
|
+
if (!input.fuentes || input.fuentes.length < 2) {
|
|
75
|
+
return {
|
|
76
|
+
error: "insufficient_fuentes",
|
|
77
|
+
hint: "hub-init requiere mínimo 2 fuentes (--fuente alias:path repetible)",
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const aliases = new Set();
|
|
81
|
+
for (const f of input.fuentes) {
|
|
82
|
+
if (!f.alias || !f.path) {
|
|
83
|
+
return { error: "invalid_fuente", hint: `fuente sin alias o path: ${JSON.stringify(f)}` };
|
|
84
|
+
}
|
|
85
|
+
if (aliases.has(f.alias)) {
|
|
86
|
+
return { error: "duplicate_alias", hint: `alias duplicado: ${f.alias}` };
|
|
87
|
+
}
|
|
88
|
+
aliases.add(f.alias);
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=hub-init-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hub-init-service.js","sourceRoot":"","sources":["../../src/application/hub-init-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAA6C,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEjG,OAAO,EAGL,uBAAuB,GACxB,MAAM,gCAAgC,CAAC;AA2CxC,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,EAAkB,EAClB,GAAY,EACZ,KAAmB,EACnB,KAAmB;IAEnB,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACxC,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC;IAElC,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;IAElF,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjB,OAAO;YACL,EAAE,EAAE,IAAI;YACR,OAAO,EAAE,IAAI;YACb,SAAS;YACT,UAAU,EAAE,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YAC/E,gBAAgB,EAAE,KAAK,CAAC,UAAU;gBAChC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,kBAAkB,EAAE;gBAC/C,CAAC,CAAC;oBACE,eAAe,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE;iBACxE;SACN,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,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K,EAAE,gBAAgB,EAAE,IAAI,EAAE,4BAA4B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC5F,CAAC;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,oBAAoB,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;QAC3E,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type McpDriftReport, type McpHost, type McpInstance } from "../domain/mcp-entry.js";
|
|
2
|
+
import type { EnvPort } from "../ports/env.js";
|
|
3
|
+
import type { PathsService } from "./paths-service.js";
|
|
4
|
+
export interface McpDoctorInput {
|
|
5
|
+
hosts: McpHost[];
|
|
6
|
+
instances: McpInstance[];
|
|
7
|
+
scope: "workspace" | "global";
|
|
8
|
+
workspace?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface McpDoctorResult {
|
|
11
|
+
scope: "workspace" | "global";
|
|
12
|
+
scope_dir: string;
|
|
13
|
+
reports: McpDriftReport[];
|
|
14
|
+
summary: {
|
|
15
|
+
ok: number;
|
|
16
|
+
missing_mcp: number;
|
|
17
|
+
dsn_mismatch: number;
|
|
18
|
+
missing_dsn: number;
|
|
19
|
+
extra: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare function runMcpDoctor(env: EnvPort, paths: PathsService, input: McpDoctorInput): McpDoctorResult;
|
|
23
|
+
//# sourceMappingURL=mcp-doctor-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-doctor-service.d.ts","sourceRoot":"","sources":["../../src/application/mcp-doctor-service.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,WAAW,EAEjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED,wBAAgB,YAAY,CAC1B,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,cAAc,GACpB,eAAe,CAoBjB"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { buildMcpEntry, } from "../domain/mcp-entry.js";
|
|
4
|
+
import { dsnKeyForInstance, readBootstrapDsn } from "./dsn-reader-service.js";
|
|
5
|
+
import { readMcpEntry } from "./mcp-host-reader.js";
|
|
6
|
+
export function runMcpDoctor(env, paths, input) {
|
|
7
|
+
const scopeDir = resolveScopeDir(env, input);
|
|
8
|
+
const dsn = readBootstrapDsn(paths);
|
|
9
|
+
const reports = [];
|
|
10
|
+
for (const host of input.hosts) {
|
|
11
|
+
for (const instance of input.instances) {
|
|
12
|
+
reports.push(buildReport(host, instance, scopeDir, dsn, input.scope));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const summary = {
|
|
16
|
+
ok: reports.filter((r) => r.status === "ok").length,
|
|
17
|
+
missing_mcp: reports.filter((r) => r.status === "missing-mcp").length,
|
|
18
|
+
dsn_mismatch: reports.filter((r) => r.status === "dsn-mismatch").length,
|
|
19
|
+
missing_dsn: reports.filter((r) => r.status === "missing-dsn").length,
|
|
20
|
+
extra: reports.filter((r) => r.status === "extra-entry").length,
|
|
21
|
+
};
|
|
22
|
+
return { scope: input.scope, scope_dir: scopeDir, reports, summary };
|
|
23
|
+
}
|
|
24
|
+
function buildReport(host, instance, scopeDir, dsn, scope) {
|
|
25
|
+
const entry = buildMcpEntry(instance);
|
|
26
|
+
const snapshot = readMcpEntry(host, scopeDir, entry.name);
|
|
27
|
+
const dsnKey = dsnKeyForInstance(instance);
|
|
28
|
+
const dsnPresent = dsn.exists && Boolean(dsn.values[dsnKey]);
|
|
29
|
+
const dsnInfo = {
|
|
30
|
+
path: dsn.path,
|
|
31
|
+
exists: dsn.exists,
|
|
32
|
+
key: dsnKey,
|
|
33
|
+
present: dsnPresent,
|
|
34
|
+
};
|
|
35
|
+
if (!snapshot.exists) {
|
|
36
|
+
return {
|
|
37
|
+
host,
|
|
38
|
+
instance,
|
|
39
|
+
scope,
|
|
40
|
+
target: snapshot.target,
|
|
41
|
+
dsn: dsnInfo,
|
|
42
|
+
mcp: { name: entry.name, present: false, matches: false },
|
|
43
|
+
status: dsnPresent ? "missing-mcp" : "missing-dsn",
|
|
44
|
+
detail: dsnPresent
|
|
45
|
+
? `Falta entrada MCP '${entry.name}' en ${snapshot.target}`
|
|
46
|
+
: `Ni DSN ni MCP registrados para ${instance}`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const matches = matchesEntry(snapshot, entry);
|
|
50
|
+
if (!dsnPresent) {
|
|
51
|
+
return {
|
|
52
|
+
host,
|
|
53
|
+
instance,
|
|
54
|
+
scope,
|
|
55
|
+
target: snapshot.target,
|
|
56
|
+
dsn: dsnInfo,
|
|
57
|
+
mcp: { name: entry.name, present: true, matches },
|
|
58
|
+
status: "dsn-mismatch",
|
|
59
|
+
detail: `MCP '${entry.name}' registrado pero ${dsnKey} no está en ${dsn.path}`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (!matches) {
|
|
63
|
+
return {
|
|
64
|
+
host,
|
|
65
|
+
instance,
|
|
66
|
+
scope,
|
|
67
|
+
target: snapshot.target,
|
|
68
|
+
dsn: dsnInfo,
|
|
69
|
+
mcp: { name: entry.name, present: true, matches: false },
|
|
70
|
+
status: "extra-entry",
|
|
71
|
+
detail: `Entrada '${entry.name}' difiere del shape esperado (command/args/env)`,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
host,
|
|
76
|
+
instance,
|
|
77
|
+
scope,
|
|
78
|
+
target: snapshot.target,
|
|
79
|
+
dsn: dsnInfo,
|
|
80
|
+
mcp: { name: entry.name, present: true, matches: true },
|
|
81
|
+
status: "ok",
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function matchesEntry(snapshot, entry) {
|
|
85
|
+
if (snapshot.command !== entry.command)
|
|
86
|
+
return false;
|
|
87
|
+
if (!arraysEqual(snapshot.args ?? [], entry.args))
|
|
88
|
+
return false;
|
|
89
|
+
if (!recordsEqual(snapshot.env ?? {}, entry.env))
|
|
90
|
+
return false;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
function arraysEqual(a, b) {
|
|
94
|
+
if (a.length !== b.length)
|
|
95
|
+
return false;
|
|
96
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
97
|
+
if (a[i] !== b[i])
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
function recordsEqual(a, b) {
|
|
103
|
+
const keysA = Object.keys(a).sort();
|
|
104
|
+
const keysB = Object.keys(b).sort();
|
|
105
|
+
if (keysA.length !== keysB.length)
|
|
106
|
+
return false;
|
|
107
|
+
for (let i = 0; i < keysA.length; i += 1) {
|
|
108
|
+
if (keysA[i] !== keysB[i])
|
|
109
|
+
return false;
|
|
110
|
+
const k = keysA[i] ?? "";
|
|
111
|
+
if (a[k] !== b[k])
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
function resolveScopeDir(env, input) {
|
|
117
|
+
if (input.scope === "global")
|
|
118
|
+
return homedir();
|
|
119
|
+
if (input.workspace)
|
|
120
|
+
return resolve(input.workspace);
|
|
121
|
+
return resolve(env.cwd());
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=mcp-doctor-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-doctor-service.js","sourceRoot":"","sources":["../../src/application/mcp-doctor-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAIL,aAAa,GACd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAuBpD,MAAM,UAAU,YAAY,CAC1B,GAAY,EACZ,KAAmB,EACnB,KAAqB;IAErB,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,OAAO,GAAqB,EAAE,CAAC;IAErC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC/B,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,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C;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,YAAY,CAAC,CAAyB,EAAE,CAAyB;IACxE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACpC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACpC,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAChD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QACxC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACzB,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IAClC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,eAAe,CAAC,GAAY,EAAE,KAAqB;IAC1D,IAAI,KAAK,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,OAAO,EAAE,CAAC;IAC/C,IAAI,KAAK,CAAC,SAAS;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACrD,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { McpHost } from "../domain/mcp-entry.js";
|
|
2
|
+
export interface McpEntrySnapshot {
|
|
3
|
+
host: McpHost;
|
|
4
|
+
target: string;
|
|
5
|
+
name: string;
|
|
6
|
+
exists: boolean;
|
|
7
|
+
command?: string;
|
|
8
|
+
args?: string[];
|
|
9
|
+
env?: Record<string, string>;
|
|
10
|
+
raw?: unknown;
|
|
11
|
+
}
|
|
12
|
+
export declare function readMcpEntry(host: McpHost, scopeDir: string, name: string): McpEntrySnapshot;
|
|
13
|
+
//# sourceMappingURL=mcp-host-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-host-reader.d.ts","sourceRoot":"","sources":["../../src/application/mcp-host-reader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAG5F"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { parse as parseToml } from "smol-toml";
|
|
4
|
+
export function readMcpEntry(host, scopeDir, name) {
|
|
5
|
+
if (host === "claude")
|
|
6
|
+
return readClaudeMcpEntry(scopeDir, name);
|
|
7
|
+
return readCodexMcpEntry(scopeDir, name);
|
|
8
|
+
}
|
|
9
|
+
function readClaudeMcpEntry(scopeDir, name) {
|
|
10
|
+
const target = join(scopeDir, ".claude", "settings.json");
|
|
11
|
+
if (!existsSync(target)) {
|
|
12
|
+
return { host: "claude", target, name, exists: false };
|
|
13
|
+
}
|
|
14
|
+
const text = readFileSync(target, "utf-8");
|
|
15
|
+
if (text.trim().length === 0) {
|
|
16
|
+
return { host: "claude", target, name, exists: false };
|
|
17
|
+
}
|
|
18
|
+
let data;
|
|
19
|
+
try {
|
|
20
|
+
data = JSON.parse(text);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return { host: "claude", target, name, exists: false };
|
|
24
|
+
}
|
|
25
|
+
const mcpServers = (data.mcpServers ?? {});
|
|
26
|
+
const entry = mcpServers[name];
|
|
27
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
28
|
+
return { host: "claude", target, name, exists: false };
|
|
29
|
+
}
|
|
30
|
+
const e = entry;
|
|
31
|
+
return {
|
|
32
|
+
host: "claude",
|
|
33
|
+
target,
|
|
34
|
+
name,
|
|
35
|
+
exists: true,
|
|
36
|
+
...(typeof e.command === "string" ? { command: e.command } : {}),
|
|
37
|
+
...(Array.isArray(e.args)
|
|
38
|
+
? { args: e.args.filter((x) => typeof x === "string") }
|
|
39
|
+
: {}),
|
|
40
|
+
...(typeof e.env === "object" && e.env !== null ? { env: toStringRecord(e.env) } : {}),
|
|
41
|
+
raw: e,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function readCodexMcpEntry(scopeDir, name) {
|
|
45
|
+
const target = join(scopeDir, ".codex", "config.toml");
|
|
46
|
+
if (!existsSync(target)) {
|
|
47
|
+
return { host: "codex", target, name, exists: false };
|
|
48
|
+
}
|
|
49
|
+
const text = readFileSync(target, "utf-8");
|
|
50
|
+
if (text.trim().length === 0) {
|
|
51
|
+
return { host: "codex", target, name, exists: false };
|
|
52
|
+
}
|
|
53
|
+
let data;
|
|
54
|
+
try {
|
|
55
|
+
data = parseToml(text);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return { host: "codex", target, name, exists: false };
|
|
59
|
+
}
|
|
60
|
+
const mcpServers = (data.mcp_servers ?? {});
|
|
61
|
+
const entry = mcpServers[name];
|
|
62
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
63
|
+
return { host: "codex", target, name, exists: false };
|
|
64
|
+
}
|
|
65
|
+
const e = entry;
|
|
66
|
+
return {
|
|
67
|
+
host: "codex",
|
|
68
|
+
target,
|
|
69
|
+
name,
|
|
70
|
+
exists: true,
|
|
71
|
+
...(typeof e.command === "string" ? { command: e.command } : {}),
|
|
72
|
+
...(Array.isArray(e.args)
|
|
73
|
+
? { args: e.args.filter((x) => typeof x === "string") }
|
|
74
|
+
: {}),
|
|
75
|
+
...(typeof e.env === "object" && e.env !== null ? { env: toStringRecord(e.env) } : {}),
|
|
76
|
+
raw: e,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function toStringRecord(obj) {
|
|
80
|
+
const out = {};
|
|
81
|
+
if (!obj || typeof obj !== "object")
|
|
82
|
+
return out;
|
|
83
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
84
|
+
if (typeof v === "string")
|
|
85
|
+
out[k] = v;
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=mcp-host-reader.js.map
|