@mycompbox/compbox-mcp 1.21.19 → 1.21.20
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/index.js +618 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4847,6 +4847,545 @@ var init_belts = __esm({
|
|
|
4847
4847
|
}
|
|
4848
4848
|
});
|
|
4849
4849
|
|
|
4850
|
+
// ../shared/dist/brief-files.js
|
|
4851
|
+
function normalizeBriefPath(path4) {
|
|
4852
|
+
if (typeof path4 !== "string" || path4.length === 0)
|
|
4853
|
+
return null;
|
|
4854
|
+
if (path4.startsWith("/") || path4.includes("\\"))
|
|
4855
|
+
return null;
|
|
4856
|
+
if (/^[A-Za-z]:/.test(path4))
|
|
4857
|
+
return null;
|
|
4858
|
+
for (let i = 0; i < path4.length; i++) {
|
|
4859
|
+
const code = path4.charCodeAt(i);
|
|
4860
|
+
if (code < 32 || code === 127)
|
|
4861
|
+
return null;
|
|
4862
|
+
}
|
|
4863
|
+
const out = [];
|
|
4864
|
+
for (const segment of path4.split("/")) {
|
|
4865
|
+
if (segment === "" || segment === ".")
|
|
4866
|
+
continue;
|
|
4867
|
+
if (segment === "..") {
|
|
4868
|
+
if (out.length === 0)
|
|
4869
|
+
return null;
|
|
4870
|
+
out.pop();
|
|
4871
|
+
continue;
|
|
4872
|
+
}
|
|
4873
|
+
out.push(segment);
|
|
4874
|
+
}
|
|
4875
|
+
return out.length === 0 ? null : out.join("/");
|
|
4876
|
+
}
|
|
4877
|
+
function isBriefPath(path4) {
|
|
4878
|
+
const normalized = normalizeBriefPath(path4);
|
|
4879
|
+
if (normalized === null)
|
|
4880
|
+
return false;
|
|
4881
|
+
const prefix = `${BRIEF_DIR}/`;
|
|
4882
|
+
return normalized.startsWith(prefix) && normalized.length > prefix.length;
|
|
4883
|
+
}
|
|
4884
|
+
function normalizeNewlines(text) {
|
|
4885
|
+
return text.replace(/\r\n?/g, "\n");
|
|
4886
|
+
}
|
|
4887
|
+
function textFile(text) {
|
|
4888
|
+
return `${normalizeNewlines(text)}
|
|
4889
|
+
`;
|
|
4890
|
+
}
|
|
4891
|
+
function slugifyDiagramKey(key) {
|
|
4892
|
+
const slug2 = key.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, BRIEF_DIAGRAM_KEY_MAX_LENGTH).replace(/-+$/g, "");
|
|
4893
|
+
return slug2.length > 0 ? slug2 : "diagram";
|
|
4894
|
+
}
|
|
4895
|
+
function bullet(item) {
|
|
4896
|
+
const [first = "", ...rest] = normalizeNewlines(item).split("\n");
|
|
4897
|
+
return [`- ${first}`, ...rest.map((line) => ` ${line}`)].join("\n");
|
|
4898
|
+
}
|
|
4899
|
+
function serializeRules(always, never) {
|
|
4900
|
+
const block = (heading, items) => items.length > 0 ? `${heading}
|
|
4901
|
+
|
|
4902
|
+
${items.map(bullet).join("\n")}
|
|
4903
|
+
` : `${heading}
|
|
4904
|
+
`;
|
|
4905
|
+
return `# Rules
|
|
4906
|
+
|
|
4907
|
+
${block(RULES_ALWAYS_HEADING, always)}
|
|
4908
|
+
${block(RULES_NEVER_HEADING, never)}`;
|
|
4909
|
+
}
|
|
4910
|
+
function escapeBriefTableCell(value) {
|
|
4911
|
+
return normalizeNewlines(value).trim().replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\n/g, "\\n");
|
|
4912
|
+
}
|
|
4913
|
+
function serializePathMap(entries) {
|
|
4914
|
+
const rows = entries.map((e) => `| ${escapeBriefTableCell(e.path)} | ${escapeBriefTableCell(e.owner)} | ${escapeBriefTableCell(e.note ?? "")} |`);
|
|
4915
|
+
return `# Path map
|
|
4916
|
+
|
|
4917
|
+
${PATH_MAP_HEADER}
|
|
4918
|
+
${PATH_MAP_SEPARATOR}
|
|
4919
|
+
${rows.map((r) => `${r}
|
|
4920
|
+
`).join("")}`;
|
|
4921
|
+
}
|
|
4922
|
+
function longestBacktickRun(text) {
|
|
4923
|
+
let longest = 0;
|
|
4924
|
+
for (const match of text.matchAll(/`+/g))
|
|
4925
|
+
longest = Math.max(longest, match[0].length);
|
|
4926
|
+
return longest;
|
|
4927
|
+
}
|
|
4928
|
+
function serializeDiagram(title, mermaid) {
|
|
4929
|
+
const body = normalizeNewlines(mermaid);
|
|
4930
|
+
const fence = "`".repeat(Math.max(3, longestBacktickRun(body) + 1));
|
|
4931
|
+
const oneLineTitle = normalizeNewlines(title).replace(/\n/g, " ");
|
|
4932
|
+
return `# ${oneLineTitle}
|
|
4933
|
+
|
|
4934
|
+
${fence}mermaid
|
|
4935
|
+
${body}
|
|
4936
|
+
${fence}
|
|
4937
|
+
`;
|
|
4938
|
+
}
|
|
4939
|
+
function serializeBrief(summary, sections) {
|
|
4940
|
+
const files = {};
|
|
4941
|
+
files[BRIEF_FILES.summary] = textFile(summary);
|
|
4942
|
+
const textSections = ["architecture", "productDesign", "businessPlan"];
|
|
4943
|
+
for (const key of textSections) {
|
|
4944
|
+
const value = sections[key];
|
|
4945
|
+
if (value !== void 0 && value.length > 0)
|
|
4946
|
+
files[BRIEF_FILES[key]] = textFile(value);
|
|
4947
|
+
}
|
|
4948
|
+
const always = sections.rules?.always ?? [];
|
|
4949
|
+
const never = sections.rules?.never ?? [];
|
|
4950
|
+
if (always.length > 0 || never.length > 0)
|
|
4951
|
+
files[BRIEF_FILES.rules] = serializeRules(always, never);
|
|
4952
|
+
if (sections.pathMap !== void 0 && sections.pathMap.length > 0) {
|
|
4953
|
+
files[BRIEF_FILES.pathMap] = serializePathMap(sections.pathMap);
|
|
4954
|
+
}
|
|
4955
|
+
const usedKeys = /* @__PURE__ */ new Set();
|
|
4956
|
+
for (const diagram of sections.diagrams ?? []) {
|
|
4957
|
+
const base = slugifyDiagramKey(diagram.key);
|
|
4958
|
+
let key = base;
|
|
4959
|
+
for (let n = 2; usedKeys.has(key); n++) {
|
|
4960
|
+
const suffix = `-${String(n)}`;
|
|
4961
|
+
key = `${base.slice(0, BRIEF_DIAGRAM_KEY_MAX_LENGTH - suffix.length).replace(/-+$/g, "")}${suffix}`;
|
|
4962
|
+
}
|
|
4963
|
+
usedKeys.add(key);
|
|
4964
|
+
files[`${BRIEF_DIAGRAMS_DIR}/${key}.md`] = serializeDiagram(diagram.title, diagram.mermaid);
|
|
4965
|
+
}
|
|
4966
|
+
const sorted = {};
|
|
4967
|
+
for (const path4 of Object.keys(files).sort())
|
|
4968
|
+
sorted[path4] = files[path4] ?? "";
|
|
4969
|
+
return sorted;
|
|
4970
|
+
}
|
|
4971
|
+
function textBody(content) {
|
|
4972
|
+
return content.endsWith("\n") ? content.slice(0, -1) : content;
|
|
4973
|
+
}
|
|
4974
|
+
function splitLines(content) {
|
|
4975
|
+
const lines = content.split("\n");
|
|
4976
|
+
if (lines.length > 0 && lines[lines.length - 1] === "")
|
|
4977
|
+
lines.pop();
|
|
4978
|
+
return lines;
|
|
4979
|
+
}
|
|
4980
|
+
function parseRules(file, content, issue) {
|
|
4981
|
+
const result2 = { always: [], never: [] };
|
|
4982
|
+
let list = null;
|
|
4983
|
+
let current = null;
|
|
4984
|
+
const flush = () => {
|
|
4985
|
+
if (current !== null && list !== null)
|
|
4986
|
+
list.push(current.lines.join("\n"));
|
|
4987
|
+
current = null;
|
|
4988
|
+
};
|
|
4989
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4990
|
+
const lines = splitLines(content);
|
|
4991
|
+
lines.forEach((line, i) => {
|
|
4992
|
+
const lineNo = i + 1;
|
|
4993
|
+
if (RULES_TITLE.test(line) && list === null)
|
|
4994
|
+
return;
|
|
4995
|
+
const heading = RULES_ALWAYS.test(line) ? "always" : RULES_NEVER.test(line) ? "never" : null;
|
|
4996
|
+
if (heading !== null) {
|
|
4997
|
+
flush();
|
|
4998
|
+
if (seen.has(heading))
|
|
4999
|
+
issue(lineNo, `Duplicate "## ${heading === "always" ? "Always" : "Never"}" heading`);
|
|
5000
|
+
seen.add(heading);
|
|
5001
|
+
list = result2[heading];
|
|
5002
|
+
return;
|
|
5003
|
+
}
|
|
5004
|
+
if (line.startsWith("#")) {
|
|
5005
|
+
flush();
|
|
5006
|
+
list = null;
|
|
5007
|
+
issue(lineNo, `Unexpected heading "${line}"; ${file} only allows "## Always" and "## Never"`);
|
|
5008
|
+
return;
|
|
5009
|
+
}
|
|
5010
|
+
if (line.startsWith(" ") && current !== null) {
|
|
5011
|
+
current.lines.push(line.slice(2));
|
|
5012
|
+
return;
|
|
5013
|
+
}
|
|
5014
|
+
if (line.trim() === "") {
|
|
5015
|
+
flush();
|
|
5016
|
+
return;
|
|
5017
|
+
}
|
|
5018
|
+
if (line === "-" || line.startsWith("- ")) {
|
|
5019
|
+
flush();
|
|
5020
|
+
if (list === null) {
|
|
5021
|
+
issue(lineNo, 'Bullet is not under a "## Always" or "## Never" heading');
|
|
5022
|
+
return;
|
|
5023
|
+
}
|
|
5024
|
+
current = { lines: [line.slice(2)] };
|
|
5025
|
+
return;
|
|
5026
|
+
}
|
|
5027
|
+
issue(lineNo, 'Expected a "- " bullet');
|
|
5028
|
+
});
|
|
5029
|
+
flush();
|
|
5030
|
+
return result2;
|
|
5031
|
+
}
|
|
5032
|
+
function parseTableRow(line) {
|
|
5033
|
+
const trimmed = line.trim();
|
|
5034
|
+
if (!trimmed.startsWith("|") || !trimmed.endsWith("|") || trimmed.length < 2)
|
|
5035
|
+
return null;
|
|
5036
|
+
const cells = [];
|
|
5037
|
+
let cell = "";
|
|
5038
|
+
for (let i = 1; i < trimmed.length; i++) {
|
|
5039
|
+
const ch = trimmed.charAt(i);
|
|
5040
|
+
if (ch === "\\" && i + 1 < trimmed.length) {
|
|
5041
|
+
const next = trimmed.charAt(i + 1);
|
|
5042
|
+
if (next === "\\" || next === "|") {
|
|
5043
|
+
cell += next;
|
|
5044
|
+
i++;
|
|
5045
|
+
continue;
|
|
5046
|
+
}
|
|
5047
|
+
if (next === "n") {
|
|
5048
|
+
cell += "\n";
|
|
5049
|
+
i++;
|
|
5050
|
+
continue;
|
|
5051
|
+
}
|
|
5052
|
+
cell += ch;
|
|
5053
|
+
continue;
|
|
5054
|
+
}
|
|
5055
|
+
if (ch === "|") {
|
|
5056
|
+
cells.push(cell.trim());
|
|
5057
|
+
cell = "";
|
|
5058
|
+
continue;
|
|
5059
|
+
}
|
|
5060
|
+
cell += ch;
|
|
5061
|
+
}
|
|
5062
|
+
if (cell.trim() !== "")
|
|
5063
|
+
return null;
|
|
5064
|
+
return cells;
|
|
5065
|
+
}
|
|
5066
|
+
function parsePathMap(content, issue) {
|
|
5067
|
+
const entries = [];
|
|
5068
|
+
const entryLines = [];
|
|
5069
|
+
let state = "before";
|
|
5070
|
+
const lines = splitLines(content);
|
|
5071
|
+
for (let i = 0; i < lines.length; i++) {
|
|
5072
|
+
const lineNo = i + 1;
|
|
5073
|
+
const trimmed = (lines[i] ?? "").trim();
|
|
5074
|
+
if (state === "before") {
|
|
5075
|
+
if (trimmed === "" || /^#\s/.test(trimmed))
|
|
5076
|
+
continue;
|
|
5077
|
+
const cells2 = parseTableRow(trimmed);
|
|
5078
|
+
if (cells2?.[0]?.toLowerCase() === "path" && cells2[1]?.toLowerCase() === "owner") {
|
|
5079
|
+
state = "header";
|
|
5080
|
+
continue;
|
|
5081
|
+
}
|
|
5082
|
+
issue(lineNo, `Expected the table header "${PATH_MAP_HEADER}"`);
|
|
5083
|
+
continue;
|
|
5084
|
+
}
|
|
5085
|
+
if (state === "header") {
|
|
5086
|
+
state = "rows";
|
|
5087
|
+
if (TABLE_SEPARATOR.test(trimmed))
|
|
5088
|
+
continue;
|
|
5089
|
+
issue(lineNo, `Expected the table separator "${PATH_MAP_SEPARATOR}"`);
|
|
5090
|
+
}
|
|
5091
|
+
if (trimmed === "")
|
|
5092
|
+
continue;
|
|
5093
|
+
const cells = parseTableRow(trimmed);
|
|
5094
|
+
if (cells === null) {
|
|
5095
|
+
issue(lineNo, "Expected a table row like `| path | owner | note |`");
|
|
5096
|
+
continue;
|
|
5097
|
+
}
|
|
5098
|
+
if (cells.length < 2 || cells.length > 3) {
|
|
5099
|
+
issue(lineNo, `Expected 2 or 3 cells, found ${String(cells.length)}`);
|
|
5100
|
+
continue;
|
|
5101
|
+
}
|
|
5102
|
+
const [path4 = "", owner = "", note = ""] = cells;
|
|
5103
|
+
entries.push(note === "" ? { path: path4, owner } : { path: path4, owner, note });
|
|
5104
|
+
entryLines.push(lineNo);
|
|
5105
|
+
}
|
|
5106
|
+
if (state === "before")
|
|
5107
|
+
issue(void 0, `Missing the table header "${PATH_MAP_HEADER}"`);
|
|
5108
|
+
return { entries, lines: entryLines };
|
|
5109
|
+
}
|
|
5110
|
+
function parseDiagram(content, issue) {
|
|
5111
|
+
const lines = splitLines(content);
|
|
5112
|
+
let i = 0;
|
|
5113
|
+
while (i < lines.length && (lines[i] ?? "").trim() === "")
|
|
5114
|
+
i++;
|
|
5115
|
+
const titleMatch = /^#\s+(.*)$/.exec(lines[i] ?? "");
|
|
5116
|
+
if (titleMatch === null) {
|
|
5117
|
+
issue(i < lines.length ? i + 1 : void 0, 'Expected a "# Title" line');
|
|
5118
|
+
return null;
|
|
5119
|
+
}
|
|
5120
|
+
const title = titleMatch[1] ?? "";
|
|
5121
|
+
i++;
|
|
5122
|
+
while (i < lines.length && (lines[i] ?? "").trim() === "")
|
|
5123
|
+
i++;
|
|
5124
|
+
const open = /^(`{3,})\s*mermaid\s*$/.exec(lines[i] ?? "");
|
|
5125
|
+
if (open === null) {
|
|
5126
|
+
issue(i < lines.length ? i + 1 : void 0, "Expected a ```mermaid fenced block");
|
|
5127
|
+
return null;
|
|
5128
|
+
}
|
|
5129
|
+
const fenceLength = (open[1] ?? "").length;
|
|
5130
|
+
const openLine = i + 1;
|
|
5131
|
+
const closing = new RegExp(`^\`{${String(fenceLength)},}\\s*$`);
|
|
5132
|
+
const body = [];
|
|
5133
|
+
i++;
|
|
5134
|
+
while (i < lines.length && !closing.test(lines[i] ?? "")) {
|
|
5135
|
+
body.push(lines[i] ?? "");
|
|
5136
|
+
i++;
|
|
5137
|
+
}
|
|
5138
|
+
if (i >= lines.length) {
|
|
5139
|
+
issue(openLine, "The mermaid fenced block is never closed");
|
|
5140
|
+
return null;
|
|
5141
|
+
}
|
|
5142
|
+
for (i++; i < lines.length; i++) {
|
|
5143
|
+
if ((lines[i] ?? "").trim() !== "") {
|
|
5144
|
+
issue(i + 1, "Unexpected content after the mermaid block (ignored)");
|
|
5145
|
+
break;
|
|
5146
|
+
}
|
|
5147
|
+
}
|
|
5148
|
+
return { title, mermaid: body.join("\n") };
|
|
5149
|
+
}
|
|
5150
|
+
function parseBrief(files) {
|
|
5151
|
+
const issues = [];
|
|
5152
|
+
const sections = {};
|
|
5153
|
+
let summary = "";
|
|
5154
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
5155
|
+
for (const [rawPath, rawContent] of Object.entries(files)) {
|
|
5156
|
+
const path4 = normalizeBriefPath(rawPath);
|
|
5157
|
+
if (path4 === null || !isBriefPath(path4)) {
|
|
5158
|
+
issues.push({
|
|
5159
|
+
file: rawPath,
|
|
5160
|
+
severity: "warning",
|
|
5161
|
+
message: `Not a path inside ${BRIEF_DIR}/; ignored`
|
|
5162
|
+
});
|
|
5163
|
+
continue;
|
|
5164
|
+
}
|
|
5165
|
+
if (byPath.has(path4)) {
|
|
5166
|
+
issues.push({ file: rawPath, severity: "error", message: `Duplicate of ${path4}; ignored` });
|
|
5167
|
+
continue;
|
|
5168
|
+
}
|
|
5169
|
+
byPath.set(path4, typeof rawContent === "string" ? normalizeNewlines(rawContent) : "");
|
|
5170
|
+
}
|
|
5171
|
+
const fileToKey = new Map(Object.entries(BRIEF_FILES).map(([key, path4]) => [path4, key]));
|
|
5172
|
+
const diagramPaths = [];
|
|
5173
|
+
for (const [path4, content] of byPath) {
|
|
5174
|
+
const issue = (line, message, severity = "error") => {
|
|
5175
|
+
issues.push(line === void 0 ? { file: path4, severity, message } : { file: path4, line, severity, message });
|
|
5176
|
+
};
|
|
5177
|
+
const key = fileToKey.get(path4);
|
|
5178
|
+
if (key === "summary") {
|
|
5179
|
+
summary = textBody(content);
|
|
5180
|
+
} else if (key === "architecture" || key === "productDesign" || key === "businessPlan") {
|
|
5181
|
+
sections[key] = textBody(content);
|
|
5182
|
+
} else if (key === "rules") {
|
|
5183
|
+
sections.rules = parseRules(path4, content, issue);
|
|
5184
|
+
} else if (key === "pathMap") {
|
|
5185
|
+
sections.pathMap = parsePathMap(content, issue).entries;
|
|
5186
|
+
} else if (path4.startsWith(`${BRIEF_DIAGRAMS_DIR}/`)) {
|
|
5187
|
+
diagramPaths.push(path4);
|
|
5188
|
+
} else {
|
|
5189
|
+
issue(void 0, "Unknown file in the brief folder; ignored", "warning");
|
|
5190
|
+
}
|
|
5191
|
+
}
|
|
5192
|
+
if (!byPath.has(BRIEF_FILES.summary)) {
|
|
5193
|
+
issues.push({
|
|
5194
|
+
file: BRIEF_FILES.summary,
|
|
5195
|
+
severity: "warning",
|
|
5196
|
+
message: "Missing; the summary is empty"
|
|
5197
|
+
});
|
|
5198
|
+
}
|
|
5199
|
+
if (diagramPaths.length > 0) {
|
|
5200
|
+
const diagrams = [];
|
|
5201
|
+
for (const path4 of diagramPaths.sort()) {
|
|
5202
|
+
const issue = (line, message) => {
|
|
5203
|
+
issues.push(line === void 0 ? { file: path4, severity: "error", message } : { file: path4, line, severity: "error", message });
|
|
5204
|
+
};
|
|
5205
|
+
const name = path4.slice(BRIEF_DIAGRAMS_DIR.length + 1);
|
|
5206
|
+
if (name.includes("/") || !name.endsWith(".md")) {
|
|
5207
|
+
issues.push({
|
|
5208
|
+
file: path4,
|
|
5209
|
+
severity: "warning",
|
|
5210
|
+
message: "Diagrams must be <key>.md files directly in diagrams/; ignored"
|
|
5211
|
+
});
|
|
5212
|
+
continue;
|
|
5213
|
+
}
|
|
5214
|
+
const key = name.slice(0, -".md".length);
|
|
5215
|
+
if (!BRIEF_DIAGRAM_KEY_PATTERN.test(key) || key.length > BRIEF_LIMITS.diagrams.keyMaxLength) {
|
|
5216
|
+
issue(void 0, `Diagram key "${key}" must match [a-z0-9-] (at most ${String(BRIEF_LIMITS.diagrams.keyMaxLength)} characters)`);
|
|
5217
|
+
continue;
|
|
5218
|
+
}
|
|
5219
|
+
const parsed = parseDiagram(byPath.get(path4) ?? "", issue);
|
|
5220
|
+
if (parsed !== null)
|
|
5221
|
+
diagrams.push({ key, ...parsed });
|
|
5222
|
+
}
|
|
5223
|
+
sections.diagrams = diagrams;
|
|
5224
|
+
}
|
|
5225
|
+
checkLimits(summary, sections, issues, byPath);
|
|
5226
|
+
return { summary, sections, issues };
|
|
5227
|
+
}
|
|
5228
|
+
function checkLimits(summary, sections, issues, byPath) {
|
|
5229
|
+
const err2 = (file, message) => {
|
|
5230
|
+
issues.push({ file, severity: "error", message });
|
|
5231
|
+
};
|
|
5232
|
+
const n = (value) => String(value);
|
|
5233
|
+
if (summary.length > BRIEF_LIMITS.summary) {
|
|
5234
|
+
err2(BRIEF_FILES.summary, `Summary is ${n(summary.length)} characters; the limit is ${n(BRIEF_LIMITS.summary)}`);
|
|
5235
|
+
}
|
|
5236
|
+
for (const key of ["architecture", "productDesign", "businessPlan"]) {
|
|
5237
|
+
const value = sections[key];
|
|
5238
|
+
if (value !== void 0 && value.length > BRIEF_LIMITS.text) {
|
|
5239
|
+
err2(BRIEF_FILES[key], `Text is ${n(value.length)} characters; the limit is ${n(BRIEF_LIMITS.text)}`);
|
|
5240
|
+
}
|
|
5241
|
+
}
|
|
5242
|
+
if (sections.rules !== void 0) {
|
|
5243
|
+
for (const list of ["always", "never"]) {
|
|
5244
|
+
const items = sections.rules[list] ?? [];
|
|
5245
|
+
const label = list === "always" ? "Always" : "Never";
|
|
5246
|
+
if (items.length > BRIEF_LIMITS.rules.maxItems) {
|
|
5247
|
+
err2(BRIEF_FILES.rules, `"${label}" has ${n(items.length)} rules; the limit is ${n(BRIEF_LIMITS.rules.maxItems)}`);
|
|
5248
|
+
}
|
|
5249
|
+
items.forEach((item, i) => {
|
|
5250
|
+
if (item.length === 0)
|
|
5251
|
+
err2(BRIEF_FILES.rules, `"${label}" rule ${n(i + 1)} is empty`);
|
|
5252
|
+
if (item.length > BRIEF_LIMITS.rules.itemMaxLength) {
|
|
5253
|
+
err2(BRIEF_FILES.rules, `"${label}" rule ${n(i + 1)} is longer than ${n(BRIEF_LIMITS.rules.itemMaxLength)} characters`);
|
|
5254
|
+
}
|
|
5255
|
+
});
|
|
5256
|
+
}
|
|
5257
|
+
}
|
|
5258
|
+
if (sections.pathMap !== void 0) {
|
|
5259
|
+
const limits = BRIEF_LIMITS.pathMap;
|
|
5260
|
+
const { lines } = parsePathMap(byPath.get(BRIEF_FILES.pathMap) ?? "", () => void 0);
|
|
5261
|
+
const rowIssue = (i, message) => {
|
|
5262
|
+
const line = lines[i];
|
|
5263
|
+
issues.push(line === void 0 ? { file: BRIEF_FILES.pathMap, severity: "error", message } : { file: BRIEF_FILES.pathMap, line, severity: "error", message });
|
|
5264
|
+
};
|
|
5265
|
+
if (sections.pathMap.length > limits.maxEntries) {
|
|
5266
|
+
err2(BRIEF_FILES.pathMap, `${n(sections.pathMap.length)} entries; the limit is ${n(limits.maxEntries)}`);
|
|
5267
|
+
}
|
|
5268
|
+
sections.pathMap.forEach((entry, i) => {
|
|
5269
|
+
if (entry.path.length === 0)
|
|
5270
|
+
rowIssue(i, "Path is empty");
|
|
5271
|
+
if (entry.path.length > limits.pathMaxLength)
|
|
5272
|
+
rowIssue(i, `Path is longer than ${n(limits.pathMaxLength)} characters`);
|
|
5273
|
+
if (entry.owner.length === 0)
|
|
5274
|
+
rowIssue(i, "Owner is empty");
|
|
5275
|
+
if (entry.owner.length > limits.ownerMaxLength)
|
|
5276
|
+
rowIssue(i, `Owner is longer than ${n(limits.ownerMaxLength)} characters`);
|
|
5277
|
+
if ((entry.note ?? "").length > limits.noteMaxLength)
|
|
5278
|
+
rowIssue(i, `Note is longer than ${n(limits.noteMaxLength)} characters`);
|
|
5279
|
+
});
|
|
5280
|
+
}
|
|
5281
|
+
if (sections.diagrams !== void 0) {
|
|
5282
|
+
const limits = BRIEF_LIMITS.diagrams;
|
|
5283
|
+
if (sections.diagrams.length > limits.maxDiagrams) {
|
|
5284
|
+
err2(BRIEF_DIAGRAMS_DIR, `${n(sections.diagrams.length)} diagrams; the limit is ${n(limits.maxDiagrams)}`);
|
|
5285
|
+
}
|
|
5286
|
+
for (const d of sections.diagrams) {
|
|
5287
|
+
const file = `${BRIEF_DIAGRAMS_DIR}/${d.key}.md`;
|
|
5288
|
+
if (d.title.length === 0)
|
|
5289
|
+
err2(file, "Title is empty");
|
|
5290
|
+
if (d.title.length > limits.titleMaxLength)
|
|
5291
|
+
err2(file, `Title is longer than ${n(limits.titleMaxLength)} characters`);
|
|
5292
|
+
if (d.mermaid.length === 0)
|
|
5293
|
+
err2(file, "Mermaid block is empty");
|
|
5294
|
+
if (d.mermaid.length > limits.mermaidMaxLength) {
|
|
5295
|
+
err2(file, `Mermaid block is longer than ${n(limits.mermaidMaxLength)} characters`);
|
|
5296
|
+
}
|
|
5297
|
+
}
|
|
5298
|
+
}
|
|
5299
|
+
}
|
|
5300
|
+
var BRIEF_DIR, BRIEF_FILES, BRIEF_DIAGRAMS_DIR, BRIEF_DIAGRAM_KEY_MAX_LENGTH, BRIEF_DIAGRAM_KEY_PATTERN, RULES_ALWAYS_HEADING, RULES_NEVER_HEADING, PATH_MAP_HEADER, PATH_MAP_SEPARATOR, BRIEF_LIMITS, RULES_TITLE, RULES_ALWAYS, RULES_NEVER, TABLE_SEPARATOR;
|
|
5301
|
+
var init_brief_files = __esm({
|
|
5302
|
+
"../shared/dist/brief-files.js"() {
|
|
5303
|
+
"use strict";
|
|
5304
|
+
BRIEF_DIR = ".compbox/brief";
|
|
5305
|
+
BRIEF_FILES = {
|
|
5306
|
+
summary: `${BRIEF_DIR}/summary.md`,
|
|
5307
|
+
architecture: `${BRIEF_DIR}/architecture.md`,
|
|
5308
|
+
productDesign: `${BRIEF_DIR}/product.md`,
|
|
5309
|
+
businessPlan: `${BRIEF_DIR}/business.md`,
|
|
5310
|
+
rules: `${BRIEF_DIR}/rules.md`,
|
|
5311
|
+
pathMap: `${BRIEF_DIR}/path-map.md`
|
|
5312
|
+
};
|
|
5313
|
+
BRIEF_DIAGRAMS_DIR = `${BRIEF_DIR}/diagrams`;
|
|
5314
|
+
BRIEF_DIAGRAM_KEY_MAX_LENGTH = 100;
|
|
5315
|
+
BRIEF_DIAGRAM_KEY_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
5316
|
+
RULES_ALWAYS_HEADING = "## Always";
|
|
5317
|
+
RULES_NEVER_HEADING = "## Never";
|
|
5318
|
+
PATH_MAP_HEADER = "| Path | Owner | Note |";
|
|
5319
|
+
PATH_MAP_SEPARATOR = "| --- | --- | --- |";
|
|
5320
|
+
BRIEF_LIMITS = {
|
|
5321
|
+
summary: 1500,
|
|
5322
|
+
text: 2e4,
|
|
5323
|
+
rules: { maxItems: 100, itemMaxLength: 500 },
|
|
5324
|
+
pathMap: { maxEntries: 500, pathMaxLength: 500, ownerMaxLength: 200, noteMaxLength: 1e3 },
|
|
5325
|
+
diagrams: {
|
|
5326
|
+
maxDiagrams: 50,
|
|
5327
|
+
keyMaxLength: BRIEF_DIAGRAM_KEY_MAX_LENGTH,
|
|
5328
|
+
titleMaxLength: 200,
|
|
5329
|
+
mermaidMaxLength: 2e4
|
|
5330
|
+
}
|
|
5331
|
+
};
|
|
5332
|
+
RULES_TITLE = /^#\s+rules\s*$/i;
|
|
5333
|
+
RULES_ALWAYS = /^##\s+always\s*$/i;
|
|
5334
|
+
RULES_NEVER = /^##\s+never\s*$/i;
|
|
5335
|
+
TABLE_SEPARATOR = /^\|(\s*:?-+:?\s*\|)+$/;
|
|
5336
|
+
}
|
|
5337
|
+
});
|
|
5338
|
+
|
|
5339
|
+
// ../shared/dist/brief-prompt.js
|
|
5340
|
+
function truncateBriefSummary(summary) {
|
|
5341
|
+
const trimmed = (summary ?? "").trim();
|
|
5342
|
+
if (trimmed.length <= BRIEF_PROMPT_MAX_LENGTH) {
|
|
5343
|
+
return trimmed;
|
|
5344
|
+
}
|
|
5345
|
+
return trimmed.slice(0, BRIEF_PROMPT_MAX_LENGTH - TRUNCATION_MARKER.length).trimEnd() + TRUNCATION_MARKER;
|
|
5346
|
+
}
|
|
5347
|
+
function composeBriefSummary(summary, rules) {
|
|
5348
|
+
let text = truncateBriefSummary(summary);
|
|
5349
|
+
const groups = [
|
|
5350
|
+
["Always:", rules?.always ?? []],
|
|
5351
|
+
["Never:", rules?.never ?? []]
|
|
5352
|
+
];
|
|
5353
|
+
for (const [heading, items] of groups) {
|
|
5354
|
+
let headed = false;
|
|
5355
|
+
for (const item of items) {
|
|
5356
|
+
const body = item.trim();
|
|
5357
|
+
if (!body)
|
|
5358
|
+
continue;
|
|
5359
|
+
const bullet2 = `- ${body}`;
|
|
5360
|
+
const addition = (headed ? "\n" : `${text ? "\n\n" : ""}${heading}
|
|
5361
|
+
`) + bullet2;
|
|
5362
|
+
if (text.length + addition.length > BRIEF_PROMPT_MAX_LENGTH)
|
|
5363
|
+
break;
|
|
5364
|
+
text += addition;
|
|
5365
|
+
headed = true;
|
|
5366
|
+
}
|
|
5367
|
+
}
|
|
5368
|
+
return text;
|
|
5369
|
+
}
|
|
5370
|
+
function briefTextFromCheckoutFiles(summaryContent, rulesContent) {
|
|
5371
|
+
const files = { [BRIEF_FILES.summary]: summaryContent };
|
|
5372
|
+
if (typeof rulesContent === "string")
|
|
5373
|
+
files[BRIEF_FILES.rules] = rulesContent;
|
|
5374
|
+
const parsed = parseBrief(files);
|
|
5375
|
+
if (!parsed.summary.trim())
|
|
5376
|
+
return null;
|
|
5377
|
+
return composeBriefSummary(parsed.summary, parsed.sections.rules);
|
|
5378
|
+
}
|
|
5379
|
+
var BRIEF_PROMPT_MAX_LENGTH, TRUNCATION_MARKER;
|
|
5380
|
+
var init_brief_prompt = __esm({
|
|
5381
|
+
"../shared/dist/brief-prompt.js"() {
|
|
5382
|
+
"use strict";
|
|
5383
|
+
init_brief_files();
|
|
5384
|
+
BRIEF_PROMPT_MAX_LENGTH = 1500;
|
|
5385
|
+
TRUNCATION_MARKER = "\u2026";
|
|
5386
|
+
}
|
|
5387
|
+
});
|
|
5388
|
+
|
|
4850
5389
|
// ../shared/dist/index.js
|
|
4851
5390
|
var dist_exports = {};
|
|
4852
5391
|
__export(dist_exports, {
|
|
@@ -4868,6 +5407,13 @@ __export(dist_exports, {
|
|
|
4868
5407
|
BILLING_USAGE_GROUP_BYS: () => BILLING_USAGE_GROUP_BYS,
|
|
4869
5408
|
BILLING_WARN_PERCENT_MAX: () => BILLING_WARN_PERCENT_MAX,
|
|
4870
5409
|
BILLING_WARN_PERCENT_MIN: () => BILLING_WARN_PERCENT_MIN,
|
|
5410
|
+
BRIEF_DIAGRAMS_DIR: () => BRIEF_DIAGRAMS_DIR,
|
|
5411
|
+
BRIEF_DIAGRAM_KEY_MAX_LENGTH: () => BRIEF_DIAGRAM_KEY_MAX_LENGTH,
|
|
5412
|
+
BRIEF_DIAGRAM_KEY_PATTERN: () => BRIEF_DIAGRAM_KEY_PATTERN,
|
|
5413
|
+
BRIEF_DIR: () => BRIEF_DIR,
|
|
5414
|
+
BRIEF_FILES: () => BRIEF_FILES,
|
|
5415
|
+
BRIEF_LIMITS: () => BRIEF_LIMITS,
|
|
5416
|
+
BRIEF_PROMPT_MAX_LENGTH: () => BRIEF_PROMPT_MAX_LENGTH,
|
|
4871
5417
|
CHECK_MODES: () => CHECK_MODES,
|
|
4872
5418
|
CLOUD_SQL_MONTHLY_ESTIMATE_USD: () => CLOUD_SQL_MONTHLY_ESTIMATE_USD,
|
|
4873
5419
|
CLOUD_SQL_PROXY_VERSION: () => CLOUD_SQL_PROXY_VERSION,
|
|
@@ -4953,6 +5499,7 @@ __export(dist_exports, {
|
|
|
4953
5499
|
beltLabelRuleSchema: () => beltLabelRuleSchema,
|
|
4954
5500
|
beltLabelRulesSchema: () => beltLabelRulesSchema,
|
|
4955
5501
|
beltSchema: () => beltSchema,
|
|
5502
|
+
briefTextFromCheckoutFiles: () => briefTextFromCheckoutFiles,
|
|
4956
5503
|
buildAuditFeedback: () => buildAuditFeedback,
|
|
4957
5504
|
buildAwsConnectTemplate: () => buildAwsConnectTemplate,
|
|
4958
5505
|
buildAzureConnectTemplate: () => buildAzureConnectTemplate,
|
|
@@ -4966,6 +5513,7 @@ __export(dist_exports, {
|
|
|
4966
5513
|
cloudSqlInstanceName: () => cloudSqlInstanceName,
|
|
4967
5514
|
compareMachineVersions: () => compareMachineVersions,
|
|
4968
5515
|
complianceFromRecord: () => complianceFromRecord,
|
|
5516
|
+
composeBriefSummary: () => composeBriefSummary,
|
|
4969
5517
|
contentText: () => contentText,
|
|
4970
5518
|
createReplyStreamFilter: () => createReplyStreamFilter,
|
|
4971
5519
|
customAgentFindingSchema: () => customAgentFindingSchema,
|
|
@@ -4975,6 +5523,7 @@ __export(dist_exports, {
|
|
|
4975
5523
|
databaseSecretName: () => databaseSecretName,
|
|
4976
5524
|
deployRunTitle: () => deployRunTitle,
|
|
4977
5525
|
err: () => err,
|
|
5526
|
+
escapeBriefTableCell: () => escapeBriefTableCell,
|
|
4978
5527
|
estimateBelt: () => estimateBelt,
|
|
4979
5528
|
estimateGcpStack: () => estimateGcpStack,
|
|
4980
5529
|
estimateStackCost: () => estimateStackCost,
|
|
@@ -5003,6 +5552,7 @@ __export(dist_exports, {
|
|
|
5003
5552
|
isAzureLocation: () => isAzureLocation,
|
|
5004
5553
|
isAzureResourceGroup: () => isAzureResourceGroup,
|
|
5005
5554
|
isAzureStorageAccount: () => isAzureStorageAccount,
|
|
5555
|
+
isBriefPath: () => isBriefPath,
|
|
5006
5556
|
isConversationChatModel: () => isConversationChatModel,
|
|
5007
5557
|
isGcpProjectId: () => isGcpProjectId,
|
|
5008
5558
|
isGcpProjectNumber: () => isGcpProjectNumber,
|
|
@@ -5036,9 +5586,11 @@ __export(dist_exports, {
|
|
|
5036
5586
|
meetsComplianceTarget: () => meetsComplianceTarget,
|
|
5037
5587
|
meetsMinimum: () => meetsMinimum,
|
|
5038
5588
|
modelRecommendationSourceValues: () => modelRecommendationSourceValues,
|
|
5589
|
+
normalizeBriefPath: () => normalizeBriefPath,
|
|
5039
5590
|
normalizeDatabaseChoice: () => normalizeDatabaseChoice,
|
|
5040
5591
|
normalizeGitRemote: () => normalizeGitRemote,
|
|
5041
5592
|
ok: () => ok,
|
|
5593
|
+
parseBrief: () => parseBrief,
|
|
5042
5594
|
parseCustomAgentPermissions: () => parseCustomAgentPermissions,
|
|
5043
5595
|
parseMachineVersion: () => parseMachineVersion,
|
|
5044
5596
|
parseMinMachineVersionOverride: () => parseMinMachineVersionOverride,
|
|
@@ -5063,11 +5615,13 @@ __export(dist_exports, {
|
|
|
5063
5615
|
sameGitRemote: () => sameGitRemote,
|
|
5064
5616
|
savedContextFromRecord: () => savedContextFromRecord,
|
|
5065
5617
|
savedMessage: () => savedMessage,
|
|
5618
|
+
serializeBrief: () => serializeBrief,
|
|
5066
5619
|
shannonEntropy: () => shannonEntropy,
|
|
5067
5620
|
skillInputSchema: () => skillInputSchema,
|
|
5068
5621
|
skillPackManifestSchema: () => skillPackManifestSchema,
|
|
5069
5622
|
skillSchema: () => skillSchema,
|
|
5070
5623
|
sleep: () => sleep,
|
|
5624
|
+
slugifyDiagramKey: () => slugifyDiagramKey,
|
|
5071
5625
|
stackAppName: () => stackAppName,
|
|
5072
5626
|
stackEnvSettings: () => stackEnvSettings,
|
|
5073
5627
|
stackEnvironments: () => stackEnvironments,
|
|
@@ -5083,6 +5637,7 @@ __export(dist_exports, {
|
|
|
5083
5637
|
toIdeaMode: () => toIdeaMode,
|
|
5084
5638
|
toIdeaRunsOn: () => toIdeaRunsOn,
|
|
5085
5639
|
toRunRouting: () => toRunRouting,
|
|
5640
|
+
truncateBriefSummary: () => truncateBriefSummary,
|
|
5086
5641
|
uploadSkillInputSchema: () => uploadSkillInputSchema,
|
|
5087
5642
|
validateBelt: () => validateBelt,
|
|
5088
5643
|
validatePackName: () => validatePackName,
|
|
@@ -5118,6 +5673,8 @@ var init_dist = __esm({
|
|
|
5118
5673
|
init_agents();
|
|
5119
5674
|
init_billing();
|
|
5120
5675
|
init_belts();
|
|
5676
|
+
init_brief_files();
|
|
5677
|
+
init_brief_prompt();
|
|
5121
5678
|
}
|
|
5122
5679
|
});
|
|
5123
5680
|
|
|
@@ -5955,7 +6512,8 @@ var ApiClient = class {
|
|
|
5955
6512
|
return this.request("GET", query ? `${base}?${query}` : base);
|
|
5956
6513
|
}
|
|
5957
6514
|
/**
|
|
5958
|
-
* Write a
|
|
6515
|
+
* Write a change to a team's project brief in its repository: a direct
|
|
6516
|
+
* commit or a pull request, depending on the project's apply mode.
|
|
5959
6517
|
*/
|
|
5960
6518
|
async updateProjectBrief(teamId, data) {
|
|
5961
6519
|
return this.request(
|
|
@@ -5965,8 +6523,8 @@ var ApiClient = class {
|
|
|
5965
6523
|
);
|
|
5966
6524
|
}
|
|
5967
6525
|
/**
|
|
5968
|
-
* Propose an edit to a team's project brief
|
|
5969
|
-
* the
|
|
6526
|
+
* Propose an edit to a team's project brief as a brief pull request. The
|
|
6527
|
+
* brief is unchanged until the pull request is merged.
|
|
5970
6528
|
*/
|
|
5971
6529
|
async proposeProjectBriefEdit(teamId, data) {
|
|
5972
6530
|
return this.request(
|
|
@@ -10683,7 +11241,9 @@ compbox__log_decision({
|
|
|
10683
11241
|
Decisions are **append-only** - once logged, they cannot be modified. This ensures a complete audit trail.`,
|
|
10684
11242
|
brief: `# Project Brief
|
|
10685
11243
|
|
|
10686
|
-
Each team has a living **project brief**: a short summary (max 1500 chars, the same text agents get in their prompt) plus sections: \`architecture\`, \`productDesign\`, \`businessPlan\`, \`rules\` ({ always, never }), \`pathMap\` ([{ path, owner, note? }]) and \`diagrams\` ([{ key, title, mermaid }]).
|
|
11244
|
+
Each team has a living **project brief**: a short summary (max 1500 chars, the same text agents get in their prompt) plus sections: \`architecture\`, \`productDesign\`, \`businessPlan\`, \`rules\` ({ always, never }), \`pathMap\` ([{ path, owner, note? }]) and \`diagrams\` ([{ key, title, mermaid }]).
|
|
11245
|
+
|
|
11246
|
+
The brief lives in the project's GitHub repository as files under \`.compbox/brief/\` on the default branch. Every change is a commit, so versions are the git history of that folder. Reads return \`headSha\` (the commit read) and \`issues\` (problems found in the files).
|
|
10687
11247
|
|
|
10688
11248
|
### Reading (cheapest first)
|
|
10689
11249
|
\`\`\`typescript
|
|
@@ -10693,8 +11253,11 @@ compbox__get_project_brief({ team: "Backend", full: true }) // eve
|
|
|
10693
11253
|
\`\`\`
|
|
10694
11254
|
|
|
10695
11255
|
### Writing
|
|
10696
|
-
- \`compbox__update_project_brief\`
|
|
10697
|
-
-
|
|
11256
|
+
- \`compbox__update_project_brief\` writes the change using the project's apply mode:
|
|
11257
|
+
- **direct**: commits to the default branch; the output has \`commitSha\`.
|
|
11258
|
+
- **pr**: opens a pull request; the output has \`prUrl\` (and \`commitSha\` on the PR branch).
|
|
11259
|
+
- If a direct commit is refused (e.g. branch protection), a pull request is opened instead and the output has \`fallback: true\` and \`fallbackReason\`.
|
|
11260
|
+
- \`compbox__propose_brief_edit\` opens a brief pull request for a human to review, or adds a commit to the one already open (use \`source: "wrap-up"\` for epic wrap-ups). The output has \`prUrl\` and \`commitSha\`; the brief changes when the pull request is merged.
|
|
10698
11261
|
|
|
10699
11262
|
Each section key you pass replaces that whole section; keys you leave out are kept. Provide \`summary\` and/or \`sections\`.
|
|
10700
11263
|
|
|
@@ -10706,7 +11269,7 @@ compbox__propose_brief_edit({
|
|
|
10706
11269
|
})
|
|
10707
11270
|
\`\`\`
|
|
10708
11271
|
|
|
10709
|
-
A **409** error means the brief changed since you read it: re-read and retry.`
|
|
11272
|
+
A **409** error means the brief changed since you read it: re-read and retry. A "Brief repository unavailable" error means the project has no usable repository; retrying won't help.`
|
|
10710
11273
|
};
|
|
10711
11274
|
var fullInstructions = `# CompBox AI Agent Instructions
|
|
10712
11275
|
|
|
@@ -14552,9 +15115,21 @@ async function resolveTeamId4(team) {
|
|
|
14552
15115
|
const result2 = await getApiClient().getTeam(team);
|
|
14553
15116
|
return result2?.data.id ?? null;
|
|
14554
15117
|
}
|
|
15118
|
+
var BRIEF_REPO_UNAVAILABLE = "BRIEF_REPO_UNAVAILABLE";
|
|
15119
|
+
function apiErrorCode(error) {
|
|
15120
|
+
const body = error.body;
|
|
15121
|
+
const code = body && typeof body === "object" ? body.error?.code : void 0;
|
|
15122
|
+
return typeof code === "string" ? code : void 0;
|
|
15123
|
+
}
|
|
14555
15124
|
function briefErrorResponse(error) {
|
|
14556
15125
|
if (error instanceof ApiError && error.status === 409) {
|
|
14557
15126
|
const base = createErrorResponse(error).content[0]?.text.replace(/^Error: /, "") ?? "";
|
|
15127
|
+
if (apiErrorCode(error) === BRIEF_REPO_UNAVAILABLE) {
|
|
15128
|
+
const reason = base && base !== "HTTP 409" ? base : "The project's repository can't be used";
|
|
15129
|
+
return errorText(
|
|
15130
|
+
`Brief repository unavailable: ${reason}. The brief is stored in the project's GitHub repository under .compbox/brief/, so the project needs a connected repository with a default branch. Retrying won't help until that is fixed.`
|
|
15131
|
+
);
|
|
15132
|
+
}
|
|
14558
15133
|
const detail = base && base !== "HTTP 409" ? base : "The brief was changed by someone else";
|
|
14559
15134
|
return errorText(
|
|
14560
15135
|
`Conflict (409): ${detail}. Re-read the brief with compbox__get_project_brief and retry with your change.`
|
|
@@ -14607,11 +15182,41 @@ function buildChange(input, source) {
|
|
|
14607
15182
|
if (input.changedByIdeaId !== void 0) body.changedByIdeaId = input.changedByIdeaId;
|
|
14608
15183
|
return { body };
|
|
14609
15184
|
}
|
|
15185
|
+
function updateOutput(data) {
|
|
15186
|
+
const prUrl = data.pullRequest?.url;
|
|
15187
|
+
const commitSha = data.sha;
|
|
15188
|
+
let message;
|
|
15189
|
+
if (data.unchanged) {
|
|
15190
|
+
message = "The brief already matched this change; nothing was written.";
|
|
15191
|
+
} else if (prUrl) {
|
|
15192
|
+
message = data.fallback ? `A direct commit to the default branch was refused${data.fallbackReason ? ` (${data.fallbackReason})` : ""}, so pull request #${String(data.pullRequest?.number)} was opened instead. The brief changes when it is merged.` : `Opened pull request #${String(data.pullRequest?.number)}. The brief changes when it is merged.`;
|
|
15193
|
+
} else {
|
|
15194
|
+
message = "Committed the brief change to the default branch.";
|
|
15195
|
+
}
|
|
15196
|
+
return {
|
|
15197
|
+
message,
|
|
15198
|
+
...prUrl !== void 0 && { prUrl },
|
|
15199
|
+
...commitSha !== void 0 && !data.unchanged && { commitSha },
|
|
15200
|
+
...data.fallback && { fallback: true, fallbackReason: data.fallbackReason ?? null },
|
|
15201
|
+
...data
|
|
15202
|
+
};
|
|
15203
|
+
}
|
|
15204
|
+
function proposalOutput(data) {
|
|
15205
|
+
const prUrl = data.pullRequest?.url;
|
|
15206
|
+
const number = data.pullRequest?.number;
|
|
15207
|
+
const message = prUrl ? data.updatedInPlace ? `Added the change to the open brief pull request #${String(number)}. The brief changes when it is merged.` : `Opened brief pull request #${String(number)}. The brief changes when it is merged.` : "Recorded the proposal.";
|
|
15208
|
+
return {
|
|
15209
|
+
message,
|
|
15210
|
+
...prUrl !== void 0 && { prUrl },
|
|
15211
|
+
...data.sha !== void 0 && { commitSha: data.sha },
|
|
15212
|
+
...data
|
|
15213
|
+
};
|
|
15214
|
+
}
|
|
14610
15215
|
function registerProjectBriefTools(server2) {
|
|
14611
15216
|
server2.registerTool(
|
|
14612
15217
|
"compbox__get_project_brief",
|
|
14613
15218
|
{
|
|
14614
|
-
description: `Read a team's project brief. By default returns only the short summary (cheap, the same text agents get in their prompt). Pass \`section\` to fetch one section (${sectionKeyList}), or full=true to get every section. Prefer summary first, then a single section, and only use full when you need everything.`,
|
|
15219
|
+
description: `Read a team's project brief. By default returns only the short summary (cheap, the same text agents get in their prompt). Pass \`section\` to fetch one section (${sectionKeyList}), or full=true to get every section. Prefer summary first, then a single section, and only use full when you need everything. The brief is read from the project's repository (.compbox/brief/ on the default branch); \`headSha\` is the commit it was read at and \`issues\` lists problems found in the files.`,
|
|
14615
15220
|
inputSchema: {
|
|
14616
15221
|
team: teamSchema,
|
|
14617
15222
|
section: z28.string().optional().describe(`Return just this section. One of: ${sectionKeyList}.`),
|
|
@@ -14641,7 +15246,7 @@ function registerProjectBriefTools(server2) {
|
|
|
14641
15246
|
server2.registerTool(
|
|
14642
15247
|
"compbox__update_project_brief",
|
|
14643
15248
|
{
|
|
14644
|
-
description: "Write a
|
|
15249
|
+
description: "Write a change to a team's project brief. The brief lives as files in the project's repository under .compbox/brief/, and how the change lands depends on the project's apply mode: 'direct' commits to the default branch (output has `commitSha`), 'pr' opens a pull request (output has `prUrl`). If a direct commit is refused (e.g. branch protection), a pull request is opened instead and the output has `fallback: true` with `fallbackReason`. Each section key you pass replaces that whole section; keys you leave out are kept. Provide summary and/or sections. Every change is a commit, so it is versioned in git history. If you are not sure the change should go in, use compbox__propose_brief_edit instead so a human can review it. A 409 error means the brief changed meanwhile: re-read and retry.",
|
|
14645
15250
|
inputSchema: {
|
|
14646
15251
|
team: teamSchema,
|
|
14647
15252
|
summary: summarySchema,
|
|
@@ -14656,7 +15261,7 @@ function registerProjectBriefTools(server2) {
|
|
|
14656
15261
|
const teamId = await resolveTeamId4(input.team);
|
|
14657
15262
|
if (!teamId) return errorText(`Team '${input.team}' not found.`);
|
|
14658
15263
|
const result2 = await getApiClient().updateProjectBrief(teamId, built.body);
|
|
14659
|
-
return createResponse(result2.data);
|
|
15264
|
+
return createResponse(updateOutput(result2.data));
|
|
14660
15265
|
} catch (error) {
|
|
14661
15266
|
return briefErrorResponse(error);
|
|
14662
15267
|
}
|
|
@@ -14665,7 +15270,7 @@ function registerProjectBriefTools(server2) {
|
|
|
14665
15270
|
server2.registerTool(
|
|
14666
15271
|
"compbox__propose_brief_edit",
|
|
14667
15272
|
{
|
|
14668
|
-
description: "Propose a change to a team's project brief without applying it. The
|
|
15273
|
+
description: "Propose a change to a team's project brief without applying it. The proposal is a pull request against the brief files in the project's repository (.compbox/brief/); if a brief pull request is already open the change is committed onto it. The output has `prUrl` and `commitSha`. The brief stays as it is until the pull request is merged, and applying it fails (409) if the brief moved on. Use this for changes a human should review, e.g. lessons from an epic wrap-up. Each section key you pass replaces that whole section. Provide summary and/or sections, with an optional changedByIdeaId.",
|
|
14669
15274
|
inputSchema: {
|
|
14670
15275
|
team: teamSchema,
|
|
14671
15276
|
summary: summarySchema,
|
|
@@ -14681,7 +15286,7 @@ function registerProjectBriefTools(server2) {
|
|
|
14681
15286
|
const teamId = await resolveTeamId4(input.team);
|
|
14682
15287
|
if (!teamId) return errorText(`Team '${input.team}' not found.`);
|
|
14683
15288
|
const result2 = await getApiClient().proposeProjectBriefEdit(teamId, built.body);
|
|
14684
|
-
return createResponse(result2.data);
|
|
15289
|
+
return createResponse(proposalOutput(result2.data));
|
|
14685
15290
|
} catch (error) {
|
|
14686
15291
|
return briefErrorResponse(error);
|
|
14687
15292
|
}
|
|
@@ -15705,7 +16310,7 @@ function withLegacyToolCallRewrite(transport) {
|
|
|
15705
16310
|
var SERVER_NAME = "compbox-mcp";
|
|
15706
16311
|
function resolveServerVersion() {
|
|
15707
16312
|
if (true) {
|
|
15708
|
-
return "1.21.
|
|
16313
|
+
return "1.21.20";
|
|
15709
16314
|
}
|
|
15710
16315
|
const require2 = createRequire(import.meta.url);
|
|
15711
16316
|
for (const candidate of ["../package.json", "./package.json"]) {
|