@oss-autopilot/core 3.42.5 → 3.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-pre-action.js +8 -3
- package/dist/cli-registry.js +428 -27
- package/dist/cli.bundle.cjs +212 -156
- package/dist/commands/check-integration.js +5 -1
- package/dist/commands/cleanup.d.ts +80 -0
- package/dist/commands/cleanup.js +334 -0
- package/dist/commands/comments.d.ts +14 -1
- package/dist/commands/comments.js +17 -5
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.js +63 -6
- package/dist/commands/daily-dismiss-filter.d.ts +7 -0
- package/dist/commands/daily-dismiss-filter.js +17 -1
- package/dist/commands/daily-ledger.d.ts +150 -0
- package/dist/commands/daily-ledger.js +248 -0
- package/dist/commands/daily-recent-prs.d.ts +26 -0
- package/dist/commands/daily-recent-prs.js +55 -0
- package/dist/commands/daily-render.d.ts +2 -1
- package/dist/commands/daily-render.js +4 -1
- package/dist/commands/daily.d.ts +5 -1
- package/dist/commands/daily.js +83 -93
- package/dist/commands/dashboard-cache.d.ts +2 -0
- package/dist/commands/dashboard-cache.js +33 -8
- package/dist/commands/dashboard-data.js +113 -69
- package/dist/commands/dashboard-gist-sync.js +3 -1
- package/dist/commands/dashboard-lifecycle.d.ts +36 -8
- package/dist/commands/dashboard-lifecycle.js +132 -39
- package/dist/commands/dashboard-process.d.ts +49 -1
- package/dist/commands/dashboard-process.js +111 -12
- package/dist/commands/dashboard-server.js +89 -23
- package/dist/commands/detect-formatters.js +1 -0
- package/dist/commands/dismiss.js +11 -7
- package/dist/commands/doctor.d.ts +15 -1
- package/dist/commands/doctor.js +66 -5
- package/dist/commands/draft.d.ts +77 -0
- package/dist/commands/draft.js +218 -0
- package/dist/commands/eval.js +1 -0
- package/dist/commands/fork-prune.d.ts +58 -0
- package/dist/commands/fork-prune.js +247 -0
- package/dist/commands/guidelines.d.ts +69 -2
- package/dist/commands/guidelines.js +158 -14
- package/dist/commands/index.d.ts +29 -4
- package/dist/commands/index.js +20 -3
- package/dist/commands/issue-thread.d.ts +46 -0
- package/dist/commands/issue-thread.js +123 -0
- package/dist/commands/ledger-backfill.d.ts +9 -0
- package/dist/commands/ledger-backfill.js +44 -1
- package/dist/commands/list-mark-done.d.ts +2 -1
- package/dist/commands/list-mark-done.js +3 -1
- package/dist/commands/list-move-tier.d.ts +2 -1
- package/dist/commands/list-move-tier.js +3 -1
- package/dist/commands/local-repos.js +10 -5
- package/dist/commands/locate-issue-list.d.ts +40 -17
- package/dist/commands/locate-issue-list.js +148 -88
- package/dist/commands/move.js +7 -1
- package/dist/commands/overnight-handoff.d.ts +17 -7
- package/dist/commands/overnight-handoff.js +36 -14
- package/dist/commands/overnight-push-prep.d.ts +14 -8
- package/dist/commands/overnight-push-prep.js +107 -35
- package/dist/commands/overnight-tool-rules.d.ts +54 -0
- package/dist/commands/overnight-tool-rules.js +217 -0
- package/dist/commands/overnight.d.ts +5 -6
- package/dist/commands/overnight.js +61 -140
- package/dist/commands/parse-list.js +7 -1
- package/dist/commands/policy.d.ts +90 -0
- package/dist/commands/policy.js +276 -0
- package/dist/commands/pr-create.d.ts +48 -0
- package/dist/commands/pr-create.js +200 -0
- package/dist/commands/pr-preflight.d.ts +69 -0
- package/dist/commands/pr-preflight.js +348 -0
- package/dist/commands/repo-vet.d.ts +9 -0
- package/dist/commands/repo-vet.js +36 -11
- package/dist/commands/scout-bridge.js +18 -8
- package/dist/commands/search.js +7 -0
- package/dist/commands/setup.d.ts +3 -3
- package/dist/commands/setup.js +160 -48
- package/dist/commands/skip-add.js +10 -1
- package/dist/commands/startup.d.ts +12 -3
- package/dist/commands/startup.js +82 -49
- package/dist/commands/state-cmd.d.ts +2 -0
- package/dist/commands/state-cmd.js +5 -1
- package/dist/commands/stats.js +1 -0
- package/dist/commands/status.js +6 -0
- package/dist/commands/strategy.js +1 -0
- package/dist/commands/validation.d.ts +5 -0
- package/dist/commands/validation.js +5 -0
- package/dist/commands/vet-list.d.ts +6 -0
- package/dist/commands/vet-list.js +26 -1
- package/dist/commands/vet.d.ts +20 -0
- package/dist/commands/vet.js +133 -2
- package/dist/commands/work.d.ts +4 -0
- package/dist/commands/work.js +34 -11
- package/dist/core/__fixtures__/prompt-injection-payloads.js +31 -0
- package/dist/core/anti-llm-policy.d.ts +3 -0
- package/dist/core/anti-llm-policy.js +3 -0
- package/dist/core/auth.js +2 -0
- package/dist/core/ci-analysis.d.ts +7 -2
- package/dist/core/ci-analysis.js +76 -21
- package/dist/core/commit-date.d.ts +45 -0
- package/dist/core/commit-date.js +45 -0
- package/dist/core/compliance-score.d.ts +3 -0
- package/dist/core/compliance-score.js +13 -9
- package/dist/core/config-registry.d.ts +27 -2
- package/dist/core/config-registry.js +94 -7
- package/dist/core/contributing.d.ts +2 -3
- package/dist/core/contributing.js +2 -3
- package/dist/core/daily-logic.d.ts +30 -5
- package/dist/core/daily-logic.js +68 -19
- package/dist/core/errors.d.ts +37 -3
- package/dist/core/errors.js +54 -5
- package/dist/core/fork-prune.d.ts +149 -0
- package/dist/core/fork-prune.js +333 -0
- package/dist/core/gist-health.d.ts +15 -3
- package/dist/core/gist-health.js +8 -0
- package/dist/core/gist-state-store.d.ts +24 -4
- package/dist/core/gist-state-store.js +98 -51
- package/dist/core/github-stats.d.ts +110 -16
- package/dist/core/github-stats.js +295 -110
- package/dist/core/http-cache.d.ts +0 -10
- package/dist/core/http-cache.js +0 -19
- package/dist/core/index.d.ts +13 -6
- package/dist/core/index.js +16 -6
- package/dist/core/issue-conversation.d.ts +8 -2
- package/dist/core/issue-conversation.js +31 -12
- package/dist/core/local-config.d.ts +95 -0
- package/dist/core/local-config.js +270 -0
- package/dist/core/merged-pr-notes.d.ts +2 -2
- package/dist/core/pacing.d.ts +41 -0
- package/dist/core/pacing.js +115 -0
- package/dist/core/pagination.d.ts +55 -0
- package/dist/core/pagination.js +59 -0
- package/dist/core/paths.d.ts +7 -0
- package/dist/core/paths.js +9 -0
- package/dist/core/pr-assembly.d.ts +2 -0
- package/dist/core/pr-assembly.js +6 -2
- package/dist/core/pr-graphql.d.ts +53 -4
- package/dist/core/pr-graphql.js +87 -14
- package/dist/core/pr-monitor.d.ts +35 -12
- package/dist/core/pr-monitor.js +110 -26
- package/dist/core/pr-preflight.d.ts +154 -0
- package/dist/core/pr-preflight.js +753 -0
- package/dist/core/pr-quality-rubric.d.ts +0 -6
- package/dist/core/pr-quality-rubric.js +0 -8
- package/dist/core/pr-template.d.ts +2 -0
- package/dist/core/pr-template.js +5 -1
- package/dist/core/prose-script.d.ts +72 -0
- package/dist/core/prose-script.js +223 -0
- package/dist/core/repo-policy.d.ts +111 -0
- package/dist/core/repo-policy.js +428 -0
- package/dist/core/repo-score-manager.d.ts +66 -0
- package/dist/core/repo-score-manager.js +140 -1
- package/dist/core/review-analysis.d.ts +49 -21
- package/dist/core/review-analysis.js +89 -15
- package/dist/core/reviewed-prs-fetch.js +11 -29
- package/dist/core/reviewed-prs.js +8 -15
- package/dist/core/stale-data.d.ts +78 -0
- package/dist/core/stale-data.js +153 -0
- package/dist/core/state-persistence.d.ts +62 -27
- package/dist/core/state-persistence.js +338 -119
- package/dist/core/state-schema.d.ts +152 -210
- package/dist/core/state-schema.js +232 -80
- package/dist/core/state.d.ts +81 -8
- package/dist/core/state.js +239 -46
- package/dist/core/status-determination.js +32 -12
- package/dist/core/strategy.js +3 -1
- package/dist/core/types.d.ts +22 -1
- package/dist/core/types.js +1 -0
- package/dist/core/untrusted-content.d.ts +30 -11
- package/dist/core/untrusted-content.js +95 -42
- package/dist/core/urls.d.ts +33 -0
- package/dist/core/urls.js +94 -0
- package/dist/dashboard/assets/chart-panel-B-nLVgzQ.js +3 -0
- package/dist/dashboard/assets/index-5IvMGokL.js +55 -0
- package/dist/dashboard/index.html +1 -1
- package/dist/formatters/json.d.ts +432 -10
- package/dist/formatters/json.js +156 -1
- package/package.json +6 -6
- package/dist/core/ci-enforced-tools.d.ts +0 -35
- package/dist/core/ci-enforced-tools.js +0 -109
- package/dist/core/comment-decision.d.ts +0 -79
- package/dist/core/comment-decision.js +0 -82
- package/dist/core/extraction-categories.d.ts +0 -55
- package/dist/core/extraction-categories.js +0 -108
- package/dist/core/follow-up-history.d.ts +0 -40
- package/dist/core/follow-up-history.js +0 -71
- package/dist/core/issue-effort.d.ts +0 -29
- package/dist/core/issue-effort.js +0 -47
- package/dist/core/maintainer-hints.d.ts +0 -23
- package/dist/core/maintainer-hints.js +0 -36
- package/dist/core/workflow-state.d.ts +0 -56
- package/dist/core/workflow-state.js +0 -101
- package/dist/dashboard/assets/chart-panel-DPKNBUts.js +0 -3
- package/dist/dashboard/assets/index-B25bZOYX.js +0 -55
package/dist/core/types.js
CHANGED
|
@@ -18,6 +18,7 @@ export const INITIAL_STATE = AgentStateSchema.parse({ version: 4 });
|
|
|
18
18
|
export const PROJECT_CATEGORIES = ProjectCategorySchema.options;
|
|
19
19
|
export const ISSUE_SCOPES = IssueScopeSchema.options;
|
|
20
20
|
export const DIFF_TOOLS = DiffToolSchema.options;
|
|
21
|
+
/** @deprecated Since #1948; nothing reads it. Will be removed in the next major version. */
|
|
21
22
|
export const SCOPE_LABELS = {
|
|
22
23
|
beginner: ['good first issue', 'help wanted', 'easy', 'up-for-grabs', 'first-timers-only', 'beginner'],
|
|
23
24
|
intermediate: ['enhancement', 'feature', 'feature-request', 'contributions welcome'],
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* and the prompt-injection corpus:
|
|
8
8
|
*
|
|
9
9
|
* 1. Output starts with the open tag and ends with the close tag.
|
|
10
|
-
* 2.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* 2. No `<` appears inside the wrapped body: every one is escaped to
|
|
11
|
+
* `<` (#1931), so no tag of any spelling (letter case, inner
|
|
12
|
+
* whitespace, attributes, zero-width or lookalike letters) can exist
|
|
13
|
+
* there and an attacker cannot close the fence early and inject
|
|
14
|
+
* instructions after it.
|
|
13
15
|
* 3. `extractFromFence(wrapUntrustedContent(x, label))` returns `x`
|
|
14
16
|
* unchanged for any input — the wrapping is lossless.
|
|
15
17
|
*
|
|
@@ -29,6 +31,8 @@
|
|
|
29
31
|
* CLI text renderers consume the same objects.
|
|
30
32
|
* - MCP-only surfaces (#1455): PR titles and branch-ref names via
|
|
31
33
|
* {@link fenceFetchedPRTitles} (mcp-server resources.ts / prompts.ts),
|
|
34
|
+
* every title and branch-ref string in MCP tool results via
|
|
35
|
+
* {@link fenceTitlesDeep} (mcp-server tools.ts `wrapTool`, #1931),
|
|
32
36
|
* and stored guidelines provenance via {@link labelGuidelinesContent}.
|
|
33
37
|
* These do NOT apply on the CLI envelope — see the helpers' docs.
|
|
34
38
|
*
|
|
@@ -54,14 +58,15 @@ export interface UntrustedContentMeta {
|
|
|
54
58
|
}
|
|
55
59
|
/**
|
|
56
60
|
* Wrap `text` in a `<github-content>` fence labeled with `label` and the
|
|
57
|
-
* optional metadata.
|
|
58
|
-
*
|
|
59
|
-
*
|
|
61
|
+
* optional metadata. Every `&` and `<` inside `text` is entity-escaped,
|
|
62
|
+
* which round-trips losslessly via {@link extractFromFence}. Wrapping
|
|
63
|
+
* already-fenced text escapes the inner fence's tags like any other.
|
|
64
|
+
* Fullwidth `<` (U+FF1C) is not ASCII `<` and stays as is.
|
|
60
65
|
*/
|
|
61
66
|
export declare function wrapUntrustedContent(text: string, label: string, meta?: UntrustedContentMeta): string;
|
|
62
67
|
/**
|
|
63
68
|
* Reverse of {@link wrapUntrustedContent}. Extracts the original body text
|
|
64
|
-
* (un-escaping
|
|
69
|
+
* (un-escaping `<` and `&`). Throws if the input is not
|
|
65
70
|
* a single well-formed fence — callers shouldn't be parsing arbitrary
|
|
66
71
|
* markdown with this; it's for tests + symmetric reasoning only.
|
|
67
72
|
*/
|
|
@@ -98,12 +103,26 @@ export declare function fenceFetchedPR<T extends FenceablePR>(pr: T): T;
|
|
|
98
103
|
*
|
|
99
104
|
* Composes safely with {@link fenceFetchedPR} (disjoint fields), and is
|
|
100
105
|
* applied to already-body-fenced digest PRs without double-wrapping.
|
|
101
|
-
* `VerifiedLinkedPR.title` (verify-issue) stays raw
|
|
102
|
-
* feeds the CLI `--json` contract (pinned by
|
|
103
|
-
* snapshots) and the consuming issue-scout agent
|
|
104
|
-
* block.
|
|
106
|
+
* `VerifiedLinkedPR.title` (verify-issue) stays raw at the producer and on
|
|
107
|
+
* the CLI: the same producer feeds the CLI `--json` contract (pinned by
|
|
108
|
+
* verify-issue contract snapshots) and the consuming issue-scout agent
|
|
109
|
+
* carries the awareness block. On the MCP `verify-issue` tool result it is
|
|
110
|
+
* fenced by {@link fenceTitlesDeep} like every other title (#1931).
|
|
111
|
+
* Returns a copy; never mutates.
|
|
105
112
|
*/
|
|
106
113
|
export declare function fenceFetchedPRTitles<T extends FenceableTitledPR>(pr: T): T;
|
|
114
|
+
/**
|
|
115
|
+
* Fence every non-empty PR/issue title and branch-ref string anywhere in an
|
|
116
|
+
* MCP tool result (#1931), and each label of an issue or PR row (#2046).
|
|
117
|
+
* Tool results reach an arbitrary MCP host LLM that never sees the "Prompt
|
|
118
|
+
* Injection Awareness" block, the same reason {@link fenceFetchedPRTitles} exists for resources and prompts, but tool
|
|
119
|
+
* payloads have no single shape, so this walks the whole value and matches
|
|
120
|
+
* by key. Field names and types are unchanged; only the string values gain
|
|
121
|
+
* the fence. Never skips a value that already looks fenced: an attacker can
|
|
122
|
+
* write a title that looks pre-fenced. Returns a copy; never mutates.
|
|
123
|
+
* MCP-only: the CLI `--json` envelope keeps these raw.
|
|
124
|
+
*/
|
|
125
|
+
export declare function fenceTitlesDeep<T>(value: T): T;
|
|
107
126
|
/**
|
|
108
127
|
* Provenance preamble for stored per-repo guidelines (#1455). Guidelines are
|
|
109
128
|
* LLM-distilled from a corpus of public PR comments — an untrusted source —
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* and the prompt-injection corpus:
|
|
8
8
|
*
|
|
9
9
|
* 1. Output starts with the open tag and ends with the close tag.
|
|
10
|
-
* 2.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* 2. No `<` appears inside the wrapped body: every one is escaped to
|
|
11
|
+
* `<` (#1931), so no tag of any spelling (letter case, inner
|
|
12
|
+
* whitespace, attributes, zero-width or lookalike letters) can exist
|
|
13
|
+
* there and an attacker cannot close the fence early and inject
|
|
14
|
+
* instructions after it.
|
|
13
15
|
* 3. `extractFromFence(wrapUntrustedContent(x, label))` returns `x`
|
|
14
16
|
* unchanged for any input — the wrapping is lossless.
|
|
15
17
|
*
|
|
@@ -29,6 +31,8 @@
|
|
|
29
31
|
* CLI text renderers consume the same objects.
|
|
30
32
|
* - MCP-only surfaces (#1455): PR titles and branch-ref names via
|
|
31
33
|
* {@link fenceFetchedPRTitles} (mcp-server resources.ts / prompts.ts),
|
|
34
|
+
* every title and branch-ref string in MCP tool results via
|
|
35
|
+
* {@link fenceTitlesDeep} (mcp-server tools.ts `wrapTool`, #1931),
|
|
32
36
|
* and stored guidelines provenance via {@link labelGuidelinesContent}.
|
|
33
37
|
* These do NOT apply on the CLI envelope — see the helpers' docs.
|
|
34
38
|
*
|
|
@@ -44,18 +48,6 @@
|
|
|
44
48
|
*/
|
|
45
49
|
export const UNTRUSTED_OPEN_TAG_NAME = 'github-content';
|
|
46
50
|
export const UNTRUSTED_CLOSE_TAG = `</${UNTRUSTED_OPEN_TAG_NAME}>`;
|
|
47
|
-
/**
|
|
48
|
-
* Sentinels used to neutralize any literal open- or close-tag substring
|
|
49
|
-
* inside the wrapped body. We use HTML entity escapes (`<` / `>`) so
|
|
50
|
-
* the result is pure ASCII, lints cleanly, and round-trips losslessly. The
|
|
51
|
-
* `&` itself is escaped first so an input containing the literal text
|
|
52
|
-
* `</github-content>` survives the wrap/unwrap round-trip without
|
|
53
|
-
* collision.
|
|
54
|
-
*/
|
|
55
|
-
const AMP_ESCAPE = '&';
|
|
56
|
-
const CLOSE_TAG_ESCAPE = `</${UNTRUSTED_OPEN_TAG_NAME}>`;
|
|
57
|
-
const OPEN_TAG_PATTERN = new RegExp(String.raw `<${UNTRUSTED_OPEN_TAG_NAME}\b`, 'g');
|
|
58
|
-
const OPEN_TAG_ESCAPE = `<${UNTRUSTED_OPEN_TAG_NAME}`;
|
|
59
51
|
function escapeAttr(value) {
|
|
60
52
|
// Newlines/carriage returns can't break out of a quoted attribute (no `"`)
|
|
61
53
|
// but they visually fragment the open tag in the prompt text the LLM
|
|
@@ -70,23 +62,18 @@ function escapeAttr(value) {
|
|
|
70
62
|
}
|
|
71
63
|
/**
|
|
72
64
|
* Wrap `text` in a `<github-content>` fence labeled with `label` and the
|
|
73
|
-
* optional metadata.
|
|
74
|
-
*
|
|
75
|
-
*
|
|
65
|
+
* optional metadata. Every `&` and `<` inside `text` is entity-escaped,
|
|
66
|
+
* which round-trips losslessly via {@link extractFromFence}. Wrapping
|
|
67
|
+
* already-fenced text escapes the inner fence's tags like any other.
|
|
68
|
+
* Fullwidth `<` (U+FF1C) is not ASCII `<` and stays as is.
|
|
76
69
|
*/
|
|
77
70
|
export function wrapUntrustedContent(text, label, meta = {}) {
|
|
78
71
|
// Escape order matters for round-trip correctness:
|
|
79
72
|
// 1. `&` first — so any pre-existing entity in the input gets a literal
|
|
80
73
|
// `&` that survives the unwrap pass below.
|
|
81
|
-
// 2.
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
const escapedBody = text
|
|
85
|
-
.split('&')
|
|
86
|
-
.join(AMP_ESCAPE)
|
|
87
|
-
.split(UNTRUSTED_CLOSE_TAG)
|
|
88
|
-
.join(CLOSE_TAG_ESCAPE)
|
|
89
|
-
.replaceAll(OPEN_TAG_PATTERN, OPEN_TAG_ESCAPE);
|
|
74
|
+
// 2. Every `<`. After pass 1 every `<` in the body is one written
|
|
75
|
+
// here, so an input holding the literal text `<` does not collide.
|
|
76
|
+
const escapedBody = text.replaceAll('&', '&').replaceAll('<', '<');
|
|
90
77
|
const attrs = [`label="${escapeAttr(label)}"`];
|
|
91
78
|
if (meta.author !== undefined)
|
|
92
79
|
attrs.push(`author="${escapeAttr(meta.author)}"`);
|
|
@@ -98,7 +85,7 @@ export function wrapUntrustedContent(text, label, meta = {}) {
|
|
|
98
85
|
}
|
|
99
86
|
/**
|
|
100
87
|
* Reverse of {@link wrapUntrustedContent}. Extracts the original body text
|
|
101
|
-
* (un-escaping
|
|
88
|
+
* (un-escaping `<` and `&`). Throws if the input is not
|
|
102
89
|
* a single well-formed fence — callers shouldn't be parsing arbitrary
|
|
103
90
|
* markdown with this; it's for tests + symmetric reasoning only.
|
|
104
91
|
*/
|
|
@@ -111,18 +98,13 @@ export function extractFromFence(fenced) {
|
|
|
111
98
|
throw new Error('extractFromFence: input does not end with </github-content>');
|
|
112
99
|
}
|
|
113
100
|
const inner = fenced.slice(openMatch[0].length, fenced.length - UNTRUSTED_CLOSE_TAG.length);
|
|
114
|
-
|
|
115
|
-
|
|
101
|
+
// wrapUntrustedContent never leaves a raw `<` in the body.
|
|
102
|
+
if (inner.includes('<')) {
|
|
103
|
+
throw new Error('extractFromFence: raw < found in body (nested tag?) — fence escaping is broken');
|
|
116
104
|
}
|
|
117
|
-
// Reverse the escapes in opposite order:
|
|
105
|
+
// Reverse the escapes in opposite order: `<` first (so an
|
|
118
106
|
// already-`&`-prefixed entity survives), then unescape `&`.
|
|
119
|
-
return inner
|
|
120
|
-
.split(CLOSE_TAG_ESCAPE)
|
|
121
|
-
.join(UNTRUSTED_CLOSE_TAG)
|
|
122
|
-
.split(OPEN_TAG_ESCAPE)
|
|
123
|
-
.join(`<${UNTRUSTED_OPEN_TAG_NAME}`)
|
|
124
|
-
.split(AMP_ESCAPE)
|
|
125
|
-
.join('&');
|
|
107
|
+
return inner.replaceAll('<', '<').replaceAll('&', '&');
|
|
126
108
|
}
|
|
127
109
|
/**
|
|
128
110
|
* Tolerant unwrap for human-facing display paths (CLI text mode). Returns
|
|
@@ -176,10 +158,12 @@ export function fenceFetchedPR(pr) {
|
|
|
176
158
|
*
|
|
177
159
|
* Composes safely with {@link fenceFetchedPR} (disjoint fields), and is
|
|
178
160
|
* applied to already-body-fenced digest PRs without double-wrapping.
|
|
179
|
-
* `VerifiedLinkedPR.title` (verify-issue) stays raw
|
|
180
|
-
* feeds the CLI `--json` contract (pinned by
|
|
181
|
-
* snapshots) and the consuming issue-scout agent
|
|
182
|
-
* block.
|
|
161
|
+
* `VerifiedLinkedPR.title` (verify-issue) stays raw at the producer and on
|
|
162
|
+
* the CLI: the same producer feeds the CLI `--json` contract (pinned by
|
|
163
|
+
* verify-issue contract snapshots) and the consuming issue-scout agent
|
|
164
|
+
* carries the awareness block. On the MCP `verify-issue` tool result it is
|
|
165
|
+
* fenced by {@link fenceTitlesDeep} like every other title (#1931).
|
|
166
|
+
* Returns a copy; never mutates.
|
|
183
167
|
*/
|
|
184
168
|
export function fenceFetchedPRTitles(pr) {
|
|
185
169
|
const label = `${pr.repo}#${pr.number}`;
|
|
@@ -195,6 +179,75 @@ export function fenceFetchedPRTitles(pr) {
|
|
|
195
179
|
}
|
|
196
180
|
return fenced;
|
|
197
181
|
}
|
|
182
|
+
/** Result keys {@link fenceTitlesDeep} fences, mapped to the fence `source`. */
|
|
183
|
+
const TITLE_KEY_SOURCES = new Map([
|
|
184
|
+
['title', 'title'],
|
|
185
|
+
['prTitle', 'pr-title'],
|
|
186
|
+
['headRefName', 'pr-head-ref'],
|
|
187
|
+
['baseRefName', 'pr-base-ref'],
|
|
188
|
+
]);
|
|
189
|
+
/** Best provenance label available on an arbitrary result object. */
|
|
190
|
+
function titleLabel(obj) {
|
|
191
|
+
if (typeof obj.repo === 'string' && typeof obj.number === 'number')
|
|
192
|
+
return `${obj.repo}#${obj.number}`;
|
|
193
|
+
for (const key of ['url', 'prUrl', 'repo']) {
|
|
194
|
+
const value = obj[key];
|
|
195
|
+
if (typeof value === 'string' && value !== '')
|
|
196
|
+
return value;
|
|
197
|
+
}
|
|
198
|
+
return 'github';
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The `labels` of an issue or PR row (an object with a numeric `number` and a
|
|
202
|
+
* string `url`): set by the repo's maintainers, so fenced like titles (#2046).
|
|
203
|
+
* Rows without both keys are left alone, so the user's own configured
|
|
204
|
+
* `labels` (config, setup) stay raw.
|
|
205
|
+
*/
|
|
206
|
+
function fenceRowLabels(obj, labels, label) {
|
|
207
|
+
if (typeof obj.number !== 'number' || typeof obj.url !== 'string')
|
|
208
|
+
return labels.map((l) => fenceTitlesDeep(l));
|
|
209
|
+
return labels.map((name) => typeof name === 'string' && name !== ''
|
|
210
|
+
? wrapUntrustedContent(name, label, { source: 'issue-label' })
|
|
211
|
+
: fenceTitlesDeep(name));
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Fence every non-empty PR/issue title and branch-ref string anywhere in an
|
|
215
|
+
* MCP tool result (#1931), and each label of an issue or PR row (#2046).
|
|
216
|
+
* Tool results reach an arbitrary MCP host LLM that never sees the "Prompt
|
|
217
|
+
* Injection Awareness" block, the same reason {@link fenceFetchedPRTitles} exists for resources and prompts, but tool
|
|
218
|
+
* payloads have no single shape, so this walks the whole value and matches
|
|
219
|
+
* by key. Field names and types are unchanged; only the string values gain
|
|
220
|
+
* the fence. Never skips a value that already looks fenced: an attacker can
|
|
221
|
+
* write a title that looks pre-fenced. Returns a copy; never mutates.
|
|
222
|
+
* MCP-only: the CLI `--json` envelope keeps these raw.
|
|
223
|
+
*/
|
|
224
|
+
export function fenceTitlesDeep(value) {
|
|
225
|
+
if (Array.isArray(value))
|
|
226
|
+
return value.map((item) => fenceTitlesDeep(item));
|
|
227
|
+
if (value === null || typeof value !== 'object')
|
|
228
|
+
return value;
|
|
229
|
+
// Plain objects only: a Date or a class with toJSON must reach
|
|
230
|
+
// JSON.stringify intact, not as a copy of its own enumerable fields.
|
|
231
|
+
const proto = Object.getPrototypeOf(value);
|
|
232
|
+
if (proto !== null && proto !== Object.prototype)
|
|
233
|
+
return value;
|
|
234
|
+
const obj = value;
|
|
235
|
+
const label = titleLabel(obj);
|
|
236
|
+
const out = {};
|
|
237
|
+
for (const [key, field] of Object.entries(obj)) {
|
|
238
|
+
out[key] = fenceEntry(obj, key, field, label);
|
|
239
|
+
}
|
|
240
|
+
return out;
|
|
241
|
+
}
|
|
242
|
+
/** One entry of a result object `obj`, fenced by {@link fenceTitlesDeep}'s rules. */
|
|
243
|
+
function fenceEntry(obj, key, field, label) {
|
|
244
|
+
if (key === 'labels' && Array.isArray(field))
|
|
245
|
+
return fenceRowLabels(obj, field, label);
|
|
246
|
+
const source = TITLE_KEY_SOURCES.get(key);
|
|
247
|
+
return source !== undefined && typeof field === 'string' && field !== ''
|
|
248
|
+
? wrapUntrustedContent(field, label, { source })
|
|
249
|
+
: fenceTitlesDeep(field);
|
|
250
|
+
}
|
|
198
251
|
/**
|
|
199
252
|
* Provenance preamble for stored per-repo guidelines (#1455). Guidelines are
|
|
200
253
|
* LLM-distilled from a corpus of public PR comments — an untrusted source —
|
package/dist/core/urls.d.ts
CHANGED
|
@@ -46,6 +46,15 @@ export declare function parseGitHubUrl(url: string): ParsedGitHubUrl | null;
|
|
|
46
46
|
* // "org/repo#5"
|
|
47
47
|
*/
|
|
48
48
|
export declare function issueRefKey(url: string): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* The key of a URL-keyed state map (`dismissedIssues`, `dismissedPRHeads`,
|
|
51
|
+
* `statusOverrides`) that names the same issue or PR as `url` (#2001): `url`
|
|
52
|
+
* itself when present, else the key with the same {@link issueRefKey}, so a
|
|
53
|
+
* mixed-case owner/repo or the `/issues/N` form of a PR still finds the entry.
|
|
54
|
+
* Keys stay URLs because older clients sharing the Gist look them up by exact
|
|
55
|
+
* URL. undefined when there is no such key.
|
|
56
|
+
*/
|
|
57
|
+
export declare function findRefKey(map: Readonly<Record<string, unknown>> | undefined, url: string): string | undefined;
|
|
49
58
|
/**
|
|
50
59
|
* Extracts the owner and repo from a GitHub web URL
|
|
51
60
|
* (e.g. `https://github.com/owner/repo/pull/42`, `https://github.com/owner/repo/`).
|
|
@@ -76,3 +85,27 @@ export declare function splitRepo(repoFullName: string): {
|
|
|
76
85
|
export declare function isOwnRepo(owner: string, username: string): boolean;
|
|
77
86
|
/** True when `owner` is listed in `config.untrackedOrgs` (case-insensitive). */
|
|
78
87
|
export declare function isUntrackedOrg(owner: string, untrackedOrgs?: readonly string[]): boolean;
|
|
88
|
+
/** GitHub's PR body limit. */
|
|
89
|
+
export declare const MAX_BODY_CHARS = 65536;
|
|
90
|
+
/**
|
|
91
|
+
* Markdown with its HTML comments and code (fenced and inline) blanked out:
|
|
92
|
+
* the text GitHub links refs in, and where PR templates keep example
|
|
93
|
+
* `Fixes #123` lines. Each match of
|
|
94
|
+
* `/<!--[\s\S]*?-->|```[\s\S]*?```|(`+)[^`]*\1/g` becomes one space, but in
|
|
95
|
+
* linear time: that regex rescans to the end from every unclosed opener.
|
|
96
|
+
*/
|
|
97
|
+
export declare function stripNonProse(markdown: string): string;
|
|
98
|
+
/** One closing reference: `repo` is the `owner/repo` the text names, null for a bare `#N`. */
|
|
99
|
+
export interface ClosingRef {
|
|
100
|
+
repo: string | null;
|
|
101
|
+
number: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Issues `text` closes with a GitHub closing keyword (#2048), in order of
|
|
105
|
+
* appearance. With `markdown` (a PR body), HTML comments and code are
|
|
106
|
+
* skipped and only the first {@link MAX_BODY_CHARS} characters are read, as
|
|
107
|
+
* GitHub links nothing there; without it (a commit message) every line counts.
|
|
108
|
+
*/
|
|
109
|
+
export declare function findClosingRefs(text: string, options?: {
|
|
110
|
+
markdown?: boolean;
|
|
111
|
+
}): ClosingRef[];
|
package/dist/core/urls.js
CHANGED
|
@@ -74,6 +74,24 @@ export function issueRefKey(url) {
|
|
|
74
74
|
const parsed = parseGitHubUrl(url);
|
|
75
75
|
return parsed ? `${parsed.owner.toLowerCase()}/${parsed.repo.toLowerCase()}#${parsed.number}` : null;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* The key of a URL-keyed state map (`dismissedIssues`, `dismissedPRHeads`,
|
|
79
|
+
* `statusOverrides`) that names the same issue or PR as `url` (#2001): `url`
|
|
80
|
+
* itself when present, else the key with the same {@link issueRefKey}, so a
|
|
81
|
+
* mixed-case owner/repo or the `/issues/N` form of a PR still finds the entry.
|
|
82
|
+
* Keys stay URLs because older clients sharing the Gist look them up by exact
|
|
83
|
+
* URL. undefined when there is no such key.
|
|
84
|
+
*/
|
|
85
|
+
export function findRefKey(map, url) {
|
|
86
|
+
if (!map)
|
|
87
|
+
return undefined;
|
|
88
|
+
if (Object.hasOwn(map, url))
|
|
89
|
+
return url;
|
|
90
|
+
const key = issueRefKey(url);
|
|
91
|
+
// ponytail: linear scan per miss, and these maps are never pruned, so cost grows with every
|
|
92
|
+
// dismiss/override ever made. Upgrade: build a ref -> key index once per daily/dashboard pass.
|
|
93
|
+
return key === null ? undefined : Object.keys(map).find((k) => issueRefKey(k) === key);
|
|
94
|
+
}
|
|
77
95
|
/**
|
|
78
96
|
* Extracts the owner and repo from a GitHub web URL
|
|
79
97
|
* (e.g. `https://github.com/owner/repo/pull/42`, `https://github.com/owner/repo/`).
|
|
@@ -120,3 +138,79 @@ export function isUntrackedOrg(owner, untrackedOrgs = []) {
|
|
|
120
138
|
const ownerLower = owner.toLowerCase();
|
|
121
139
|
return untrackedOrgs.some((org) => org.toLowerCase() === ownerLower);
|
|
122
140
|
}
|
|
141
|
+
/** GitHub's PR body limit. */
|
|
142
|
+
export const MAX_BODY_CHARS = 65_536;
|
|
143
|
+
function commentEnd(text, i, closers) {
|
|
144
|
+
if (!closers.comment || !text.startsWith('<!--', i))
|
|
145
|
+
return -1;
|
|
146
|
+
const close = text.indexOf('-->', i + 4);
|
|
147
|
+
if (close === -1)
|
|
148
|
+
closers.comment = false;
|
|
149
|
+
return close === -1 ? -1 : close + 3;
|
|
150
|
+
}
|
|
151
|
+
function fenceEnd(text, i, closers) {
|
|
152
|
+
if (!closers.fence || !text.startsWith('```', i))
|
|
153
|
+
return -1;
|
|
154
|
+
const close = text.indexOf('```', i + 3);
|
|
155
|
+
if (close === -1)
|
|
156
|
+
closers.fence = false;
|
|
157
|
+
return close === -1 ? -1 : close + 3;
|
|
158
|
+
}
|
|
159
|
+
/** A run of N backticks closed by the next N; failing that, half the run closes the other half. */
|
|
160
|
+
function codeSpanEnd(text, i) {
|
|
161
|
+
let run = 0;
|
|
162
|
+
while (text[i + run] === '`')
|
|
163
|
+
run++;
|
|
164
|
+
if (run === 0)
|
|
165
|
+
return -1;
|
|
166
|
+
const close = text.indexOf('`', i + run);
|
|
167
|
+
if (close !== -1 && text.startsWith('`'.repeat(run), close))
|
|
168
|
+
return close + run;
|
|
169
|
+
return run >= 2 ? i + 2 * Math.floor(run / 2) : -1;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Markdown with its HTML comments and code (fenced and inline) blanked out:
|
|
173
|
+
* the text GitHub links refs in, and where PR templates keep example
|
|
174
|
+
* `Fixes #123` lines. Each match of
|
|
175
|
+
* `/<!--[\s\S]*?-->|```[\s\S]*?```|(`+)[^`]*\1/g` becomes one space, but in
|
|
176
|
+
* linear time: that regex rescans to the end from every unclosed opener.
|
|
177
|
+
*/
|
|
178
|
+
export function stripNonProse(markdown) {
|
|
179
|
+
const closers = { comment: true, fence: true };
|
|
180
|
+
let out = '';
|
|
181
|
+
let prose = 0;
|
|
182
|
+
let i = 0;
|
|
183
|
+
while (i < markdown.length) {
|
|
184
|
+
const end = Math.max(commentEnd(markdown, i, closers), fenceEnd(markdown, i, closers));
|
|
185
|
+
const span = end === -1 ? codeSpanEnd(markdown, i) : end;
|
|
186
|
+
if (span === -1) {
|
|
187
|
+
i++;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
out += `${markdown.slice(prose, i)} `;
|
|
191
|
+
prose = span;
|
|
192
|
+
i = span;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return out + markdown.slice(prose);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* GitHub's closing keyword (close, closes, closed, fix, fixes, fixed, resolve,
|
|
199
|
+
* resolves, resolved; any case), an optional colon, then one ref: `#12`,
|
|
200
|
+
* `owner/repo#12` or an issue URL. Each ref needs its own keyword, as on
|
|
201
|
+
* GitHub, so `Fixes #1, #2` closes only #1.
|
|
202
|
+
*/
|
|
203
|
+
const CLOSING_REF_RE = /\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)(?::\s*|\s+)(?:https?:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/issues\/(\d+)|([\w.-]+\/[\w.-]+)?#(\d+))\b/gi;
|
|
204
|
+
/**
|
|
205
|
+
* Issues `text` closes with a GitHub closing keyword (#2048), in order of
|
|
206
|
+
* appearance. With `markdown` (a PR body), HTML comments and code are
|
|
207
|
+
* skipped and only the first {@link MAX_BODY_CHARS} characters are read, as
|
|
208
|
+
* GitHub links nothing there; without it (a commit message) every line counts.
|
|
209
|
+
*/
|
|
210
|
+
export function findClosingRefs(text, options = {}) {
|
|
211
|
+
const scanned = options.markdown ? stripNonProse(text.slice(0, MAX_BODY_CHARS)) : text;
|
|
212
|
+
return Array.from(scanned.matchAll(CLOSING_REF_RE), (m) => ({
|
|
213
|
+
repo: m[1] ?? m[3] ?? null,
|
|
214
|
+
number: Number(m[2] ?? m[4]),
|
|
215
|
+
}));
|
|
216
|
+
}
|