@jxsuite/studio 3.0.0 → 4.1.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/README.md +5 -5
- package/dist/chunks/{2020-xp8vnwma.js → 2020-n6tfwnda.js} +2 -2
- package/dist/chunks/Overlay.dev-etqjwyf9.js +23 -0
- package/dist/chunks/cf-account-picker-en86v7x7.js +163 -0
- package/dist/chunks/{cf-settings-zj2cj1ar.js → cf-settings-45fgyx8y.js} +6 -5
- package/dist/chunks/{components-z6cnkyy1.js → components-zmx10t62.js} +6 -5
- package/dist/chunks/content-source-48xg86wj.js +49 -0
- package/dist/chunks/{convert-to-repeater-6vvx96n2.js → convert-to-repeater-43tfn7cs.js} +33 -25
- package/dist/chunks/entry-commands-e63f1xc0.js +46 -0
- package/dist/chunks/{extension-sections-kwzvpemr.js → extension-sections-txv08xxg.js} +34 -26
- package/dist/chunks/file-ops-wbh4hhsx.js +48 -0
- package/dist/chunks/files-3kfkwhk4.js +93 -0
- package/dist/chunks/{focus-trap.esm-ggawf1hy.js → focus-trap.esm-9t2drp0g.js} +6 -5
- package/dist/chunks/{format-host-8fr3545e.js → format-host-w16q81tf.js} +3 -3
- package/dist/chunks/fs-events-hrrg328g.js +21 -0
- package/dist/chunks/{git-panel-g01d93vc.js → git-panel-532whr1y.js} +22 -16
- package/dist/chunks/{index-nj44jpzj.js → index-wcnt3r9g.js} +2 -2
- package/dist/chunks/{jx-validate-jj9rnt4n.js → jx-validate-8er6gbxy.js} +6 -4
- package/dist/chunks/layers-panel-07hm7g5j.js +67 -0
- package/dist/chunks/layers-q75tj2mf.js +45 -0
- package/dist/chunks/lit-html-j055mkh8.js +22 -0
- package/dist/chunks/monaco-buffer-dqw0xxpx.js +25 -0
- package/dist/chunks/{monaco-setup-a5wkmbgh.js → monaco-setup-vx9bhp1d.js} +4 -4
- package/dist/chunks/notify-yjm79n4s.js +30 -0
- package/dist/chunks/parse-24d0gay3.js +19 -0
- package/dist/chunks/platform-ba1j1gbh.js +16 -0
- package/dist/chunks/publish-panel-v9st96ja.js +29 -0
- package/dist/chunks/quick-search-zccjp6gv.js +66 -0
- package/dist/chunks/references-3qx8fkyp.js +29 -0
- package/dist/chunks/right-panel-vm3b6kwy.js +46 -0
- package/dist/chunks/sp-overlay.dev-qgvhnxf4.js +18 -0
- package/dist/chunks/sp-popover.dev-n2etmqdp.js +9 -0
- package/dist/chunks/sp-progress-circle.dev-hryhj0es.js +15 -0
- package/dist/chunks/sp-tooltip.dev-4sastdnw.js +15 -0
- package/dist/chunks/{sp-tray.dev-64v4pxw8.js → sp-tray.dev-tkbscm06.js} +5 -5
- package/dist/chunks/{studio-wdt9y92a.js → studio-0bq6eh7v.js} +2 -2
- package/dist/chunks/studio-1ngbejft.js +181 -0
- package/dist/chunks/studio-1wagb550.js +118 -0
- package/dist/chunks/{studio-j595e748.js → studio-2b946z26.js} +172 -95
- package/dist/chunks/{studio-pkp61mh8.js → studio-3bqpr0zh.js} +25 -17
- package/dist/chunks/{studio-k4jvjcfx.js → studio-4b5z1x43.js} +46 -12
- package/dist/chunks/{studio-ry1vz5sv.js → studio-4n2b5gzb.js} +15 -13
- package/dist/chunks/{studio-p5dja96s.js → studio-4r1pv6zf.js} +2 -2
- package/dist/chunks/{studio-kvfx9z2c.js → studio-4rzyrtjz.js} +70 -31
- package/dist/chunks/{studio-tzx3xmvx.js → studio-5fx3g9jg.js} +33 -52
- package/dist/chunks/{studio-rh1cnamv.js → studio-5myknm0a.js} +565 -135
- package/dist/chunks/studio-6yw4y3my.js +91 -0
- package/dist/chunks/{studio-0rqqhrdy.js → studio-7nte2hj4.js} +2 -2
- package/dist/chunks/studio-92ab2jqe.js +282 -0
- package/dist/chunks/{studio-6z5eyjwn.js → studio-950k0dx6.js} +72 -135
- package/dist/chunks/{studio-sas7mt3k.js → studio-9ab8gqsm.js} +2 -2
- package/dist/chunks/studio-9n4mrmnb.js +184 -0
- package/dist/chunks/{studio-hcxzyk3x.js → studio-ahn3pdgx.js} +6 -6
- package/dist/chunks/studio-b55y6ewx.js +498 -0
- package/dist/chunks/{studio-s519zc99.js → studio-bgxt93ga.js} +3 -3
- package/dist/chunks/studio-cft9r4r7.js +119 -0
- package/dist/chunks/{studio-dc8s8heb.js → studio-cmb03bg5.js} +6904 -8321
- package/dist/chunks/studio-dm19q43r.js +195 -0
- package/dist/chunks/{studio-2x9zbxmx.js → studio-ef49pnzx.js} +11 -9
- package/dist/chunks/{studio-ay8wcr2b.js → studio-eqq1w638.js} +7 -9
- package/dist/chunks/{studio-5efrtn1m.js → studio-ew0djmhg.js} +23 -19
- package/dist/chunks/{studio-tr20m8g8.js → studio-f3wqjtk5.js} +39 -3
- package/dist/chunks/{studio-xntfdy1x.js → studio-fbf92ckf.js} +36 -23
- package/dist/chunks/{studio-4q0wznzf.js → studio-gcye7qka.js} +442 -126
- package/dist/chunks/{studio-7p35254k.js → studio-gfgb8pe6.js} +36 -193
- package/dist/chunks/studio-jc994dnr.js +1066 -0
- package/dist/chunks/{studio-hj2se583.js → studio-jkftxyvz.js} +69 -3423
- package/dist/chunks/{studio-5x5774ak.js → studio-kryvsw6j.js} +3 -3
- package/dist/chunks/{studio-kfpek536.js → studio-kyh9avvv.js} +2 -2
- package/dist/chunks/{studio-twsafr1e.js → studio-m3hwn7y1.js} +3 -3
- package/dist/chunks/studio-msd847zn.js +1315 -0
- package/dist/chunks/{studio-g5gdqnyd.js → studio-mtfnaqs9.js} +19 -19
- package/dist/chunks/{studio-7ejemhej.js → studio-n6j9t10q.js} +6 -6
- package/dist/chunks/{studio-vhk5fmfv.js → studio-n8b9wqwy.js} +5 -5
- package/dist/chunks/{studio-cjm7fdjf.js → studio-p4ngc046.js} +8 -104
- package/dist/chunks/studio-q43a5y9h.js +394 -0
- package/dist/chunks/studio-q7v10cg2.js +106 -0
- package/dist/chunks/{studio-6kv3apa9.js → studio-q9jd1a60.js} +27 -11
- package/dist/chunks/studio-qcy05dp8.js +1743 -0
- package/dist/chunks/{studio-a0yp7syn.js → studio-qjy2z9bv.js} +29 -132
- package/dist/chunks/{studio-2w11grav.js → studio-qq6jym04.js} +3 -3
- package/dist/chunks/{studio-3fk1ac9z.js → studio-rdx8jcxy.js} +4 -4
- package/dist/chunks/{studio-4mqb9a0j.js → studio-rn9ta2mz.js} +4 -4
- package/dist/chunks/studio-t7qb9db8.js +665 -0
- package/dist/chunks/studio-tmc5emrw.js +8 -0
- package/dist/chunks/{studio-r5xbtctf.js → studio-trxrabqf.js} +292 -2297
- package/dist/chunks/studio-wcy8trfx.js +263 -0
- package/dist/chunks/{studio-3dkcd4c5.js → studio-x4qkdat5.js} +62 -57
- package/dist/chunks/studio-x813zp48.js +195 -0
- package/dist/chunks/{studio-qpfq7xhm.js → studio-xrapxwwc.js} +22 -285
- package/dist/chunks/{studio-xm3dbxvn.js → studio-zczps70q.js} +2 -2
- package/dist/chunks/{studio-8ezdegcx.js → studio-zqazsct2.js} +40 -36
- package/dist/chunks/workspace-fjx52ryv.js +89 -0
- package/dist/iframe-entry.js +141 -56
- package/dist/manifest.json +7 -0
- package/dist/studio.js +2605 -1950
- package/favicon.ico +0 -0
- package/index.html +1 -0
- package/package.json +20 -18
- package/src/about/about-modal.ts +4 -3
- package/src/browse/library-pane.ts +57 -3
- package/src/canvas/canvas-render.ts +23 -1
- package/src/canvas/iframe-patch.ts +47 -21
- package/src/canvas/iframe-render.ts +22 -6
- package/src/commands/app-commands.ts +4 -0
- package/src/commands/command-args.ts +29 -0
- package/src/commands/context.ts +15 -1
- package/src/commands/defaults.ts +29 -1
- package/src/commands/levels.ts +16 -0
- package/src/commands/live-context.ts +3 -0
- package/src/content/collection-match.ts +267 -0
- package/src/content/entry-commands.ts +38 -29
- package/src/content/entry-fields.ts +6 -0
- package/src/editor/shortcuts.ts +5 -0
- package/src/files/file-ops.ts +10 -42
- package/src/files/files.ts +487 -59
- package/src/files/fs-events.ts +9 -0
- package/src/files/gitignore.ts +432 -0
- package/src/files/media-paths.ts +13 -42
- package/src/files/media-usage.ts +41 -131
- package/src/files/serialize-document.ts +60 -0
- package/src/format/convert-file.ts +511 -0
- package/src/format/format-choices.ts +199 -0
- package/src/grid/grid-view.ts +16 -2
- package/src/hosting/document.ts +2 -0
- package/src/hosting/layout.ts +8 -0
- package/src/media/media-open.ts +58 -0
- package/src/media/media-pane.ts +310 -0
- package/src/new-project/import-tab.ts +357 -163
- package/src/new-project/location-fields.ts +8 -5
- package/src/new-project/new-project-modal.ts +27 -34
- package/src/packages/ensure-deps.ts +14 -7
- package/src/packages/jxsuite-update.ts +11 -11
- package/src/page-params.ts +10 -46
- package/src/panels/activity-bar.ts +45 -16
- package/src/panels/ai-chat/attached-context.ts +6 -1
- package/src/panels/ai-chat/chat-view.ts +255 -13
- package/src/panels/ai-chat/composer.ts +31 -97
- package/src/panels/ai-panel.ts +116 -2
- package/src/panels/navigator-panels.ts +7 -6
- package/src/panels/settings-menu.ts +799 -0
- package/src/panels/toolbar.ts +135 -15
- package/src/platforms/cloud.ts +261 -70
- package/src/platforms/devserver.ts +67 -33
- package/src/preview/preview-overlay.ts +226 -0
- package/src/publish/publish-panel.ts +62 -2
- package/src/services/ai-ask.ts +247 -0
- package/src/services/ai-import-tools.ts +532 -0
- package/src/services/ai-models.ts +108 -1
- package/src/services/ai-project-tools.ts +20 -26
- package/src/services/ai-system-prompt.ts +88 -2
- package/src/services/ai-turn-signal.ts +70 -0
- package/src/services/connection.ts +74 -0
- package/src/services/context-manager.ts +101 -1
- package/src/services/document-assistant.ts +45 -4
- package/src/services/import-client.ts +33 -6
- package/src/services/import-run.ts +158 -0
- package/src/services/import-seed.ts +120 -0
- package/src/services/jx-validate.ts +58 -6
- package/src/services/project-adoption.ts +71 -0
- package/src/services/references.ts +0 -0
- package/src/services/settings/definitions.ts +17 -0
- package/src/services/tool-executor.ts +45 -2
- package/src/settings/contexts-section.ts +45 -3
- package/src/settings/dependencies-editor.ts +43 -23
- package/src/settings/general-settings.ts +30 -12
- package/src/settings/preferences-accounts.ts +193 -12
- package/src/settings/preferences-dialog.ts +93 -59
- package/src/settings/preferences-sections.ts +57 -0
- package/src/settings/settings-document.ts +65 -9
- package/src/studio.ts +33 -6
- package/src/tabs/transact.ts +42 -19
- package/src/types.ts +129 -7
- package/src/ui/ai-managed-connect.ts +62 -13
- package/src/ui/ai-model-picker.ts +189 -0
- package/src/ui/cf-account-picker.ts +200 -0
- package/src/ui/choice-field.ts +72 -0
- package/src/ui/layers.ts +83 -5
- package/src/utils/studio-utils.ts +22 -52
- package/styles/forced-colors.css +7 -0
- package/styles/overlays.css +256 -0
- package/styles/panels.css +13 -1
- package/styles/shell.css +147 -0
- package/dist/chunks/Overlay.dev-d2ajy6sj.js +0 -23
- package/dist/chunks/content-source-7fy9qrm0.js +0 -40
- package/dist/chunks/files-xcybanxe.js +0 -70
- package/dist/chunks/layers-panel-27essgkc.js +0 -60
- package/dist/chunks/publish-panel-09sy2bab.js +0 -22
- package/dist/chunks/quick-search-sefb61v8.js +0 -55
- package/dist/chunks/right-panel-9r32jd5j.js +0 -39
- package/dist/chunks/sp-overlay.dev-s18hymn9.js +0 -18
- package/dist/chunks/sp-popover.dev-dj9x7e7a.js +0 -9
- package/dist/chunks/sp-progress-circle.dev-0zxcyz3r.js +0 -15
- package/dist/chunks/sp-tooltip.dev-5c6d1kjz.js +0 -15
- package/dist/chunks/studio-bw5dz6km.js +0 -608
- package/dist/chunks/studio-c31yb4t6.js +0 -55
- package/src/canvas/site-style-css.ts +0 -117
|
@@ -3,11 +3,21 @@
|
|
|
3
3
|
* streaming fetch to some URL" — the dev server posts to its own origin, the desktop platforms post
|
|
4
4
|
* to their token-gated loopback servers — so the request/parse/settle logic lives here once.
|
|
5
5
|
*
|
|
6
|
-
* The endpoint emits one JSON object per line: `progress` lines (forwarded to onProgress),
|
|
7
|
-
* `
|
|
6
|
+
* The endpoint emits one JSON object per line: `progress` lines (forwarded to onProgress), a
|
|
7
|
+
* `ready` line the moment the destination is an openable project (forwarded to onReady),
|
|
8
|
+
* `heartbeat` keep-alives (ignored), and a terminal `done` ({root, config, result}) or `error`
|
|
9
|
+
* line. `result` is optional — a backend that does not send one is not broken, and every caller
|
|
10
|
+
* treats its absence as "the run happened, and it did not say what it found". `ready` is optional
|
|
11
|
+
* for the same reason: an older backend simply never sends one, and the caller opens the project at
|
|
12
|
+
* the end as it always did.
|
|
8
13
|
*/
|
|
9
14
|
|
|
10
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
ImportProgressEvent,
|
|
17
|
+
ImportReadyEvent,
|
|
18
|
+
ImportSiteOptions,
|
|
19
|
+
ImportSiteSummary,
|
|
20
|
+
} from "../types";
|
|
11
21
|
import type { ProjectConfig } from "@jxsuite/schema/types";
|
|
12
22
|
|
|
13
23
|
/**
|
|
@@ -27,6 +37,7 @@ interface StreamLine {
|
|
|
27
37
|
total?: number;
|
|
28
38
|
root?: string;
|
|
29
39
|
config?: ProjectConfig;
|
|
40
|
+
result?: ImportSiteSummary;
|
|
30
41
|
error?: string;
|
|
31
42
|
}
|
|
32
43
|
|
|
@@ -37,13 +48,17 @@ interface StreamLine {
|
|
|
37
48
|
* @param {ImportSiteOptions} opts — the import request; `apiKey`/`baseUrl` travel as headers
|
|
38
49
|
* @param {(evt: ImportProgressEvent) => void} onProgress
|
|
39
50
|
* @param {AbortSignal} [signal]
|
|
51
|
+
* @param {(evt: ImportReadyEvent) => void} [onReady] — fires once, as soon as the destination holds
|
|
52
|
+
* an openable project. Minutes before `done` on a real crawl, which is the whole reason it
|
|
53
|
+
* exists.
|
|
40
54
|
*/
|
|
41
55
|
export async function streamImport(
|
|
42
56
|
endpoint: string,
|
|
43
57
|
opts: ImportSiteOptions,
|
|
44
58
|
onProgress: (evt: ImportProgressEvent) => void,
|
|
45
59
|
signal?: AbortSignal,
|
|
46
|
-
|
|
60
|
+
onReady?: (evt: ImportReadyEvent) => void,
|
|
61
|
+
): Promise<{ root: string; config: ProjectConfig; result?: ImportSiteSummary }> {
|
|
47
62
|
const headers: Record<string, string> = { "Content-Type": "application/json" };
|
|
48
63
|
if (opts.apiKey) {
|
|
49
64
|
headers["X-Api-Key"] = opts.apiKey;
|
|
@@ -59,7 +74,13 @@ export async function streamImport(
|
|
|
59
74
|
depth: opts.depth,
|
|
60
75
|
maxPages: opts.maxPages,
|
|
61
76
|
aiComponents: opts.aiComponents,
|
|
77
|
+
...(opts.breakpoints === undefined ? {} : { breakpoints: opts.breakpoints }),
|
|
62
78
|
...(opts.model === undefined ? {} : { aiModel: opts.model }),
|
|
79
|
+
...(opts.verify === undefined ? {} : { verify: opts.verify }),
|
|
80
|
+
...(opts.verifyThreshold === undefined ? {} : { verifyThreshold: opts.verifyThreshold }),
|
|
81
|
+
...(opts.verifyMinFidelity === undefined
|
|
82
|
+
? {}
|
|
83
|
+
: { verifyMinFidelity: opts.verifyMinFidelity }),
|
|
63
84
|
}),
|
|
64
85
|
headers,
|
|
65
86
|
method: "POST",
|
|
@@ -85,7 +106,7 @@ export async function streamImport(
|
|
|
85
106
|
const reader = res.body.getReader();
|
|
86
107
|
const decoder = new TextDecoder();
|
|
87
108
|
let buffer = "";
|
|
88
|
-
let result: { root: string; config: ProjectConfig } | null = null;
|
|
109
|
+
let result: { root: string; config: ProjectConfig; result?: ImportSiteSummary } | null = null;
|
|
89
110
|
/*
|
|
90
111
|
* Lines the parser could not read. Tolerating one is right — an import that ran for two minutes
|
|
91
112
|
* should not die on a garbled progress line — but doing it *silently* is not: the import then
|
|
@@ -113,8 +134,14 @@ export async function streamImport(
|
|
|
113
134
|
...(parsed.current === undefined ? {} : { current: parsed.current }),
|
|
114
135
|
...(parsed.total === undefined ? {} : { total: parsed.total }),
|
|
115
136
|
});
|
|
137
|
+
} else if (parsed.type === "ready" && parsed.root !== undefined) {
|
|
138
|
+
onReady?.({ root: parsed.root });
|
|
116
139
|
} else if (parsed.type === "done" && parsed.root !== undefined && parsed.config) {
|
|
117
|
-
result = {
|
|
140
|
+
result = {
|
|
141
|
+
root: parsed.root,
|
|
142
|
+
config: parsed.config,
|
|
143
|
+
...(parsed.result === undefined ? {} : { result: parsed.result }),
|
|
144
|
+
};
|
|
118
145
|
} else if (parsed.type === "error") {
|
|
119
146
|
throw new Error(parsed.error || "Import failed");
|
|
120
147
|
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import-run.ts — the live state of a site import, for the transcript to draw.
|
|
3
|
+
*
|
|
4
|
+
* An import takes minutes and reports a line at a time. Those lines used to render into the New
|
|
5
|
+
* Project modal and die with it: a successful import destroyed its own account of what it had done
|
|
6
|
+
* at the moment it handed off. Now the run belongs to a tool call, so the record is keyed by that
|
|
7
|
+
* call's id and the chip and its progress are one thing rather than two.
|
|
8
|
+
*
|
|
9
|
+
* Reactive, so `panels/ai-panel.ts`'s watcher repaints on it through the same rAF coalescer that
|
|
10
|
+
* carries streaming tokens — a crawl emitting a line per page cannot outrun the frame rate.
|
|
11
|
+
*
|
|
12
|
+
* @license MIT
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { reactive } from "../reactivity";
|
|
16
|
+
|
|
17
|
+
import type { ImportProgressEvent } from "../types";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Lines kept per run.
|
|
21
|
+
*
|
|
22
|
+
* A wide crawl emits one per page plus one per asset batch, and every line is also held in the
|
|
23
|
+
* session's localStorage budget once the tool result lands — so there is a ceiling, and it is here.
|
|
24
|
+
* It was 200 back when the view showed the last SIX of them and the rest existed only to be
|
|
25
|
+
* summarised; the transcript now renders the whole log in a scroller the reader owns, so the number
|
|
26
|
+
* that matters is how far back they can scroll.
|
|
27
|
+
*/
|
|
28
|
+
export const MAX_LOG_LINES = 500;
|
|
29
|
+
|
|
30
|
+
export interface ImportRunRecord {
|
|
31
|
+
/** The tool-call id — the join key with the chip the transcript draws. */
|
|
32
|
+
id: string;
|
|
33
|
+
url: string;
|
|
34
|
+
directory: string;
|
|
35
|
+
phase: string;
|
|
36
|
+
message: string;
|
|
37
|
+
current: number | null;
|
|
38
|
+
total: number | null;
|
|
39
|
+
log: ImportProgressEvent[];
|
|
40
|
+
/** Lines the pipeline marked with `⚠`, kept apart so the summary can name them. */
|
|
41
|
+
warnings: string[];
|
|
42
|
+
status: "running" | "done" | "failed" | "stopped";
|
|
43
|
+
error: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* One run at a time, because one project is created at a time and `import_site` is `no-project`
|
|
48
|
+
* tiered. Keyed rather than bare so a finished run still renders under its own chip after the next
|
|
49
|
+
* one starts, which is what makes the transcript readable after two attempts.
|
|
50
|
+
*/
|
|
51
|
+
const runs = reactive<{ records: ImportRunRecord[] }>({ records: [] });
|
|
52
|
+
|
|
53
|
+
/** Runs kept before the oldest is dropped. Two attempts and a retry is the realistic ceiling. */
|
|
54
|
+
const MAX_RUNS = 5;
|
|
55
|
+
|
|
56
|
+
/** Aborts the in-flight run. Owned here because `ToolRegistry.execute` cannot be handed a signal. */
|
|
57
|
+
let controller: AbortController | null = null;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Open a run record and return the signal its request should carry.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} id - The tool-call id.
|
|
63
|
+
* @param {{ url: string; directory: string }} init
|
|
64
|
+
* @returns {AbortSignal}
|
|
65
|
+
*/
|
|
66
|
+
export function beginImportRun(id: string, init: { url: string; directory: string }): AbortSignal {
|
|
67
|
+
controller?.abort();
|
|
68
|
+
controller = new AbortController();
|
|
69
|
+
runs.records.push({
|
|
70
|
+
current: null,
|
|
71
|
+
directory: init.directory,
|
|
72
|
+
error: "",
|
|
73
|
+
id,
|
|
74
|
+
log: [],
|
|
75
|
+
message: "Starting…",
|
|
76
|
+
phase: "start",
|
|
77
|
+
status: "running",
|
|
78
|
+
total: null,
|
|
79
|
+
url: init.url,
|
|
80
|
+
warnings: [],
|
|
81
|
+
});
|
|
82
|
+
if (runs.records.length > MAX_RUNS) {
|
|
83
|
+
runs.records.shift();
|
|
84
|
+
}
|
|
85
|
+
return controller.signal;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Record one progress line against a run.
|
|
90
|
+
*
|
|
91
|
+
* @param {string} id
|
|
92
|
+
* @param {ImportProgressEvent} evt
|
|
93
|
+
*/
|
|
94
|
+
export function recordImportProgress(id: string, evt: ImportProgressEvent): void {
|
|
95
|
+
const record = runs.records.find((r) => r.id === id);
|
|
96
|
+
if (!record) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
record.phase = evt.phase;
|
|
100
|
+
record.message = evt.message;
|
|
101
|
+
record.current = evt.current ?? null;
|
|
102
|
+
record.total = evt.total ?? null;
|
|
103
|
+
record.log.push(evt);
|
|
104
|
+
if (record.log.length > MAX_LOG_LINES) {
|
|
105
|
+
record.log.shift();
|
|
106
|
+
}
|
|
107
|
+
/* The pipeline reports a soft failure by prefixing its progress line, and `ImportSiteResult`'s
|
|
108
|
+
own `warnings` array does not cross the HTTP boundary — so this is the only place they can be
|
|
109
|
+
recovered from, and the summary needs them to be honest about what was skipped. */
|
|
110
|
+
if (evt.message.startsWith("⚠")) {
|
|
111
|
+
record.warnings.push(evt.message.replace(/^⚠\s*/, ""));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Close a run.
|
|
117
|
+
*
|
|
118
|
+
* @param {string} id
|
|
119
|
+
* @param {{ status: Exclude<ImportRunRecord["status"], "running">; error?: string }} outcome
|
|
120
|
+
*/
|
|
121
|
+
export function finishImportRun(
|
|
122
|
+
id: string,
|
|
123
|
+
outcome: { status: Exclude<ImportRunRecord["status"], "running">; error?: string },
|
|
124
|
+
): void {
|
|
125
|
+
const record = runs.records.find((r) => r.id === id);
|
|
126
|
+
if (record) {
|
|
127
|
+
record.status = outcome.status;
|
|
128
|
+
record.error = outcome.error ?? "";
|
|
129
|
+
}
|
|
130
|
+
controller = null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The record for one tool call, or null. Reactive — read it inside an `effect()` to repaint on it.
|
|
135
|
+
*
|
|
136
|
+
* @param {string} id
|
|
137
|
+
* @returns {ImportRunRecord | null}
|
|
138
|
+
*/
|
|
139
|
+
export function importRun(id: string): ImportRunRecord | null {
|
|
140
|
+
return runs.records.find((r) => r.id === id) ?? null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** The run still going, or null. What the panel's watcher tracks. */
|
|
144
|
+
export function activeImportRun(): ImportRunRecord | null {
|
|
145
|
+
return runs.records.find((r) => r.status === "running") ?? null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Abort the in-flight run. Called from `assistant.stop`, which cannot reach the tool directly. */
|
|
149
|
+
export function abortImportRun(): void {
|
|
150
|
+
controller?.abort();
|
|
151
|
+
controller = null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Drop every record. For New Chat and for tests. */
|
|
155
|
+
export function resetImportRuns(): void {
|
|
156
|
+
abortImportRun();
|
|
157
|
+
runs.records.length = 0;
|
|
158
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import-seed.ts — the New Project Import form's hand-off to the assistant.
|
|
3
|
+
*
|
|
4
|
+
* The wizard collects a URL, crawl options, a model and a brief, then closes; the assistant takes
|
|
5
|
+
* the turn and runs the import as a tool call. This holds what the form gathered for the one turn
|
|
6
|
+
* that consumes it.
|
|
7
|
+
*
|
|
8
|
+
* **Module state, and deliberately NOT a copy of `agent-seed.ts`.** That one uses localStorage keyed
|
|
9
|
+
* by project root because the project it seeds opens in a NEW WINDOW, and the key is the
|
|
10
|
+
* cross-window channel. Neither half of that applies here: the project does not exist yet at
|
|
11
|
+
* hand-off time, so there is no root to key on, and the assistant taking the turn is in this window
|
|
12
|
+
* — `import_site` is `no-project` tiered precisely because it runs before there is a project. A
|
|
13
|
+
* localStorage clone would be a channel with nothing on the other end and a key that cannot be
|
|
14
|
+
* computed.
|
|
15
|
+
*
|
|
16
|
+
* @license MIT
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { ImportBreakpointPolicy } from "../types";
|
|
20
|
+
|
|
21
|
+
/** What the wizard gathered, as the tool needs it. */
|
|
22
|
+
export interface ImportBrief {
|
|
23
|
+
/** Absolute http(s) URL of the site to clone. */
|
|
24
|
+
url: string;
|
|
25
|
+
/** Human project name (the wizard prefills it from the hostname). */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Absolute destination directory, already resolved from Location + folder name. */
|
|
28
|
+
directory: string;
|
|
29
|
+
depth: number;
|
|
30
|
+
maxPages: number;
|
|
31
|
+
/**
|
|
32
|
+
* How many of the site's declared breakpoints the project keeps.
|
|
33
|
+
*
|
|
34
|
+
* A real site declares as many as it has accumulated frameworks — nine is ordinary — and each one
|
|
35
|
+
* is a canvas size in Studio and a column in every style editor. The wizard defaults this to
|
|
36
|
+
* three because that is the complaint it answers, not because three is a magic number.
|
|
37
|
+
*/
|
|
38
|
+
breakpoints: ImportBreakpointPolicy;
|
|
39
|
+
aiComponents: boolean;
|
|
40
|
+
/** Build and screenshot-diff the result. Off by default — it roughly doubles the run. */
|
|
41
|
+
verify: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The average fidelity, 0..100, the clone has to reach for `verify` to report success.
|
|
44
|
+
*
|
|
45
|
+
* Only meaningful when `verify` is on. A finding rather than a failure here: the project is
|
|
46
|
+
* written and opened either way, and the assistant says the bar was missed.
|
|
47
|
+
*/
|
|
48
|
+
minFidelity: number;
|
|
49
|
+
/** Empty means "whatever the assistant would use" (`preferredModel()`). */
|
|
50
|
+
model: string;
|
|
51
|
+
/** What the user wants done with the site once it is cloned. May be empty. */
|
|
52
|
+
prompt: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let _brief: ImportBrief | null = null;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Store the brief the assistant's next turn will act on.
|
|
59
|
+
*
|
|
60
|
+
* @param {ImportBrief} brief
|
|
61
|
+
*/
|
|
62
|
+
export function setPendingImportBrief(brief: ImportBrief): void {
|
|
63
|
+
_brief = brief;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The brief without consuming it — what `import_site` reads to fill in a destination the model was
|
|
68
|
+
* never told and must not invent.
|
|
69
|
+
*
|
|
70
|
+
* @returns {ImportBrief | null}
|
|
71
|
+
*/
|
|
72
|
+
export function pendingImportBrief(): ImportBrief | null {
|
|
73
|
+
return _brief;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Forget the brief.
|
|
78
|
+
*
|
|
79
|
+
* There is deliberately no consume-on-read here, unlike `agent-seed.ts`. TWO readers need the same
|
|
80
|
+
* brief and they read at different moments: the panel, to compose the turn, and `import_site`, for
|
|
81
|
+
* the destination — which is minutes later, after the model has decided to call it. A read that
|
|
82
|
+
* cleared would leave the tool inventing a path the user never chose. The tool clears it once the
|
|
83
|
+
* import has actually run.
|
|
84
|
+
*/
|
|
85
|
+
export function clearPendingImportBrief(): void {
|
|
86
|
+
_brief = null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ─── The hand-off itself ────────────────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The assistant's side of the hand-off, registered at boot.
|
|
93
|
+
*
|
|
94
|
+
* A late-bound slot for the same reason `services/project-adoption.ts` is one: the New Project
|
|
95
|
+
* wizard must not import `panels/ai-panel.ts`. That import is not just a layering preference — the
|
|
96
|
+
* panel constructs a `DocumentAssistant` singleton at module load, so reaching for it from
|
|
97
|
+
* `new-project/` drags a live assistant into every surface that opens the wizard.
|
|
98
|
+
*/
|
|
99
|
+
let _handoff: ((brief: ImportBrief) => Promise<void>) | null = null;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Register the assistant's hand-off (studio.ts boot).
|
|
103
|
+
*
|
|
104
|
+
* @param {(brief: ImportBrief) => Promise<void>} fn
|
|
105
|
+
*/
|
|
106
|
+
export function setImportHandoff(fn: (brief: ImportBrief) => Promise<void>): void {
|
|
107
|
+
_handoff = fn;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Start the import as an assistant turn.
|
|
112
|
+
*
|
|
113
|
+
* A no-op with nothing registered — a reduced host (a test fixture, an embedder without the
|
|
114
|
+
* assistant) would otherwise crash on a button the wizard should simply not have offered.
|
|
115
|
+
*
|
|
116
|
+
* @param {ImportBrief} brief
|
|
117
|
+
*/
|
|
118
|
+
export async function runImportHandoff(brief: ImportBrief): Promise<void> {
|
|
119
|
+
await _handoff?.(brief);
|
|
120
|
+
}
|
|
@@ -21,7 +21,7 @@ import coreDocumentSchema from "@jxsuite/schema/schema.json";
|
|
|
21
21
|
import coreProjectSchema from "@jxsuite/schema/project-schema.json";
|
|
22
22
|
|
|
23
23
|
type ValidateFn = ((doc: unknown) => boolean) & {
|
|
24
|
-
errors?: { instancePath?: string; message?: string }[] | null;
|
|
24
|
+
errors?: { instancePath?: string; message?: string; params?: Record<string, unknown> }[] | null;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
/** Which of the two entry documents a validator covers. */
|
|
@@ -78,6 +78,16 @@ function getValidator(kind: SchemaKind): Promise<ValidateFn | null> {
|
|
|
78
78
|
return compiling[kind];
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/** A payload half that is usable as a JSON Schema — a non-empty, non-array object. */
|
|
82
|
+
function asSchema(value: unknown): object | undefined {
|
|
83
|
+
return typeof value === "object" &&
|
|
84
|
+
value !== null &&
|
|
85
|
+
!Array.isArray(value) &&
|
|
86
|
+
Object.keys(value).length > 0
|
|
87
|
+
? (value as object)
|
|
88
|
+
: undefined;
|
|
89
|
+
}
|
|
90
|
+
|
|
81
91
|
/**
|
|
82
92
|
* Swap in the active project's pre-bundled entry documents (the payload behind the platform's
|
|
83
93
|
* `fetchProjectSchemas` member). Each half falls back to its core schema when absent, so a partial
|
|
@@ -90,16 +100,24 @@ function getValidator(kind: SchemaKind): Promise<ValidateFn | null> {
|
|
|
90
100
|
export function applyProjectSchemas(
|
|
91
101
|
schemas: { project?: unknown; document?: unknown } | null,
|
|
92
102
|
): boolean {
|
|
93
|
-
|
|
94
|
-
|
|
103
|
+
/*
|
|
104
|
+
* A payload half that is not a schema OBJECT falls back to core.
|
|
105
|
+
*
|
|
106
|
+
* `ajv.compile({})` succeeds and accepts everything, so a backend answering `null`, a string, or
|
|
107
|
+
* an error envelope under `document` would not fail loudly — it would install a validator that
|
|
108
|
+
* calls every document valid, and every consumer would go on trusting it.
|
|
109
|
+
*/
|
|
110
|
+
const document = asSchema(schemas?.document) ?? CORE.document;
|
|
111
|
+
const project = asSchema(schemas?.project) ?? CORE.project;
|
|
112
|
+
const applied = document !== CORE.document || project !== CORE.project;
|
|
95
113
|
if (document === active.document && project === active.project) {
|
|
96
|
-
return
|
|
114
|
+
return applied;
|
|
97
115
|
}
|
|
98
116
|
active.document = document;
|
|
99
117
|
active.project = project;
|
|
100
118
|
compiling.document = null;
|
|
101
119
|
compiling.project = null;
|
|
102
|
-
return
|
|
120
|
+
return applied;
|
|
103
121
|
}
|
|
104
122
|
|
|
105
123
|
/** Restore the core schemas (project closed / tests). */
|
|
@@ -107,6 +125,17 @@ export function resetProjectSchemas(): void {
|
|
|
107
125
|
applyProjectSchemas(null);
|
|
108
126
|
}
|
|
109
127
|
|
|
128
|
+
/**
|
|
129
|
+
* The keys ajv uses to name the property an error is ABOUT, in the order they can appear.
|
|
130
|
+
*
|
|
131
|
+
* `message` alone is not a diagnosis for any of these three. "must NOT have unevaluated properties"
|
|
132
|
+
* says a key is unrecognised without saying which key — and at the root of a `project.json` that is
|
|
133
|
+
* the difference between a fixable problem and a mystery. An imported project once produced that
|
|
134
|
+
* line three times over, naming nothing, and the only way to learn it meant `title`, `description`
|
|
135
|
+
* and `$style` was to compile the schema by hand.
|
|
136
|
+
*/
|
|
137
|
+
const ERROR_PROPERTY_KEYS = ["unevaluatedProperty", "additionalProperty", "missingProperty"];
|
|
138
|
+
|
|
110
139
|
/**
|
|
111
140
|
* Format ajv errors the way the agent loop consumes them (see ai-tools.ts
|
|
112
141
|
* `translateValidationError`).
|
|
@@ -115,7 +144,11 @@ export function resetProjectSchemas(): void {
|
|
|
115
144
|
* @returns {string[]} One formatted string per error
|
|
116
145
|
*/
|
|
117
146
|
function formatErrors(validate: ValidateFn): string[] {
|
|
118
|
-
return (validate.errors || []).map((e) =>
|
|
147
|
+
return (validate.errors || []).map((e) => {
|
|
148
|
+
const key = ERROR_PROPERTY_KEYS.find((name) => typeof e.params?.[name] === "string");
|
|
149
|
+
const property = key ? ` (${String(e.params?.[key])})` : "";
|
|
150
|
+
return `${e.instancePath || "(root)"}: ${e.message}${property}`;
|
|
151
|
+
});
|
|
119
152
|
}
|
|
120
153
|
|
|
121
154
|
/**
|
|
@@ -132,6 +165,25 @@ export async function validateDoc(doc: unknown): Promise<string[]> {
|
|
|
132
165
|
return formatErrors(validate);
|
|
133
166
|
}
|
|
134
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Validate a Jx document, distinguishing "valid" from "could not be checked".
|
|
170
|
+
*
|
|
171
|
+
* {@link validateDoc} fails OPEN — an unavailable validator answers `[]`, which is the same answer
|
|
172
|
+
* as "no errors". That is right where validation decorates an editor and wrong where it GATES a
|
|
173
|
+
* destructive step: a conversion that says "this will be a valid JSON document" on the strength of
|
|
174
|
+
* a schema it never compiled is the "never render 0" defect §9.1.1 forbids, one layer down.
|
|
175
|
+
*
|
|
176
|
+
* @param doc - Parsed document
|
|
177
|
+
* @returns The errors, `[]` when valid, or `null` when no validator could be compiled
|
|
178
|
+
*/
|
|
179
|
+
export async function validateDocOrNull(doc: unknown): Promise<string[] | null> {
|
|
180
|
+
const validate = await getValidator("document");
|
|
181
|
+
if (!validate) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
return validate(doc) ? [] : formatErrors(validate);
|
|
185
|
+
}
|
|
186
|
+
|
|
135
187
|
/**
|
|
136
188
|
* Validate a `project.json` config against the active project schema. The per-project entry
|
|
137
189
|
* document is what closes the composition (`unevaluatedProperties: false` over core + every enabled
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { initProjectRepo } from "../files/files";
|
|
13
|
+
import { beginBatch, endBatch, isBatching } from "../tabs/transact";
|
|
14
|
+
import { workspace } from "../workspace/workspace";
|
|
15
|
+
import type { Tab } from "../tabs/tab";
|
|
16
|
+
|
|
12
17
|
let _adopter: ((root: string) => Promise<void>) | null = null;
|
|
13
18
|
|
|
14
19
|
/** Register the project-open flow (studio.ts boot). */
|
|
@@ -29,3 +34,69 @@ export async function adoptProject(root: string): Promise<void> {
|
|
|
29
34
|
}
|
|
30
35
|
await _adopter(root);
|
|
31
36
|
}
|
|
37
|
+
|
|
38
|
+
/** What {@link adoptCreatedProject} observed, so a tool reports the outcome instead of the intent. */
|
|
39
|
+
export interface AdoptOutcome {
|
|
40
|
+
/** The workspace is now on this root. False means the project exists but this window is not on it. */
|
|
41
|
+
adopted: boolean;
|
|
42
|
+
/** Why adoption failed, when it threw. Null when it did not (including when it silently did not). */
|
|
43
|
+
error: string | null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The seams {@link adoptCreatedProject} runs through, so each caller keeps the one it already had. */
|
|
47
|
+
export interface AdoptCreatedOptions {
|
|
48
|
+
/** The active tab, read AFTER adoption to re-anchor the agent loop's undo batch. */
|
|
49
|
+
getTab: () => Tab | null;
|
|
50
|
+
/** The project-open flow. Defaults to this module's late-bound {@link adoptProject}. */
|
|
51
|
+
adopt?: (root: string) => Promise<void>;
|
|
52
|
+
/** Version-control init. Defaults to `files/files.ts`'s `initProjectRepo`. */
|
|
53
|
+
initRepo?: (root: string) => Promise<boolean>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Everything that must happen to a project the moment it exists: version control, then adoption.
|
|
58
|
+
*
|
|
59
|
+
* Extracted because `create_project` and `import_site` are the same act with different backends,
|
|
60
|
+
* and the wizard is a third caller of half of it. Two things it does are easy to leave out, and
|
|
61
|
+
* both were:
|
|
62
|
+
*
|
|
63
|
+
* - **Git init.** `specs/desktop.md` §4.5 is normative — _"On the create path, every source,
|
|
64
|
+
* including Import and Agent, Studio therefore binds the backend to the new root (`activate`),
|
|
65
|
+
* reads `gitStatus`, and runs `gitInit`."_ `initProjectRepo` had exactly two call sites, both in
|
|
66
|
+
* the New Project modal, so a project the ASSISTANT bootstrapped was not a repository and nothing
|
|
67
|
+
* said so. It runs first because it is what calls `platform.activate(root)`, which the open flow
|
|
68
|
+
* below needs.
|
|
69
|
+
* - **Verifying.** `openRecentProject` swallows its failures into a status message, so a resolved
|
|
70
|
+
* promise is not proof of adoption. The caller must be told which of the two happened.
|
|
71
|
+
*
|
|
72
|
+
* The batch dance is the third: the agent loop may hold an undo batch on the pre-adoption tab, and
|
|
73
|
+
* adoption replaces every tab in the workspace. Flush it, adopt, re-open one on whatever tab
|
|
74
|
+
* adoption left active.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} root - Absolute root of the project that was just created.
|
|
77
|
+
* @param {AdoptCreatedOptions} opts
|
|
78
|
+
* @returns {Promise<AdoptOutcome>}
|
|
79
|
+
*/
|
|
80
|
+
export async function adoptCreatedProject(
|
|
81
|
+
root: string,
|
|
82
|
+
{ getTab, adopt = adoptProject, initRepo = initProjectRepo }: AdoptCreatedOptions,
|
|
83
|
+
): Promise<AdoptOutcome> {
|
|
84
|
+
// Never fails the create: a project that was written stays written (initProjectRepo notifies).
|
|
85
|
+
await initRepo(root);
|
|
86
|
+
|
|
87
|
+
const wasBatching = isBatching();
|
|
88
|
+
if (wasBatching) {
|
|
89
|
+
endBatch();
|
|
90
|
+
}
|
|
91
|
+
let adoptionError: string | null = null;
|
|
92
|
+
try {
|
|
93
|
+
await adopt(root);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
adoptionError = error instanceof Error ? error.message : String(error);
|
|
96
|
+
}
|
|
97
|
+
if (wasBatching) {
|
|
98
|
+
beginBatch(getTab());
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return { adopted: workspace.projectRoot === root, error: adoptionError };
|
|
102
|
+
}
|
|
Binary file
|
|
@@ -127,6 +127,23 @@ export const SETTINGS = {
|
|
|
127
127
|
normalize: trimmed,
|
|
128
128
|
scope: "user",
|
|
129
129
|
},
|
|
130
|
+
/**
|
|
131
|
+
* Whether the Files tree draws what `.gitignore` masks.
|
|
132
|
+
*
|
|
133
|
+
* Unset — the default — HIDES them, which is the whole point: a project root holds the author's
|
|
134
|
+
* forty documents and a tool's forty thousand, and the author already said which is which. The
|
|
135
|
+
* setting exists so that answer is not a trap. `.env`, a built `dist/` an author wants to read, a
|
|
136
|
+
* generated file being debugged: each is a legitimate reason to look at an ignored file, and a
|
|
137
|
+
* sidebar that cannot show one sends the author to a different program.
|
|
138
|
+
*
|
|
139
|
+
* Roams, because "show me everything" is a way of working rather than a property of a window.
|
|
140
|
+
*/
|
|
141
|
+
showIgnoredFiles: {
|
|
142
|
+
default: "",
|
|
143
|
+
key: "jx.files.showIgnored",
|
|
144
|
+
normalize: trimmed,
|
|
145
|
+
scope: "user",
|
|
146
|
+
},
|
|
130
147
|
cfAccountId: {
|
|
131
148
|
default: "",
|
|
132
149
|
key: "jx.cf.accountId",
|