poe-code 3.0.268 → 3.0.269
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +284 -257
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/dist/providers/poe-agent.js +276 -250
- package/dist/providers/poe-agent.js.map +4 -4
- package/package.json +1 -1
- package/packages/agent-code-review/dist/config.js +15 -1
- package/packages/agent-code-review/dist/document-schemas.js +1 -4
- package/packages/agent-code-review/dist/mcp.js +16 -4
- package/packages/agent-code-review/dist/review-store.js +9 -2
package/dist/index.js
CHANGED
|
@@ -52499,6 +52499,252 @@ var init_config_scope2 = __esm({
|
|
|
52499
52499
|
}
|
|
52500
52500
|
});
|
|
52501
52501
|
|
|
52502
|
+
// packages/agent-code-review/src/document-schemas.ts
|
|
52503
|
+
import { basename as basename3 } from "node:path";
|
|
52504
|
+
import { parse as load, stringify as stringify3 } from "yaml";
|
|
52505
|
+
function requireSafeDocumentSegment(value, field) {
|
|
52506
|
+
if (typeof value !== "string" || value.trim() !== value || value.normalize("NFKC") !== value || !SAFE_SEGMENT_RE.test(value) || value.startsWith(".") || value === "." || value === "..") {
|
|
52507
|
+
throw new Error(`${field} must be a safe path segment.`);
|
|
52508
|
+
}
|
|
52509
|
+
return value;
|
|
52510
|
+
}
|
|
52511
|
+
function requireGitHubActorName(value, field) {
|
|
52512
|
+
if (typeof value !== "string" || !SAFE_GITHUB_ACTOR_RE.test(value)) {
|
|
52513
|
+
throw new Error(`${field} must be a safe GitHub actor name.`);
|
|
52514
|
+
}
|
|
52515
|
+
return value;
|
|
52516
|
+
}
|
|
52517
|
+
function parseCodeReviewProfileMarkdown(content, filePath) {
|
|
52518
|
+
const parsed = parseOptionalFrontmatter(content, filePath);
|
|
52519
|
+
if (!parsed.frontmatter) {
|
|
52520
|
+
return { content: parsed.body };
|
|
52521
|
+
}
|
|
52522
|
+
const metadata = requireMapping(parsed.frontmatter, filePath, "frontmatter");
|
|
52523
|
+
requireOnlyFields(metadata, filePath, "frontmatter", ["version", "name"]);
|
|
52524
|
+
requireVersion(metadata.version, filePath, "frontmatter.version");
|
|
52525
|
+
const name = requireSafeDocumentSegment(metadata.name, `${filePath}: frontmatter.name`);
|
|
52526
|
+
if (basename3(filePath, ".md") !== name) {
|
|
52527
|
+
throw invalidField(filePath, "frontmatter.name", "must match the filename");
|
|
52528
|
+
}
|
|
52529
|
+
return { content: parsed.body, metadata: { version: 1, name } };
|
|
52530
|
+
}
|
|
52531
|
+
function parseCodeReviewPromptMarkdown(content, filePath, role) {
|
|
52532
|
+
const parsed = parseOptionalFrontmatter(content, filePath);
|
|
52533
|
+
if (!parsed.frontmatter) {
|
|
52534
|
+
return { content: parsed.body };
|
|
52535
|
+
}
|
|
52536
|
+
const metadata = requireMapping(parsed.frontmatter, filePath, "frontmatter");
|
|
52537
|
+
requireOnlyFields(metadata, filePath, "frontmatter", ["version", "role"]);
|
|
52538
|
+
requireVersion(metadata.version, filePath, "frontmatter.version");
|
|
52539
|
+
if (!CODE_REVIEW_PROMPT_ROLES.includes(metadata.role)) {
|
|
52540
|
+
throw invalidField(filePath, "frontmatter.role", "is not a supported role");
|
|
52541
|
+
}
|
|
52542
|
+
const promptRole = metadata.role;
|
|
52543
|
+
if (role !== void 0 && promptRole !== role) {
|
|
52544
|
+
throw invalidField(filePath, "frontmatter.role", `must equal ${role}`);
|
|
52545
|
+
}
|
|
52546
|
+
return { content: parsed.body, metadata: { version: 1, role: promptRole } };
|
|
52547
|
+
}
|
|
52548
|
+
function parseCodeReviewIngestSource(content, filePath = "code-review ingest source.yaml") {
|
|
52549
|
+
try {
|
|
52550
|
+
const source = requireMapping(load(content), filePath, "document");
|
|
52551
|
+
requireOnlyFields(source, filePath, "document", [
|
|
52552
|
+
"version",
|
|
52553
|
+
"username",
|
|
52554
|
+
"repos",
|
|
52555
|
+
"fetched_at",
|
|
52556
|
+
"output_profile_path",
|
|
52557
|
+
"pagination",
|
|
52558
|
+
"rate_limit"
|
|
52559
|
+
]);
|
|
52560
|
+
requireVersion(source.version, filePath, "version");
|
|
52561
|
+
const username = requireGitHubActorName(source.username, `${filePath}: username`);
|
|
52562
|
+
if (!Array.isArray(source.repos) || source.repos.length === 0) {
|
|
52563
|
+
throw invalidField(filePath, "repos", "must be a non-empty array");
|
|
52564
|
+
}
|
|
52565
|
+
const repos = source.repos.map((repo, index) => requireRepo(repo, filePath, `repos[${index}]`));
|
|
52566
|
+
const fetchedAt = requireDate(source.fetched_at, filePath, "fetched_at");
|
|
52567
|
+
if (typeof source.output_profile_path !== "string" || !source.output_profile_path) {
|
|
52568
|
+
throw invalidField(filePath, "output_profile_path", "must be a non-empty string");
|
|
52569
|
+
}
|
|
52570
|
+
const pagination = requireMapping(source.pagination, filePath, "pagination");
|
|
52571
|
+
requireOnlyFields(pagination, filePath, "pagination", [
|
|
52572
|
+
"partial",
|
|
52573
|
+
"comments_written",
|
|
52574
|
+
"resume_endpoint"
|
|
52575
|
+
]);
|
|
52576
|
+
if (typeof pagination.partial !== "boolean") {
|
|
52577
|
+
throw invalidField(filePath, "pagination.partial", "must be a boolean");
|
|
52578
|
+
}
|
|
52579
|
+
const commentsWritten = requireNonNegativeInteger(
|
|
52580
|
+
pagination.comments_written,
|
|
52581
|
+
filePath,
|
|
52582
|
+
"pagination.comments_written"
|
|
52583
|
+
);
|
|
52584
|
+
const resumeEndpoint = optionalString(
|
|
52585
|
+
pagination.resume_endpoint,
|
|
52586
|
+
filePath,
|
|
52587
|
+
"pagination.resume_endpoint"
|
|
52588
|
+
);
|
|
52589
|
+
let rateLimit = null;
|
|
52590
|
+
if (source.rate_limit !== null) {
|
|
52591
|
+
const rate = requireMapping(source.rate_limit, filePath, "rate_limit");
|
|
52592
|
+
requireOnlyFields(rate, filePath, "rate_limit", [
|
|
52593
|
+
"repo",
|
|
52594
|
+
"limit",
|
|
52595
|
+
"remaining",
|
|
52596
|
+
"reset_at",
|
|
52597
|
+
"retry_after",
|
|
52598
|
+
"partial_results",
|
|
52599
|
+
"reason"
|
|
52600
|
+
]);
|
|
52601
|
+
const reason = optionalString(rate.reason, filePath, "rate_limit.reason");
|
|
52602
|
+
if (reason !== void 0 && !["low_remaining", "primary", "secondary"].includes(
|
|
52603
|
+
reason
|
|
52604
|
+
)) {
|
|
52605
|
+
throw invalidField(filePath, "rate_limit.reason", "is not supported");
|
|
52606
|
+
}
|
|
52607
|
+
rateLimit = {
|
|
52608
|
+
repo: requireRepo(rate.repo, filePath, "rate_limit.repo"),
|
|
52609
|
+
limit: rate.limit === null || rate.limit === void 0 ? null : requireNonNegativeInteger(rate.limit, filePath, "rate_limit.limit"),
|
|
52610
|
+
remaining: rate.remaining === null ? null : requireNonNegativeInteger(rate.remaining, filePath, "rate_limit.remaining"),
|
|
52611
|
+
resetAt: rate.reset_at === null ? null : requireDate(rate.reset_at, filePath, "rate_limit.reset_at"),
|
|
52612
|
+
retryAfter: rate.retry_after === null || rate.retry_after === void 0 ? null : optionalString(rate.retry_after, filePath, "rate_limit.retry_after") ?? null,
|
|
52613
|
+
partialResults: requireNonNegativeInteger(
|
|
52614
|
+
rate.partial_results,
|
|
52615
|
+
filePath,
|
|
52616
|
+
"rate_limit.partial_results"
|
|
52617
|
+
),
|
|
52618
|
+
reason: reason ?? "low_remaining"
|
|
52619
|
+
};
|
|
52620
|
+
}
|
|
52621
|
+
return {
|
|
52622
|
+
version: 1,
|
|
52623
|
+
username,
|
|
52624
|
+
repos,
|
|
52625
|
+
fetchedAt,
|
|
52626
|
+
outputProfilePath: source.output_profile_path,
|
|
52627
|
+
pagination: {
|
|
52628
|
+
partial: pagination.partial,
|
|
52629
|
+
commentsWritten,
|
|
52630
|
+
...resumeEndpoint === void 0 ? {} : { resumeEndpoint }
|
|
52631
|
+
},
|
|
52632
|
+
rateLimit
|
|
52633
|
+
};
|
|
52634
|
+
} catch (error3) {
|
|
52635
|
+
if (error3 instanceof Error && error3.message.startsWith(`${filePath}:`)) {
|
|
52636
|
+
throw error3;
|
|
52637
|
+
}
|
|
52638
|
+
throw new Error(`${filePath}: invalid YAML: ${errorMessage3(error3)}`);
|
|
52639
|
+
}
|
|
52640
|
+
}
|
|
52641
|
+
function serializeCodeReviewIngestSource(source, filePath = "code-review ingest source.yaml") {
|
|
52642
|
+
const content = stringify3(
|
|
52643
|
+
{
|
|
52644
|
+
version: source.version,
|
|
52645
|
+
username: source.username,
|
|
52646
|
+
repos: source.repos,
|
|
52647
|
+
fetched_at: source.fetchedAt,
|
|
52648
|
+
pagination: {
|
|
52649
|
+
partial: source.pagination.partial,
|
|
52650
|
+
comments_written: source.pagination.commentsWritten,
|
|
52651
|
+
...source.pagination.resumeEndpoint === void 0 ? {} : { resume_endpoint: source.pagination.resumeEndpoint }
|
|
52652
|
+
},
|
|
52653
|
+
rate_limit: source.rateLimit === null ? null : {
|
|
52654
|
+
repo: source.rateLimit.repo,
|
|
52655
|
+
limit: source.rateLimit.limit,
|
|
52656
|
+
remaining: source.rateLimit.remaining,
|
|
52657
|
+
reset_at: source.rateLimit.resetAt,
|
|
52658
|
+
retry_after: source.rateLimit.retryAfter,
|
|
52659
|
+
partial_results: source.rateLimit.partialResults,
|
|
52660
|
+
reason: source.rateLimit.reason
|
|
52661
|
+
},
|
|
52662
|
+
output_profile_path: source.outputProfilePath
|
|
52663
|
+
},
|
|
52664
|
+
{ aliasDuplicateObjects: false, lineWidth: 0 }
|
|
52665
|
+
);
|
|
52666
|
+
parseCodeReviewIngestSource(content, filePath);
|
|
52667
|
+
return content;
|
|
52668
|
+
}
|
|
52669
|
+
function parseOptionalFrontmatter(content, filePath) {
|
|
52670
|
+
const match = content.match(FRONTMATTER_RE);
|
|
52671
|
+
if (!match) {
|
|
52672
|
+
return { body: content };
|
|
52673
|
+
}
|
|
52674
|
+
try {
|
|
52675
|
+
return { frontmatter: load(match[1]), body: match[2] };
|
|
52676
|
+
} catch (error3) {
|
|
52677
|
+
throw new Error(`${filePath}: invalid frontmatter YAML: ${errorMessage3(error3)}`);
|
|
52678
|
+
}
|
|
52679
|
+
}
|
|
52680
|
+
function requireMapping(value, filePath, field) {
|
|
52681
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
52682
|
+
throw invalidField(filePath, field, "must be a YAML mapping");
|
|
52683
|
+
}
|
|
52684
|
+
return value;
|
|
52685
|
+
}
|
|
52686
|
+
function requireVersion(value, filePath, field) {
|
|
52687
|
+
if (value !== 1) {
|
|
52688
|
+
throw invalidField(filePath, field, "must equal 1");
|
|
52689
|
+
}
|
|
52690
|
+
}
|
|
52691
|
+
function requireOnlyFields(value, filePath, field, allowedFields) {
|
|
52692
|
+
const allowed = new Set(allowedFields);
|
|
52693
|
+
for (const key2 of Object.keys(value)) {
|
|
52694
|
+
if (!allowed.has(key2)) {
|
|
52695
|
+
throw invalidField(filePath, `${field}.${key2}`, "is not supported");
|
|
52696
|
+
}
|
|
52697
|
+
}
|
|
52698
|
+
}
|
|
52699
|
+
function requireRepo(value, filePath, field) {
|
|
52700
|
+
if (typeof value !== "string" || !/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/.test(value)) {
|
|
52701
|
+
throw invalidField(filePath, field, "must be a safe owner/repository name");
|
|
52702
|
+
}
|
|
52703
|
+
return value;
|
|
52704
|
+
}
|
|
52705
|
+
function requireDate(value, filePath, field) {
|
|
52706
|
+
if (typeof value !== "string" || Number.isNaN(Date.parse(value))) {
|
|
52707
|
+
throw invalidField(filePath, field, "must be a valid timestamp");
|
|
52708
|
+
}
|
|
52709
|
+
return value;
|
|
52710
|
+
}
|
|
52711
|
+
function requireNonNegativeInteger(value, filePath, field) {
|
|
52712
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
52713
|
+
throw invalidField(filePath, field, "must be a non-negative integer");
|
|
52714
|
+
}
|
|
52715
|
+
return value;
|
|
52716
|
+
}
|
|
52717
|
+
function optionalString(value, filePath, field) {
|
|
52718
|
+
if (value === void 0) {
|
|
52719
|
+
return void 0;
|
|
52720
|
+
}
|
|
52721
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
52722
|
+
throw invalidField(filePath, field, "must be a non-empty string");
|
|
52723
|
+
}
|
|
52724
|
+
return value;
|
|
52725
|
+
}
|
|
52726
|
+
function invalidField(filePath, field, reason) {
|
|
52727
|
+
return new Error(`${filePath}: ${field} ${reason}.`);
|
|
52728
|
+
}
|
|
52729
|
+
function errorMessage3(error3) {
|
|
52730
|
+
return error3 instanceof Error ? error3.message : String(error3);
|
|
52731
|
+
}
|
|
52732
|
+
var CODE_REVIEW_PROMPT_ROLES, FRONTMATTER_RE, SAFE_SEGMENT_RE, SAFE_GITHUB_ACTOR_RE;
|
|
52733
|
+
var init_document_schemas = __esm({
|
|
52734
|
+
"packages/agent-code-review/src/document-schemas.ts"() {
|
|
52735
|
+
"use strict";
|
|
52736
|
+
CODE_REVIEW_PROMPT_ROLES = [
|
|
52737
|
+
"orchestrator",
|
|
52738
|
+
"subagent",
|
|
52739
|
+
"agent",
|
|
52740
|
+
"profile-synthesis"
|
|
52741
|
+
];
|
|
52742
|
+
FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/;
|
|
52743
|
+
SAFE_SEGMENT_RE = /^[A-Za-z0-9._-]+$/;
|
|
52744
|
+
SAFE_GITHUB_ACTOR_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
|
|
52745
|
+
}
|
|
52746
|
+
});
|
|
52747
|
+
|
|
52502
52748
|
// packages/agent-code-review/src/error-codes.ts
|
|
52503
52749
|
function hasOwnErrorCode14(error3, code) {
|
|
52504
52750
|
return error3 instanceof Error && Object.prototype.hasOwnProperty.call(error3, "code") && error3.code === code;
|
|
@@ -53638,255 +53884,6 @@ var init_src25 = __esm({
|
|
|
53638
53884
|
}
|
|
53639
53885
|
});
|
|
53640
53886
|
|
|
53641
|
-
// packages/agent-code-review/src/document-schemas.ts
|
|
53642
|
-
import { basename as basename3 } from "node:path";
|
|
53643
|
-
import { parse as load, stringify as stringify3 } from "yaml";
|
|
53644
|
-
function requireSafeDocumentSegment(value, field) {
|
|
53645
|
-
if (typeof value !== "string" || value.trim() !== value || value.normalize("NFKC") !== value || !SAFE_SEGMENT_RE.test(value) || value.startsWith(".") || value === "." || value === "..") {
|
|
53646
|
-
throw new Error(`${field} must be a safe path segment.`);
|
|
53647
|
-
}
|
|
53648
|
-
return value;
|
|
53649
|
-
}
|
|
53650
|
-
function requireGitHubActorName(value, field) {
|
|
53651
|
-
if (typeof value !== "string" || !SAFE_GITHUB_ACTOR_RE.test(value)) {
|
|
53652
|
-
throw new Error(`${field} must be a safe GitHub actor name.`);
|
|
53653
|
-
}
|
|
53654
|
-
return value;
|
|
53655
|
-
}
|
|
53656
|
-
function parseCodeReviewProfileMarkdown(content, filePath) {
|
|
53657
|
-
const parsed = parseOptionalFrontmatter(content, filePath);
|
|
53658
|
-
if (!parsed.frontmatter) {
|
|
53659
|
-
return { content: parsed.body };
|
|
53660
|
-
}
|
|
53661
|
-
const metadata = requireMapping(parsed.frontmatter, filePath, "frontmatter");
|
|
53662
|
-
requireOnlyFields(metadata, filePath, "frontmatter", ["version", "name"]);
|
|
53663
|
-
requireVersion(metadata.version, filePath, "frontmatter.version");
|
|
53664
|
-
const name = requireSafeDocumentSegment(metadata.name, `${filePath}: frontmatter.name`);
|
|
53665
|
-
if (basename3(filePath, ".md") !== name) {
|
|
53666
|
-
throw invalidField(filePath, "frontmatter.name", "must match the filename");
|
|
53667
|
-
}
|
|
53668
|
-
return { content: parsed.body, metadata: { version: 1, name } };
|
|
53669
|
-
}
|
|
53670
|
-
function parseCodeReviewPromptMarkdown(content, filePath, role) {
|
|
53671
|
-
const parsed = parseOptionalFrontmatter(content, filePath);
|
|
53672
|
-
if (!parsed.frontmatter) {
|
|
53673
|
-
return { content: parsed.body };
|
|
53674
|
-
}
|
|
53675
|
-
const metadata = requireMapping(parsed.frontmatter, filePath, "frontmatter");
|
|
53676
|
-
requireOnlyFields(metadata, filePath, "frontmatter", ["version", "role"]);
|
|
53677
|
-
requireVersion(metadata.version, filePath, "frontmatter.version");
|
|
53678
|
-
if (!CODE_REVIEW_PROMPT_ROLES.includes(metadata.role)) {
|
|
53679
|
-
throw invalidField(filePath, "frontmatter.role", "is not a supported role");
|
|
53680
|
-
}
|
|
53681
|
-
const promptRole = metadata.role;
|
|
53682
|
-
if (role !== void 0 && promptRole !== role) {
|
|
53683
|
-
throw invalidField(filePath, "frontmatter.role", `must equal ${role}`);
|
|
53684
|
-
}
|
|
53685
|
-
return { content: parsed.body, metadata: { version: 1, role: promptRole } };
|
|
53686
|
-
}
|
|
53687
|
-
function parseCodeReviewIngestSource(content, filePath = "code-review ingest source.yaml") {
|
|
53688
|
-
try {
|
|
53689
|
-
const source = requireMapping(load(content), filePath, "document");
|
|
53690
|
-
requireOnlyFields(source, filePath, "document", [
|
|
53691
|
-
"version",
|
|
53692
|
-
"username",
|
|
53693
|
-
"repos",
|
|
53694
|
-
"fetched_at",
|
|
53695
|
-
"output_profile_path",
|
|
53696
|
-
"pagination",
|
|
53697
|
-
"rate_limit"
|
|
53698
|
-
]);
|
|
53699
|
-
requireVersion(source.version, filePath, "version");
|
|
53700
|
-
const username = requireGitHubActorName(source.username, `${filePath}: username`);
|
|
53701
|
-
if (!Array.isArray(source.repos) || source.repos.length === 0) {
|
|
53702
|
-
throw invalidField(filePath, "repos", "must be a non-empty array");
|
|
53703
|
-
}
|
|
53704
|
-
const repos = source.repos.map((repo, index) => requireRepo(repo, filePath, `repos[${index}]`));
|
|
53705
|
-
const fetchedAt = requireDate(source.fetched_at, filePath, "fetched_at");
|
|
53706
|
-
if (typeof source.output_profile_path !== "string" || !source.output_profile_path) {
|
|
53707
|
-
throw invalidField(filePath, "output_profile_path", "must be a non-empty string");
|
|
53708
|
-
}
|
|
53709
|
-
const pagination = requireMapping(source.pagination, filePath, "pagination");
|
|
53710
|
-
requireOnlyFields(pagination, filePath, "pagination", [
|
|
53711
|
-
"partial",
|
|
53712
|
-
"comments_written",
|
|
53713
|
-
"resume_endpoint"
|
|
53714
|
-
]);
|
|
53715
|
-
if (typeof pagination.partial !== "boolean") {
|
|
53716
|
-
throw invalidField(filePath, "pagination.partial", "must be a boolean");
|
|
53717
|
-
}
|
|
53718
|
-
const commentsWritten = requireNonNegativeInteger(
|
|
53719
|
-
pagination.comments_written,
|
|
53720
|
-
filePath,
|
|
53721
|
-
"pagination.comments_written"
|
|
53722
|
-
);
|
|
53723
|
-
const resumeEndpoint = optionalString(
|
|
53724
|
-
pagination.resume_endpoint,
|
|
53725
|
-
filePath,
|
|
53726
|
-
"pagination.resume_endpoint"
|
|
53727
|
-
);
|
|
53728
|
-
let rateLimit = null;
|
|
53729
|
-
if (source.rate_limit !== null) {
|
|
53730
|
-
const rate = requireMapping(source.rate_limit, filePath, "rate_limit");
|
|
53731
|
-
requireOnlyFields(rate, filePath, "rate_limit", [
|
|
53732
|
-
"repo",
|
|
53733
|
-
"limit",
|
|
53734
|
-
"remaining",
|
|
53735
|
-
"reset_at",
|
|
53736
|
-
"retry_after",
|
|
53737
|
-
"partial_results",
|
|
53738
|
-
"reason"
|
|
53739
|
-
]);
|
|
53740
|
-
const reason = optionalString(rate.reason, filePath, "rate_limit.reason");
|
|
53741
|
-
if (reason !== void 0 && !["low_remaining", "primary", "secondary"].includes(
|
|
53742
|
-
reason
|
|
53743
|
-
)) {
|
|
53744
|
-
throw invalidField(filePath, "rate_limit.reason", "is not supported");
|
|
53745
|
-
}
|
|
53746
|
-
rateLimit = {
|
|
53747
|
-
repo: requireRepo(rate.repo, filePath, "rate_limit.repo"),
|
|
53748
|
-
limit: rate.limit === null || rate.limit === void 0 ? null : requireNonNegativeInteger(rate.limit, filePath, "rate_limit.limit"),
|
|
53749
|
-
remaining: rate.remaining === null ? null : requireNonNegativeInteger(rate.remaining, filePath, "rate_limit.remaining"),
|
|
53750
|
-
resetAt: rate.reset_at === null ? null : requireDate(rate.reset_at, filePath, "rate_limit.reset_at"),
|
|
53751
|
-
retryAfter: rate.retry_after === null || rate.retry_after === void 0 ? null : optionalString(rate.retry_after, filePath, "rate_limit.retry_after") ?? null,
|
|
53752
|
-
partialResults: requireNonNegativeInteger(
|
|
53753
|
-
rate.partial_results,
|
|
53754
|
-
filePath,
|
|
53755
|
-
"rate_limit.partial_results"
|
|
53756
|
-
),
|
|
53757
|
-
reason: reason ?? "low_remaining"
|
|
53758
|
-
};
|
|
53759
|
-
}
|
|
53760
|
-
return {
|
|
53761
|
-
version: 1,
|
|
53762
|
-
username,
|
|
53763
|
-
repos,
|
|
53764
|
-
fetchedAt,
|
|
53765
|
-
outputProfilePath: source.output_profile_path,
|
|
53766
|
-
pagination: {
|
|
53767
|
-
partial: pagination.partial,
|
|
53768
|
-
commentsWritten,
|
|
53769
|
-
...resumeEndpoint === void 0 ? {} : { resumeEndpoint }
|
|
53770
|
-
},
|
|
53771
|
-
rateLimit
|
|
53772
|
-
};
|
|
53773
|
-
} catch (error3) {
|
|
53774
|
-
if (error3 instanceof Error && error3.message.startsWith(`${filePath}:`)) {
|
|
53775
|
-
throw error3;
|
|
53776
|
-
}
|
|
53777
|
-
throw new Error(`${filePath}: invalid YAML: ${errorMessage3(error3)}`);
|
|
53778
|
-
}
|
|
53779
|
-
}
|
|
53780
|
-
function serializeCodeReviewIngestSource(source, filePath = "code-review ingest source.yaml") {
|
|
53781
|
-
const content = stringify3(
|
|
53782
|
-
{
|
|
53783
|
-
version: source.version,
|
|
53784
|
-
username: source.username,
|
|
53785
|
-
repos: source.repos,
|
|
53786
|
-
fetched_at: source.fetchedAt,
|
|
53787
|
-
pagination: {
|
|
53788
|
-
partial: source.pagination.partial,
|
|
53789
|
-
comments_written: source.pagination.commentsWritten,
|
|
53790
|
-
...source.pagination.resumeEndpoint === void 0 ? {} : { resume_endpoint: source.pagination.resumeEndpoint }
|
|
53791
|
-
},
|
|
53792
|
-
rate_limit: source.rateLimit === null ? null : {
|
|
53793
|
-
repo: source.rateLimit.repo,
|
|
53794
|
-
limit: source.rateLimit.limit,
|
|
53795
|
-
remaining: source.rateLimit.remaining,
|
|
53796
|
-
reset_at: source.rateLimit.resetAt,
|
|
53797
|
-
retry_after: source.rateLimit.retryAfter,
|
|
53798
|
-
partial_results: source.rateLimit.partialResults,
|
|
53799
|
-
reason: source.rateLimit.reason
|
|
53800
|
-
},
|
|
53801
|
-
output_profile_path: source.outputProfilePath
|
|
53802
|
-
},
|
|
53803
|
-
{ aliasDuplicateObjects: false, lineWidth: 0 }
|
|
53804
|
-
);
|
|
53805
|
-
parseCodeReviewIngestSource(content, filePath);
|
|
53806
|
-
return content;
|
|
53807
|
-
}
|
|
53808
|
-
function parseOptionalFrontmatter(content, filePath) {
|
|
53809
|
-
const match = content.match(FRONTMATTER_RE);
|
|
53810
|
-
if (!match) {
|
|
53811
|
-
if (/^---\r?\n/.test(content)) {
|
|
53812
|
-
throw new Error(`${filePath}: frontmatter is missing a closing --- delimiter.`);
|
|
53813
|
-
}
|
|
53814
|
-
return { body: content };
|
|
53815
|
-
}
|
|
53816
|
-
try {
|
|
53817
|
-
return { frontmatter: load(match[1]), body: match[2] };
|
|
53818
|
-
} catch (error3) {
|
|
53819
|
-
throw new Error(`${filePath}: invalid frontmatter YAML: ${errorMessage3(error3)}`);
|
|
53820
|
-
}
|
|
53821
|
-
}
|
|
53822
|
-
function requireMapping(value, filePath, field) {
|
|
53823
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
53824
|
-
throw invalidField(filePath, field, "must be a YAML mapping");
|
|
53825
|
-
}
|
|
53826
|
-
return value;
|
|
53827
|
-
}
|
|
53828
|
-
function requireVersion(value, filePath, field) {
|
|
53829
|
-
if (value !== 1) {
|
|
53830
|
-
throw invalidField(filePath, field, "must equal 1");
|
|
53831
|
-
}
|
|
53832
|
-
}
|
|
53833
|
-
function requireOnlyFields(value, filePath, field, allowedFields) {
|
|
53834
|
-
const allowed = new Set(allowedFields);
|
|
53835
|
-
for (const key2 of Object.keys(value)) {
|
|
53836
|
-
if (!allowed.has(key2)) {
|
|
53837
|
-
throw invalidField(filePath, `${field}.${key2}`, "is not supported");
|
|
53838
|
-
}
|
|
53839
|
-
}
|
|
53840
|
-
}
|
|
53841
|
-
function requireRepo(value, filePath, field) {
|
|
53842
|
-
if (typeof value !== "string" || !/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/.test(value)) {
|
|
53843
|
-
throw invalidField(filePath, field, "must be a safe owner/repository name");
|
|
53844
|
-
}
|
|
53845
|
-
return value;
|
|
53846
|
-
}
|
|
53847
|
-
function requireDate(value, filePath, field) {
|
|
53848
|
-
if (typeof value !== "string" || Number.isNaN(Date.parse(value))) {
|
|
53849
|
-
throw invalidField(filePath, field, "must be a valid timestamp");
|
|
53850
|
-
}
|
|
53851
|
-
return value;
|
|
53852
|
-
}
|
|
53853
|
-
function requireNonNegativeInteger(value, filePath, field) {
|
|
53854
|
-
if (!Number.isSafeInteger(value) || value < 0) {
|
|
53855
|
-
throw invalidField(filePath, field, "must be a non-negative integer");
|
|
53856
|
-
}
|
|
53857
|
-
return value;
|
|
53858
|
-
}
|
|
53859
|
-
function optionalString(value, filePath, field) {
|
|
53860
|
-
if (value === void 0) {
|
|
53861
|
-
return void 0;
|
|
53862
|
-
}
|
|
53863
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
53864
|
-
throw invalidField(filePath, field, "must be a non-empty string");
|
|
53865
|
-
}
|
|
53866
|
-
return value;
|
|
53867
|
-
}
|
|
53868
|
-
function invalidField(filePath, field, reason) {
|
|
53869
|
-
return new Error(`${filePath}: ${field} ${reason}.`);
|
|
53870
|
-
}
|
|
53871
|
-
function errorMessage3(error3) {
|
|
53872
|
-
return error3 instanceof Error ? error3.message : String(error3);
|
|
53873
|
-
}
|
|
53874
|
-
var CODE_REVIEW_PROMPT_ROLES, FRONTMATTER_RE, SAFE_SEGMENT_RE, SAFE_GITHUB_ACTOR_RE;
|
|
53875
|
-
var init_document_schemas = __esm({
|
|
53876
|
-
"packages/agent-code-review/src/document-schemas.ts"() {
|
|
53877
|
-
"use strict";
|
|
53878
|
-
CODE_REVIEW_PROMPT_ROLES = [
|
|
53879
|
-
"orchestrator",
|
|
53880
|
-
"subagent",
|
|
53881
|
-
"agent",
|
|
53882
|
-
"profile-synthesis"
|
|
53883
|
-
];
|
|
53884
|
-
FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/;
|
|
53885
|
-
SAFE_SEGMENT_RE = /^[A-Za-z0-9._-]+$/;
|
|
53886
|
-
SAFE_GITHUB_ACTOR_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/;
|
|
53887
|
-
}
|
|
53888
|
-
});
|
|
53889
|
-
|
|
53890
53887
|
// packages/agent-code-review/src/review-state.ts
|
|
53891
53888
|
import { parse as load2, stringify as stringify4 } from "yaml";
|
|
53892
53889
|
function parseCodeReviewState(content, filePath = "code-review review YAML") {
|
|
@@ -54383,8 +54380,8 @@ async function withFileLock2(lockPath, lockTimeoutMs, operation) {
|
|
|
54383
54380
|
}
|
|
54384
54381
|
async function isStaleLock(lockPath, lockTimeoutMs) {
|
|
54385
54382
|
try {
|
|
54386
|
-
const ownerPid =
|
|
54387
|
-
if (
|
|
54383
|
+
const ownerPid = parseLockOwnerPid((await readFile10(lockPath, "utf8")).trim());
|
|
54384
|
+
if (ownerPid !== void 0) {
|
|
54388
54385
|
return !isRunningProcess(ownerPid);
|
|
54389
54386
|
}
|
|
54390
54387
|
return Date.now() - (await stat6(lockPath)).mtimeMs >= lockTimeoutMs;
|
|
@@ -54395,6 +54392,13 @@ async function isStaleLock(lockPath, lockTimeoutMs) {
|
|
|
54395
54392
|
throw error3;
|
|
54396
54393
|
}
|
|
54397
54394
|
}
|
|
54395
|
+
function parseLockOwnerPid(value) {
|
|
54396
|
+
const processId = Number(value);
|
|
54397
|
+
if (!Number.isSafeInteger(processId) || processId <= 0) {
|
|
54398
|
+
return void 0;
|
|
54399
|
+
}
|
|
54400
|
+
return String(processId) === value ? processId : void 0;
|
|
54401
|
+
}
|
|
54398
54402
|
function isRunningProcess(processId) {
|
|
54399
54403
|
try {
|
|
54400
54404
|
process.kill(processId, 0);
|
|
@@ -54969,7 +54973,7 @@ async function resolveCodeReviewRunOptions(input, configOptions) {
|
|
|
54969
54973
|
),
|
|
54970
54974
|
...inputProfilePath === void 0 ? {} : { profilePath: inputProfilePath },
|
|
54971
54975
|
...inputPromptPath === void 0 ? {} : { promptPath: inputPromptPath },
|
|
54972
|
-
...inputProfiles === void 0 ? {} : { profiles: inputProfiles },
|
|
54976
|
+
...inputProfiles === void 0 ? {} : { profiles: requireProfileFilters(inputProfiles) },
|
|
54973
54977
|
...inputAdditionalFeedback === void 0 ? {} : { additionalFeedback: inputAdditionalFeedback }
|
|
54974
54978
|
};
|
|
54975
54979
|
}
|
|
@@ -55022,6 +55026,18 @@ function requireNonEmptyString(value, field) {
|
|
|
55022
55026
|
}
|
|
55023
55027
|
return normalized;
|
|
55024
55028
|
}
|
|
55029
|
+
function requireProfileFilters(value) {
|
|
55030
|
+
if (!Array.isArray(value)) {
|
|
55031
|
+
throw new Error("profiles must be an array of safe profile names.");
|
|
55032
|
+
}
|
|
55033
|
+
return value.map((profile) => {
|
|
55034
|
+
try {
|
|
55035
|
+
return requireSafeDocumentSegment(profile, "profiles");
|
|
55036
|
+
} catch {
|
|
55037
|
+
throw new Error("profiles must be an array of safe profile names.");
|
|
55038
|
+
}
|
|
55039
|
+
});
|
|
55040
|
+
}
|
|
55025
55041
|
function isMissingFileError5(error3) {
|
|
55026
55042
|
return hasOwnErrorCode14(error3, "ENOENT");
|
|
55027
55043
|
}
|
|
@@ -55031,6 +55047,7 @@ var init_config4 = __esm({
|
|
|
55031
55047
|
"use strict";
|
|
55032
55048
|
init_src9();
|
|
55033
55049
|
init_config_scope2();
|
|
55050
|
+
init_document_schemas();
|
|
55034
55051
|
init_error_codes11();
|
|
55035
55052
|
init_review_store();
|
|
55036
55053
|
poeCoreAgentScope = defineScope("core", {
|
|
@@ -61159,7 +61176,7 @@ function createCodeReviewAgentMcpGroup(context, dependencies = {}) {
|
|
|
61159
61176
|
handler: async ({ params }) => {
|
|
61160
61177
|
const pr = canonicalPullRequestUrl(params.pr);
|
|
61161
61178
|
const draft = validateDraft2(params);
|
|
61162
|
-
const currentState = await ensureState(store, context, pr);
|
|
61179
|
+
const currentState = context.role === "orchestrator" ? await ensureState(store, context, pr) : await requireState(store, context, pr);
|
|
61163
61180
|
if (context.role === "orchestrator") {
|
|
61164
61181
|
const unfinishedProfiles = Object.values(currentState.subagents).filter(({ status }) => status === "pending" || status === "running").map(({ profile }) => profile);
|
|
61165
61182
|
if (unfinishedProfiles.length > 0) {
|
|
@@ -61354,7 +61371,11 @@ function createCodeReviewAgentMcpGroup(context, dependencies = {}) {
|
|
|
61354
61371
|
pr: prParam,
|
|
61355
61372
|
index: inlineCommentIndexSchema,
|
|
61356
61373
|
path: S.String({ description: "Repository-relative path in the PR diff." }),
|
|
61357
|
-
line: S.Number({
|
|
61374
|
+
line: S.Number({
|
|
61375
|
+
description: "Right-side line number in the PR diff.",
|
|
61376
|
+
jsonType: "integer",
|
|
61377
|
+
minimum: 1
|
|
61378
|
+
}),
|
|
61358
61379
|
body: S.String({ description: "Inline review comment body." })
|
|
61359
61380
|
}),
|
|
61360
61381
|
handler: async ({ params }) => {
|
|
@@ -61520,11 +61541,17 @@ var init_mcp3 = __esm({
|
|
|
61520
61541
|
CODE_REVIEW_AGENT_MCP_ROLES = ["agent", "orchestrator", "subagent"];
|
|
61521
61542
|
inlineCommentSchema = S.Object({
|
|
61522
61543
|
path: S.String({ description: "Repository-relative path in the PR diff." }),
|
|
61523
|
-
line: S.Number({
|
|
61544
|
+
line: S.Number({
|
|
61545
|
+
description: "Right-side line number in the PR diff.",
|
|
61546
|
+
jsonType: "integer",
|
|
61547
|
+
minimum: 1
|
|
61548
|
+
}),
|
|
61524
61549
|
body: S.String({ description: "Inline review comment body." })
|
|
61525
61550
|
});
|
|
61526
61551
|
inlineCommentIndexSchema = S.Number({
|
|
61527
|
-
description: "Zero-based merged review inline comment index."
|
|
61552
|
+
description: "Zero-based merged review inline comment index.",
|
|
61553
|
+
jsonType: "integer",
|
|
61554
|
+
minimum: 0
|
|
61528
61555
|
});
|
|
61529
61556
|
prParam = S.String({ description: "GitHub pull request URL." });
|
|
61530
61557
|
}
|
|
@@ -136049,7 +136076,7 @@ var init_package2 = __esm({
|
|
|
136049
136076
|
"package.json"() {
|
|
136050
136077
|
package_default2 = {
|
|
136051
136078
|
name: "poe-code",
|
|
136052
|
-
version: "3.0.
|
|
136079
|
+
version: "3.0.269",
|
|
136053
136080
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
136054
136081
|
type: "module",
|
|
136055
136082
|
main: "./dist/index.js",
|