@a-t-h-i/bot-lobby 0.7.0 → 0.7.2
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/package.json +1 -1
- package/prompts/global.md +13 -0
- package/prompts/master.md +8 -8
- package/prompts/planner.md +14 -0
- package/src/classifier/knowledge.ts +22 -3
- package/src/execution/lint-setup.ts +409 -0
- package/src/execution/lint.ts +25 -13
- package/src/execution/verification.ts +65 -13
- package/src/lobby/planner.ts +2 -2
- package/src/master/master.ts +30 -13
- package/src/pi/tools.ts +1 -1
- package/src/schemas/configuration.ts +14 -1
- package/src/schemas/lint.ts +50 -0
- package/src/webui/api/index.ts +12 -1
- package/src/webui/api/settings.ts +39 -0
- package/src/webui/protocol.ts +5 -0
- package/src/workflow/workflow.ts +22 -7
- package/webui/dist/assets/{CodeSurface-FHm02AXI.js → CodeSurface-12WUcZSS.js} +1 -1
- package/webui/dist/assets/{TerminalView-Be3q2ej_.js → TerminalView-C1ez7iqT.js} +1 -1
- package/webui/dist/assets/index-BUrfox9b.js +117 -0
- package/webui/dist/assets/index-CoVxsMKn.css +2 -0
- package/webui/dist/build.json +39 -19
- package/webui/dist/index.html +2 -2
- package/webui/dist/assets/index-B_7Iioqo.js +0 -115
- package/webui/dist/assets/index-DPP8sEwW.css +0 -2
|
@@ -114,7 +114,7 @@ export interface FinalCheckSpec {
|
|
|
114
114
|
|
|
115
115
|
/** The checks a project's own scripts define, in run order; absent scripts are not applicable. */
|
|
116
116
|
export const FINAL_CHECK_SPECS: readonly FinalCheckSpec[] = [
|
|
117
|
-
{ script: "typecheck", check: { id: "typecheck", timeoutMs: 10 * 60_000, inputs: ["package.json", "package-lock.json", "tsconfig.json", "src", "webui/tsconfig.json", "webui/src"] } },
|
|
117
|
+
{ script: "typecheck", check: { id: "typecheck", timeoutMs: 10 * 60_000, inputs: ["package.json", "package-lock.json", "tsconfig.json", "src", "test", "webui/tsconfig.json", "webui/src"] } },
|
|
118
118
|
{ script: "test", check: { id: "test", timeoutMs: 60 * 60_000, inputs: ["package.json", "package-lock.json", "tsconfig.json", "src", "test"] } },
|
|
119
119
|
{ script: "web:build", check: { id: "web:build", timeoutMs: 10 * 60_000, inputs: ["package.json", "package-lock.json", "webui", "src/lobby/prompts.ts", "src/webui/protocol.ts"] } },
|
|
120
120
|
{ script: "web:check", check: { id: "web:check", timeoutMs: 60 * 60_000, inputs: ["package.json", "package-lock.json", "playwright.config.ts", "test/web", "webui/dist/build.json", "src"], dependsOn: ["web:build"] } },
|
|
@@ -134,32 +134,72 @@ export function finalChecks(top: string): VerifyCheck[] {
|
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
/**
|
|
138
|
+
* One shared execution per fingerprint. It runs under its own controller, so
|
|
139
|
+
* one caller's cancellation never cancels another caller's wait: the shared
|
|
140
|
+
* run is aborted only once every caller waiting on it has aborted.
|
|
141
|
+
*/
|
|
142
|
+
interface SharedRun {
|
|
143
|
+
result: Promise<VerifyResult>;
|
|
144
|
+
controller: AbortController;
|
|
145
|
+
waiters: number;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const inFlight = new Map<string, SharedRun>();
|
|
138
149
|
|
|
139
150
|
function resultOf(id: string, state: VerifyState, summary: string, fingerprint: string, ms = 0, output?: string, reused = false): VerifyResult {
|
|
140
151
|
return { id, state, at: new Date().toISOString(), ms, fingerprint, summary, ...(output ? { output } : {}), ...(reused ? { reused: true } : {}) };
|
|
141
152
|
}
|
|
142
153
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
154
|
+
function cancelledResult(check: VerifyCheck, fingerprint: string, ms = 0): VerifyResult {
|
|
155
|
+
return resultOf(check.id, "cancelled", `${check.id} was cancelled; a cancelled check is not a pass — complete again to re-run it`, fingerprint, ms);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function startShared(top: string, check: VerifyCheck, exec: VerifyExec, fingerprint: string, key: string): SharedRun {
|
|
159
|
+
const controller = new AbortController();
|
|
149
160
|
const started = Date.now();
|
|
150
|
-
const
|
|
161
|
+
const result = exec(check.command, check.args, { cwd: top, timeoutMs: check.timeoutMs, signal: controller.signal })
|
|
151
162
|
.then((outcome): VerifyResult => {
|
|
152
163
|
const ms = Date.now() - started;
|
|
153
|
-
if (signal
|
|
164
|
+
if (controller.signal.aborted) return cancelledResult(check, fingerprint, ms);
|
|
154
165
|
if (outcome.timedOut) return resultOf(check.id, "fail", `${check.id} timed out after ${Math.round(check.timeoutMs / 60_000)} min`, fingerprint, ms, outcome.output.slice(-4_000));
|
|
155
166
|
if (outcome.code === 0) return resultOf(check.id, "pass", `${check.id} passed`, fingerprint, ms);
|
|
156
167
|
if (outcome.code === null) return resultOf(check.id, "unavailable", `${check.id} could not run (command not found or terminated); an unavailable check is not a pass`, fingerprint, ms, outcome.output.slice(-4_000));
|
|
157
168
|
return resultOf(check.id, "fail", `${check.id} failed with exit ${outcome.code}`, fingerprint, ms, outcome.output.slice(-4_000));
|
|
158
169
|
})
|
|
159
170
|
.catch((error: unknown) => resultOf(check.id, "unavailable", `${check.id} could not run: ${error instanceof Error ? error.message : String(error)}`, fingerprint, Date.now() - started))
|
|
160
|
-
.finally(() => { if (inFlight.get(key) ===
|
|
161
|
-
|
|
162
|
-
|
|
171
|
+
.finally(() => { if (inFlight.get(key) === shared) inFlight.delete(key); });
|
|
172
|
+
const shared: SharedRun = { controller, waiters: 0, result };
|
|
173
|
+
inFlight.set(key, shared);
|
|
174
|
+
return shared;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Run one check: single-flight per fingerprint, so concurrent callers share the work, each under its own cancellation. */
|
|
178
|
+
function runCheck(top: string, check: VerifyCheck, exec: VerifyExec, signal: AbortSignal | undefined): Promise<VerifyResult> {
|
|
179
|
+
const fingerprint = checkFingerprint(top, check);
|
|
180
|
+
if (signal?.aborted) return Promise.resolve(cancelledResult(check, fingerprint));
|
|
181
|
+
const key = `${top}:${check.id}:${fingerprint}`;
|
|
182
|
+
const shared = inFlight.get(key) ?? startShared(top, check, exec, fingerprint, key);
|
|
183
|
+
shared.waiters += 1;
|
|
184
|
+
if (!signal) return shared.result;
|
|
185
|
+
return new Promise<VerifyResult>((resolve) => {
|
|
186
|
+
const started = Date.now();
|
|
187
|
+
const onAbort = () => {
|
|
188
|
+
shared.waiters -= 1;
|
|
189
|
+
// The last waiter leaving stops the shared run (and its process tree); earlier ones just stop waiting.
|
|
190
|
+
if (shared.waiters <= 0) {
|
|
191
|
+
// A stopped run is never joined again: the next caller starts a fresh one.
|
|
192
|
+
if (inFlight.get(key) === shared) inFlight.delete(key);
|
|
193
|
+
shared.controller.abort();
|
|
194
|
+
}
|
|
195
|
+
resolve(cancelledResult(check, fingerprint, Date.now() - started));
|
|
196
|
+
};
|
|
197
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
198
|
+
shared.result.then((result) => {
|
|
199
|
+
signal.removeEventListener("abort", onAbort);
|
|
200
|
+
resolve(signal.aborted ? cancelledResult(check, fingerprint, result.ms) : result);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
163
203
|
}
|
|
164
204
|
|
|
165
205
|
export interface VerificationInput {
|
|
@@ -198,6 +238,18 @@ export async function runVerification(input: VerificationInput): Promise<Verific
|
|
|
198
238
|
return { at: (input.now ?? (() => new Date()))().toISOString(), state, fingerprint, results, ...(results.length === 0 ? { note: "no applicable checks: the project defines none of typecheck, test, web:build, web:check" } : {}) };
|
|
199
239
|
}
|
|
200
240
|
|
|
241
|
+
/**
|
|
242
|
+
* The passing checks whose inputs no longer match the report: what changed
|
|
243
|
+
* since verification finished. Completion calls this again right before it
|
|
244
|
+
* commits, so an edit made after the run never inherits its success.
|
|
245
|
+
*/
|
|
246
|
+
export function staleVerification(top: string, checks: readonly VerifyCheck[], report: VerificationReport): string[] {
|
|
247
|
+
return report.results.flatMap((result) => {
|
|
248
|
+
const check = checks.find((entry) => entry.id === result.id);
|
|
249
|
+
return check && result.state === "pass" && result.fingerprint !== checkFingerprint(top, check) ? [result.id] : [];
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
201
253
|
/** Checks cannot pass on inputs that changed while this run was in flight. */
|
|
202
254
|
function invalidateChangedInputs(top: string, checks: readonly VerifyCheck[], results: VerifyResult[]): void {
|
|
203
255
|
for (const result of results) {
|
package/src/lobby/planner.ts
CHANGED
|
@@ -1108,7 +1108,7 @@ export class PlanningSession {
|
|
|
1108
1108
|
const seated = eligible.filter((member) => this.pins.has(member) || decision.seat.has(member));
|
|
1109
1109
|
for (const member of open) if (!decision.seat.has(member)) this.satOut.set(member, decision.probabilities.get(member) ?? 0);
|
|
1110
1110
|
const out = [...this.satOut].map(([member, probability]) => `${MEMBER_LABELS[member]} sat out (${probability.toFixed(2)})`);
|
|
1111
|
-
this.deps.feed?.log("CLASSIFIER", [`seated ${seated.length > 0 ? seated.map((member) => MEMBER_LABELS[member]).join(", ") : "nobody (the
|
|
1111
|
+
this.deps.feed?.log("CLASSIFIER", [`seated ${seated.length > 0 ? seated.map((member) => MEMBER_LABELS[member]).join(", ") : "nobody (the orchestrator plans alone)"}`, ...out, `${decision.ms} ms`].join(" · "), "info");
|
|
1112
1112
|
return seated;
|
|
1113
1113
|
}
|
|
1114
1114
|
|
|
@@ -1183,7 +1183,7 @@ export class PlanningSession {
|
|
|
1183
1183
|
}
|
|
1184
1184
|
this.reply = { ...reply, status: ready ? "ready" : "grilling", ...(mode !== "normal" ? { questions: [] } : {}), ...(plan ? { plan } : {}) };
|
|
1185
1185
|
} else {
|
|
1186
|
-
this.error = `the
|
|
1186
|
+
this.error = `the orchestrator's part of the round failed — ${lead.error ?? lead.status}`;
|
|
1187
1187
|
}
|
|
1188
1188
|
if (!reply && seatQuestions.length === 0) return;
|
|
1189
1189
|
this.questions = ready ? [] : questions;
|
package/src/master/master.ts
CHANGED
|
@@ -577,20 +577,29 @@ export function packFingerprint(content: string): string {
|
|
|
577
577
|
return createHash("sha1").update(content).digest("hex").slice(0, 16);
|
|
578
578
|
}
|
|
579
579
|
|
|
580
|
-
/** A stale entry's refreshed form: new fingerprint,
|
|
580
|
+
/** A stale entry's refreshed form: new fingerprint, ranges clamped into the file as it is, and a snippet re-read across every range. */
|
|
581
581
|
function refreshedEntry(file: ContextPackFile, content: string): ContextPackFile {
|
|
582
582
|
const lines = content.replace(/\r?\n$/, "").split("\n");
|
|
583
583
|
const clamp = (value: number): number => Math.min(Math.max(1, value), Math.max(1, lines.length));
|
|
584
584
|
const ranges = file.ranges?.map(([start, end]): [number, number] => { const from = clamp(start); const to = clamp(end); return from <= to ? [from, to] : [to, from]; });
|
|
585
|
-
const
|
|
586
|
-
const snippet = file.snippet === undefined && !ranges?.length ? undefined :
|
|
585
|
+
const read = (ranges?.length ? ranges : [[1, Math.min(lines.length, 60)] as [number, number]]).map(([start, end]) => lines.slice(Math.max(0, start - 1), Math.max(0, end)).join("\n"));
|
|
586
|
+
const snippet = file.snippet === undefined && !ranges?.length ? undefined : read.join("\n…\n").slice(0, CONTEXT_SNIPPET_MAX_CHARS);
|
|
587
587
|
return { ...file, ...(ranges ? { ranges } : {}), fingerprint: packFingerprint(content), ...(snippet !== undefined ? { snippet } : {}) };
|
|
588
588
|
}
|
|
589
589
|
|
|
590
|
+
/** The 1-based line a snippet starts on in the file as it is, when the snippet is still there verbatim. */
|
|
591
|
+
function snippetLine(content: string, snippet: string): number | undefined {
|
|
592
|
+
const at = snippet.trim() ? content.indexOf(snippet) : -1;
|
|
593
|
+
return at < 0 ? undefined : content.slice(0, at).split("\n").length;
|
|
594
|
+
}
|
|
595
|
+
|
|
590
596
|
/**
|
|
591
|
-
* Stale-context refresh at dispatch.
|
|
592
|
-
*
|
|
593
|
-
*
|
|
597
|
+
* Stale-context refresh at dispatch. The engine fingerprints every entry
|
|
598
|
+
* itself, so an orchestrator never has to compute a hash: a missing or
|
|
599
|
+
* mismatched fingerprint is checked against the file. A snippet still in the
|
|
600
|
+
* file verbatim is kept (its ranges follow it if lines moved); otherwise the
|
|
601
|
+
* entry is refreshed (new fingerprint, ranges clamped, snippet re-read across
|
|
602
|
+
* every range). A path that no longer exists drops its entry. The pack is
|
|
594
603
|
* never delivered silently stale, and the returned notes say exactly what
|
|
595
604
|
* changed so the worker knows which entries are newer than the rest.
|
|
596
605
|
*/
|
|
@@ -598,20 +607,28 @@ export async function refreshContextPack(pack: ContextPack, root: string): Promi
|
|
|
598
607
|
const notes: string[] = [];
|
|
599
608
|
const files: ContextPackFile[] = [];
|
|
600
609
|
for (const file of pack.files) {
|
|
601
|
-
if (!file.fingerprint) {
|
|
602
|
-
files.push(file);
|
|
603
|
-
continue;
|
|
604
|
-
}
|
|
605
610
|
const content = await readFile(join(root, file.path), "utf8").catch(() => undefined);
|
|
606
611
|
if (content === undefined) {
|
|
607
612
|
notes.push(`dropped ${file.path} (the file no longer exists)`);
|
|
608
613
|
continue;
|
|
609
614
|
}
|
|
610
615
|
const fingerprint = packFingerprint(content);
|
|
611
|
-
if (fingerprint === file.fingerprint)
|
|
612
|
-
|
|
616
|
+
if (fingerprint === file.fingerprint) {
|
|
617
|
+
files.push(file);
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
620
|
+
const line = file.snippet === undefined ? undefined : snippetLine(content, file.snippet);
|
|
621
|
+
if (file.snippet === undefined && !file.ranges?.length) {
|
|
622
|
+
// Path only: nothing to go stale, the engine's fingerprint is all it needs.
|
|
623
|
+
files.push({ ...file, fingerprint });
|
|
624
|
+
} else if (line !== undefined) {
|
|
625
|
+
const shift = file.ranges?.[0] ? line - file.ranges[0][0] : 0;
|
|
626
|
+
const ranges = file.ranges?.map(([start, end]): [number, number] => [Math.max(1, start + shift), Math.max(1, end + shift)]);
|
|
627
|
+
files.push({ ...file, ...(ranges ? { ranges } : {}), fingerprint });
|
|
628
|
+
if (shift !== 0) notes.push(`moved ${file.path} ranges by ${shift > 0 ? "+" : ""}${shift} lines (the snippet is unchanged)`);
|
|
629
|
+
} else {
|
|
613
630
|
files.push(refreshedEntry(file, content));
|
|
614
|
-
notes.push(`refreshed ${file.path} (content had changed; new fingerprint ${fingerprint})`);
|
|
631
|
+
notes.push(`refreshed ${file.path} (${file.fingerprint ? "content had changed" : "the snippet no longer matches the file"}; new fingerprint ${fingerprint})`);
|
|
615
632
|
}
|
|
616
633
|
}
|
|
617
634
|
pack.files = files;
|
package/src/pi/tools.ts
CHANGED
|
@@ -31,7 +31,7 @@ export const ContextPackSchema = Type.Object({
|
|
|
31
31
|
files: Type.Array(Type.Object({
|
|
32
32
|
path: Type.String({ minLength: 1 }),
|
|
33
33
|
ranges: Type.Optional(Type.Array(Type.Tuple([Type.Integer({ minimum: 1 }), Type.Integer({ minimum: 1 })]), { description: "[start, end] line ranges with 1 <= start <= end" })),
|
|
34
|
-
fingerprint: Type.Optional(Type.String({ minLength: 1, description: "
|
|
34
|
+
fingerprint: Type.Optional(Type.String({ minLength: 1, description: "optional; leave it out — the engine fingerprints each file at dispatch and refreshes stale snippets" })),
|
|
35
35
|
snippet: Type.Optional(Type.String({ maxLength: 2000, description: "bounded excerpt, current at pack-build time" })),
|
|
36
36
|
}, { additionalProperties: false })),
|
|
37
37
|
invariants: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
|
|
@@ -124,6 +124,9 @@ export function isLintMode(value: unknown): value is LintMode {
|
|
|
124
124
|
return typeof value === "string" && (LINT_MODES as readonly string[]).includes(value);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
export const LINT_RULE_LEVELS = ["off", "warn", "error"] as const;
|
|
128
|
+
export type LintRuleLevel = (typeof LINT_RULE_LEVELS)[number];
|
|
129
|
+
|
|
127
130
|
export interface LintConfig {
|
|
128
131
|
mode: LintMode;
|
|
129
132
|
/** A command of your own, run without a shell from the repository's top; `{files}` stands for the touched files (they are appended when it is absent). Empty: the project's own linters are found (ESLint, Biome, Oxlint, Ruff). */
|
|
@@ -132,6 +135,8 @@ export interface LintConfig {
|
|
|
132
135
|
extensions: string[];
|
|
133
136
|
/** Time limit for one linter run. */
|
|
134
137
|
timeoutMs: number;
|
|
138
|
+
/** ESLint rules the gate adds on top of the project's config (`--rule name: level`), set in Settings' linting wizard. ESLint's config is code, so it is never rewritten. */
|
|
139
|
+
eslintRules: Record<string, LintRuleLevel>;
|
|
135
140
|
}
|
|
136
141
|
|
|
137
142
|
export interface KnowledgeConfig {
|
|
@@ -289,7 +294,7 @@ export const DEFAULT_CONFIG: BotLobbyConfig = {
|
|
|
289
294
|
cleanReview: true,
|
|
290
295
|
knowledgeStartupBudget: 8000,
|
|
291
296
|
},
|
|
292
|
-
lint: { mode: "advise", command: "", extensions: [], timeoutMs: 2 * 60 * 1000 },
|
|
297
|
+
lint: { mode: "advise", command: "", extensions: [], timeoutMs: 2 * 60 * 1000, eslintRules: {} },
|
|
293
298
|
knowledge: {
|
|
294
299
|
compactionThreshold: 20000,
|
|
295
300
|
backupCount: 1,
|
|
@@ -474,9 +479,17 @@ function normalizeLint(value: unknown): LintConfig {
|
|
|
474
479
|
command: text(source.command, defaults.command),
|
|
475
480
|
extensions: [...new Set(extensions)],
|
|
476
481
|
timeoutMs: timeout ? Math.min(30 * 60 * 1000, Math.round(timeout)) : defaults.timeoutMs,
|
|
482
|
+
eslintRules: eslintRules(source.eslintRules),
|
|
477
483
|
};
|
|
478
484
|
}
|
|
479
485
|
|
|
486
|
+
/** Rule names as ESLint writes them (`no-console`, `@typescript-eslint/no-explicit-any`), each with a level; at most 200. */
|
|
487
|
+
function eslintRules(value: unknown): Record<string, LintRuleLevel> {
|
|
488
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
489
|
+
const entries = Object.entries(value as Record<string, unknown>).filter((entry): entry is [string, LintRuleLevel] => /^[@\w][\w@/.-]{0,120}$/.test(entry[0]) && (LINT_RULE_LEVELS as readonly unknown[]).includes(entry[1]));
|
|
490
|
+
return Object.fromEntries(entries.slice(0, 200));
|
|
491
|
+
}
|
|
492
|
+
|
|
480
493
|
function normalizeClassifier(value: unknown): ClassifierConfig {
|
|
481
494
|
const source = (value && typeof value === "object" ? value : {}) as Record<string, unknown>;
|
|
482
495
|
const defaults = DEFAULT_CONFIG.classifier;
|
package/src/schemas/lint.ts
CHANGED
|
@@ -53,3 +53,53 @@ export interface LintReport {
|
|
|
53
53
|
/** The touched files as they stood and the settings: an equal key means an equal result. */
|
|
54
54
|
fingerprint: string;
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
// The Settings page's linting wizard (`settings.lintSetup`).
|
|
58
|
+
|
|
59
|
+
export type LintRuleLevel = "off" | "warn" | "error";
|
|
60
|
+
/** A rule's level as the page shows it: `default` is whatever the project's config (or the linter) already says. */
|
|
61
|
+
export type RuleChoice = "default" | LintRuleLevel;
|
|
62
|
+
|
|
63
|
+
export interface LintRuleInfo {
|
|
64
|
+
id: string;
|
|
65
|
+
label: string;
|
|
66
|
+
help: string;
|
|
67
|
+
level: RuleChoice;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface LintSetupLinter {
|
|
71
|
+
tool: string;
|
|
72
|
+
/** Repository-relative ("" at the top). */
|
|
73
|
+
folder: string;
|
|
74
|
+
installed: boolean;
|
|
75
|
+
/** The file the rules are read from and written to, repository-relative, when there is one. */
|
|
76
|
+
config?: string;
|
|
77
|
+
/** file: switches edit `config`; gate: they are the lint gate's `--rule` flags; read: shown, not switchable (see `note`). */
|
|
78
|
+
rulesAt: "file" | "gate" | "read";
|
|
79
|
+
/** The levels a rule can take: Ruff has no warnings, so its rules are on (error) or off. */
|
|
80
|
+
levels: LintRuleLevel[];
|
|
81
|
+
rules: LintRuleInfo[];
|
|
82
|
+
/** Commands that install it in its folder, when it is not installed. */
|
|
83
|
+
install: string[];
|
|
84
|
+
note?: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** A step of setting up a linter the project does not have yet: a command to run, or a starter config the page writes. */
|
|
88
|
+
export interface LintSetupStep {
|
|
89
|
+
label: string;
|
|
90
|
+
command?: string;
|
|
91
|
+
/** The config file the page creates for this step (`ruff.toml`). */
|
|
92
|
+
create?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface LintSetupOffer {
|
|
96
|
+
tool: string;
|
|
97
|
+
blurb: string;
|
|
98
|
+
steps: LintSetupStep[];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface LintSetup {
|
|
102
|
+
linters: LintSetupLinter[];
|
|
103
|
+
offers: LintSetupOffer[];
|
|
104
|
+
}
|
|
105
|
+
|
package/src/webui/api/index.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { tasksArchive, tasksArchived, tasksAuto, tasksComment, tasksComments, ta
|
|
|
18
18
|
import { knowledgeAccept, knowledgeAdd, knowledgeAsk, knowledgeComment, knowledgeDismiss, knowledgeEdit, knowledgeFiles, knowledgeLedger, knowledgeMove, knowledgeOpen, knowledgePin, knowledgeRemove, knowledgeReplaceFile, knowledgeRestore, knowledgeUnnote } from "./knowledge.ts";
|
|
19
19
|
import { plansDiscard, plansGet, plansStart } from "./plans.ts";
|
|
20
20
|
import { sessionsAnswer, sessionsArchive, sessionsChat, sessionsDelete, sessionsList, sessionsMessage, sessionsRename, sessionsStart, sessionsStop, sessionsSwitch } from "./sessions.ts";
|
|
21
|
-
import { settingsGet, settingsGrants, settingsHarnesses, settingsLinters, settingsSet } from "./settings.ts";
|
|
21
|
+
import { settingsGet, settingsGrants, settingsHarnesses, settingsLintCreate, settingsLinters, settingsLintRule, settingsLintSetup, settingsSet } from "./settings.ts";
|
|
22
22
|
import { lobbyRetention, lobbySetRetention } from "./retention.ts";
|
|
23
23
|
import { terminalClose, terminalInput, terminalList, terminalOpen, terminalResize } from "./terminal.ts";
|
|
24
24
|
import { MAX_INPUT_CHARS } from "../terminal.ts";
|
|
@@ -377,6 +377,17 @@ function buildRoutes(): Record<string, Route> {
|
|
|
377
377
|
run: (body, ctx) => settingsSet(body as { patch: Record<string, unknown> }, ctx),
|
|
378
378
|
};
|
|
379
379
|
routes["settings.linters"] = { schema: Empty, run: (_body, ctx) => settingsLinters(ctx) };
|
|
380
|
+
routes["settings.lintSetup"] = { schema: Empty, run: (_body, ctx) => settingsLintSetup(ctx) };
|
|
381
|
+
routes["settings.lintRule"] = {
|
|
382
|
+
schema: Type.Object({
|
|
383
|
+
tool: Type.String({ minLength: 1, maxLength: 40 }),
|
|
384
|
+
folder: Type.String({ maxLength: 4096 }),
|
|
385
|
+
rule: Type.String({ minLength: 1, maxLength: 120 }),
|
|
386
|
+
level: Type.Union([Type.Literal("default"), Type.Literal("off"), Type.Literal("warn"), Type.Literal("error")]),
|
|
387
|
+
}, { additionalProperties: false }),
|
|
388
|
+
run: (body, ctx) => settingsLintRule(body as { tool: string; folder: string; rule: string; level: "default" | "off" | "warn" | "error" }, ctx),
|
|
389
|
+
};
|
|
390
|
+
routes["settings.lintCreate"] = { schema: Type.Object({ name: Type.String({ minLength: 1, maxLength: 60 }) }, { additionalProperties: false }), run: (body, ctx) => settingsLintCreate(body as { name: string }, ctx) };
|
|
380
391
|
routes["settings.grants"] = { schema: Empty, run: (_body, ctx) => settingsGrants(ctx) };
|
|
381
392
|
routes["settings.harnesses"] = { schema: Empty, run: (_body, ctx) => settingsHarnesses(ctx) };
|
|
382
393
|
const ThemeId = Type.String({ minLength: 1, maxLength: 40 });
|
|
@@ -12,6 +12,8 @@ import { kindLabel } from "../../pi/model-support.ts";
|
|
|
12
12
|
import { pushNotice } from "../notices.ts";
|
|
13
13
|
import type { SettingsGrants, SettingsHarnesses, SettingsInfo, SettingsLinter } from "../protocol.ts";
|
|
14
14
|
import { harnessStatuses } from "../../harness/status.ts";
|
|
15
|
+
import { createLintConfig, lintSetup, LintSetupError, setLintRule } from "../../execution/lint-setup.ts";
|
|
16
|
+
import type { LintSetup, RuleChoice } from "../../schemas/lint.ts";
|
|
15
17
|
import type { ApiContext } from "./index.ts";
|
|
16
18
|
import { fail } from "./index.ts";
|
|
17
19
|
|
|
@@ -84,6 +86,43 @@ export function settingsLinters(ctx: ApiContext): { linters: SettingsLinter[] }
|
|
|
84
86
|
return { linters: ctx.service.linters?.() ?? [] };
|
|
85
87
|
}
|
|
86
88
|
|
|
89
|
+
const lintRoot = (ctx: ApiContext) => ctx.service.projectRoot?.() ?? process.cwd();
|
|
90
|
+
|
|
91
|
+
/** The linting wizard: the linters found, their common rules, and how to install or add one. */
|
|
92
|
+
export function settingsLintSetup(ctx: ApiContext): LintSetup {
|
|
93
|
+
return lintSetup(lintRoot(ctx), readConfig(ctx).lint, ctx.service.linters?.());
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Switch one of a linter's common rules: in its config file, or (ESLint) in the gate's own rules. */
|
|
97
|
+
export function settingsLintRule(body: { tool: string; folder: string; rule: string; level: RuleChoice }, ctx: ApiContext): LintSetup {
|
|
98
|
+
const config = readConfig(ctx);
|
|
99
|
+
try {
|
|
100
|
+
const result = setLintRule(lintRoot(ctx), config.lint, body);
|
|
101
|
+
if (result.eslintRules) {
|
|
102
|
+
// Replaced whole, not merged, so a rule set back to the project's default is gone.
|
|
103
|
+
const next = resolveConfig({ ...config, lint: { ...config.lint, eslintRules: result.eslintRules } });
|
|
104
|
+
writeConfig(ctx, next);
|
|
105
|
+
ctx.service.configChanged?.();
|
|
106
|
+
lobbyTopics.bump("status");
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
if (error instanceof LintSetupError) fail(409, "conflict", error.message);
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
return settingsLintSetup(ctx);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Write a starter config the wizard offers (ruff.toml). */
|
|
116
|
+
export function settingsLintCreate(body: { name: string }, ctx: ApiContext): LintSetup {
|
|
117
|
+
try {
|
|
118
|
+
createLintConfig(lintRoot(ctx), body.name);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
if (error instanceof LintSetupError) fail(409, "conflict", error.message);
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
return settingsLintSetup(ctx);
|
|
124
|
+
}
|
|
125
|
+
|
|
87
126
|
/** The MCP tools and skills pi offers now, for each agent's grants. */
|
|
88
127
|
export function settingsGrants(ctx: ApiContext): SettingsGrants {
|
|
89
128
|
return ctx.service.grants?.() ?? { mcpTools: [], skills: [] };
|
package/src/webui/protocol.ts
CHANGED
|
@@ -13,6 +13,8 @@ import type { TaskRow } from "../lobby/task-rows.ts";
|
|
|
13
13
|
import type { PlanComment } from "../state/comments.ts";
|
|
14
14
|
import type { BotLobbyConfig, PanelMember } from "../schemas/configuration.ts";
|
|
15
15
|
import type { QaRiskAssessment } from "../schemas/task.ts";
|
|
16
|
+
import type { LintSetup } from "../schemas/lint.ts";
|
|
17
|
+
export type { LintRuleInfo, LintSetup, LintSetupLinter, LintSetupOffer, LintSetupStep, RuleChoice } from "../schemas/lint.ts";
|
|
16
18
|
import type { MemberState, PanelNote, PanelQuestion, PlannerMessage } from "../lobby/planner.ts";
|
|
17
19
|
import type { HarnessStatus } from "../harness/status.ts";
|
|
18
20
|
import type { HarnessModel } from "../harness/catalog.ts";
|
|
@@ -561,6 +563,9 @@ export interface Api {
|
|
|
561
563
|
"settings.get": { request: Record<string, never>; result: SettingsInfo };
|
|
562
564
|
"settings.set": { request: { patch: Record<string, unknown> }; result: { config: BotLobbyConfig } };
|
|
563
565
|
"settings.linters": { request: Record<string, never>; result: { linters: SettingsLinter[] } };
|
|
566
|
+
"settings.lintSetup": { request: Record<string, never>; result: LintSetup };
|
|
567
|
+
"settings.lintRule": { request: { tool: string; folder: string; rule: string; level: "default" | "off" | "warn" | "error" }; result: LintSetup };
|
|
568
|
+
"settings.lintCreate": { request: { name: string }; result: LintSetup };
|
|
564
569
|
"settings.grants": { request: Record<string, never>; result: SettingsGrants };
|
|
565
570
|
"settings.harnesses": { request: Record<string, never>; result: SettingsHarnesses };
|
|
566
571
|
"themes.get": { request: Record<string, never>; result: ThemeStoreInfo };
|
package/src/workflow/workflow.ts
CHANGED
|
@@ -31,8 +31,8 @@ import { loadTask, ownerlessTask, readTaskArtifact, removeTaskScratchpads, saveT
|
|
|
31
31
|
import { dataRoot, readDataRoots } from "../state/project.ts";
|
|
32
32
|
import { appendCompletedTask, appendDecision, applyKnowledge, readFileOr, writeFileEnsured, type KnowledgeKind } from "../knowledge/store.ts";
|
|
33
33
|
import { proposalParts, propose } from "../knowledge/ledger.ts";
|
|
34
|
-
import { compactKnowledgeFile, overThreshold, scheduleKnowledgeMaintenance } from "../knowledge/compactor.ts";
|
|
35
|
-
import { finalChecks, runVerification, verificationSummary } from "../execution/verification.ts";
|
|
34
|
+
import { compactKnowledgeFile, overThreshold, scheduleKnowledgeMaintenance, type MaintenanceSchedule } from "../knowledge/compactor.ts";
|
|
35
|
+
import { finalChecks, runVerification, staleVerification, verificationSummary } from "../execution/verification.ts";
|
|
36
36
|
import { oracleBookmarkOp, retireBookmarks, type OracleBookmarkOp } from "../knowledge/bookmarks.ts";
|
|
37
37
|
import { knowledgeDir, type KnowledgeAgent } from "../knowledge/paths.ts";
|
|
38
38
|
import { lobbyTopics } from "../lobby/topics.ts";
|
|
@@ -1895,6 +1895,17 @@ function handleCompact(task: Task | undefined, params: OrchestrateParams, deps:
|
|
|
1895
1895
|
}
|
|
1896
1896
|
|
|
1897
1897
|
/** §63: record history, drop scratchpads, then mark the task completed. */
|
|
1898
|
+
/** Scheduled knowledge maintenance reports back: a failed or busy run is visible and says what to do, never dropped. */
|
|
1899
|
+
function reportMaintenance(deps: WorkflowDeps, schedule: MaintenanceSchedule): void {
|
|
1900
|
+
void schedule.done.then((result) => {
|
|
1901
|
+
const file = `${result.agent}/${result.file}`;
|
|
1902
|
+
if (result.status === "unchanged") deps.notify(`Knowledge maintenance: ${file} has nothing clearly duplicate or historical to archive, so it stays over the compaction threshold. Rewrite it with action=compact if it should shrink.`, "info");
|
|
1903
|
+
if (result.status === "maintained") deps.notify(`Knowledge maintenance: ${file} archived ${result.before - result.after} characters to ${result.history}.`, "info");
|
|
1904
|
+
else if (result.status === "busy") deps.notify(`Knowledge maintenance: ${file} was already being maintained; it is retried at the next completion.`, "warning");
|
|
1905
|
+
else if (result.status === "failed") deps.notify(`Knowledge maintenance failed for ${file}: ${result.error ?? "unknown error"} Maintenance left the active file as it was; it is retried at the next completion, or rewrite it with action=compact.`, "warning");
|
|
1906
|
+
}).catch(() => undefined);
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1898
1909
|
async function handleComplete(task: Task, params: OrchestrateParams, deps: WorkflowDeps): Promise<string> {
|
|
1899
1910
|
// The fast track (and a plan QA sat out) completes straight from its work; the full workflow from review.
|
|
1900
1911
|
requireState(task, onFastTrack(task) || !qaRequired(task) ? ["implementing", "reviewing", "blocked"] : ["reviewing", "blocked"]);
|
|
@@ -1915,20 +1926,24 @@ async function handleComplete(task: Task, params: OrchestrateParams, deps: Workf
|
|
|
1915
1926
|
// fast tasks included) must pass on the tree as it stands before anything is committed. Recorded
|
|
1916
1927
|
// passes are reused while their inputs are unchanged; missing, stale, failed, cancelled and
|
|
1917
1928
|
// unavailable results are not passes. Heavy checks run here only, never between worker steps.
|
|
1918
|
-
const
|
|
1929
|
+
const checks = finalChecks(deps.cwd);
|
|
1930
|
+
const verification = await runVerification({ top: deps.cwd, checks, previous: task.verification, ...(deps.signal ? { signal: deps.signal } : {}) });
|
|
1919
1931
|
deps.signal?.throwIfAborted();
|
|
1920
1932
|
task.verification = verification;
|
|
1921
1933
|
saveTask(deps.root, deps.configDir, task);
|
|
1922
|
-
appendMetrics(deps.root, deps.configDir, [{ id: randomUUID(), kind: "master", agent: "
|
|
1934
|
+
appendMetrics(deps.root, deps.configDir, [{ id: randomUUID(), kind: "master", agent: "MASTER", status: "success", startedAt: verification.at, durationMs: verification.results.reduce((total, result) => total + result.ms, 0), purpose: `final verification (${verification.results.length} checks)`, cacheHits: verification.results.filter((result) => result.reused).length, ...(task.id ? { taskId: task.id } : {}) }]);
|
|
1923
1935
|
if (verification.state !== "passing") throw new Error(`cannot complete: final verification failed — ${verificationSummary(verification)}. Fix the failing checks and call complete again; unchanged passes are kept.`);
|
|
1924
1936
|
// The gate refuses before any side effect, so a refusal leaves the task untouched. Oversized knowledge no
|
|
1925
1937
|
// longer holds completion: automatic maintenance is scheduled and runs after this response.
|
|
1926
1938
|
const oversized = overThreshold(readDataRoots(deps.root, deps.configDir), deps.config.knowledge.compactionThreshold);
|
|
1927
|
-
for (const entry of oversized) {
|
|
1928
|
-
scheduleKnowledgeMaintenance({ dataRoot: dataRoot(deps.root, deps.configDir), agent: entry.agent, file: entry.file, backupCount: deps.config.knowledge.backupCount });
|
|
1929
|
-
}
|
|
1930
1939
|
const maintenance = oversized.length > 0 ? ` Automatic knowledge maintenance scheduled for ${oversized.map((entry) => `${entry.agent}/${entry.file}`).join(", ")}; it archives duplicate and historical material after this response.` : "";
|
|
1931
1940
|
deps.signal?.throwIfAborted();
|
|
1941
|
+
// An edit made after the checks ran never inherits their success: re-key the passes right before the commit.
|
|
1942
|
+
const stale = staleVerification(deps.cwd, checks, verification);
|
|
1943
|
+
if (stale.length > 0) throw new Error(`cannot complete: ${stale.join(", ")} inputs changed after final verification passed; call complete again to verify the current tree.`);
|
|
1944
|
+
for (const entry of oversized) {
|
|
1945
|
+
reportMaintenance(deps, scheduleKnowledgeMaintenance({ dataRoot: dataRoot(deps.root, deps.configDir), agent: entry.agent, file: entry.file, backupCount: deps.config.knowledge.backupCount }));
|
|
1946
|
+
}
|
|
1932
1947
|
const committed = await commitTaskWork(task, params, deps);
|
|
1933
1948
|
deps.signal?.throwIfAborted();
|
|
1934
1949
|
const summary = params.text?.trim() || task.proposal || task.title;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/astro-p42oEArs.js","assets/json-qhed-kSA.js","assets/javascript-BgS3c2Ky.js","assets/typescript-BydbNFcO.js","assets/rolldown-runtime-hePW80VL.js","assets/css-C8fQr_0Q.js","assets/postcss-D_Wz94rJ.js","assets/tsx-CUOciP0b.js","assets/graphql-AVu4aKQX.js","assets/jsx-gTgmArGx.js","assets/html-wSbaAAK3.js","assets/java-DdHNQ9hk.js","assets/kts-DFAlwc6n.js","assets/kotlin-DhhofPvG.js","assets/lua-xZcbXUE9.js","assets/c-DaO8xguW.js","assets/php-C6PDnbTe.js","assets/xml-CeXJrFlG.js","assets/sql-CEbI0hMM.js","assets/properties-CxAuzHS9.js","assets/ini-B5eOa1yu.js","assets/ruby-CPL7DL0w.js","assets/shellscript-CLZ0U2zV.js","assets/yaml-rwi0_p6S.js","assets/scss-CHVQqdPx.js","assets/svelte-DKhxH1PN.js","assets/vue-kBwcnTZb.js","assets/yml-s9iVJXCw.js","assets/zsh-B7CDPTg5.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{a as n,c as r,i,l as a,n as o,o as s,r as c,s as l,t as u}from"./ccount-DQxSH8e6.js";import{t as d}from"./index-
|
|
2
|
+
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{a as n,c as r,i,l as a,n as o,o as s,r as c,s as l,t as u}from"./ccount-DQxSH8e6.js";import{t as d}from"./index-BUrfox9b.js";var f={}.hasOwnProperty;function p(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&f.call(t,e)){let n=String(t[e]);i=f.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var m=10,h=13,g=4,_=40;function v(e){let t=[0],n=e.indexOf(`\r`),r=e.indexOf(`
|
|
3
3
|
`),i=0,a=0;for(;n!==-1||r!==-1;){let o;if(n!==-1&&(r===-1||n<r)?r===n+1?(o=r+1,n=e.indexOf(`\r`,o),r=e.indexOf(`
|
|
4
4
|
`,o)):(o=n+1,n=e.indexOf(`\r`,o)):(o=r+1,r=e.indexOf(`
|
|
5
5
|
`,o)),t.push(o),++a===g){if(o-i<=_){for(let n=o;n<e.length;n++){let r=e.charCodeAt(n);(r===m||r===h)&&(r===h&&n+1<e.length&&e.charCodeAt(n+1)===m&&n++,t.push(n+1))}return t}i=o,a=0}}return t}function y(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);(r===m||r===h)&&(r===h&&n+1<e.length&&e.charCodeAt(n+1)===m&&n++,t++)}return t}function b(e){let t=v(e);return Array.from({length:t.length},(n,r)=>{let i=t[r],a=t[r+1]??e.length;return e.slice(i,a)})}var x=100,S=`insert`,C=`backspace`,w=`delete`,T=class e{#e=[];#t=[];#n;#r=!1;constructor(e){this.#n=Math.max(1,e?.maxEntries??x)}get canUndo(){return this.#e.length>0}get canRedo(){return this.#t.length>0}getState(){return{undoStack:this.#e.map(ee),redoStack:this.#t.map(ee),maxEntries:this.#n,canCoalesce:this.#r}}getLiveState(){return Object.defineProperties({},{undoStack:{enumerable:!0,get:()=>this.#e},redoStack:{enumerable:!0,get:()=>this.#t},maxEntries:{enumerable:!0,get:()=>this.#n},canCoalesce:{enumerable:!0,get:()=>this.#r}})}static fromState(t){let n=new e({maxEntries:t.maxEntries});return n.#e=t.undoStack,n.#t=t.redoStack,n.#r=t.canCoalesce,n}clear(){this.#e.length=0,this.#t.length=0,this.#r=!1}clearRedo(){this.#t.length=0}push(e){this.#e.push(e),this.clearRedo(),this.#r=!0,this.#e.length>this.#n&&this.#e.shift()}setLastUndoSelectionsAfter(e){let t=this.#e[this.#e.length-1];t!==void 0&&(t.selectionsAfter=e.map(e=>({...e})))}setLastUndoLineAnnotations(e,t){let n=this.#e[this.#e.length-1];n!==void 0&&(n.lineAnnotationsBefore=e.slice(),n.lineAnnotationsAfter=t.slice())}peekUndo(){return this.#e[this.#e.length-1]}peekUndoForCoalescing(){return this.#r?this.peekUndo():void 0}replaceLastUndo(e){if(this.#e.length===0){this.push(e);return}this.#e[this.#e.length-1]=e,this.clearRedo(),this.#r=!0}popUndoToRedo(){let e=this.#e.pop();if(e!==void 0)return this.#t.push(e),this.#r=!1,e}popRedoToUndo(){let e=this.#t.pop();if(e!==void 0)return this.#e.push(e),this.#r=!1,e}};function E(e){return{...e,forwardEdits:e.forwardEdits.map(e=>({...e})),inverseEdits:e.inverseEdits.map(e=>({...e})),selectionsBefore:e.selectionsBefore?.map(D),selectionsAfter:e.selectionsAfter?.map(D),lineAnnotationsBefore:e.lineAnnotationsBefore?.slice(),lineAnnotationsAfter:e.lineAnnotationsAfter?.slice()}}function ee(e){return{...E(e),lineAnnotationsBefore:e.lineAnnotationsBefore?.map(e=>({...e})),lineAnnotationsAfter:e.lineAnnotationsAfter?.map(e=>({...e}))}}function D(e){return{...e,start:{...e.start},end:{...e.end}}}function O(e,t,n,r,i,a,o,s){let c=[...t].sort((e,t)=>e.start-t.start),l=[],u;if(i?.length===c.length){let t=[];for(let n of i){if(n.start.line!==n.end.line||n.start.character!==n.end.character)break;t.push(e.offsetAt(n.start))}if(t.length===c.length){t.sort((e,t)=>e-t);let e=!0,n=!0;for(let r=0;r<c.length;r++){let i=c[r];if(i.text.length>0||i.start===i.end){e=!1,n=!1;break}e&&=t[r]===i.end,n&&=t[r]===i.start}u=e?C:n?w:void 0}}for(let t=0,n=0;t<c.length;t++){let r=c[t],i=e.getTextSlice(r.start,r.end),a=r.start+n;l.push({start:a,end:a+r.text.length,text:i}),n+=r.text.length-(r.end-r.start)}return{forwardEdits:c.map(e=>({...e})),inverseEdits:l,versionBefore:n,versionAfter:r,selectionsBefore:i?.map(e=>({...e})),selectionsAfter:a?.map(e=>({...e})),lineAnnotationsBefore:o?.slice(),lineAnnotationsAfter:s?.slice(),coalescingMode:u}}function k(e,t){if(e===void 0||e.undoBoundary===!0||t.undoBoundary===!0||e.forwardEdits.length===0||e.forwardEdits.length!==e.inverseEdits.length||e.forwardEdits.length!==t.forwardEdits.length||t.forwardEdits.length!==t.inverseEdits.length)return!1;let n;for(let r=0;r<e.forwardEdits.length;r++){let i=e.forwardEdits[r],a=e.inverseEdits[r],o=t.forwardEdits[r],s=t.inverseEdits[r],c=ne(o.start,e.forwardEdits),l=i.start<=i.end&&i.text.length>0&&!i.text.includes(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./ccount-DQxSH8e6.js";import{i as r,n as i,r as a}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./ccount-DQxSH8e6.js";import{i as r,n as i,r as a}from"./index-BUrfox9b.js";var o=e(n(),1),s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=(e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{for(var i=r>1?void 0:r?c(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&s(t,n,i),i},d=(e,t)=>(n,r)=>t(n,r,e),f=`Terminal input`,p={get:()=>f,set:e=>f=e},m=`Too much output to announce, navigate to rows manually to read`,h={get:()=>m,set:e=>m=e};function g(e){return e.replace(/\r?\n/g,`\r`)}function _(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function ee(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function te(e,t,n,r){e.stopPropagation(),e.clipboardData&&ne(e.clipboardData.getData(`text/plain`),t,n,r)}function ne(e,t,n,r){e=g(e),e=_(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function re(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ie(e,t,n,r,i){re(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function ae(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function oe(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var se=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},ce=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},v=``,le=` `,ue=class e{constructor(){this.fg=0,this.bg=0,this.extended=new de}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},de=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},y=class e extends ue{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new de,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?ae(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},fe=`di$target`,pe=`di$dependencies`,me=new Map;function b(e){return e[pe]||[]}function x(e){if(me.has(e))return me.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);he(t,e,r)};return t._id=e,me.set(e,t),t}function he(e,t,n){t[fe]===t?t[pe].push({id:e,index:n}):(t[pe]=[{id:e,index:n}],t[fe]=t)}var S=x(`BufferService`),ge=x(`CoreMouseService`),_e=x(`CoreService`),C=x(`CharsetService`),ve=x(`InstantiationService`),w=x(`LogService`),T=x(`OptionsService`),ye=x(`OscLinkService`),be=x(`UnicodeService`),xe=x(`DecorationService`),Se=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new y,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Ce(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Se=u([d(0,S),d(1,T),d(2,ye)],Se);function Ce(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
2
2
|
|
|
3
3
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var we=x(`CharSizeService`),Te=x(`CoreBrowserService`),Ee=x(`MouseService`),De=x(`RenderService`),Oe=x(`SelectionService`),ke=x(`CharacterJoinerService`),Ae=x(`ThemeService`),je=x(`LinkProviderService`),Me=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Re.isErrorNoTelemetry(e)?new Re(e.message+`
|
|
4
4
|
|