@evandu/super-pi 0.1.232 → 0.1.234

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.
Files changed (55) hide show
  1. package/agents/super-pi-task/core.ts +38 -0
  2. package/agents/super-pi-task/index.ts +17 -0
  3. package/dist/client/.super-pi-client-sources.json +9 -9
  4. package/dist/client/assets/CodeMirrorEditor-Bghp-U4C.js +2 -0
  5. package/dist/client/assets/{dist-C7VEKkD-.js → dist-B8NaV9Cv.js} +1 -1
  6. package/dist/client/assets/{dist-Bv4wCENt.js → dist-BESOLyaG.js} +1 -1
  7. package/dist/client/assets/{dist-BFeunbEX.js → dist-BNTyu0GR.js} +1 -1
  8. package/dist/client/assets/{dist-BKp3q2wn.js → dist-BOLAeWpo.js} +1 -1
  9. package/dist/client/assets/{dist-C31-s_h7.js → dist-BXS7H8-R.js} +1 -1
  10. package/dist/client/assets/{dist-D8RY2jNq.js → dist-BfJ86nxw.js} +1 -1
  11. package/dist/client/assets/{dist-Dfq0xUba.js → dist-Bs7CHuCU.js} +1 -1
  12. package/dist/client/assets/{dist-BIy5crB3.js → dist-C7Frt-j5.js} +1 -1
  13. package/dist/client/assets/{dist-BpINRZym.js → dist-CWI_J8Y8.js} +1 -1
  14. package/dist/client/assets/{dist-UKx13tHO.js → dist-CXgcMgdt.js} +1 -1
  15. package/dist/client/assets/{dist-C6wg16BA.js → dist-CeyskXU5.js} +1 -1
  16. package/dist/client/assets/{dist-B9BbvWot.js → dist-CpJDmC2s.js} +1 -1
  17. package/dist/client/assets/{dist-DEKenQm-.js → dist-DDQEsi6d.js} +1 -1
  18. package/dist/client/assets/{dist-znfz-BcE.js → dist-DkGaMCuB.js} +1 -1
  19. package/dist/client/assets/{dist-a2NOYHv3.js → dist-DzEYlfwN.js} +1 -1
  20. package/dist/client/assets/{dist-H6BCSlev.js → dist-Ka-oeqiz.js} +1 -1
  21. package/dist/client/assets/{dist-IEeNkSQA.js → dist-Zo5WaMe0.js} +1 -1
  22. package/dist/client/assets/{dist-BJ6foecv.js → dist-gzowmwC2.js} +1 -1
  23. package/dist/client/assets/{dist-Ydfp2kM0.js → dist-jtZ_yT6e.js} +1 -1
  24. package/dist/client/assets/{dist-DXa_Ik6q.js → dist-pz-FtJ-_.js} +1 -1
  25. package/dist/client/assets/{dist-C0RopB4q.js → dist-qY4JuH16.js} +1 -1
  26. package/dist/client/assets/{dist-Opwy6jSg.js → dist-vqHBACjg.js} +1 -1
  27. package/dist/client/assets/{index-P5ei_l2b.css → index-CYevEn2Z.css} +1 -1
  28. package/dist/client/assets/{index-DREwHzYy.js → index-_JUMqd3d.js} +59 -58
  29. package/dist/client/index.html +2 -2
  30. package/dist/server/application/worktree-service.d.ts +13 -0
  31. package/dist/server/application/worktree-service.js +76 -0
  32. package/dist/server/explicit-file-open.d.ts +34 -0
  33. package/dist/server/explicit-file-open.js +105 -0
  34. package/dist/server/file-name-index.d.ts +5 -5
  35. package/dist/server/file-name-index.js +22 -19
  36. package/dist/server/files.d.ts +5 -0
  37. package/dist/server/files.js +12 -6
  38. package/dist/server/git.d.ts +23 -0
  39. package/dist/server/git.js +234 -18
  40. package/dist/server/http-server.js +129 -6
  41. package/dist/server/model-filter.js +2 -2
  42. package/dist/server/runtime.js +3 -3
  43. package/dist/server/store.d.ts +2 -1
  44. package/dist/server/store.js +19 -3
  45. package/dist/server/task-tool.d.ts +1 -0
  46. package/dist/server/task-tool.js +1 -0
  47. package/dist/server/types.d.ts +3 -0
  48. package/dist/server/workspace-file-response.d.ts +6 -2
  49. package/dist/server/workspace-file-response.js +6 -6
  50. package/dist/shared/git-commit.d.ts +11 -0
  51. package/dist/shared/git-commit.js +1 -0
  52. package/dist/shared/git-graph.d.ts +38 -0
  53. package/dist/shared/git-graph.js +30 -0
  54. package/package.json +1 -1
  55. package/dist/client/assets/CodeMirrorEditor-UhCYm5Wx.js +0 -2
