@opencodehub/mcp 0.1.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/README.md +62 -0
- package/dist/analysis-bridge.d.ts +23 -0
- package/dist/analysis-bridge.d.ts.map +1 -0
- package/dist/analysis-bridge.js +83 -0
- package/dist/analysis-bridge.js.map +1 -0
- package/dist/connection-pool.d.ts +76 -0
- package/dist/connection-pool.d.ts.map +1 -0
- package/dist/connection-pool.js +179 -0
- package/dist/connection-pool.js.map +1 -0
- package/dist/error-envelope.d.ts +97 -0
- package/dist/error-envelope.d.ts.map +1 -0
- package/dist/error-envelope.js +75 -0
- package/dist/error-envelope.js.map +1 -0
- package/dist/group-resolver.d.ts +29 -0
- package/dist/group-resolver.d.ts.map +1 -0
- package/dist/group-resolver.js +100 -0
- package/dist/group-resolver.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/next-step-hints.d.ts +24 -0
- package/dist/next-step-hints.d.ts.map +1 -0
- package/dist/next-step-hints.js +41 -0
- package/dist/next-step-hints.js.map +1 -0
- package/dist/repo-resolver.d.ts +88 -0
- package/dist/repo-resolver.d.ts.map +1 -0
- package/dist/repo-resolver.js +211 -0
- package/dist/repo-resolver.js.map +1 -0
- package/dist/repo-uri-for-entry.d.ts +25 -0
- package/dist/repo-uri-for-entry.d.ts.map +1 -0
- package/dist/repo-uri-for-entry.js +64 -0
- package/dist/repo-uri-for-entry.js.map +1 -0
- package/dist/resources/repo-cluster.d.ts +19 -0
- package/dist/resources/repo-cluster.d.ts.map +1 -0
- package/dist/resources/repo-cluster.js +203 -0
- package/dist/resources/repo-cluster.js.map +1 -0
- package/dist/resources/repo-clusters.d.ts +14 -0
- package/dist/resources/repo-clusters.d.ts.map +1 -0
- package/dist/resources/repo-clusters.js +97 -0
- package/dist/resources/repo-clusters.js.map +1 -0
- package/dist/resources/repo-context.d.ts +12 -0
- package/dist/resources/repo-context.d.ts.map +1 -0
- package/dist/resources/repo-context.js +84 -0
- package/dist/resources/repo-context.js.map +1 -0
- package/dist/resources/repo-process.d.ts +19 -0
- package/dist/resources/repo-process.d.ts.map +1 -0
- package/dist/resources/repo-process.js +220 -0
- package/dist/resources/repo-process.js.map +1 -0
- package/dist/resources/repo-processes.d.ts +13 -0
- package/dist/resources/repo-processes.d.ts.map +1 -0
- package/dist/resources/repo-processes.js +99 -0
- package/dist/resources/repo-processes.js.map +1 -0
- package/dist/resources/repo-schema.d.ts +13 -0
- package/dist/resources/repo-schema.d.ts.map +1 -0
- package/dist/resources/repo-schema.js +99 -0
- package/dist/resources/repo-schema.js.map +1 -0
- package/dist/resources/repos.d.ts +20 -0
- package/dist/resources/repos.d.ts.map +1 -0
- package/dist/resources/repos.js +58 -0
- package/dist/resources/repos.js.map +1 -0
- package/dist/resources/store-helper.d.ts +28 -0
- package/dist/resources/store-helper.d.ts.map +1 -0
- package/dist/resources/store-helper.js +58 -0
- package/dist/resources/store-helper.js.map +1 -0
- package/dist/resources/yaml.d.ts +10 -0
- package/dist/resources/yaml.d.ts.map +1 -0
- package/dist/resources/yaml.js +16 -0
- package/dist/resources/yaml.js.map +1 -0
- package/dist/server.d.ts +46 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +194 -0
- package/dist/server.js.map +1 -0
- package/dist/staleness.d.ts +19 -0
- package/dist/staleness.d.ts.map +1 -0
- package/dist/staleness.js +40 -0
- package/dist/staleness.js.map +1 -0
- package/dist/test-utils.d.ts +170 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/test-utils.js +473 -0
- package/dist/test-utils.js.map +1 -0
- package/dist/tools/api-impact.d.ts +47 -0
- package/dist/tools/api-impact.d.ts.map +1 -0
- package/dist/tools/api-impact.js +199 -0
- package/dist/tools/api-impact.js.map +1 -0
- package/dist/tools/confidence.d.ts +39 -0
- package/dist/tools/confidence.d.ts.map +1 -0
- package/dist/tools/confidence.js +58 -0
- package/dist/tools/confidence.js.map +1 -0
- package/dist/tools/context.d.ts +47 -0
- package/dist/tools/context.d.ts.map +1 -0
- package/dist/tools/context.js +577 -0
- package/dist/tools/context.js.map +1 -0
- package/dist/tools/dependencies.d.ts +29 -0
- package/dist/tools/dependencies.d.ts.map +1 -0
- package/dist/tools/dependencies.js +110 -0
- package/dist/tools/dependencies.js.map +1 -0
- package/dist/tools/detect-changes.d.ts +15 -0
- package/dist/tools/detect-changes.d.ts.map +1 -0
- package/dist/tools/detect-changes.js +78 -0
- package/dist/tools/detect-changes.js.map +1 -0
- package/dist/tools/group-contracts.d.ts +26 -0
- package/dist/tools/group-contracts.d.ts.map +1 -0
- package/dist/tools/group-contracts.js +251 -0
- package/dist/tools/group-contracts.js.map +1 -0
- package/dist/tools/group-cross-repo-links.d.ts +28 -0
- package/dist/tools/group-cross-repo-links.d.ts.map +1 -0
- package/dist/tools/group-cross-repo-links.js +128 -0
- package/dist/tools/group-cross-repo-links.js.map +1 -0
- package/dist/tools/group-list.d.ts +10 -0
- package/dist/tools/group-list.d.ts.map +1 -0
- package/dist/tools/group-list.js +74 -0
- package/dist/tools/group-list.js.map +1 -0
- package/dist/tools/group-query.d.ts +40 -0
- package/dist/tools/group-query.d.ts.map +1 -0
- package/dist/tools/group-query.js +209 -0
- package/dist/tools/group-query.js.map +1 -0
- package/dist/tools/group-status.d.ts +21 -0
- package/dist/tools/group-status.d.ts.map +1 -0
- package/dist/tools/group-status.js +121 -0
- package/dist/tools/group-status.js.map +1 -0
- package/dist/tools/group-sync.d.ts +23 -0
- package/dist/tools/group-sync.d.ts.map +1 -0
- package/dist/tools/group-sync.js +112 -0
- package/dist/tools/group-sync.js.map +1 -0
- package/dist/tools/impact.d.ts +36 -0
- package/dist/tools/impact.d.ts.map +1 -0
- package/dist/tools/impact.js +232 -0
- package/dist/tools/impact.js.map +1 -0
- package/dist/tools/license-audit.d.ts +34 -0
- package/dist/tools/license-audit.d.ts.map +1 -0
- package/dist/tools/license-audit.js +108 -0
- package/dist/tools/license-audit.js.map +1 -0
- package/dist/tools/list-dead-code.d.ts +26 -0
- package/dist/tools/list-dead-code.d.ts.map +1 -0
- package/dist/tools/list-dead-code.js +110 -0
- package/dist/tools/list-dead-code.js.map +1 -0
- package/dist/tools/list-findings-delta.d.ts +36 -0
- package/dist/tools/list-findings-delta.d.ts.map +1 -0
- package/dist/tools/list-findings-delta.js +274 -0
- package/dist/tools/list-findings-delta.js.map +1 -0
- package/dist/tools/list-findings.d.ts +30 -0
- package/dist/tools/list-findings.d.ts.map +1 -0
- package/dist/tools/list-findings.js +129 -0
- package/dist/tools/list-findings.js.map +1 -0
- package/dist/tools/list-repos.d.ts +17 -0
- package/dist/tools/list-repos.d.ts.map +1 -0
- package/dist/tools/list-repos.js +63 -0
- package/dist/tools/list-repos.js.map +1 -0
- package/dist/tools/owners.d.ts +23 -0
- package/dist/tools/owners.d.ts.map +1 -0
- package/dist/tools/owners.js +103 -0
- package/dist/tools/owners.js.map +1 -0
- package/dist/tools/pack-codebase.d.ts +76 -0
- package/dist/tools/pack-codebase.d.ts.map +1 -0
- package/dist/tools/pack-codebase.js +289 -0
- package/dist/tools/pack-codebase.js.map +1 -0
- package/dist/tools/project-profile.d.ts +28 -0
- package/dist/tools/project-profile.d.ts.map +1 -0
- package/dist/tools/project-profile.js +109 -0
- package/dist/tools/project-profile.js.map +1 -0
- package/dist/tools/query.d.ts +63 -0
- package/dist/tools/query.d.ts.map +1 -0
- package/dist/tools/query.js +662 -0
- package/dist/tools/query.js.map +1 -0
- package/dist/tools/remove-dead-code.d.ts +47 -0
- package/dist/tools/remove-dead-code.d.ts.map +1 -0
- package/dist/tools/remove-dead-code.js +258 -0
- package/dist/tools/remove-dead-code.js.map +1 -0
- package/dist/tools/rename.d.ts +21 -0
- package/dist/tools/rename.d.ts.map +1 -0
- package/dist/tools/rename.js +116 -0
- package/dist/tools/rename.js.map +1 -0
- package/dist/tools/risk-trends.d.ts +19 -0
- package/dist/tools/risk-trends.d.ts.map +1 -0
- package/dist/tools/risk-trends.js +73 -0
- package/dist/tools/risk-trends.js.map +1 -0
- package/dist/tools/route-map.d.ts +27 -0
- package/dist/tools/route-map.d.ts.map +1 -0
- package/dist/tools/route-map.js +119 -0
- package/dist/tools/route-map.js.map +1 -0
- package/dist/tools/scan.d.ts +27 -0
- package/dist/tools/scan.d.ts.map +1 -0
- package/dist/tools/scan.js +136 -0
- package/dist/tools/scan.js.map +1 -0
- package/dist/tools/shape-check.d.ts +53 -0
- package/dist/tools/shape-check.d.ts.map +1 -0
- package/dist/tools/shape-check.js +161 -0
- package/dist/tools/shape-check.js.map +1 -0
- package/dist/tools/shared.d.ts +101 -0
- package/dist/tools/shared.d.ts.map +1 -0
- package/dist/tools/shared.js +114 -0
- package/dist/tools/shared.js.map +1 -0
- package/dist/tools/signature.d.ts +38 -0
- package/dist/tools/signature.d.ts.map +1 -0
- package/dist/tools/signature.js +332 -0
- package/dist/tools/signature.js.map +1 -0
- package/dist/tools/sql.d.ts +34 -0
- package/dist/tools/sql.d.ts.map +1 -0
- package/dist/tools/sql.js +222 -0
- package/dist/tools/sql.js.map +1 -0
- package/dist/tools/tool-map.d.ts +24 -0
- package/dist/tools/tool-map.d.ts.map +1 -0
- package/dist/tools/tool-map.js +97 -0
- package/dist/tools/tool-map.js.map +1 -0
- package/dist/tools/verdict.d.ts +33 -0
- package/dist/tools/verdict.d.ts.map +1 -0
- package/dist/tools/verdict.js +102 -0
- package/dist/tools/verdict.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pack_codebase` — produce a snapshot of a registered repo for an LLM
|
|
3
|
+
* to consume.
|
|
4
|
+
*
|
|
5
|
+
* Two engines are supported via the `engine` input field:
|
|
6
|
+
* - `pack` (DEFAULT) — `@opencodehub/pack`'s deterministic 9-item BOM
|
|
7
|
+
* written to `<repo>/.codehub/packs/<packHash>/`. The BOM is what
|
|
8
|
+
* downstream agents should consume — it carries skeleton + file-tree
|
|
9
|
+
* + deps + ast-chunks + xrefs + findings + licenses + readme +
|
|
10
|
+
* optional embeddings.parquet, all bound by a manifest with a
|
|
11
|
+
* content-addressed `pack_hash`.
|
|
12
|
+
* - `repomix` — the legacy single-file XML/Markdown snapshot under
|
|
13
|
+
* `<repo>/.codehub/pack/repo.<ext>`. Retained as an opt-in for one
|
|
14
|
+
* milestone (drop deferred to M7 per spec 005 Q-DELTA-6). Operators
|
|
15
|
+
* who relied on repomix for raw repo packing keep a stable path.
|
|
16
|
+
*
|
|
17
|
+
* For relational/structural questions about the repo, prefer
|
|
18
|
+
* `query`/`context`/`impact` — those are backed by the SCIP graph and
|
|
19
|
+
* give graph-aware answers without consuming context window.
|
|
20
|
+
*/
|
|
21
|
+
import { spawn } from "node:child_process";
|
|
22
|
+
import { existsSync, statSync } from "node:fs";
|
|
23
|
+
import { mkdir } from "node:fs/promises";
|
|
24
|
+
import { dirname, join } from "node:path";
|
|
25
|
+
import { generatePack as defaultGeneratePack } from "@opencodehub/pack";
|
|
26
|
+
import { z } from "zod";
|
|
27
|
+
import { toolErrorFromUnknown } from "../error-envelope.js";
|
|
28
|
+
import { withNextSteps } from "../next-step-hints.js";
|
|
29
|
+
import { resolveRepo } from "../repo-resolver.js";
|
|
30
|
+
import { fromToolResult, toToolResult } from "./shared.js";
|
|
31
|
+
const DEFAULT_REPOMIX_VERSION = "1.14.0";
|
|
32
|
+
/** Default token budget passed to the pack engine when `budget` is omitted. */
|
|
33
|
+
export const DEFAULT_PACK_BUDGET = 100_000;
|
|
34
|
+
/** Default tokenizer identifier when `tokenizer` is omitted. */
|
|
35
|
+
export const DEFAULT_PACK_TOKENIZER = "openai:o200k_base@tiktoken-0.8.0";
|
|
36
|
+
const PackInput = z.object({
|
|
37
|
+
repo: z
|
|
38
|
+
.string()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe("Registered repo name (see list_repos). Provide `repo` or `repo_uri`; required when ≥ 2 repos are registered."),
|
|
41
|
+
repo_uri: z
|
|
42
|
+
.string()
|
|
43
|
+
.optional()
|
|
44
|
+
.describe("Sourcegraph-style repo URI (e.g. `github.com/org/repo`). Accepted as an alias for `repo`; wins when both are provided."),
|
|
45
|
+
engine: z
|
|
46
|
+
.enum(["pack", "repomix"])
|
|
47
|
+
.optional()
|
|
48
|
+
.default("pack")
|
|
49
|
+
.describe("Engine: `pack` (default) writes the 9-item BOM via @opencodehub/pack. " +
|
|
50
|
+
"`repomix` is the legacy single-file snapshot, retained as an opt-in."),
|
|
51
|
+
budget: z
|
|
52
|
+
.number()
|
|
53
|
+
.int()
|
|
54
|
+
.positive()
|
|
55
|
+
.optional()
|
|
56
|
+
.default(DEFAULT_PACK_BUDGET)
|
|
57
|
+
.describe("Token budget for the AST chunker. Pack engine only. Default 100000."),
|
|
58
|
+
tokenizer: z
|
|
59
|
+
.string()
|
|
60
|
+
.optional()
|
|
61
|
+
.default(DEFAULT_PACK_TOKENIZER)
|
|
62
|
+
.describe('Tokenizer pin "<vendor>:<name>@<pin>". Pack engine only. Default openai:o200k_base@tiktoken-0.8.0.'),
|
|
63
|
+
// Legacy repomix-only fields. Honored when engine === "repomix"; ignored
|
|
64
|
+
// for the pack engine.
|
|
65
|
+
style: z
|
|
66
|
+
.enum(["xml", "markdown", "json", "plain"])
|
|
67
|
+
.optional()
|
|
68
|
+
.default("xml")
|
|
69
|
+
.describe("Repomix output style. Repomix engine only."),
|
|
70
|
+
compress: z
|
|
71
|
+
.boolean()
|
|
72
|
+
.optional()
|
|
73
|
+
.default(true)
|
|
74
|
+
.describe("Repomix tree-sitter signature compression. Repomix engine only."),
|
|
75
|
+
removeComments: z
|
|
76
|
+
.boolean()
|
|
77
|
+
.optional()
|
|
78
|
+
.default(false)
|
|
79
|
+
.describe("Repomix --remove-comments. Repomix engine only."),
|
|
80
|
+
});
|
|
81
|
+
export async function runPackCodebase(ctx, input, deps = {}) {
|
|
82
|
+
try {
|
|
83
|
+
const entry = await resolveRepo({
|
|
84
|
+
...(input.repo !== undefined ? { repo: input.repo } : {}),
|
|
85
|
+
...(input.repo_uri !== undefined ? { repo_uri: input.repo_uri } : {}),
|
|
86
|
+
}, {
|
|
87
|
+
...(ctx.home !== undefined ? { home: ctx.home } : {}),
|
|
88
|
+
skipMeta: true,
|
|
89
|
+
});
|
|
90
|
+
if (input.engine === "repomix") {
|
|
91
|
+
return await runRepomixPath(entry, input, deps);
|
|
92
|
+
}
|
|
93
|
+
return await runPackPath(entry, input, deps);
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
return toToolResult(toolErrorFromUnknown(err));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async function runPackPath(entry, input, deps) {
|
|
100
|
+
const start = Date.now();
|
|
101
|
+
const result = deps._runPackEngine !== undefined
|
|
102
|
+
? await deps._runPackEngine({
|
|
103
|
+
repo: entry.repoPath,
|
|
104
|
+
budget: input.budget,
|
|
105
|
+
tokenizer: input.tokenizer,
|
|
106
|
+
})
|
|
107
|
+
: await callRealPackEngine({
|
|
108
|
+
repo: entry.repoPath,
|
|
109
|
+
budget: input.budget,
|
|
110
|
+
tokenizer: input.tokenizer,
|
|
111
|
+
});
|
|
112
|
+
const durationMs = Date.now() - start;
|
|
113
|
+
const body = [
|
|
114
|
+
`Packed ${entry.name} via @opencodehub/pack to ${result.outDir}`,
|
|
115
|
+
` bomItemCount: ${result.bomItemCount}`,
|
|
116
|
+
` packHash: ${result.packHash}`,
|
|
117
|
+
` budget: ${input.budget}`,
|
|
118
|
+
` tokenizer: ${input.tokenizer}`,
|
|
119
|
+
` duration: ${durationMs}ms`,
|
|
120
|
+
].join("\n");
|
|
121
|
+
return toToolResult(withNextSteps(body, {
|
|
122
|
+
engine: "pack",
|
|
123
|
+
outDir: result.outDir,
|
|
124
|
+
packHash: result.packHash,
|
|
125
|
+
bomItemCount: result.bomItemCount,
|
|
126
|
+
budget: input.budget,
|
|
127
|
+
tokenizer: input.tokenizer,
|
|
128
|
+
durationMs,
|
|
129
|
+
}, [
|
|
130
|
+
"load .codehub/packs/<hash>/manifest.json to inspect the BOM, then read the per-BOM-item files (skeleton, file-tree, ast-chunks, xrefs, findings, licenses).",
|
|
131
|
+
"structural questions go to `query`/`context`/`impact` — those answer without consuming context window.",
|
|
132
|
+
]));
|
|
133
|
+
}
|
|
134
|
+
async function runRepomixPath(entry, input, deps) {
|
|
135
|
+
const result = deps._runRepomixEngine !== undefined
|
|
136
|
+
? await deps._runRepomixEngine({
|
|
137
|
+
repoPath: entry.repoPath,
|
|
138
|
+
style: input.style,
|
|
139
|
+
compress: input.compress,
|
|
140
|
+
removeComments: input.removeComments,
|
|
141
|
+
})
|
|
142
|
+
: await callRealRepomixEngine({
|
|
143
|
+
repoPath: entry.repoPath,
|
|
144
|
+
style: input.style,
|
|
145
|
+
compress: input.compress,
|
|
146
|
+
removeComments: input.removeComments,
|
|
147
|
+
});
|
|
148
|
+
const body = [
|
|
149
|
+
`Packed ${entry.name} via repomix to ${result.outputPath}`,
|
|
150
|
+
` bytes: ${result.bytes}`,
|
|
151
|
+
` style: ${input.style}`,
|
|
152
|
+
` compress: ${input.compress}`,
|
|
153
|
+
` duration: ${result.durationMs}ms`,
|
|
154
|
+
].join("\n");
|
|
155
|
+
// Mark the engine in `_meta.engine` so callers can detect the legacy path
|
|
156
|
+
// and migrate; `next_steps` flags the M7 deprecation explicitly.
|
|
157
|
+
return toToolResult(withNextSteps(body, {
|
|
158
|
+
engine: "repomix",
|
|
159
|
+
outputPath: result.outputPath,
|
|
160
|
+
bytes: result.bytes,
|
|
161
|
+
style: input.style,
|
|
162
|
+
durationMs: result.durationMs,
|
|
163
|
+
_meta: { engine: "repomix" },
|
|
164
|
+
}, [
|
|
165
|
+
"repomix engine is opt-in and slated for removal in M7 — prefer engine='pack' (default) for new callers.",
|
|
166
|
+
"load the output file into your context; structural questions go to `query`/`context`/`impact`.",
|
|
167
|
+
]));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Real-world implementation of the pack engine. Imports the CLI's
|
|
171
|
+
* `runCodePack` lazily so MCP servers without `@opencodehub/cli`
|
|
172
|
+
* installed (e.g. embed-only deployments) still type-check; the import
|
|
173
|
+
* happens only on engine=pack invocations.
|
|
174
|
+
*/
|
|
175
|
+
async function callRealPackEngine(args) {
|
|
176
|
+
// Inline the same wiring as `runCodePack` rather than importing
|
|
177
|
+
// `@opencodehub/cli` (which would create a cycle, MCP <- CLI <- MCP).
|
|
178
|
+
// Open the DuckStore directly, call generatePack, rename into place.
|
|
179
|
+
const { mkdtemp, rename, rm } = await import("node:fs/promises");
|
|
180
|
+
const { tmpdir } = await import("node:os");
|
|
181
|
+
const { join, resolve } = await import("node:path");
|
|
182
|
+
const { openStore, resolveDbPath } = await import("@opencodehub/storage");
|
|
183
|
+
const dbPath = resolveDbPath(args.repo);
|
|
184
|
+
if (!existsSync(dbPath)) {
|
|
185
|
+
throw new Error(`pack_codebase: no graph index at ${dbPath}. ` +
|
|
186
|
+
"Run `codehub analyze` first to populate the store.");
|
|
187
|
+
}
|
|
188
|
+
const store = await openStore({ path: dbPath, backend: "duck", readOnly: true });
|
|
189
|
+
const stagingDir = await mkdtemp(join(tmpdir(), "codehub-pack-mcp-"));
|
|
190
|
+
try {
|
|
191
|
+
const manifest = await defaultGeneratePack({
|
|
192
|
+
repoPath: args.repo,
|
|
193
|
+
outDir: stagingDir,
|
|
194
|
+
budgetTokens: args.budget,
|
|
195
|
+
tokenizerId: args.tokenizer,
|
|
196
|
+
}, { store });
|
|
197
|
+
const finalOutDir = resolve(args.repo, ".codehub", "packs", manifest.packHash);
|
|
198
|
+
await mkdir(dirname(finalOutDir), { recursive: true });
|
|
199
|
+
if (existsSync(finalOutDir)) {
|
|
200
|
+
await rm(finalOutDir, { recursive: true, force: true });
|
|
201
|
+
}
|
|
202
|
+
await rename(stagingDir, finalOutDir);
|
|
203
|
+
return {
|
|
204
|
+
outDir: finalOutDir,
|
|
205
|
+
packHash: manifest.packHash,
|
|
206
|
+
bomItemCount: manifest.files.length + 1,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
finally {
|
|
210
|
+
await store.close();
|
|
211
|
+
await rm(stagingDir, { recursive: true, force: true });
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/** Real-world repomix shell-out. */
|
|
215
|
+
async function callRealRepomixEngine(args) {
|
|
216
|
+
const outputPath = join(args.repoPath, ".codehub", "pack", `repo.${extForStyle(args.style)}`);
|
|
217
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
218
|
+
const cmdArgs = [
|
|
219
|
+
`repomix@${DEFAULT_REPOMIX_VERSION}`,
|
|
220
|
+
"--style",
|
|
221
|
+
args.style,
|
|
222
|
+
"--output",
|
|
223
|
+
outputPath,
|
|
224
|
+
];
|
|
225
|
+
if (args.compress)
|
|
226
|
+
cmdArgs.push("--compress");
|
|
227
|
+
if (args.removeComments)
|
|
228
|
+
cmdArgs.push("--remove-comments");
|
|
229
|
+
const start = Date.now();
|
|
230
|
+
await new Promise((res, rej) => {
|
|
231
|
+
const child = spawn("npx", cmdArgs, {
|
|
232
|
+
cwd: args.repoPath,
|
|
233
|
+
env: { ...process.env },
|
|
234
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
235
|
+
});
|
|
236
|
+
let stderr = "";
|
|
237
|
+
child.stderr?.on("data", (d) => {
|
|
238
|
+
stderr += d.toString();
|
|
239
|
+
});
|
|
240
|
+
child.on("error", (err) => {
|
|
241
|
+
rej(err.code === "ENOENT"
|
|
242
|
+
? new Error("pack_codebase: `npx` not found on PATH. Install Node.js 20+.")
|
|
243
|
+
: err);
|
|
244
|
+
});
|
|
245
|
+
child.on("exit", (code) => {
|
|
246
|
+
if (code === 0)
|
|
247
|
+
res();
|
|
248
|
+
else
|
|
249
|
+
rej(new Error(`pack_codebase: repomix exited ${code}. ${stderr.slice(-400)}`));
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
const durationMs = Date.now() - start;
|
|
253
|
+
if (!existsSync(outputPath)) {
|
|
254
|
+
throw new Error(`pack_codebase: repomix did not produce ${outputPath}`);
|
|
255
|
+
}
|
|
256
|
+
const bytes = statSync(outputPath).size;
|
|
257
|
+
return { outputPath, bytes, durationMs };
|
|
258
|
+
}
|
|
259
|
+
export function registerPackCodebaseTool(server, ctx) {
|
|
260
|
+
server.registerTool("pack_codebase", {
|
|
261
|
+
title: "Pack a repo into an LLM-ready snapshot",
|
|
262
|
+
description: "Produce a snapshot of a registered repo. The default `pack` engine writes the deterministic " +
|
|
263
|
+
"9-item BOM (manifest + skeleton + file-tree + deps + ast-chunks + xrefs + findings + " +
|
|
264
|
+
"licenses + readme + optional embeddings.parquet) under <repo>/.codehub/packs/<packHash>/. " +
|
|
265
|
+
"The legacy `repomix` engine is retained as an opt-in single-file snapshot (drop deferred to M7). " +
|
|
266
|
+
"For relational/structural questions about the repo, prefer query/context/impact — those are " +
|
|
267
|
+
"backed by the SCIP graph and give graph-aware answers without consuming context window.",
|
|
268
|
+
annotations: {
|
|
269
|
+
readOnlyHint: false,
|
|
270
|
+
destructiveHint: false,
|
|
271
|
+
idempotentHint: true,
|
|
272
|
+
openWorldHint: false,
|
|
273
|
+
},
|
|
274
|
+
inputSchema: PackInput.shape,
|
|
275
|
+
}, async (input) => fromToolResult(await runPackCodebase(ctx, input)));
|
|
276
|
+
}
|
|
277
|
+
function extForStyle(style) {
|
|
278
|
+
switch (style) {
|
|
279
|
+
case "xml":
|
|
280
|
+
return "xml";
|
|
281
|
+
case "markdown":
|
|
282
|
+
return "md";
|
|
283
|
+
case "json":
|
|
284
|
+
return "json";
|
|
285
|
+
case "plain":
|
|
286
|
+
return "txt";
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
//# sourceMappingURL=pack-codebase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack-codebase.js","sourceRoot":"","sources":["../../src/tools/pack-codebase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmB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,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `project_profile` — return the ProjectProfile node for a repo.
|
|
3
|
+
*
|
|
4
|
+
* Profile is a singleton per repo, emitted by the ingestion `profile` phase.
|
|
5
|
+
* Each array field is stored in DuckDB as a JSON-encoded TEXT column
|
|
6
|
+
* (`languages_json`, `frameworks_json`, etc.) so we decode every column
|
|
7
|
+
* back into a `string[]` before returning. If the repo was indexed before
|
|
8
|
+
* the profile phase shipped (or the phase failed to write the node), we
|
|
9
|
+
* return empty arrays and a hint nudging the caller toward `codehub
|
|
10
|
+
* analyze --force`.
|
|
11
|
+
*
|
|
12
|
+
* `frameworks_json` is polymorphic across two generations:
|
|
13
|
+
* - v1.0 (legacy) → a flat `string[]` of framework names.
|
|
14
|
+
* - v2.0 (post-P05) → `{ flat: string[], detected: FrameworkDetection[] }`
|
|
15
|
+
* so variant / version / confidence / parent metadata survives the
|
|
16
|
+
* round-trip. Both are read transparently; callers receive both a
|
|
17
|
+
* flat form (backward-compat) and the structured form in the payload.
|
|
18
|
+
*/
|
|
19
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
20
|
+
import { type ToolContext, type ToolResult } from "./shared.js";
|
|
21
|
+
interface ProjectProfileArgs {
|
|
22
|
+
readonly repo?: string | undefined;
|
|
23
|
+
readonly repo_uri?: string | undefined;
|
|
24
|
+
}
|
|
25
|
+
export declare function runProjectProfile(ctx: ToolContext, args: ProjectProfileArgs): Promise<ToolResult>;
|
|
26
|
+
export declare function registerProjectProfileTool(server: McpServer, ctx: ToolContext): void;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=project-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-profile.d.ts","sourceRoot":"","sources":["../../src/tools/project-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,UAAU,EAGhB,MAAM,aAAa,CAAC;AAkBrB,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,UAAU,CAAC,CAoFrB;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,CAiBpF"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `project_profile` — return the ProjectProfile node for a repo.
|
|
3
|
+
*
|
|
4
|
+
* Profile is a singleton per repo, emitted by the ingestion `profile` phase.
|
|
5
|
+
* Each array field is stored in DuckDB as a JSON-encoded TEXT column
|
|
6
|
+
* (`languages_json`, `frameworks_json`, etc.) so we decode every column
|
|
7
|
+
* back into a `string[]` before returning. If the repo was indexed before
|
|
8
|
+
* the profile phase shipped (or the phase failed to write the node), we
|
|
9
|
+
* return empty arrays and a hint nudging the caller toward `codehub
|
|
10
|
+
* analyze --force`.
|
|
11
|
+
*
|
|
12
|
+
* `frameworks_json` is polymorphic across two generations:
|
|
13
|
+
* - v1.0 (legacy) → a flat `string[]` of framework names.
|
|
14
|
+
* - v2.0 (post-P05) → `{ flat: string[], detected: FrameworkDetection[] }`
|
|
15
|
+
* so variant / version / confidence / parent metadata survives the
|
|
16
|
+
* round-trip. Both are read transparently; callers receive both a
|
|
17
|
+
* flat form (backward-compat) and the structured form in the payload.
|
|
18
|
+
*/
|
|
19
|
+
// biome-ignore-all lint/complexity/useLiteralKeys: dot-access disallowed on Record index signatures
|
|
20
|
+
import { toolErrorFromUnknown } from "../error-envelope.js";
|
|
21
|
+
import { withNextSteps } from "../next-step-hints.js";
|
|
22
|
+
import { stalenessFromMeta } from "../staleness.js";
|
|
23
|
+
import { fromToolResult, repoArgShape, toToolResult, withStore, } from "./shared.js";
|
|
24
|
+
const ProjectProfileInput = {
|
|
25
|
+
...repoArgShape,
|
|
26
|
+
};
|
|
27
|
+
export async function runProjectProfile(ctx, args) {
|
|
28
|
+
const call = await withStore(ctx, args, async (store, resolved) => {
|
|
29
|
+
try {
|
|
30
|
+
const nodes = await store.graph.listNodesByKind("ProjectProfile", { limit: 1 });
|
|
31
|
+
const profile = nodes[0];
|
|
32
|
+
const payload = {
|
|
33
|
+
languages: profile?.languages ? [...profile.languages] : [],
|
|
34
|
+
frameworks: profile?.frameworks ? [...profile.frameworks] : [],
|
|
35
|
+
frameworksDetected: profile?.frameworksDetected ? [...profile.frameworksDetected] : [],
|
|
36
|
+
iacTypes: profile?.iacTypes ? [...profile.iacTypes] : [],
|
|
37
|
+
apiContracts: profile?.apiContracts ? [...profile.apiContracts] : [],
|
|
38
|
+
manifests: profile?.manifests ? [...profile.manifests] : [],
|
|
39
|
+
srcDirs: profile?.srcDirs ? [...profile.srcDirs] : [],
|
|
40
|
+
};
|
|
41
|
+
const profileExists = profile !== undefined;
|
|
42
|
+
const header = profileExists
|
|
43
|
+
? `Project profile for ${resolved.name}:`
|
|
44
|
+
: `No ProjectProfile node in ${resolved.name}. Re-index with \`codehub analyze --force\` to populate.`;
|
|
45
|
+
const lines = [header];
|
|
46
|
+
if (payload.languages.length > 0) {
|
|
47
|
+
lines.push(` languages (${payload.languages.length}): ${payload.languages.join(", ")}`);
|
|
48
|
+
}
|
|
49
|
+
if (payload.frameworks.length > 0) {
|
|
50
|
+
// Prefer the structured form for display when available — render
|
|
51
|
+
// each framework with its variant so operators see "nextjs:app-router"
|
|
52
|
+
// rather than a bare "nextjs". Fall back to flat names.
|
|
53
|
+
const display = payload.frameworksDetected.length > 0
|
|
54
|
+
? payload.frameworksDetected.map((d) => (d.variant ? `${d.name}:${d.variant}` : d.name))
|
|
55
|
+
: payload.frameworks;
|
|
56
|
+
lines.push(` frameworks (${display.length}): ${display.join(", ")}`);
|
|
57
|
+
}
|
|
58
|
+
if (payload.iacTypes.length > 0) {
|
|
59
|
+
lines.push(` iacTypes (${payload.iacTypes.length}): ${payload.iacTypes.join(", ")}`);
|
|
60
|
+
}
|
|
61
|
+
if (payload.apiContracts.length > 0) {
|
|
62
|
+
lines.push(` apiContracts (${payload.apiContracts.length}): ${payload.apiContracts.join(", ")}`);
|
|
63
|
+
}
|
|
64
|
+
if (payload.manifests.length > 0) {
|
|
65
|
+
lines.push(` manifests (${payload.manifests.length}): ${payload.manifests.join(", ")}`);
|
|
66
|
+
}
|
|
67
|
+
if (payload.srcDirs.length > 0) {
|
|
68
|
+
lines.push(` srcDirs (${payload.srcDirs.length}): ${payload.srcDirs.join(", ")}`);
|
|
69
|
+
}
|
|
70
|
+
const next = [];
|
|
71
|
+
if (!profileExists) {
|
|
72
|
+
next.push("run `codehub analyze --force` to emit the ProjectProfile node");
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
if (payload.frameworks.length > 0) {
|
|
76
|
+
next.push(`call \`query\` with the framework name (e.g. "${payload.frameworks[0] ?? ""}") to find entry points`);
|
|
77
|
+
}
|
|
78
|
+
if (payload.apiContracts.includes("openapi")) {
|
|
79
|
+
next.push("call `query` with kinds=['Operation'] to list OpenAPI operations");
|
|
80
|
+
}
|
|
81
|
+
if (payload.iacTypes.includes("terraform")) {
|
|
82
|
+
next.push("call `list_findings` (once scanners are wired) for tfsec/checkov results");
|
|
83
|
+
}
|
|
84
|
+
if (next.length === 0) {
|
|
85
|
+
next.push("call `list_repos` to pick a different repo");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return withNextSteps(lines.join("\n"), { profile: payload }, next, stalenessFromMeta(resolved.meta));
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
return toolErrorFromUnknown(err);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return toToolResult(call);
|
|
95
|
+
}
|
|
96
|
+
export function registerProjectProfileTool(server, ctx) {
|
|
97
|
+
server.registerTool("project_profile", {
|
|
98
|
+
title: "Project Profile",
|
|
99
|
+
description: "Returns the detected project profile: languages, frameworks (flat + structured), IaC types, API contracts, manifests, source directories.",
|
|
100
|
+
inputSchema: ProjectProfileInput,
|
|
101
|
+
annotations: {
|
|
102
|
+
readOnlyHint: true,
|
|
103
|
+
destructiveHint: false,
|
|
104
|
+
openWorldHint: false,
|
|
105
|
+
idempotentHint: true,
|
|
106
|
+
},
|
|
107
|
+
}, async (args) => fromToolResult(await runProjectProfile(ctx, args)));
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=project-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-profile.js","sourceRoot":"","sources":["../../src/tools/project-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,oGAAoG;AAIpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EACL,cAAc,EACd,YAAY,EAGZ,YAAY,EACZ,SAAS,GACV,MAAM,aAAa,CAAC;AAErB,MAAM,mBAAmB,GAAG;IAC1B,GAAG,YAAY;CAChB,CAAC;AAmBF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAgB,EAChB,IAAwB;IAExB,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;QAChE,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CA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B,IAAI,EACJ,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,CACjC,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,MAAiB,EAAE,GAAgB;IAC5E,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,iBAAiB;QACxB,WAAW,EACT,2IAA2I;QAC7I,WAAW,EAAE,mBAAmB;QAChC,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,IAAI;SACrB;KACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,iBAAiB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CACnE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `query` — true hybrid retrieval over the indexed graph.
|
|
3
|
+
*
|
|
4
|
+
* Two ranked runs, fused with Reciprocal Rank Fusion (k=60):
|
|
5
|
+
* 1. BM25 (DuckDB FTS) over `nodes.name` + `nodes.signature` +
|
|
6
|
+
* `nodes.description`. If a `symbol_summaries` table is present the
|
|
7
|
+
* corpus extends transparently (see {@link bm25CorpusHasSummaries}) so
|
|
8
|
+
* summarized prose participates as soon as the ingestion phase lands.
|
|
9
|
+
* 2. HNSW vector search over the `embeddings` table. The query text is
|
|
10
|
+
* embedded with the same gte-modernbert-base ONNX model the ingestion
|
|
11
|
+
* pipeline uses, so the vectors live in the same space.
|
|
12
|
+
*
|
|
13
|
+
* Graceful fallback:
|
|
14
|
+
* - If the `embeddings` table is empty, skip the vector leg entirely.
|
|
15
|
+
* - If the embedder weights are missing (EMBEDDER_NOT_SETUP) or any other
|
|
16
|
+
* failure blocks the embedder from opening, warn once to stderr and fall
|
|
17
|
+
* back to BM25-only. We never abort the query — the invariant is that a
|
|
18
|
+
* fresh-cloned repo still answers `query` before `codehub setup
|
|
19
|
+
* --embeddings` has been run.
|
|
20
|
+
*
|
|
21
|
+
* The response shape is stable across BM25-only and hybrid paths:
|
|
22
|
+
* `{ results, definitions, processes, process_symbols, mode }`.
|
|
23
|
+
* `results` is the primary ranked list; `definitions` mirrors it one-to-one
|
|
24
|
+
* (preserved for agents that learned the legacy shape). `processes` +
|
|
25
|
+
* `process_symbols` hold the process-grouped view: after fusion we walk
|
|
26
|
+
* PROCESS_STEP edges backwards from each top-K hit to locate the containing
|
|
27
|
+
* Process nodes, then walk PROCESS_STEP edges forward from each matched
|
|
28
|
+
* Process's entry point to enumerate its ordered member steps. Both walks
|
|
29
|
+
* happen in ONE consolidated SQL query (two CTEs + a join) so the enrichment
|
|
30
|
+
* pass is a single round-trip. When no Process touches a top-K hit, or the
|
|
31
|
+
* repo has no PROCESS_STEP edges yet, the arrays stay empty — the flat
|
|
32
|
+
* `results` ranking still covers the query.
|
|
33
|
+
*/
|
|
34
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
35
|
+
import { type ToolContext, type ToolResult } from "./shared.js";
|
|
36
|
+
interface QueryArgs {
|
|
37
|
+
readonly query: string;
|
|
38
|
+
readonly repo?: string;
|
|
39
|
+
readonly repo_uri?: string;
|
|
40
|
+
readonly limit?: number;
|
|
41
|
+
readonly kinds?: readonly string[];
|
|
42
|
+
readonly task_context?: string;
|
|
43
|
+
readonly goal?: string;
|
|
44
|
+
readonly include_content?: boolean;
|
|
45
|
+
readonly max_symbols?: number;
|
|
46
|
+
/** Hierarchical tier filter (P03). Defaults to "symbol". */
|
|
47
|
+
readonly granularity?: "symbol" | "file" | "community";
|
|
48
|
+
/** "flat" (default) or "zoom" coarse-to-fine retrieval. */
|
|
49
|
+
readonly mode?: "flat" | "zoom";
|
|
50
|
+
/** Coarse file-tier fanout when mode=zoom. */
|
|
51
|
+
readonly zoom_fanout?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Bypass the embedder fingerprint refusal. When `true`, the query
|
|
54
|
+
* proceeds against an `embeddings` table populated by a different
|
|
55
|
+
* embedder than the one currently active. Vectors may be stale;
|
|
56
|
+
* results may misrank. Default `false`.
|
|
57
|
+
*/
|
|
58
|
+
readonly force_backend_mismatch?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export declare function runQuery(ctx: ToolContext, args: QueryArgs): Promise<ToolResult>;
|
|
61
|
+
export declare function registerQueryTool(server: McpServer, ctx: ToolContext): void;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/tools/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAoBzE,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,UAAU,EAGhB,MAAM,aAAa,CAAC;AAkhBrB,UAAU,SAAS;IACjB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,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