Merge remote-tracking branch 'upstream/master' into dev
# Conflicts: # packages/shared/src/validators/company-skill.ts # packages/shared/src/validators/index.ts # server/src/__tests__/company-skills-routes.test.ts # server/src/routes/company-skills.ts # server/src/services/company-skills.ts # ui/src/pages/CompanySkills.tsx
This commit is contained in:
@@ -281,6 +281,22 @@ export function isSystemIssueDocumentKey(key: string): key is SystemIssueDocumen
|
||||
export const ISSUE_REFERENCE_SOURCE_KINDS = ["title", "description", "comment", "document"] as const;
|
||||
export type IssueReferenceSourceKind = (typeof ISSUE_REFERENCE_SOURCE_KINDS)[number];
|
||||
|
||||
export const DOCUMENT_ANNOTATION_THREAD_STATUSES = ["open", "resolved"] as const;
|
||||
export type DocumentAnnotationThreadStatus = (typeof DOCUMENT_ANNOTATION_THREAD_STATUSES)[number];
|
||||
|
||||
export const DOCUMENT_ANNOTATION_ANCHOR_STATES = ["active", "stale", "orphaned"] as const;
|
||||
export type DocumentAnnotationAnchorState = (typeof DOCUMENT_ANNOTATION_ANCHOR_STATES)[number];
|
||||
|
||||
export const DOCUMENT_ANNOTATION_ANCHOR_CONFIDENCES = [
|
||||
"exact",
|
||||
"duplicate",
|
||||
"fuzzy",
|
||||
"ambiguous",
|
||||
"missing",
|
||||
] as const;
|
||||
export type DocumentAnnotationAnchorConfidence =
|
||||
(typeof DOCUMENT_ANNOTATION_ANCHOR_CONFIDENCES)[number];
|
||||
|
||||
export const ISSUE_EXECUTION_POLICY_MODES = ["normal", "auto"] as const;
|
||||
export type IssueExecutionPolicyMode = (typeof ISSUE_EXECUTION_POLICY_MODES)[number];
|
||||
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
createDocumentAnchorSelector,
|
||||
projectMarkdownToText,
|
||||
remapDocumentAnchor,
|
||||
resolveProjectionRange,
|
||||
verifyDocumentAnchorSelector,
|
||||
} from "./document-anchors.js";
|
||||
|
||||
function selectorFor(markdown: string, quote: string) {
|
||||
const projection = projectMarkdownToText(markdown);
|
||||
const start = projection.text.indexOf(quote);
|
||||
expect(start).toBeGreaterThanOrEqual(0);
|
||||
const range = resolveProjectionRange(projection, start, start + quote.length);
|
||||
expect(range).not.toBeNull();
|
||||
return createDocumentAnchorSelector(projection, range!);
|
||||
}
|
||||
|
||||
describe("document text projection", () => {
|
||||
it("projects markdown into normalized rendered text with source ranges", () => {
|
||||
const markdown = [
|
||||
"# Heading",
|
||||
"",
|
||||
"- Ship **bold** [link text](https://example.com) and `code span`.",
|
||||
"| Name | Value |",
|
||||
"| --- | --- |",
|
||||
"| Alpha | Beta |",
|
||||
].join("\n");
|
||||
|
||||
const projection = projectMarkdownToText(markdown);
|
||||
|
||||
expect(projection.text).toContain("Heading");
|
||||
expect(projection.text).toContain("Ship bold link text and code span.");
|
||||
expect(projection.text).toContain("Name Value");
|
||||
expect(projection.text).toContain("Alpha Beta");
|
||||
expect(projection.text).not.toContain("https://example.com");
|
||||
expect(projection.positions).toHaveLength(projection.text.length);
|
||||
|
||||
const linkStart = projection.text.indexOf("link text");
|
||||
const range = resolveProjectionRange(projection, linkStart, linkStart + "link text".length);
|
||||
expect(range?.markdownStart).toBe(markdown.indexOf("link text"));
|
||||
expect(range?.markdownEnd).toBe(markdown.indexOf("link text") + "link text".length);
|
||||
});
|
||||
|
||||
it("normalizes whitespace while retaining markdown offsets", () => {
|
||||
const markdown = "First line\n\nSecond\t\tline";
|
||||
const projection = projectMarkdownToText(markdown);
|
||||
|
||||
expect(projection.text).toBe("First line Second line");
|
||||
const range = resolveProjectionRange(projection, projection.text.indexOf("Second"), projection.text.length);
|
||||
expect(range?.markdownStart).toBe(markdown.indexOf("Second"));
|
||||
expect(range?.markdownEnd).toBe(markdown.length);
|
||||
});
|
||||
|
||||
it("preserves non-link punctuation", () => {
|
||||
const markdown = "Keep (parenthetical) [plain brackets] visible.";
|
||||
const projection = projectMarkdownToText(markdown);
|
||||
|
||||
expect(projection.text).toBe("Keep (parenthetical) [plain brackets] visible.");
|
||||
});
|
||||
});
|
||||
|
||||
describe("document anchor verification and remapping", () => {
|
||||
it("verifies a selector against its base revision", () => {
|
||||
const markdown = "Intro text with **selected text** inside.";
|
||||
const selector = selectorFor(markdown, "selected text");
|
||||
|
||||
const result = verifyDocumentAnchorSelector({ markdown, selector });
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
expect(result.anchor?.selectedText).toBe("selected text");
|
||||
expect(result.anchor?.markdownStart).toBe(markdown.indexOf("selected text"));
|
||||
});
|
||||
|
||||
it("remaps exact anchors after surrounding text moves", () => {
|
||||
const selector = selectorFor("Alpha paragraph.\n\nTarget sentence here.\n\nOmega paragraph.", "Target sentence here.");
|
||||
const previousAnchor = {
|
||||
selectedText: selector.quote.exact,
|
||||
prefixText: selector.quote.prefix,
|
||||
suffixText: selector.quote.suffix,
|
||||
normalizedStart: selector.position.normalizedStart,
|
||||
normalizedEnd: selector.position.normalizedEnd,
|
||||
markdownStart: selector.position.markdownStart,
|
||||
markdownEnd: selector.position.markdownEnd,
|
||||
};
|
||||
|
||||
const result = remapDocumentAnchor({
|
||||
previousAnchor,
|
||||
nextMarkdown: "Omega paragraph.\n\nAlpha paragraph.\n\nTarget sentence here.",
|
||||
});
|
||||
|
||||
expect(result.anchorState).toBe("active");
|
||||
expect(result.confidence).toBe("exact");
|
||||
expect(result.anchor?.selectedText).toBe("Target sentence here.");
|
||||
});
|
||||
|
||||
it("uses context and proximity to disambiguate duplicate quotes", () => {
|
||||
const selector = selectorFor("One apple near the start.\n\nTwo apple near the end.", "apple");
|
||||
const previousAnchor = {
|
||||
selectedText: selector.quote.exact,
|
||||
prefixText: selector.quote.prefix,
|
||||
suffixText: selector.quote.suffix,
|
||||
normalizedStart: selector.position.normalizedStart,
|
||||
normalizedEnd: selector.position.normalizedEnd,
|
||||
markdownStart: selector.position.markdownStart,
|
||||
markdownEnd: selector.position.markdownEnd,
|
||||
};
|
||||
|
||||
const result = remapDocumentAnchor({
|
||||
previousAnchor,
|
||||
nextMarkdown: "Zero apple elsewhere.\n\nOne apple near the start.\n\nTwo apple near the end.",
|
||||
});
|
||||
|
||||
expect(result.anchorState).toBe("active");
|
||||
expect(result.confidence).toBe("duplicate");
|
||||
expect(result.anchor?.prefixText).toContain("One");
|
||||
});
|
||||
|
||||
it("marks duplicate anchors ambiguous when context cannot distinguish them", () => {
|
||||
const selector = selectorFor("apple apple", "apple");
|
||||
const previousAnchor = {
|
||||
selectedText: selector.quote.exact,
|
||||
prefixText: "",
|
||||
suffixText: "",
|
||||
normalizedStart: selector.position.normalizedStart,
|
||||
normalizedEnd: selector.position.normalizedEnd,
|
||||
markdownStart: selector.position.markdownStart,
|
||||
markdownEnd: selector.position.markdownEnd,
|
||||
};
|
||||
|
||||
const result = remapDocumentAnchor({ previousAnchor, nextMarkdown: "apple apple" });
|
||||
|
||||
expect(result.anchorState).toBe("stale");
|
||||
expect(result.confidence).toBe("ambiguous");
|
||||
});
|
||||
|
||||
it("keeps edited anchors as stale fuzzy matches", () => {
|
||||
const selector = selectorFor("We rely on an important launch assumption for scope.", "important launch assumption");
|
||||
const previousAnchor = {
|
||||
selectedText: selector.quote.exact,
|
||||
prefixText: selector.quote.prefix,
|
||||
suffixText: selector.quote.suffix,
|
||||
normalizedStart: selector.position.normalizedStart,
|
||||
normalizedEnd: selector.position.normalizedEnd,
|
||||
markdownStart: selector.position.markdownStart,
|
||||
markdownEnd: selector.position.markdownEnd,
|
||||
};
|
||||
|
||||
const result = remapDocumentAnchor({
|
||||
previousAnchor,
|
||||
nextMarkdown: "We rely on an important product launch assumption for scope.",
|
||||
});
|
||||
|
||||
expect(result.anchorState).toBe("stale");
|
||||
expect(result.confidence).toBe("fuzzy");
|
||||
expect(result.anchor?.selectedText).toBe("important product launch assumption");
|
||||
});
|
||||
|
||||
it("marks deleted anchors orphaned and allows future remapping from the latest known anchor", () => {
|
||||
const selector = selectorFor("Keep this reviewed phrase in mind.", "reviewed phrase");
|
||||
const previousAnchor = {
|
||||
selectedText: selector.quote.exact,
|
||||
prefixText: selector.quote.prefix,
|
||||
suffixText: selector.quote.suffix,
|
||||
normalizedStart: selector.position.normalizedStart,
|
||||
normalizedEnd: selector.position.normalizedEnd,
|
||||
markdownStart: selector.position.markdownStart,
|
||||
markdownEnd: selector.position.markdownEnd,
|
||||
};
|
||||
|
||||
const missing = remapDocumentAnchor({ previousAnchor, nextMarkdown: "The target disappeared." });
|
||||
const recovered = remapDocumentAnchor({
|
||||
previousAnchor,
|
||||
nextMarkdown: "The target came back: reviewed phrase.",
|
||||
});
|
||||
|
||||
expect(missing.anchorState).toBe("orphaned");
|
||||
expect(missing.confidence).toBe("missing");
|
||||
expect(missing.anchor).toBeNull();
|
||||
expect(recovered.anchorState).toBe("active");
|
||||
expect(recovered.anchor?.selectedText).toBe("reviewed phrase");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,464 @@
|
||||
import type {
|
||||
DocumentAnnotationAnchorConfidence,
|
||||
DocumentAnnotationAnchorState,
|
||||
} from "./constants.js";
|
||||
import type {
|
||||
DocumentAnnotationAnchorSelector,
|
||||
DocumentAnnotationAnchorSnapshot,
|
||||
DocumentTextPosition,
|
||||
DocumentTextProjection,
|
||||
DocumentTextRange,
|
||||
} from "./types/document-annotation.js";
|
||||
|
||||
export interface CreateDocumentAnchorSelectorOptions {
|
||||
contextLength?: number;
|
||||
}
|
||||
|
||||
export interface VerifyDocumentAnchorSelectorInput {
|
||||
markdown: string;
|
||||
selector: DocumentAnnotationAnchorSelector;
|
||||
contextLength?: number;
|
||||
}
|
||||
|
||||
export interface VerifyDocumentAnchorSelectorResult {
|
||||
ok: boolean;
|
||||
anchor: DocumentAnnotationAnchorSnapshot | null;
|
||||
projection: DocumentTextProjection;
|
||||
reason: "verified" | "quote_mismatch" | "position_mismatch" | "invalid_range";
|
||||
}
|
||||
|
||||
export interface RemapDocumentAnchorInput {
|
||||
previousAnchor: DocumentAnnotationAnchorSnapshot;
|
||||
nextMarkdown: string;
|
||||
contextLength?: number;
|
||||
}
|
||||
|
||||
export interface RemapDocumentAnchorResult {
|
||||
anchorState: DocumentAnnotationAnchorState;
|
||||
confidence: DocumentAnnotationAnchorConfidence;
|
||||
anchor: DocumentAnnotationAnchorSnapshot | null;
|
||||
projection: DocumentTextProjection;
|
||||
reason: "exact" | "duplicate" | "fuzzy" | "ambiguous" | "missing";
|
||||
}
|
||||
|
||||
interface Candidate {
|
||||
start: number;
|
||||
end: number;
|
||||
score: number;
|
||||
reason: RemapDocumentAnchorResult["reason"];
|
||||
}
|
||||
|
||||
const DEFAULT_CONTEXT_LENGTH = 48;
|
||||
|
||||
export function normalizeAnchorText(value: string): string {
|
||||
return value.replace(/\s+/g, " ").trim();
|
||||
}
|
||||
|
||||
export function projectMarkdownToText(markdown: string): DocumentTextProjection {
|
||||
const builder = new ProjectionBuilder(markdown);
|
||||
const lines = markdown.match(/[^\n]*(?:\n|$)/g) ?? [markdown];
|
||||
let offset = 0;
|
||||
let inFence = false;
|
||||
|
||||
for (const rawLine of lines) {
|
||||
if (rawLine === "") continue;
|
||||
const hasNewline = rawLine.endsWith("\n");
|
||||
const line = hasNewline ? rawLine.slice(0, -1) : rawLine;
|
||||
const fenceMatch = line.match(/^\s*(```+|~~~+)/);
|
||||
|
||||
if (fenceMatch) {
|
||||
inFence = !inFence;
|
||||
offset += rawLine.length;
|
||||
builder.addSeparator(offset - (hasNewline ? 1 : 0));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inFence) {
|
||||
builder.addText(line, offset);
|
||||
builder.addSeparator(offset + line.length);
|
||||
offset += rawLine.length;
|
||||
continue;
|
||||
}
|
||||
|
||||
const { text, sourceOffset } = stripBlockSyntax(line, offset);
|
||||
addInlineMarkdownText(builder, text, sourceOffset);
|
||||
builder.addSeparator(offset + line.length);
|
||||
offset += rawLine.length;
|
||||
}
|
||||
|
||||
return builder.toProjection();
|
||||
}
|
||||
|
||||
export function resolveProjectionRange(
|
||||
projection: DocumentTextProjection,
|
||||
normalizedStart: number,
|
||||
normalizedEnd: number,
|
||||
): DocumentTextRange | null {
|
||||
if (
|
||||
normalizedStart < 0
|
||||
|| normalizedEnd <= normalizedStart
|
||||
|| normalizedEnd > projection.text.length
|
||||
|| normalizedStart >= projection.positions.length
|
||||
|| normalizedEnd - 1 >= projection.positions.length
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
text: projection.text.slice(normalizedStart, normalizedEnd),
|
||||
normalizedStart,
|
||||
normalizedEnd,
|
||||
markdownStart: projection.positions[normalizedStart]?.sourceStart ?? 0,
|
||||
markdownEnd: projection.positions[normalizedEnd - 1]?.sourceEnd ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
export function createDocumentAnchorSelector(
|
||||
projection: DocumentTextProjection,
|
||||
range: DocumentTextRange,
|
||||
options: CreateDocumentAnchorSelectorOptions = {},
|
||||
): DocumentAnnotationAnchorSelector {
|
||||
const contextLength = options.contextLength ?? DEFAULT_CONTEXT_LENGTH;
|
||||
return {
|
||||
quote: {
|
||||
exact: range.text,
|
||||
prefix: projection.text.slice(Math.max(0, range.normalizedStart - contextLength), range.normalizedStart),
|
||||
suffix: projection.text.slice(range.normalizedEnd, range.normalizedEnd + contextLength),
|
||||
},
|
||||
position: {
|
||||
normalizedStart: range.normalizedStart,
|
||||
normalizedEnd: range.normalizedEnd,
|
||||
markdownStart: range.markdownStart,
|
||||
markdownEnd: range.markdownEnd,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function selectorToAnchorSnapshot(selector: DocumentAnnotationAnchorSelector): DocumentAnnotationAnchorSnapshot {
|
||||
return {
|
||||
selectedText: selector.quote.exact,
|
||||
prefixText: selector.quote.prefix,
|
||||
suffixText: selector.quote.suffix,
|
||||
normalizedStart: selector.position.normalizedStart,
|
||||
normalizedEnd: selector.position.normalizedEnd,
|
||||
markdownStart: selector.position.markdownStart,
|
||||
markdownEnd: selector.position.markdownEnd,
|
||||
};
|
||||
}
|
||||
|
||||
export function anchorSnapshotToSelector(anchor: DocumentAnnotationAnchorSnapshot): DocumentAnnotationAnchorSelector {
|
||||
return {
|
||||
quote: {
|
||||
exact: anchor.selectedText,
|
||||
prefix: anchor.prefixText,
|
||||
suffix: anchor.suffixText,
|
||||
},
|
||||
position: {
|
||||
normalizedStart: anchor.normalizedStart,
|
||||
normalizedEnd: anchor.normalizedEnd,
|
||||
markdownStart: anchor.markdownStart,
|
||||
markdownEnd: anchor.markdownEnd,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function verifyDocumentAnchorSelector(
|
||||
input: VerifyDocumentAnchorSelectorInput,
|
||||
): VerifyDocumentAnchorSelectorResult {
|
||||
const projection = projectMarkdownToText(input.markdown);
|
||||
const range = resolveProjectionRange(
|
||||
projection,
|
||||
input.selector.position.normalizedStart,
|
||||
input.selector.position.normalizedEnd,
|
||||
);
|
||||
if (!range) {
|
||||
return { ok: false, anchor: null, projection, reason: "invalid_range" };
|
||||
}
|
||||
|
||||
if (normalizeAnchorText(range.text) !== normalizeAnchorText(input.selector.quote.exact)) {
|
||||
return { ok: false, anchor: null, projection, reason: "quote_mismatch" };
|
||||
}
|
||||
|
||||
if (
|
||||
range.markdownStart !== input.selector.position.markdownStart
|
||||
|| range.markdownEnd !== input.selector.position.markdownEnd
|
||||
) {
|
||||
return { ok: false, anchor: null, projection, reason: "position_mismatch" };
|
||||
}
|
||||
|
||||
const selector = createDocumentAnchorSelector(projection, range, {
|
||||
contextLength: input.contextLength ?? DEFAULT_CONTEXT_LENGTH,
|
||||
});
|
||||
return { ok: true, anchor: selectorToAnchorSnapshot(selector), projection, reason: "verified" };
|
||||
}
|
||||
|
||||
export function remapDocumentAnchor(input: RemapDocumentAnchorInput): RemapDocumentAnchorResult {
|
||||
const projection = projectMarkdownToText(input.nextMarkdown);
|
||||
const contextLength = input.contextLength ?? DEFAULT_CONTEXT_LENGTH;
|
||||
const quote = normalizeAnchorText(input.previousAnchor.selectedText);
|
||||
if (!quote) {
|
||||
return { anchorState: "orphaned", confidence: "missing", anchor: null, projection, reason: "missing" };
|
||||
}
|
||||
|
||||
const exactCandidates = findOccurrences(projection.text, quote).map((start) => scoreCandidate({
|
||||
projection,
|
||||
start,
|
||||
end: start + quote.length,
|
||||
previousAnchor: input.previousAnchor,
|
||||
reason: "exact",
|
||||
contextLength,
|
||||
}));
|
||||
|
||||
if (exactCandidates.length > 0) {
|
||||
exactCandidates.sort((a, b) => b.score - a.score);
|
||||
const [best, second] = exactCandidates;
|
||||
if (exactCandidates.length > 1 && (!second || Math.abs(best.score - second.score) < 0.05)) {
|
||||
return {
|
||||
anchorState: "stale",
|
||||
confidence: "ambiguous",
|
||||
anchor: buildAnchorSnapshot(projection, best.start, best.end, contextLength),
|
||||
projection,
|
||||
reason: "ambiguous",
|
||||
};
|
||||
}
|
||||
return {
|
||||
anchorState: "active",
|
||||
confidence: exactCandidates.length === 1 ? "exact" : "duplicate",
|
||||
anchor: buildAnchorSnapshot(projection, best.start, best.end, contextLength),
|
||||
projection,
|
||||
reason: exactCandidates.length === 1 ? "exact" : "duplicate",
|
||||
};
|
||||
}
|
||||
|
||||
const fuzzy = findFuzzyCandidate(projection, input.previousAnchor, contextLength);
|
||||
if (fuzzy && fuzzy.score >= 0.58) {
|
||||
return {
|
||||
anchorState: "stale",
|
||||
confidence: "fuzzy",
|
||||
anchor: buildAnchorSnapshot(projection, fuzzy.start, fuzzy.end, contextLength),
|
||||
projection,
|
||||
reason: "fuzzy",
|
||||
};
|
||||
}
|
||||
|
||||
return { anchorState: "orphaned", confidence: "missing", anchor: null, projection, reason: "missing" };
|
||||
}
|
||||
|
||||
function stripBlockSyntax(line: string, absoluteOffset: number): { text: string; sourceOffset: number } {
|
||||
const blockMatch = line.match(/^\s{0,3}(?:(#{1,6})\s+|(?:[-+*]|\d+[.)])\s+|>\s?)/);
|
||||
if (!blockMatch) return { text: line, sourceOffset: absoluteOffset };
|
||||
return { text: line.slice(blockMatch[0].length), sourceOffset: absoluteOffset + blockMatch[0].length };
|
||||
}
|
||||
|
||||
function addInlineMarkdownText(builder: ProjectionBuilder, text: string, sourceOffset: number): void {
|
||||
for (let index = 0; index < text.length; index += 1) {
|
||||
const char = text[index] ?? "";
|
||||
const absolute = sourceOffset + index;
|
||||
const rest = text.slice(index);
|
||||
|
||||
const image = rest.match(/^!\[([^\]]*)\]\(([^)]*)\)/);
|
||||
if (image) {
|
||||
const altStart = absolute + 2;
|
||||
builder.addText(image[1] ?? "", altStart);
|
||||
index += image[0].length - 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
const link = rest.match(/^\[([^\]]+)\]\(([^)]*)\)/);
|
||||
if (link) {
|
||||
const labelStart = absolute + 1;
|
||||
builder.addText(link[1] ?? "", labelStart);
|
||||
index += link[0].length - 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (char === "`") {
|
||||
const closing = text.indexOf("`", index + 1);
|
||||
if (closing > index + 1) {
|
||||
builder.addText(text.slice(index + 1, closing), absolute + 1);
|
||||
index = closing;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (char === "|" || char === "\t") {
|
||||
builder.addSeparator(absolute);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isMarkdownFormattingChar(char, text, index)) continue;
|
||||
|
||||
builder.addChar(char, absolute, absolute + 1);
|
||||
}
|
||||
}
|
||||
|
||||
function isMarkdownFormattingChar(char: string, text: string, index: number): boolean {
|
||||
if (char === "*" || char === "_" || char === "~") return true;
|
||||
if (char === "\\" && index + 1 < text.length) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function findOccurrences(text: string, quote: string): number[] {
|
||||
const starts: number[] = [];
|
||||
let start = text.indexOf(quote);
|
||||
while (start !== -1) {
|
||||
starts.push(start);
|
||||
start = text.indexOf(quote, start + 1);
|
||||
}
|
||||
return starts;
|
||||
}
|
||||
|
||||
function scoreCandidate(args: {
|
||||
projection: DocumentTextProjection;
|
||||
start: number;
|
||||
end: number;
|
||||
previousAnchor: DocumentAnnotationAnchorSnapshot;
|
||||
reason: Candidate["reason"];
|
||||
contextLength: number;
|
||||
}): Candidate {
|
||||
const before = args.projection.text.slice(Math.max(0, args.start - args.contextLength), args.start);
|
||||
const after = args.projection.text.slice(args.end, args.end + args.contextLength);
|
||||
const prefixScore = suffixOverlapScore(args.previousAnchor.prefixText, before);
|
||||
const suffixScore = prefixOverlapScore(args.previousAnchor.suffixText, after);
|
||||
const distance = Math.abs(args.start - args.previousAnchor.normalizedStart);
|
||||
const proximity = 1 / (1 + distance / 200);
|
||||
return {
|
||||
start: args.start,
|
||||
end: args.end,
|
||||
score: prefixScore * 0.35 + suffixScore * 0.35 + proximity * 0.3,
|
||||
reason: args.reason,
|
||||
};
|
||||
}
|
||||
|
||||
function findFuzzyCandidate(
|
||||
projection: DocumentTextProjection,
|
||||
previousAnchor: DocumentAnnotationAnchorSnapshot,
|
||||
contextLength: number,
|
||||
): Candidate | null {
|
||||
const words = normalizeAnchorText(previousAnchor.selectedText).split(" ").filter(Boolean);
|
||||
if (words.length === 0) return null;
|
||||
const textWords = [...projection.text.matchAll(/\S+/g)].map((match) => ({
|
||||
text: match[0],
|
||||
start: match.index ?? 0,
|
||||
end: (match.index ?? 0) + match[0].length,
|
||||
}));
|
||||
const windowSizes = new Set([words.length - 1, words.length, words.length + 1, words.length + 2].filter((n) => n > 0));
|
||||
let best: Candidate | null = null;
|
||||
|
||||
for (const size of windowSizes) {
|
||||
for (let index = 0; index + size <= textWords.length; index += 1) {
|
||||
const window = textWords.slice(index, index + size);
|
||||
const candidateText = window.map((word) => word.text).join(" ");
|
||||
const similarity = similarityScore(normalizeAnchorText(previousAnchor.selectedText), candidateText);
|
||||
if (similarity < 0.45) continue;
|
||||
const scored = scoreCandidate({
|
||||
projection,
|
||||
start: window[0]?.start ?? 0,
|
||||
end: window[window.length - 1]?.end ?? 0,
|
||||
previousAnchor,
|
||||
reason: "fuzzy",
|
||||
contextLength,
|
||||
});
|
||||
scored.score = scored.score * 0.35 + similarity * 0.65;
|
||||
if (!best || scored.score > best.score) best = scored;
|
||||
}
|
||||
}
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
function buildAnchorSnapshot(
|
||||
projection: DocumentTextProjection,
|
||||
normalizedStart: number,
|
||||
normalizedEnd: number,
|
||||
contextLength: number,
|
||||
): DocumentAnnotationAnchorSnapshot {
|
||||
const range = resolveProjectionRange(projection, normalizedStart, normalizedEnd);
|
||||
if (!range) {
|
||||
return {
|
||||
selectedText: "",
|
||||
prefixText: "",
|
||||
suffixText: "",
|
||||
normalizedStart,
|
||||
normalizedEnd,
|
||||
markdownStart: 0,
|
||||
markdownEnd: 0,
|
||||
};
|
||||
}
|
||||
const selector = createDocumentAnchorSelector(projection, range, { contextLength });
|
||||
return selectorToAnchorSnapshot(selector);
|
||||
}
|
||||
|
||||
function prefixOverlapScore(expectedPrefix: string, actualPrefix: string): number {
|
||||
const expected = normalizeAnchorText(expectedPrefix);
|
||||
const actual = normalizeAnchorText(actualPrefix);
|
||||
if (!expected) return 0.5;
|
||||
for (let size = Math.min(expected.length, actual.length); size > 0; size -= 1) {
|
||||
if (expected.slice(0, size) === actual.slice(0, size)) return size / expected.length;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function suffixOverlapScore(expectedPrefix: string, actualPrefix: string): number {
|
||||
const expected = normalizeAnchorText(expectedPrefix);
|
||||
const actual = normalizeAnchorText(actualPrefix);
|
||||
if (!expected) return 0.5;
|
||||
for (let size = Math.min(expected.length, actual.length); size > 0; size -= 1) {
|
||||
if (expected.slice(-size) === actual.slice(-size)) return size / expected.length;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function similarityScore(left: string, right: string): number {
|
||||
if (left === right) return 1;
|
||||
const leftWords = new Set(left.toLowerCase().split(/\s+/).filter(Boolean));
|
||||
const rightWords = new Set(right.toLowerCase().split(/\s+/).filter(Boolean));
|
||||
const intersection = [...leftWords].filter((word) => rightWords.has(word)).length;
|
||||
const union = new Set([...leftWords, ...rightWords]).size || 1;
|
||||
const jaccard = intersection / union;
|
||||
const lengthRatio = Math.min(left.length, right.length) / Math.max(left.length, right.length, 1);
|
||||
return jaccard * 0.75 + lengthRatio * 0.25;
|
||||
}
|
||||
|
||||
class ProjectionBuilder {
|
||||
private text = "";
|
||||
private positions: DocumentTextPosition[] = [];
|
||||
private pendingSpace: DocumentTextPosition | null = null;
|
||||
|
||||
constructor(private readonly source: string) {}
|
||||
|
||||
addText(text: string, sourceOffset: number): void {
|
||||
for (let index = 0; index < text.length; index += 1) {
|
||||
this.addChar(text[index] ?? "", sourceOffset + index, sourceOffset + index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
addSeparator(sourceOffset: number): void {
|
||||
this.addChar(" ", sourceOffset, sourceOffset + 1);
|
||||
}
|
||||
|
||||
addChar(char: string, sourceStart: number, sourceEnd: number): void {
|
||||
if (/\s/.test(char)) {
|
||||
if (this.text.length > 0 && !this.pendingSpace) {
|
||||
this.pendingSpace = { sourceStart, sourceEnd };
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.pendingSpace && this.text.length > 0) {
|
||||
this.text += " ";
|
||||
this.positions.push(this.pendingSpace);
|
||||
}
|
||||
this.pendingSpace = null;
|
||||
this.text += char;
|
||||
this.positions.push({ sourceStart, sourceEnd });
|
||||
}
|
||||
|
||||
toProjection(): DocumentTextProjection {
|
||||
return {
|
||||
source: this.source,
|
||||
text: this.text,
|
||||
positions: this.positions,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,9 @@ export {
|
||||
SYSTEM_ISSUE_DOCUMENT_KEYS,
|
||||
isSystemIssueDocumentKey,
|
||||
ISSUE_REFERENCE_SOURCE_KINDS,
|
||||
DOCUMENT_ANNOTATION_THREAD_STATUSES,
|
||||
DOCUMENT_ANNOTATION_ANCHOR_STATES,
|
||||
DOCUMENT_ANNOTATION_ANCHOR_CONFIDENCES,
|
||||
ISSUE_EXECUTION_POLICY_MODES,
|
||||
ISSUE_EXECUTION_STAGE_TYPES,
|
||||
ISSUE_MONITOR_SCHEDULED_BY,
|
||||
@@ -164,6 +167,9 @@ export {
|
||||
type IssueTreeHoldStatus,
|
||||
type SystemIssueDocumentKey,
|
||||
type IssueReferenceSourceKind,
|
||||
type DocumentAnnotationThreadStatus,
|
||||
type DocumentAnnotationAnchorState,
|
||||
type DocumentAnnotationAnchorConfidence,
|
||||
type IssueExecutionPolicyMode,
|
||||
type IssueExecutionStageType,
|
||||
type IssueMonitorScheduledBy,
|
||||
@@ -290,6 +296,13 @@ export type {
|
||||
CompanySkillUsageAgent,
|
||||
CompanySkillDetail,
|
||||
CompanySkillUpdateStatus,
|
||||
CompanySkillAuditSeverity,
|
||||
CompanySkillAuditVerdict,
|
||||
CompanySkillUpdateHoldReason,
|
||||
CompanySkillAuditFinding,
|
||||
CompanySkillAuditResult,
|
||||
CompanySkillInstallUpdateRequest,
|
||||
CompanySkillResetRequest,
|
||||
CompanySkillImportRequest,
|
||||
CompanySkillImportResult,
|
||||
CompanySkillProjectScanRequest,
|
||||
@@ -299,6 +312,14 @@ export type {
|
||||
CompanySkillCreateRequest,
|
||||
CompanySkillFileDetail,
|
||||
CompanySkillFileUpdateRequest,
|
||||
CatalogSkillKind,
|
||||
CatalogSkillFileKind,
|
||||
CatalogSkillFile,
|
||||
CatalogSkill,
|
||||
CatalogSkillListQuery,
|
||||
CatalogSkillFileDetail,
|
||||
CompanySkillInstallCatalogRequest,
|
||||
CompanySkillInstallCatalogResult,
|
||||
AgentSkillSyncMode,
|
||||
AgentSkillState,
|
||||
AgentSkillOrigin,
|
||||
@@ -376,6 +397,20 @@ export type {
|
||||
IssueWorkProductProvider,
|
||||
IssueWorkProductStatus,
|
||||
IssueWorkProductReviewState,
|
||||
CreateDocumentAnnotationCommentRequest,
|
||||
CreateDocumentAnnotationThreadRequest,
|
||||
DocumentAnnotationAnchorRemapSnapshot,
|
||||
DocumentAnnotationAnchorSelector,
|
||||
DocumentAnnotationAnchorSnapshot,
|
||||
DocumentAnnotationComment,
|
||||
DocumentAnnotationTextPositionSelector,
|
||||
DocumentAnnotationTextQuoteSelector,
|
||||
DocumentAnnotationThread,
|
||||
DocumentAnnotationThreadWithComments,
|
||||
DocumentTextPosition,
|
||||
DocumentTextProjection,
|
||||
DocumentTextRange,
|
||||
UpdateDocumentAnnotationThreadRequest,
|
||||
Issue,
|
||||
IssueAssigneeAdapterOverrides,
|
||||
IssueBlockerAttention,
|
||||
@@ -438,6 +473,12 @@ export type {
|
||||
RequestConfirmationTarget,
|
||||
RequestConfirmationPayload,
|
||||
RequestConfirmationResult,
|
||||
AcceptedPlanDecompositionStatus,
|
||||
AcceptedPlanDecompositionChild,
|
||||
AcceptedPlanDecomposition,
|
||||
AcceptedPlanDecompositionResult,
|
||||
AcceptedPlanDecompositionChildIssue,
|
||||
AcceptedPlanDecompositionSummary,
|
||||
IssueThreadInteractionBase,
|
||||
SuggestTasksInteraction,
|
||||
AskUserQuestionsInteraction,
|
||||
@@ -655,6 +696,22 @@ export {
|
||||
type IssueReferenceMatch,
|
||||
} from "./issue-references.js";
|
||||
|
||||
export {
|
||||
anchorSnapshotToSelector,
|
||||
createDocumentAnchorSelector,
|
||||
normalizeAnchorText,
|
||||
projectMarkdownToText,
|
||||
remapDocumentAnchor,
|
||||
resolveProjectionRange,
|
||||
selectorToAnchorSnapshot,
|
||||
verifyDocumentAnchorSelector,
|
||||
type CreateDocumentAnchorSelectorOptions,
|
||||
type RemapDocumentAnchorInput,
|
||||
type RemapDocumentAnchorResult,
|
||||
type VerifyDocumentAnchorSelectorInput,
|
||||
type VerifyDocumentAnchorSelectorResult,
|
||||
} from "./document-anchors.js";
|
||||
|
||||
export {
|
||||
sidebarOrderPreferenceSchema,
|
||||
upsertSidebarOrderPreferenceSchema,
|
||||
@@ -796,6 +853,18 @@ export {
|
||||
type CreateProjectWorkspace,
|
||||
type UpdateProjectWorkspace,
|
||||
projectExecutionWorkspacePolicySchema,
|
||||
createDocumentAnnotationCommentSchema,
|
||||
createDocumentAnnotationThreadSchema,
|
||||
documentAnnotationAnchorConfidenceSchema,
|
||||
documentAnnotationAnchorSelectorSchema,
|
||||
documentAnnotationAnchorStateSchema,
|
||||
documentAnnotationTextPositionSelectorSchema,
|
||||
documentAnnotationTextQuoteSelectorSchema,
|
||||
documentAnnotationThreadStatusSchema,
|
||||
updateDocumentAnnotationThreadSchema,
|
||||
type CreateDocumentAnnotationComment,
|
||||
type CreateDocumentAnnotationThread,
|
||||
type UpdateDocumentAnnotationThread,
|
||||
companySearchQuerySchema,
|
||||
COMPANY_SEARCH_DEFAULT_LIMIT,
|
||||
COMPANY_SEARCH_MAX_LIMIT,
|
||||
@@ -806,6 +875,7 @@ export {
|
||||
createIssueSchema,
|
||||
createIssueInputSchema,
|
||||
createChildIssueSchema,
|
||||
createAcceptedPlanDecompositionSchema,
|
||||
resolveCreateIssueStatusDefault,
|
||||
createIssueLabelSchema,
|
||||
issueBlockedInboxAttentionSchema,
|
||||
@@ -874,6 +944,7 @@ export {
|
||||
releaseIssueTreeHoldSchema,
|
||||
type CreateIssue,
|
||||
type CreateChildIssue,
|
||||
type CreateAcceptedPlanDecomposition,
|
||||
type CreateIssueLabel,
|
||||
type UpdateIssue,
|
||||
type ResolveIssueRecoveryAction,
|
||||
@@ -1013,6 +1084,8 @@ export {
|
||||
companySkillUsageAgentSchema,
|
||||
companySkillDetailSchema,
|
||||
companySkillUpdateStatusSchema,
|
||||
companySkillAuditFindingSchema,
|
||||
companySkillAuditResultSchema,
|
||||
companySkillImportSchema,
|
||||
companySkillUpdateAuthSchema,
|
||||
companySkillProjectScanRequestSchema,
|
||||
@@ -1022,6 +1095,15 @@ export {
|
||||
companySkillCreateSchema,
|
||||
companySkillFileDetailSchema,
|
||||
companySkillFileUpdateSchema,
|
||||
catalogSkillKindSchema,
|
||||
catalogSkillFileSchema,
|
||||
catalogSkillSchema,
|
||||
catalogSkillListQuerySchema,
|
||||
catalogSkillFileDetailSchema,
|
||||
companySkillInstallCatalogSchema,
|
||||
companySkillInstallCatalogResultSchema,
|
||||
companySkillInstallUpdateSchema,
|
||||
companySkillResetSchema,
|
||||
portabilityIncludeSchema,
|
||||
portabilityEnvInputSchema,
|
||||
portabilityCompanyManifestEntrySchema,
|
||||
|
||||
@@ -51,6 +51,10 @@ export interface CompanySkillListItem {
|
||||
sourceLabel: string | null;
|
||||
sourceBadge: CompanySkillSourceBadge;
|
||||
sourcePath: string | null;
|
||||
catalogKind: "bundled" | "optional" | null;
|
||||
originHash: string | null;
|
||||
packageName: string | null;
|
||||
packageVersion: string | null;
|
||||
}
|
||||
|
||||
export interface CompanySkillUsageAgent {
|
||||
@@ -84,6 +88,49 @@ export interface CompanySkillUpdateStatus {
|
||||
currentRef: string | null;
|
||||
latestRef: string | null;
|
||||
hasUpdate: boolean;
|
||||
installedHash: string | null;
|
||||
originHash: string | null;
|
||||
userModifiedAt: string | null;
|
||||
updateHoldReason: CompanySkillUpdateHoldReason | null;
|
||||
auditVerdict: CompanySkillAuditVerdict | null;
|
||||
auditCodes: string[];
|
||||
}
|
||||
|
||||
export type CompanySkillAuditSeverity = "warning" | "error";
|
||||
|
||||
export type CompanySkillAuditVerdict = "pass" | "warning" | "fail";
|
||||
|
||||
export type CompanySkillUpdateHoldReason =
|
||||
| "local_modifications"
|
||||
| "audit_hard_stop"
|
||||
| "origin_unavailable"
|
||||
| "compatibility_invalid"
|
||||
| "operator_hold";
|
||||
|
||||
export interface CompanySkillAuditFinding {
|
||||
code: string;
|
||||
severity: CompanySkillAuditSeverity;
|
||||
message: string;
|
||||
path: string | null;
|
||||
}
|
||||
|
||||
export interface CompanySkillAuditResult {
|
||||
skillId: string;
|
||||
installedHash: string | null;
|
||||
originHash: string | null;
|
||||
verdict: CompanySkillAuditVerdict;
|
||||
codes: string[];
|
||||
findings: CompanySkillAuditFinding[];
|
||||
scannedAt: string;
|
||||
scanVersion: string;
|
||||
}
|
||||
|
||||
export interface CompanySkillInstallUpdateRequest {
|
||||
force?: boolean;
|
||||
}
|
||||
|
||||
export interface CompanySkillResetRequest {
|
||||
force?: boolean;
|
||||
}
|
||||
|
||||
export interface CompanySkillImportRequest {
|
||||
@@ -155,3 +202,64 @@ export interface CompanySkillFileUpdateRequest {
|
||||
path: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
export type CatalogSkillKind = "bundled" | "optional";
|
||||
|
||||
export type CatalogSkillFileKind = CompanySkillFileInventoryEntry["kind"];
|
||||
|
||||
export interface CatalogSkillFile {
|
||||
path: string;
|
||||
kind: CatalogSkillFileKind;
|
||||
sizeBytes: number;
|
||||
sha256: string;
|
||||
}
|
||||
|
||||
export interface CatalogSkill {
|
||||
id: string;
|
||||
key: string;
|
||||
kind: CatalogSkillKind;
|
||||
category: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
description: string;
|
||||
path: string;
|
||||
entrypoint: "SKILL.md";
|
||||
trustLevel: CompanySkillTrustLevel;
|
||||
compatibility: CompanySkillCompatibility;
|
||||
defaultInstall: boolean;
|
||||
recommendedForRoles: string[];
|
||||
requires: string[];
|
||||
tags: string[];
|
||||
files: CatalogSkillFile[];
|
||||
contentHash: string;
|
||||
packageName?: string;
|
||||
packageVersion?: string;
|
||||
}
|
||||
|
||||
export interface CatalogSkillListQuery {
|
||||
kind?: CatalogSkillKind;
|
||||
category?: string;
|
||||
q?: string;
|
||||
}
|
||||
|
||||
export interface CatalogSkillFileDetail {
|
||||
catalogSkillId: string;
|
||||
path: string;
|
||||
kind: CatalogSkillFileKind;
|
||||
content: string;
|
||||
language: string | null;
|
||||
markdown: boolean;
|
||||
}
|
||||
|
||||
export interface CompanySkillInstallCatalogRequest {
|
||||
catalogSkillId: string;
|
||||
slug?: string | null;
|
||||
force?: boolean;
|
||||
}
|
||||
|
||||
export interface CompanySkillInstallCatalogResult {
|
||||
action: "created" | "updated" | "unchanged";
|
||||
skill: CompanySkill;
|
||||
catalogSkill: CatalogSkill;
|
||||
warnings: string[];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
import type {
|
||||
DocumentAnnotationAnchorConfidence,
|
||||
DocumentAnnotationAnchorState,
|
||||
DocumentAnnotationThreadStatus,
|
||||
IssueCommentAuthorType,
|
||||
} from "../constants.js";
|
||||
|
||||
export interface DocumentTextPosition {
|
||||
sourceStart: number;
|
||||
sourceEnd: number;
|
||||
}
|
||||
|
||||
export interface DocumentTextProjection {
|
||||
source: string;
|
||||
text: string;
|
||||
positions: DocumentTextPosition[];
|
||||
}
|
||||
|
||||
export interface DocumentTextRange {
|
||||
text: string;
|
||||
normalizedStart: number;
|
||||
normalizedEnd: number;
|
||||
markdownStart: number;
|
||||
markdownEnd: number;
|
||||
}
|
||||
|
||||
export interface DocumentAnnotationTextQuoteSelector {
|
||||
exact: string;
|
||||
prefix: string;
|
||||
suffix: string;
|
||||
}
|
||||
|
||||
export interface DocumentAnnotationTextPositionSelector {
|
||||
normalizedStart: number;
|
||||
normalizedEnd: number;
|
||||
markdownStart: number;
|
||||
markdownEnd: number;
|
||||
}
|
||||
|
||||
export interface DocumentAnnotationAnchorSelector {
|
||||
quote: DocumentAnnotationTextQuoteSelector;
|
||||
position: DocumentAnnotationTextPositionSelector;
|
||||
}
|
||||
|
||||
export interface DocumentAnnotationAnchorSnapshot {
|
||||
selectedText: string;
|
||||
prefixText: string;
|
||||
suffixText: string;
|
||||
normalizedStart: number;
|
||||
normalizedEnd: number;
|
||||
markdownStart: number;
|
||||
markdownEnd: number;
|
||||
}
|
||||
|
||||
export interface DocumentAnnotationThread {
|
||||
id: string;
|
||||
companyId: string;
|
||||
issueId: string;
|
||||
documentId: string;
|
||||
documentKey: string;
|
||||
status: DocumentAnnotationThreadStatus;
|
||||
anchorState: DocumentAnnotationAnchorState;
|
||||
anchorConfidence: DocumentAnnotationAnchorConfidence;
|
||||
originalRevisionId: string | null;
|
||||
originalRevisionNumber: number;
|
||||
currentRevisionId: string | null;
|
||||
currentRevisionNumber: number;
|
||||
selectedText: string;
|
||||
prefixText: string;
|
||||
suffixText: string;
|
||||
normalizedStart: number;
|
||||
normalizedEnd: number;
|
||||
markdownStart: number;
|
||||
markdownEnd: number;
|
||||
anchorSelector: DocumentAnnotationAnchorSelector;
|
||||
createdByAgentId: string | null;
|
||||
createdByUserId: string | null;
|
||||
resolvedByAgentId: string | null;
|
||||
resolvedByUserId: string | null;
|
||||
resolvedAt: Date | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export interface DocumentAnnotationComment {
|
||||
id: string;
|
||||
companyId: string;
|
||||
threadId: string;
|
||||
issueId: string;
|
||||
documentId: string;
|
||||
body: string;
|
||||
authorType: IssueCommentAuthorType;
|
||||
authorAgentId: string | null;
|
||||
authorUserId: string | null;
|
||||
createdByRunId: string | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export interface DocumentAnnotationAnchorRemapSnapshot {
|
||||
id: string;
|
||||
companyId: string;
|
||||
threadId: string;
|
||||
documentId: string;
|
||||
fromRevisionId: string | null;
|
||||
fromRevisionNumber: number | null;
|
||||
toRevisionId: string | null;
|
||||
toRevisionNumber: number;
|
||||
previousAnchor: DocumentAnnotationAnchorSnapshot;
|
||||
nextAnchor: DocumentAnnotationAnchorSnapshot | null;
|
||||
anchorState: DocumentAnnotationAnchorState;
|
||||
anchorConfidence: DocumentAnnotationAnchorConfidence;
|
||||
failureReason: string | null;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface DocumentAnnotationThreadWithComments extends DocumentAnnotationThread {
|
||||
comments: DocumentAnnotationComment[];
|
||||
}
|
||||
|
||||
export interface CreateDocumentAnnotationThreadRequest {
|
||||
baseRevisionId: string;
|
||||
baseRevisionNumber: number;
|
||||
selector: DocumentAnnotationAnchorSelector;
|
||||
body: string;
|
||||
}
|
||||
|
||||
export interface CreateDocumentAnnotationCommentRequest {
|
||||
body: string;
|
||||
}
|
||||
|
||||
export interface UpdateDocumentAnnotationThreadRequest {
|
||||
status?: DocumentAnnotationThreadStatus;
|
||||
}
|
||||
@@ -51,6 +51,13 @@ export type {
|
||||
CompanySkillUsageAgent,
|
||||
CompanySkillDetail,
|
||||
CompanySkillUpdateStatus,
|
||||
CompanySkillAuditSeverity,
|
||||
CompanySkillAuditVerdict,
|
||||
CompanySkillUpdateHoldReason,
|
||||
CompanySkillAuditFinding,
|
||||
CompanySkillAuditResult,
|
||||
CompanySkillInstallUpdateRequest,
|
||||
CompanySkillResetRequest,
|
||||
CompanySkillImportRequest,
|
||||
CompanySkillImportResult,
|
||||
CompanySkillProjectScanRequest,
|
||||
@@ -60,6 +67,14 @@ export type {
|
||||
CompanySkillCreateRequest,
|
||||
CompanySkillFileDetail,
|
||||
CompanySkillFileUpdateRequest,
|
||||
CatalogSkillKind,
|
||||
CatalogSkillFileKind,
|
||||
CatalogSkillFile,
|
||||
CatalogSkill,
|
||||
CatalogSkillListQuery,
|
||||
CatalogSkillFileDetail,
|
||||
CompanySkillInstallCatalogRequest,
|
||||
CompanySkillInstallCatalogResult,
|
||||
} from "./company-skill.js";
|
||||
export type {
|
||||
AgentSkillSyncMode,
|
||||
@@ -89,6 +104,22 @@ export type {
|
||||
AdapterEnvironmentTestResult,
|
||||
} from "./agent.js";
|
||||
export type { AssetImage } from "./asset.js";
|
||||
export type {
|
||||
CreateDocumentAnnotationCommentRequest,
|
||||
CreateDocumentAnnotationThreadRequest,
|
||||
DocumentAnnotationAnchorRemapSnapshot,
|
||||
DocumentAnnotationAnchorSelector,
|
||||
DocumentAnnotationAnchorSnapshot,
|
||||
DocumentAnnotationComment,
|
||||
DocumentAnnotationTextPositionSelector,
|
||||
DocumentAnnotationTextQuoteSelector,
|
||||
DocumentAnnotationThread,
|
||||
DocumentAnnotationThreadWithComments,
|
||||
DocumentTextPosition,
|
||||
DocumentTextProjection,
|
||||
DocumentTextRange,
|
||||
UpdateDocumentAnnotationThreadRequest,
|
||||
} from "./document-annotation.js";
|
||||
export type { Project, ProjectCodebase, ProjectCodebaseOrigin, ProjectGoalRef, ProjectManagedByPlugin, ProjectWorkspace } from "./project.js";
|
||||
export type {
|
||||
CompanySearchHighlight,
|
||||
@@ -207,6 +238,12 @@ export type {
|
||||
RequestConfirmationTarget,
|
||||
RequestConfirmationPayload,
|
||||
RequestConfirmationResult,
|
||||
AcceptedPlanDecompositionStatus,
|
||||
AcceptedPlanDecompositionChild,
|
||||
AcceptedPlanDecomposition,
|
||||
AcceptedPlanDecompositionResult,
|
||||
AcceptedPlanDecompositionChildIssue,
|
||||
AcceptedPlanDecompositionSummary,
|
||||
IssueThreadInteractionBase,
|
||||
SuggestTasksInteraction,
|
||||
AskUserQuestionsInteraction,
|
||||
|
||||
@@ -29,6 +29,7 @@ export interface InstanceGeneralSettings {
|
||||
export interface InstanceExperimentalSettings {
|
||||
enableEnvironments: boolean;
|
||||
enableIsolatedWorkspaces: boolean;
|
||||
enableIssuePlanDecompositions: boolean;
|
||||
enableCloudSync: boolean;
|
||||
autoRestartDevServerWhenIdle: boolean;
|
||||
enableIssueGraphLivenessAutoRecovery: boolean;
|
||||
|
||||
@@ -129,6 +129,71 @@ export interface LegacyPlanDocument {
|
||||
source: "issue_description";
|
||||
}
|
||||
|
||||
export type AcceptedPlanDecompositionStatus = "in_flight" | "completed";
|
||||
|
||||
export interface AcceptedPlanDecompositionChild {
|
||||
projectId?: string | null;
|
||||
projectWorkspaceId?: string | null;
|
||||
goalId?: string | null;
|
||||
blockedByIssueIds?: string[];
|
||||
title: string;
|
||||
description?: string | null;
|
||||
status: IssueStatus;
|
||||
workMode: IssueWorkMode;
|
||||
priority: IssuePriority;
|
||||
assigneeAgentId?: string | null;
|
||||
assigneeUserId?: string | null;
|
||||
requestDepth?: number;
|
||||
billingCode?: string | null;
|
||||
assigneeAdapterOverrides?: IssueAssigneeAdapterOverrides | null;
|
||||
executionPolicy?: IssueExecutionPolicy | null;
|
||||
executionWorkspaceId?: string | null;
|
||||
executionWorkspacePreference?: string | null;
|
||||
executionWorkspaceSettings?: IssueExecutionWorkspaceSettings | null;
|
||||
labelIds?: string[];
|
||||
acceptanceCriteria?: string[];
|
||||
blockParentUntilDone?: boolean;
|
||||
}
|
||||
|
||||
export interface AcceptedPlanDecomposition {
|
||||
id: string;
|
||||
companyId: string;
|
||||
sourceIssueId: string;
|
||||
acceptedPlanRevisionId: string;
|
||||
acceptedInteractionId: string | null;
|
||||
status: AcceptedPlanDecompositionStatus;
|
||||
requestFingerprint: string;
|
||||
requestedChildCount: number;
|
||||
childIssueIds: string[];
|
||||
ownerAgentId: string | null;
|
||||
ownerUserId: string | null;
|
||||
ownerRunId: string | null;
|
||||
completedAt: Date | string | null;
|
||||
createdAt: Date | string;
|
||||
updatedAt: Date | string;
|
||||
}
|
||||
|
||||
export interface AcceptedPlanDecompositionResult {
|
||||
decomposition: AcceptedPlanDecomposition;
|
||||
childIssueIds: string[];
|
||||
newlyCreatedChildIssueIds: string[];
|
||||
}
|
||||
|
||||
export interface AcceptedPlanDecompositionChildIssue {
|
||||
id: string;
|
||||
identifier: string | null;
|
||||
title: string;
|
||||
status: IssueStatus;
|
||||
priority: IssuePriority;
|
||||
assigneeAgentId: string | null;
|
||||
assigneeUserId: string | null;
|
||||
}
|
||||
|
||||
export interface AcceptedPlanDecompositionSummary extends AcceptedPlanDecomposition {
|
||||
acceptedPlanRevisionNumber: number | null;
|
||||
childIssues: AcceptedPlanDecompositionChildIssue[];
|
||||
}
|
||||
|
||||
export interface IssueRelationIssueSummary {
|
||||
id: string;
|
||||
identifier: string | null;
|
||||
|
||||
@@ -38,8 +38,24 @@ import type { Routine, RoutineTrigger, RoutineVariable } from "./routine.js";
|
||||
/**
|
||||
* A JSON Schema object used for plugin config schemas and tool parameter schemas.
|
||||
* Plugins provide these as plain JSON Schema compatible objects.
|
||||
*
|
||||
* The Paperclip extension keywords below are recognised by the Paperclip UI
|
||||
* but are otherwise ignored by standard JSON Schema validators.
|
||||
*/
|
||||
export type JsonSchema = Record<string, unknown>;
|
||||
export type JsonSchema = {
|
||||
/**
|
||||
* When true, the Paperclip config UI hides this property behind an
|
||||
* "Advanced options" disclosure. Defaults to false (always visible).
|
||||
*/
|
||||
"x-paperclip-advanced"?: boolean;
|
||||
/**
|
||||
* Optional sub-section heading used to group advanced properties inside
|
||||
* the disclosure (e.g. "SSH access", "VM resources"). Ignored when
|
||||
* `x-paperclip-advanced` is not true.
|
||||
*/
|
||||
"x-paperclip-group"?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
export type {
|
||||
PluginDatabaseCoreReadTable,
|
||||
|
||||
@@ -2,7 +2,8 @@ export type WorkspaceOperationPhase =
|
||||
| "worktree_prepare"
|
||||
| "workspace_provision"
|
||||
| "workspace_teardown"
|
||||
| "worktree_cleanup";
|
||||
| "worktree_cleanup"
|
||||
| "workspace_finalize";
|
||||
|
||||
export type WorkspaceOperationStatus = "running" | "succeeded" | "failed" | "skipped";
|
||||
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
catalogSkillFileDetailSchema,
|
||||
catalogSkillListQuerySchema,
|
||||
companySkillAuditResultSchema,
|
||||
companySkillInstallCatalogResultSchema,
|
||||
companySkillInstallCatalogSchema,
|
||||
companySkillInstallUpdateSchema,
|
||||
companySkillResetSchema,
|
||||
companySkillUpdateStatusSchema,
|
||||
} from "./company-skill.js";
|
||||
|
||||
const catalogSkill = {
|
||||
id: "paperclipai:bundled:software-development:review",
|
||||
key: "paperclipai/bundled/software-development/review",
|
||||
kind: "bundled",
|
||||
category: "software-development",
|
||||
slug: "review",
|
||||
name: "review",
|
||||
description: "Review code",
|
||||
path: "catalog/bundled/software-development/review",
|
||||
entrypoint: "SKILL.md",
|
||||
trustLevel: "markdown_only",
|
||||
compatibility: "compatible",
|
||||
defaultInstall: false,
|
||||
recommendedForRoles: ["engineer"],
|
||||
requires: [],
|
||||
tags: ["review"],
|
||||
files: [{ path: "SKILL.md", kind: "skill", sizeBytes: 8, sha256: "abc" }],
|
||||
contentHash: "sha256:abc",
|
||||
};
|
||||
|
||||
const companySkill = {
|
||||
id: "00000000-0000-4000-8000-000000000001",
|
||||
companyId: "00000000-0000-4000-8000-000000000002",
|
||||
key: catalogSkill.key,
|
||||
slug: catalogSkill.slug,
|
||||
name: catalogSkill.name,
|
||||
description: catalogSkill.description,
|
||||
markdown: "# Review\n",
|
||||
sourceType: "catalog",
|
||||
sourceLocator: "/tmp/review",
|
||||
sourceRef: catalogSkill.contentHash,
|
||||
trustLevel: "markdown_only",
|
||||
compatibility: "compatible",
|
||||
fileInventory: [{ path: "SKILL.md", kind: "skill" }],
|
||||
metadata: {
|
||||
sourceKind: "catalog",
|
||||
catalogId: catalogSkill.id,
|
||||
originHash: catalogSkill.contentHash,
|
||||
},
|
||||
createdAt: "2026-05-26T00:00:00.000Z",
|
||||
updatedAt: "2026-05-26T00:00:00.000Z",
|
||||
};
|
||||
|
||||
describe("company skill catalog validators", () => {
|
||||
it("accepts catalog list and install request shapes", () => {
|
||||
expect(catalogSkillListQuerySchema.parse({
|
||||
kind: "bundled",
|
||||
category: "software-development",
|
||||
q: "review",
|
||||
})).toEqual({
|
||||
kind: "bundled",
|
||||
category: "software-development",
|
||||
q: "review",
|
||||
});
|
||||
|
||||
expect(companySkillInstallCatalogSchema.parse({
|
||||
catalogSkillId: catalogSkill.id,
|
||||
slug: "team-review",
|
||||
force: true,
|
||||
})).toEqual({
|
||||
catalogSkillId: catalogSkill.id,
|
||||
slug: "team-review",
|
||||
force: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects invalid catalog filter and install payloads", () => {
|
||||
expect(() => catalogSkillListQuerySchema.parse({ kind: "external" })).toThrow();
|
||||
expect(() => companySkillInstallCatalogSchema.parse({ force: true })).toThrow();
|
||||
});
|
||||
|
||||
it("accepts catalog file and install result responses", () => {
|
||||
expect(catalogSkillFileDetailSchema.parse({
|
||||
catalogSkillId: catalogSkill.id,
|
||||
path: "SKILL.md",
|
||||
kind: "skill",
|
||||
content: "# Review\n",
|
||||
language: "markdown",
|
||||
markdown: true,
|
||||
})).toMatchObject({
|
||||
catalogSkillId: catalogSkill.id,
|
||||
path: "SKILL.md",
|
||||
});
|
||||
|
||||
expect(companySkillInstallCatalogResultSchema.parse({
|
||||
action: "created",
|
||||
skill: companySkill,
|
||||
catalogSkill,
|
||||
warnings: [],
|
||||
})).toMatchObject({
|
||||
action: "created",
|
||||
skill: {
|
||||
key: catalogSkill.key,
|
||||
sourceType: "catalog",
|
||||
},
|
||||
catalogSkill: {
|
||||
id: catalogSkill.id,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("accepts update status, audit, update, and reset contract shapes", () => {
|
||||
expect(companySkillUpdateStatusSchema.parse({
|
||||
supported: true,
|
||||
reason: null,
|
||||
trackingRef: catalogSkill.id,
|
||||
currentRef: "sha256:old",
|
||||
latestRef: catalogSkill.contentHash,
|
||||
hasUpdate: true,
|
||||
installedHash: "sha256:installed",
|
||||
originHash: catalogSkill.contentHash,
|
||||
userModifiedAt: "2026-05-26T00:00:00.000Z",
|
||||
updateHoldReason: "local_modifications",
|
||||
auditVerdict: "warning",
|
||||
auditCodes: ["local_modifications"],
|
||||
})).toMatchObject({
|
||||
supported: true,
|
||||
updateHoldReason: "local_modifications",
|
||||
auditVerdict: "warning",
|
||||
});
|
||||
|
||||
expect(companySkillAuditResultSchema.parse({
|
||||
skillId: companySkill.id,
|
||||
installedHash: "sha256:installed",
|
||||
originHash: catalogSkill.contentHash,
|
||||
verdict: "fail",
|
||||
codes: ["remote_fetch_exec"],
|
||||
findings: [{
|
||||
code: "remote_fetch_exec",
|
||||
severity: "error",
|
||||
message: "Remote-fetch or dynamic execution pattern is not allowed.",
|
||||
path: "SKILL.md",
|
||||
}],
|
||||
scannedAt: "2026-05-26T00:00:00.000Z",
|
||||
scanVersion: "skills-audit-v1",
|
||||
})).toMatchObject({
|
||||
verdict: "fail",
|
||||
codes: ["remote_fetch_exec"],
|
||||
});
|
||||
|
||||
expect(companySkillInstallUpdateSchema.parse(undefined)).toEqual({});
|
||||
expect(companySkillInstallUpdateSchema.parse({ force: true })).toEqual({ force: true });
|
||||
expect(companySkillResetSchema.parse(undefined)).toEqual({});
|
||||
expect(companySkillResetSchema.parse({ force: true })).toEqual({ force: true });
|
||||
});
|
||||
});
|
||||
@@ -35,6 +35,10 @@ export const companySkillListItemSchema = companySkillSchema.extend({
|
||||
editableReason: z.string().nullable(),
|
||||
sourceLabel: z.string().nullable(),
|
||||
sourceBadge: companySkillSourceBadgeSchema,
|
||||
catalogKind: z.enum(["bundled", "optional"]).nullable(),
|
||||
originHash: z.string().nullable(),
|
||||
packageName: z.string().nullable(),
|
||||
packageVersion: z.string().nullable(),
|
||||
});
|
||||
|
||||
export const companySkillUsageAgentSchema = z.object({
|
||||
@@ -64,15 +68,48 @@ export const companySkillUpdateStatusSchema = z.object({
|
||||
currentRef: z.string().nullable(),
|
||||
latestRef: z.string().nullable(),
|
||||
hasUpdate: z.boolean(),
|
||||
installedHash: z.string().nullable(),
|
||||
originHash: z.string().nullable(),
|
||||
userModifiedAt: z.string().nullable(),
|
||||
updateHoldReason: z.enum([
|
||||
"local_modifications",
|
||||
"audit_hard_stop",
|
||||
"origin_unavailable",
|
||||
"compatibility_invalid",
|
||||
"operator_hold",
|
||||
]).nullable(),
|
||||
auditVerdict: z.enum(["pass", "warning", "fail"]).nullable(),
|
||||
auditCodes: z.array(z.string()),
|
||||
});
|
||||
|
||||
export const companySkillAuditFindingSchema = z.object({
|
||||
code: z.string().min(1),
|
||||
severity: z.enum(["warning", "error"]),
|
||||
message: z.string().min(1),
|
||||
path: z.string().nullable(),
|
||||
});
|
||||
|
||||
export const companySkillAuditResultSchema = z.object({
|
||||
skillId: z.string().uuid(),
|
||||
installedHash: z.string().nullable(),
|
||||
originHash: z.string().nullable(),
|
||||
verdict: z.enum(["pass", "warning", "fail"]),
|
||||
codes: z.array(z.string()),
|
||||
findings: z.array(companySkillAuditFindingSchema),
|
||||
scannedAt: z.string().min(1),
|
||||
scanVersion: z.string().min(1),
|
||||
});
|
||||
|
||||
export const companySkillInstallUpdateSchema = z.object({
|
||||
force: z.boolean().optional(),
|
||||
}).default({});
|
||||
|
||||
export const companySkillResetSchema = z.object({
|
||||
force: z.boolean().optional(),
|
||||
}).default({});
|
||||
|
||||
export const companySkillImportSchema = z.object({
|
||||
source: z.string().min(1),
|
||||
authToken: z.string().min(1).optional(),
|
||||
});
|
||||
|
||||
export const companySkillUpdateAuthSchema = z.object({
|
||||
authToken: z.string().min(1).nullable(),
|
||||
});
|
||||
|
||||
export const companySkillProjectScanRequestSchema = z.object({
|
||||
@@ -136,8 +173,70 @@ export const companySkillFileUpdateSchema = z.object({
|
||||
content: z.string(),
|
||||
});
|
||||
|
||||
export const catalogSkillKindSchema = z.enum(["bundled", "optional"]);
|
||||
|
||||
export const catalogSkillFileSchema = z.object({
|
||||
path: z.string().min(1),
|
||||
kind: z.enum(["skill", "markdown", "reference", "script", "asset", "other"]),
|
||||
sizeBytes: z.number().int().nonnegative(),
|
||||
sha256: z.string().min(1),
|
||||
});
|
||||
|
||||
export const catalogSkillSchema = z.object({
|
||||
id: z.string().min(1),
|
||||
key: z.string().min(1),
|
||||
kind: catalogSkillKindSchema,
|
||||
category: z.string().min(1),
|
||||
slug: z.string().min(1),
|
||||
name: z.string().min(1),
|
||||
description: z.string(),
|
||||
path: z.string().min(1),
|
||||
entrypoint: z.literal("SKILL.md"),
|
||||
trustLevel: companySkillTrustLevelSchema,
|
||||
compatibility: companySkillCompatibilitySchema,
|
||||
defaultInstall: z.boolean(),
|
||||
recommendedForRoles: z.array(z.string()),
|
||||
requires: z.array(z.string()),
|
||||
tags: z.array(z.string()),
|
||||
files: z.array(catalogSkillFileSchema),
|
||||
contentHash: z.string().min(1),
|
||||
packageName: z.string().min(1).optional(),
|
||||
packageVersion: z.string().min(1).optional(),
|
||||
});
|
||||
|
||||
export const catalogSkillListQuerySchema = z.object({
|
||||
kind: catalogSkillKindSchema.optional(),
|
||||
category: z.string().min(1).optional(),
|
||||
q: z.string().min(1).optional(),
|
||||
});
|
||||
|
||||
export const catalogSkillFileDetailSchema = z.object({
|
||||
catalogSkillId: z.string().min(1),
|
||||
path: z.string().min(1),
|
||||
kind: z.enum(["skill", "markdown", "reference", "script", "asset", "other"]),
|
||||
content: z.string(),
|
||||
language: z.string().nullable(),
|
||||
markdown: z.boolean(),
|
||||
});
|
||||
|
||||
export const companySkillInstallCatalogSchema = z.object({
|
||||
catalogSkillId: z.string().min(1),
|
||||
slug: z.string().min(1).nullable().optional(),
|
||||
force: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const companySkillInstallCatalogResultSchema = z.object({
|
||||
action: z.enum(["created", "updated", "unchanged"]),
|
||||
skill: companySkillSchema,
|
||||
catalogSkill: catalogSkillSchema,
|
||||
warnings: z.array(z.string()),
|
||||
});
|
||||
|
||||
export type CompanySkillImport = z.infer<typeof companySkillImportSchema>;
|
||||
export type CompanySkillProjectScan = z.infer<typeof companySkillProjectScanRequestSchema>;
|
||||
export type CompanySkillCreate = z.infer<typeof companySkillCreateSchema>;
|
||||
export type CompanySkillFileUpdate = z.infer<typeof companySkillFileUpdateSchema>;
|
||||
export type CompanySkillUpdateAuth = z.infer<typeof companySkillUpdateAuthSchema>;
|
||||
export type CatalogSkillListQuery = z.infer<typeof catalogSkillListQuerySchema>;
|
||||
export type CompanySkillInstallCatalog = z.infer<typeof companySkillInstallCatalogSchema>;
|
||||
export type CompanySkillInstallUpdate = z.infer<typeof companySkillInstallUpdateSchema>;
|
||||
export type CompanySkillReset = z.infer<typeof companySkillResetSchema>;
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import { z } from "zod";
|
||||
import {
|
||||
DOCUMENT_ANNOTATION_ANCHOR_CONFIDENCES,
|
||||
DOCUMENT_ANNOTATION_ANCHOR_STATES,
|
||||
DOCUMENT_ANNOTATION_THREAD_STATUSES,
|
||||
} from "../constants.js";
|
||||
import { multilineTextSchema } from "./text.js";
|
||||
|
||||
export const documentAnnotationThreadStatusSchema = z.enum(DOCUMENT_ANNOTATION_THREAD_STATUSES);
|
||||
export const documentAnnotationAnchorStateSchema = z.enum(DOCUMENT_ANNOTATION_ANCHOR_STATES);
|
||||
export const documentAnnotationAnchorConfidenceSchema = z.enum(DOCUMENT_ANNOTATION_ANCHOR_CONFIDENCES);
|
||||
|
||||
export const documentAnnotationTextQuoteSelectorSchema = z.object({
|
||||
exact: z.string().min(1).max(10_000),
|
||||
prefix: z.string().max(1_000).default(""),
|
||||
suffix: z.string().max(1_000).default(""),
|
||||
}).strict();
|
||||
|
||||
export const documentAnnotationTextPositionSelectorSchema = z.object({
|
||||
normalizedStart: z.number().int().nonnegative(),
|
||||
normalizedEnd: z.number().int().nonnegative(),
|
||||
markdownStart: z.number().int().nonnegative(),
|
||||
markdownEnd: z.number().int().nonnegative(),
|
||||
}).strict().superRefine((value, ctx) => {
|
||||
if (value.normalizedEnd <= value.normalizedStart) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "normalizedEnd must be greater than normalizedStart",
|
||||
path: ["normalizedEnd"],
|
||||
});
|
||||
}
|
||||
if (value.markdownEnd <= value.markdownStart) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "markdownEnd must be greater than markdownStart",
|
||||
path: ["markdownEnd"],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export const documentAnnotationAnchorSelectorSchema = z.object({
|
||||
quote: documentAnnotationTextQuoteSelectorSchema,
|
||||
position: documentAnnotationTextPositionSelectorSchema,
|
||||
}).strict();
|
||||
|
||||
export const createDocumentAnnotationThreadSchema = z.object({
|
||||
baseRevisionId: z.string().uuid(),
|
||||
baseRevisionNumber: z.number().int().positive(),
|
||||
selector: documentAnnotationAnchorSelectorSchema,
|
||||
body: multilineTextSchema.pipe(z.string().min(1).max(20_000)),
|
||||
}).strict();
|
||||
|
||||
export const createDocumentAnnotationCommentSchema = z.object({
|
||||
body: multilineTextSchema.pipe(z.string().min(1).max(20_000)),
|
||||
}).strict();
|
||||
|
||||
export const updateDocumentAnnotationThreadSchema = z.object({
|
||||
status: documentAnnotationThreadStatusSchema.optional(),
|
||||
}).strict().refine((value) => value.status != null, {
|
||||
message: "At least one field must be provided",
|
||||
});
|
||||
|
||||
export type CreateDocumentAnnotationThread = z.infer<typeof createDocumentAnnotationThreadSchema>;
|
||||
export type CreateDocumentAnnotationComment = z.infer<typeof createDocumentAnnotationCommentSchema>;
|
||||
export type UpdateDocumentAnnotationThread = z.infer<typeof updateDocumentAnnotationThreadSchema>;
|
||||
@@ -67,8 +67,9 @@ export {
|
||||
companySkillUsageAgentSchema,
|
||||
companySkillDetailSchema,
|
||||
companySkillUpdateStatusSchema,
|
||||
companySkillAuditFindingSchema,
|
||||
companySkillAuditResultSchema,
|
||||
companySkillImportSchema,
|
||||
companySkillUpdateAuthSchema,
|
||||
companySkillProjectScanRequestSchema,
|
||||
companySkillProjectScanSkippedSchema,
|
||||
companySkillProjectScanConflictSchema,
|
||||
@@ -76,11 +77,23 @@ export {
|
||||
companySkillCreateSchema,
|
||||
companySkillFileDetailSchema,
|
||||
companySkillFileUpdateSchema,
|
||||
catalogSkillKindSchema,
|
||||
catalogSkillFileSchema,
|
||||
catalogSkillSchema,
|
||||
catalogSkillListQuerySchema,
|
||||
catalogSkillFileDetailSchema,
|
||||
companySkillInstallCatalogSchema,
|
||||
companySkillInstallCatalogResultSchema,
|
||||
companySkillInstallUpdateSchema,
|
||||
companySkillResetSchema,
|
||||
type CompanySkillImport,
|
||||
type CompanySkillProjectScan,
|
||||
type CompanySkillCreate,
|
||||
type CompanySkillFileUpdate,
|
||||
type CompanySkillUpdateAuth,
|
||||
type CatalogSkillListQuery,
|
||||
type CompanySkillInstallCatalog,
|
||||
type CompanySkillInstallUpdate,
|
||||
type CompanySkillReset,
|
||||
} from "./company-skill.js";
|
||||
export {
|
||||
agentSkillStateSchema,
|
||||
@@ -154,10 +167,26 @@ export {
|
||||
type ProjectExecutionWorkspacePolicy,
|
||||
} from "./project.js";
|
||||
|
||||
export {
|
||||
createDocumentAnnotationCommentSchema,
|
||||
createDocumentAnnotationThreadSchema,
|
||||
documentAnnotationAnchorConfidenceSchema,
|
||||
documentAnnotationAnchorSelectorSchema,
|
||||
documentAnnotationAnchorStateSchema,
|
||||
documentAnnotationTextPositionSelectorSchema,
|
||||
documentAnnotationTextQuoteSelectorSchema,
|
||||
documentAnnotationThreadStatusSchema,
|
||||
updateDocumentAnnotationThreadSchema,
|
||||
type CreateDocumentAnnotationComment,
|
||||
type CreateDocumentAnnotationThread,
|
||||
type UpdateDocumentAnnotationThread,
|
||||
} from "./document-annotation.js";
|
||||
|
||||
export {
|
||||
createIssueSchema,
|
||||
createIssueInputSchema,
|
||||
createChildIssueSchema,
|
||||
createAcceptedPlanDecompositionSchema,
|
||||
resolveCreateIssueStatusDefault,
|
||||
createIssueLabelSchema,
|
||||
issueBlockedInboxAttentionSchema,
|
||||
@@ -209,6 +238,7 @@ export {
|
||||
restoreIssueDocumentRevisionSchema,
|
||||
type CreateIssue,
|
||||
type CreateChildIssue,
|
||||
type CreateAcceptedPlanDecomposition,
|
||||
type CreateIssueLabel,
|
||||
type UpdateIssue,
|
||||
type IssueExecutionWorkspaceSettings,
|
||||
|
||||
@@ -38,6 +38,7 @@ export const patchInstanceGeneralSettingsSchema = instanceGeneralSettingsSchema.
|
||||
export const instanceExperimentalSettingsSchema = z.object({
|
||||
enableEnvironments: z.boolean().default(false),
|
||||
enableIsolatedWorkspaces: z.boolean().default(false),
|
||||
enableIssuePlanDecompositions: z.boolean().default(false),
|
||||
enableCloudSync: z.boolean().default(false),
|
||||
autoRestartDevServerWhenIdle: z.boolean().default(false),
|
||||
enableIssueGraphLivenessAutoRecovery: z.boolean().default(false),
|
||||
|
||||
@@ -412,6 +412,13 @@ export const createChildIssueSchema = withCreateIssueStatusDefault(createIssueBa
|
||||
|
||||
export type CreateChildIssue = z.infer<typeof createChildIssueSchema>;
|
||||
|
||||
export const createAcceptedPlanDecompositionSchema = z.object({
|
||||
acceptedPlanRevisionId: z.string().uuid(),
|
||||
children: z.array(createChildIssueSchema).min(1).max(25),
|
||||
});
|
||||
|
||||
export type CreateAcceptedPlanDecomposition = z.infer<typeof createAcceptedPlanDecompositionSchema>;
|
||||
|
||||
export const createIssueLabelSchema = z.object({
|
||||
name: z.string().trim().min(1).max(48),
|
||||
color: z.string().regex(/^#(?:[0-9a-fA-F]{6})$/, "Color must be a 6-digit hex value"),
|
||||
|
||||
Reference in New Issue
Block a user