@@ -493,6 +493,7 @@ export type Conversation = {
493
493
  status: RunStatus;
494
494
  messages: Message[];
495
495
  archivedAt?: string;
496
+ followedWorktreeId?: string;
496
497
  /** Private receipts retained even when a message is withdrawn or cut from history. */
497
498
  acceptedSendIds?: string[];
498
499
  warmSession?: true;
@@ -739,6 +740,8 @@ export type Workspace = {
739
740
  defaultThinkingLevel?: string;
740
741
  defaultAgentId?: string;
741
742
  closedAt?: string;
743
+ worktreeOf?: string;
744
+ worktreeProjectPath?: string;
742
745
  };
743
746
  /**
744
747
  * Usage accumulated across one sub-agent run. `turns` is the number of finished assistant messages,
@@ -1,3 +1,7 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
- export declare function readWorkspaceDocumentPreview(path: string): Promise<import("./documents.js").ExtractResult>;
3
- export declare function respondWithWorkspaceFile(request: IncomingMessage, response: ServerResponse, path: string, download: boolean): Promise<void>;
2
+ type OpenOptions = {
3
+ noFollow?: boolean;
4
+ };
5
+ export declare function readWorkspaceDocumentPreview(path: string, options?: OpenOptions): Promise<import("./documents.js").ExtractResult>;
6
+ export declare function respondWithWorkspaceFile(request: IncomingMessage, response: ServerResponse, path: string, download: boolean, options?: OpenOptions): Promise<void>;
7
+ export {};
@@ -6,17 +6,17 @@ import { workspaceFileMime } from "../shared/workspace-file-preview.js";
6
6
  import { FilesError } from "./files.js";
7
7
  import { extractTextFromBytes } from "./documents.js";
8
8
  const MAX_DOCUMENT_PREVIEW_BYTES = 16 * 1024 * 1024;
9
- function openWorkspaceAsset(path) {
10
- return open(path, constants.O_RDONLY | constants.O_NONBLOCK).catch((error) => {
9
+ function openWorkspaceAsset(path, { noFollow } = {}) {
10
+ return open(path, constants.O_RDONLY | constants.O_NONBLOCK | (noFollow ? constants.O_NOFOLLOW ?? 0 : 0)).catch((error) => {
11
11
  if (error.code === "ENOENT" || error.code === "ENOTDIR")
12
12
  throw new FilesError(404, "文件已不存在。", "missing");
13
13
  throw error;
14
14
  });
15
15
  }
16
- export async function readWorkspaceDocumentPreview(path) {
16
+ export async function readWorkspaceDocumentPreview(path, options) {
17
17
  if (!/\.docx$/i.test(path))
18
18
  throw new FilesError(415, "该文件没有文字预览。", "unsupported_entry");
19
- const handle = await openWorkspaceAsset(path);
19
+ const handle = await openWorkspaceAsset(path, options);
20
20
  try {
21
21
  const info = await handle.stat();
22
22
  if (!info.isFile())
@@ -41,11 +41,11 @@ function parseRange(header, size) {
41
41
  if (Number.isSafeInteger(start) && Number.isSafeInteger(end) && start <= end)
42
42
  return { start, end };
43
43
  }
44
- export async function respondWithWorkspaceFile(request, response, path, download) {
44
+ export async function respondWithWorkspaceFile(request, response, path, download, options) {
45
45
  const mime = workspaceFileMime(path);
46
46
  if (!download && !mime)
47
47
  throw new FilesError(415, "该文件可下载。", "unsupported_entry");
48
- const handle = await openWorkspaceAsset(path);
48
+ const handle = await openWorkspaceAsset(path, options);
49
49
  try {
50
50
  const info = await handle.stat();
51
51
  if (!info.isFile())
@@ -0,0 +1,11 @@
1
+ export type GitCommitFile = {
2
+ path: string;
3
+ previousPath?: string;
4
+ status: string;
5
+ };
6
+ export type GitCommitDetail = {
7
+ hash: string;
8
+ parents: string[];
9
+ message: string;
10
+ files: GitCommitFile[];
11
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ export type GitGraphRef = {
2
+ kind: "head" | "worktree" | "branch" | "remote" | "tag" | "stash";
3
+ name: string;
4
+ checkoutId?: string;
5
+ };
6
+ export type GitGraphCommit = {
7
+ hash: string;
8
+ short: string;
9
+ parents: string[];
10
+ subject: string;
11
+ author: string;
12
+ date: string;
13
+ refs: GitGraphRef[];
14
+ };
15
+ export type GitGraphPage = {
16
+ commits: GitGraphCommit[];
17
+ snapshot: string;
18
+ hasMore: boolean;
19
+ };
20
+ type Lane = {
21
+ index: number;
22
+ color: number;
23
+ };
24
+ type ParentLine = {
25
+ hash: string;
26
+ lane: Lane;
27
+ };
28
+ export type GitGraphRow = {
29
+ node: Lane;
30
+ incoming: boolean;
31
+ through: Lane[];
32
+ parents: ParentLine[];
33
+ };
34
+ export declare function layoutGitGraph(commits: readonly Pick<GitGraphCommit, "hash" | "parents">[]): {
35
+ columns: number;
36
+ rows: GitGraphRow[];
37
+ };
38
+ export {};
@@ -0,0 +1,30 @@
1
+ export function layoutGitGraph(commits) {
2
+ const pending = new Map();
3
+ const occupied = [];
4
+ let nextColor = 0;
5
+ let columns = 1;
6
+ const reserve = (color, preferred) => {
7
+ const free = preferred ?? occupied.indexOf(false);
8
+ const index = free < 0 ? occupied.length : free;
9
+ occupied[index] = true;
10
+ columns = Math.max(columns, index + 1);
11
+ return { index, color };
12
+ };
13
+ const rows = commits.map(({ hash, parents }) => {
14
+ const previous = pending.get(hash);
15
+ const node = previous ?? reserve(nextColor++);
16
+ pending.delete(hash);
17
+ occupied[node.index] = false;
18
+ const through = [...pending.values()];
19
+ const edges = [...new Set(parents)].map((parent, order) => {
20
+ let lane = pending.get(parent);
21
+ if (!lane) {
22
+ lane = order === 0 ? reserve(node.color, node.index) : reserve(nextColor++);
23
+ pending.set(parent, lane);
24
+ }
25
+ return { hash: parent, lane };
26
+ });
27
+ return { node, incoming: previous !== undefined, through, parents: edges };
28
+ });
29
+ return { columns, rows };
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evandu/super-pi",
3
- "version": "0.1.232",
3
+ "version": "0.1.234",
4
4
  "description": "Web control plane and companion for Pi",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-B9BbvWot.js","assets/dist-BJ6foecv.js","assets/index-DREwHzYy.js","assets/index-P5ei_l2b.css","assets/dist-znfz-BcE.js","assets/dist-Dfq0xUba.js","assets/dist-DXa_Ik6q.js","assets/dist-DEKenQm-.js","assets/dist-C31-s_h7.js","assets/dist-IEeNkSQA.js","assets/dist-D8RY2jNq.js","assets/dist-BIy5crB3.js","assets/dist-Opwy6jSg.js","assets/dist-a2NOYHv3.js","assets/dist-UKx13tHO.js","assets/dist-C0RopB4q.js","assets/dist-BpINRZym.js","assets/dist-Bv4wCENt.js","assets/dist-BKp3q2wn.js","assets/dist-C6wg16BA.js","assets/dist-BFeunbEX.js","assets/dist-H6BCSlev.js","assets/dist-C7VEKkD-.js","assets/dist-Ydfp2kM0.js"])))=>i.map(i=>d[i]);
2
- import{a as e,i as t,n,r,s as i,t as a}from"./index-DREwHzYy.js";var o=i(e(),1);async function s(e,t){let[{StreamLanguage:n},i]=await Promise.all([r(()=>import(`./dist-B9BbvWot.js`),__vite__mapDeps([0,1,2,3,4,5])),e()]),a=i[t]??i.default??i;return n.define(a)}var c={cpp:()=>r(()=>import(`./dist-DXa_Ik6q.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cc:()=>r(()=>import(`./dist-DXa_Ik6q.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cxx:()=>r(()=>import(`./dist-DXa_Ik6q.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hpp:()=>r(()=>import(`./dist-DXa_Ik6q.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hh:()=>r(()=>import(`./dist-DXa_Ik6q.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hxx:()=>r(()=>import(`./dist-DXa_Ik6q.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),c:()=>r(()=>import(`./dist-DXa_Ik6q.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),h:()=>r(()=>import(`./dist-DXa_Ik6q.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cu:()=>r(()=>import(`./dist-DXa_Ik6q.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cuh:()=>r(()=>import(`./dist-DXa_Ik6q.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),js:()=>r(()=>import(`./dist-C31-s_h7.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),jsx:()=>r(()=>import(`./dist-C31-s_h7.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mjs:()=>r(()=>import(`./dist-C31-s_h7.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cjs:()=>r(()=>import(`./dist-C31-s_h7.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),ts:()=>r(()=>import(`./dist-C31-s_h7.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),tsx:()=>r(()=>import(`./dist-C31-s_h7.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0,jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mts:()=>r(()=>import(`./dist-C31-s_h7.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cts:()=>r(()=>import(`./dist-C31-s_h7.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),py:()=>r(()=>import(`./dist-D8RY2jNq.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),pyi:()=>r(()=>import(`./dist-D8RY2jNq.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),java:()=>r(()=>import(`./dist-BIy5crB3.js`).then(e=>e.java()),__vite__mapDeps([11,5,2,3,0,1,4,7])),php:()=>r(()=>import(`./dist-Opwy6jSg.js`).then(e=>e.php()),__vite__mapDeps([12,5,2,3,0,1,4,7,13,14,8,9])),sql:()=>r(()=>import(`./dist-C0RopB4q.js`).then(e=>e.sql()),__vite__mapDeps([15,5,2,3,0,1,4,7,9])),yaml:()=>r(()=>import(`./dist-BpINRZym.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),yml:()=>r(()=>import(`./dist-BpINRZym.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),xml:()=>r(()=>import(`./dist-Bv4wCENt.js`).then(e=>e.xml()),__vite__mapDeps([17,1,2,3,4,5,0,7])),json:()=>r(()=>import(`./dist-BKp3q2wn.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),jsonc:()=>r(()=>import(`./dist-BKp3q2wn.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),json5:()=>r(()=>import(`./dist-BKp3q2wn.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),html:()=>r(()=>import(`./dist-a2NOYHv3.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),htm:()=>r(()=>import(`./dist-a2NOYHv3.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),vue:()=>r(()=>import(`./dist-a2NOYHv3.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),svelte:()=>r(()=>import(`./dist-a2NOYHv3.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),css:()=>r(()=>import(`./dist-UKx13tHO.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([14,2,3,5,0,1,4,7])),md:()=>r(()=>import(`./dist-C6wg16BA.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),markdown:()=>r(()=>import(`./dist-C6wg16BA.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),mdx:()=>r(()=>import(`./dist-C6wg16BA.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),rs:()=>r(()=>import(`./dist-BFeunbEX.js`).then(e=>e.rust()),__vite__mapDeps([20,5,2,3,0,1,4,7])),go:()=>r(()=>import(`./dist-H6BCSlev.js`).then(e=>e.go()),__vite__mapDeps([21,5,2,3,0,1,4,7,9])),sh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),bash:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),zsh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),fish:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),ps1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),psm1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),rb:()=>s(()=>r(()=>import(`./ruby-ChfNwlCY.js`),[]),`ruby`),swift:()=>s(()=>r(()=>import(`./swift-DKB6_1j6.js`),[]),`swift`),toml:()=>s(()=>r(()=>import(`./toml-BPTmHmyx.js`),[]),`toml`),ini:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),cfg:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),conf:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),properties:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),dockerfile:()=>s(()=>r(()=>import(`./dockerfile-BDePf5PZ.js`),[]),`dockerfile`),diff:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`),patch:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`)},l={cpp:`C++`,cc:`C++`,cxx:`C++`,hpp:`C++`,hh:`C++`,hxx:`C++`,cu:`CUDA C++`,cuh:`CUDA C++`,c:`C`,h:`C/C++ Header`,js:`JavaScript`,jsx:`JSX`,mjs:`JavaScript`,cjs:`JavaScript`,ts:`TypeScript`,tsx:`TSX`,mts:`TypeScript`,cts:`TypeScript`,py:`Python`,pyi:`Python Stub`,java:`Java`,php:`PHP`,sql:`SQL`,yaml:`YAML`,yml:`YAML`,xml:`XML`,json:`JSON`,jsonc:`JSON with Comments`,json5:`JSON5`,css:`CSS`,md:`Markdown`,markdown:`Markdown`,mdx:`MDX`,rs:`Rust`,go:`Go`,html:`HTML`,htm:`HTML`,vue:`Vue`,svelte:`Svelte`,sh:`Shell`,bash:`Bash`,zsh:`Zsh`,fish:`Fish`,ps1:`PowerShell`,psm1:`PowerShell`,rb:`Ruby`,swift:`Swift`,toml:`TOML`,ini:`INI`,cfg:`Config`,conf:`Config`,properties:`Properties`,dockerfile:`Dockerfile`,diff:`Diff`,patch:`Patch`};function u(e){return c[e.toLowerCase()]}function d(e){return l[e.toLowerCase()]}var f=t(),p=262144,m=131072;function h(e){return e.split(`.`).pop()?.toLowerCase()??``}function g(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function _(e,t){return e.HighlightStyle.define([{tag:t.tags.keyword,color:g(`--cm-keyword`)},{tag:t.tags.string,color:g(`--cm-string`)},{tag:t.tags.number,color:g(`--cm-number`)},{tag:t.tags.comment,color:g(`--cm-comment`),fontStyle:`italic`},{tag:t.tags.function(t.tags.variableName),color:g(`--cm-function`)},{tag:t.tags.typeName,color:g(`--cm-type`)},{tag:t.tags.className,color:g(`--cm-type`)},{tag:t.tags.propertyName,color:g(`--cm-property`)},{tag:t.tags.operator,color:g(`--cm-operator`)},{tag:t.tags.variableName,color:g(`--cm-variable`)}])}function v({path:e,value:t,onChange:i,jumpToLine:s,onSave:c,workspaceId:l,blame:g,onPosition:v}){let y=(0,o.useRef)(null),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)(null),C=(0,o.useRef)(null),w=(0,o.useRef)(null),T=(0,o.useRef)(null),E=(0,o.useRef)(null),D=(0,o.useRef)(i),O=(0,o.useRef)(c);D.current=i,O.current=c;let[k,A]=(0,o.useState)(!1),[j,M]=(0,o.useState)(!1),[N,P]=(0,o.useState)(`0,0`),[F,I]=(0,o.useState)(0);(0,o.useEffect)(()=>{let i=!1,a,o,s,c,l;return(async()=>{try{let d=h(e),f=u(d),[m,g,v,k,j,N,F,L]=await Promise.all([r(()=>import(`./dist-BJ6foecv.js`).then(e=>e.x),__vite__mapDeps([1,2,3])),r(()=>import(`./dist-znfz-BcE.js`).then(e=>e.s),__vite__mapDeps([4,2,3,1])),r(()=>import(`./dist-C7VEKkD-.js`),__vite__mapDeps([22,1,2,3,4,5,0])),r(()=>import(`./dist-Ydfp2kM0.js`),__vite__mapDeps([23,1,2,3,4])),r(()=>import(`./dist-B9BbvWot.js`),__vite__mapDeps([0,1,2,3,4,5])),r(()=>import(`./dist-Dfq0xUba.js`).then(e=>e.n),__vite__mapDeps([5,2,3])),f?f().catch(e=>(console.warn(`[CodeMirror] Failed to load language for .${d}:`,e),null)):Promise.resolve(null),n().catch(e=>(console.warn(`[CodeMirror] Failed to build the blame extension:`,e),null))]);if(i||!y.current)return;c=j,l=N,S.current=m.Annotation.define(),C.current=m.Transaction.addToHistory;let R=t.length<=p&&F!==null;o=new m.Compartment;let z=[g.lineNumbers(),g.highlightActiveLine(),g.drawSelection(),v.history(),g.keymap.of([v.indentWithTab,...v.defaultKeymap,...v.historyKeymap,...k.searchKeymap,{key:`Mod-s`,run:()=>(O.current(),!0)}]),g.EditorView.updateListener.of(e=>{e.docChanged&&!(S.current&&e.transactions.some(e=>e.annotation(S.current)===!0))&&D.current(e.state.doc.toString()),e.selectionSet&&P(`${e.state.selection.main.from},${e.state.selection.main.to}`)}),g.EditorView.domEventHandlers({mousedown:(e,t)=>(t.focus(),!1)})];if(L&&(s=new m.Compartment,z.splice(1,0,s.of([])),z.push(L.base)),F)try{z.push(F)}catch(e){console.warn(`[CodeMirror] Failed to apply language extension for .${d}:`,e),R=!1}if(R&&o&&c&&l)try{z.push(o.of(c.syntaxHighlighting(_(c,l))))}catch(e){console.warn(`[CodeMirror] Failed to attach syntaxHighlighting for .${d}:`,e),R=!1}if(a=new g.EditorView({state:m.EditorState.create({doc:t,extensions:z}),parent:y.current}),i){a.destroy();return}b.current=a,A(R),M(!0),w.current=L,T.current=s??null,E.current=null,I(e=>e+1);let B=new MutationObserver(()=>{let e=b.current;if(e&&R&&o&&c&&l)try{e.dispatch({effects:o.reconfigure(c.syntaxHighlighting(_(c,l)))})}catch{}});x.current=B,B.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}catch(e){console.error(`[CodeMirror] Fatal editor initialization error:`,e),i||M(!0)}})(),()=>{i=!0,x.current?.disconnect(),x.current=null,a?.destroy(),b.current=null,M(!1),y.current&&(y.current.textContent=``)}},[e]),(0,o.useEffect)(()=>{let e=b.current;if(!e)return;let n=e.state.doc.toString();n!==t&&e.dispatch({changes:{from:0,to:n.length,insert:t},annotations:S.current?S.current.of(!0):void 0})},[t]),(0,o.useEffect)(()=>{let e=b.current;if(!e||!s)return;let t=e.state.doc.line(Math.min(Math.max(1,s.line),e.state.doc.lines));e.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0}),e.focus()},[s,j]);let L=!!(g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l);(0,o.useEffect)(()=>{let t=b.current,n=w.current,r=T.current;if(!t||!n||!r)return;let i=g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l?g.response:null,o=i?a(i):null;E.current!==o&&(E.current=o,t.dispatch({effects:[n.setBlame.of(o),r.reconfigure(o?n.gutter:[])]}))},[g?.state,g?.response,g?.path,g?.workspaceId,e,l,F]);let R=b.current?.state.doc.toString()??t,z=R.length<=m?R:R.slice(0,m),B=h(e),V=d(B),H=b.current?.state,U=H?.selection.main.head,W=U===void 0?void 0:H?.doc.lineAt(U),G=W?.number,K=U!==void 0&&W?U-W.from+1:void 0;return(0,o.useEffect)(()=>{j&&G!==void 0&&K!==void 0&&v?.({line:G,column:K,language:k&&V||`纯文本`,highlight:k?B:`plain`})},[j,G,K,k,V,B,v]),(0,o.useEffect)(()=>()=>v?.(),[v]),(0,f.jsxs)(`div`,{className:`file-cm-wrap`,"data-file-text":e,"data-file-content":z,"data-file-content-truncated":R.length>m?`1`:`0`,"data-file-selection":N,"data-file-editor-ready":j?`1`:`0`,"data-file-blame-gutter":L?`1`:void 0,onMouseDown:()=>b.current?.focus(),children:[(0,f.jsx)(`div`,{className:`file-cm`,ref:y,"aria-label":`编辑 ${e}`}),(!j||!v)&&(0,f.jsxs)(`div`,{className:`file-editor-status`,children:[!j&&(0,f.jsx)(`span`,{"data-file-editor-loading":`1`,children:`正在加载编辑器…`}),j&&U!==void 0&&W&&(0,f.jsxs)(`span`,{children:[`第 `,W.number,` 行,第 `,U-W.from+1,` 列`]}),j&&!k&&(0,f.jsx)(`span`,{"data-file-highlight-status":`plain`,children:`纯文本`}),j&&k&&V&&(0,f.jsx)(`span`,{"data-file-highlight-status":B,children:V})]})]})}export{v as CodeMirrorEditor};