@jay-framework/aiditor 0.19.6 → 0.19.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/cancel-agent-task.jay-action +9 -0
- package/dist/actions/cancel-agent-task.jay-action.d.ts +8 -0
- package/dist/actions/check-aiditor-publish.jay-action +7 -0
- package/dist/actions/check-aiditor-publish.jay-action.d.ts +5 -0
- package/dist/actions/run-aiditor-publish.jay-action +7 -0
- package/dist/actions/run-aiditor-publish.jay-action.d.ts +5 -0
- package/dist/index.client.d.ts +165 -186
- package/dist/index.client.js +2672 -1120
- package/dist/index.d.ts +48 -3
- package/dist/index.js +246 -28
- package/dist/pages/aiditor/page.css +746 -67
- package/dist/pages/aiditor/page.jay-html +1573 -520
- package/package.json +10 -6
- package/plugin.yaml +6 -0
package/dist/index.d.ts
CHANGED
|
@@ -107,6 +107,18 @@ interface SubmitTaskActionOutput {
|
|
|
107
107
|
|
|
108
108
|
declare const submitTaskAction: _jay_framework_fullstack_component.JayStreamAction<SubmitTaskActionInput, SubmitTaskActionOutput> & _jay_framework_fullstack_component.JayStreamActionDefinition<SubmitTaskActionInput, SubmitTaskActionOutput, []>;
|
|
109
109
|
|
|
110
|
+
declare const cancelAgentTaskAction: _jay_framework_fullstack_component.JayAction<{
|
|
111
|
+
pageRoute?: string;
|
|
112
|
+
renderedUrl?: string;
|
|
113
|
+
}, {
|
|
114
|
+
cancelled: boolean;
|
|
115
|
+
}> & _jay_framework_fullstack_component.JayActionDefinition<{
|
|
116
|
+
pageRoute?: string;
|
|
117
|
+
renderedUrl?: string;
|
|
118
|
+
}, {
|
|
119
|
+
cancelled: boolean;
|
|
120
|
+
}, []>;
|
|
121
|
+
|
|
110
122
|
/** Design Log #19 — Add Menu agreement types (M19.1). */
|
|
111
123
|
type AddMenuItem = {
|
|
112
124
|
/** Stable unique id, convention: `<pluginName>:<slug>` */
|
|
@@ -368,7 +380,7 @@ declare const generateAddPageBriefFromImageAction: _jay_framework_fullstack_comp
|
|
|
368
380
|
ok: boolean;
|
|
369
381
|
markdown: string;
|
|
370
382
|
suggestedRoute: string;
|
|
371
|
-
suggestedRouteKind: "
|
|
383
|
+
suggestedRouteKind: "static" | "dynamic";
|
|
372
384
|
referenceAttachments: {
|
|
373
385
|
id: string;
|
|
374
386
|
path: string;
|
|
@@ -392,7 +404,7 @@ declare const generateAddPageBriefFromImageAction: _jay_framework_fullstack_comp
|
|
|
392
404
|
ok: boolean;
|
|
393
405
|
markdown: string;
|
|
394
406
|
suggestedRoute: string;
|
|
395
|
-
suggestedRouteKind: "
|
|
407
|
+
suggestedRouteKind: "static" | "dynamic";
|
|
396
408
|
referenceAttachments: {
|
|
397
409
|
id: string;
|
|
398
410
|
path: string;
|
|
@@ -687,6 +699,39 @@ declare const syncAddMenuAttachmentsAction: _jay_framework_fullstack_component.J
|
|
|
687
699
|
error?: string;
|
|
688
700
|
}, [_jay_framework_dev_server.DevServerService]>;
|
|
689
701
|
|
|
702
|
+
declare const checkAiditorPublishAction: _jay_framework_fullstack_component.JayAction<unknown, {
|
|
703
|
+
hasPublishScript: boolean;
|
|
704
|
+
}> & _jay_framework_fullstack_component.JayActionDefinition<unknown, {
|
|
705
|
+
hasPublishScript: boolean;
|
|
706
|
+
}, []>;
|
|
707
|
+
declare const runAiditorPublishAction: _jay_framework_fullstack_component.JayStreamAction<unknown, {
|
|
708
|
+
type: "output";
|
|
709
|
+
stream: "stdout" | "stderr";
|
|
710
|
+
text: string;
|
|
711
|
+
} | {
|
|
712
|
+
type: "complete";
|
|
713
|
+
success: boolean;
|
|
714
|
+
code: number | null;
|
|
715
|
+
} | {
|
|
716
|
+
type: "error";
|
|
717
|
+
message: string;
|
|
718
|
+
} | {
|
|
719
|
+
type: string;
|
|
720
|
+
}> & _jay_framework_fullstack_component.JayStreamActionDefinition<unknown, {
|
|
721
|
+
type: "output";
|
|
722
|
+
stream: "stdout" | "stderr";
|
|
723
|
+
text: string;
|
|
724
|
+
} | {
|
|
725
|
+
type: "complete";
|
|
726
|
+
success: boolean;
|
|
727
|
+
code: number | null;
|
|
728
|
+
} | {
|
|
729
|
+
type: "error";
|
|
730
|
+
message: string;
|
|
731
|
+
} | {
|
|
732
|
+
type: string;
|
|
733
|
+
}, []>;
|
|
734
|
+
|
|
690
735
|
declare function setupAiditor(ctx: PluginSetupContext): Promise<PluginSetupResult>;
|
|
691
736
|
|
|
692
|
-
export { checkAddPageRouteAction, checkPageAddPageBriefAction, checkPluginUpdateAction, ensureProjectPluginAction, generateAddPageBriefFromImageAction, getAiditorBootstrap, getPageParamsAction, getPluginSetupStatusAction, getProjectInfoAction, listAddMenuItemsAction, listFreezesAction, listJayPluginsAction, listPluginContractsAction, openAddPageFromBriefAction, readFileAction, reclassifyAddPageAssetAction, rerunPluginSetupAction, resolveAddMenuContractParamsAction, saveAddPageDraftAction, setupAiditor, startAddPageRequestAction, submitAddPageAction, submitTaskAction, syncAddMenuAttachmentsAction, syncAddPagePluginManifestAction, uploadAddPageAssetAction, writePluginSourceAction };
|
|
737
|
+
export { cancelAgentTaskAction, checkAddPageRouteAction, checkAiditorPublishAction, checkPageAddPageBriefAction, checkPluginUpdateAction, ensureProjectPluginAction, generateAddPageBriefFromImageAction, getAiditorBootstrap, getPageParamsAction, getPluginSetupStatusAction, getProjectInfoAction, listAddMenuItemsAction, listFreezesAction, listJayPluginsAction, listPluginContractsAction, openAddPageFromBriefAction, readFileAction, reclassifyAddPageAssetAction, rerunPluginSetupAction, resolveAddMenuContractParamsAction, runAiditorPublishAction, saveAddPageDraftAction, setupAiditor, startAddPageRequestAction, submitAddPageAction, submitTaskAction, syncAddMenuAttachmentsAction, syncAddPagePluginManifestAction, uploadAddPageAssetAction, writePluginSourceAction };
|
package/dist/index.js
CHANGED
|
@@ -230,6 +230,49 @@ async function replaceRouteSessionAfterStaleResume(projectDir, routeKey) {
|
|
|
230
230
|
return { sessionId };
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
|
+
function isDynamicJayRoute(templateRoute) {
|
|
234
|
+
return templateRoute.includes(":") || templateRoute.includes("[");
|
|
235
|
+
}
|
|
236
|
+
function resolveAgentContextKey(input) {
|
|
237
|
+
const template = normalizePageRoute(input.pageRoute);
|
|
238
|
+
if (!isDynamicJayRoute(template)) {
|
|
239
|
+
return template;
|
|
240
|
+
}
|
|
241
|
+
if (input.renderedUrl?.trim()) {
|
|
242
|
+
try {
|
|
243
|
+
const pathname = new URL(input.renderedUrl.trim(), "http://aiditor.local").pathname;
|
|
244
|
+
return normalizePageRoute(pathname);
|
|
245
|
+
} catch {
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return template;
|
|
249
|
+
}
|
|
250
|
+
const activeTokens = /* @__PURE__ */ new Map();
|
|
251
|
+
const cancelledRoutes = /* @__PURE__ */ new Set();
|
|
252
|
+
function beginCancellableAgentTask(routeKey) {
|
|
253
|
+
const token = Symbol("agent-task-cancel");
|
|
254
|
+
activeTokens.set(routeKey, token);
|
|
255
|
+
cancelledRoutes.delete(routeKey);
|
|
256
|
+
return token;
|
|
257
|
+
}
|
|
258
|
+
function endCancellableAgentTask(routeKey, token) {
|
|
259
|
+
if (activeTokens.get(routeKey) !== token) return;
|
|
260
|
+
activeTokens.delete(routeKey);
|
|
261
|
+
cancelledRoutes.delete(routeKey);
|
|
262
|
+
}
|
|
263
|
+
function isAgentTaskCancelled(routeKey) {
|
|
264
|
+
return cancelledRoutes.has(routeKey);
|
|
265
|
+
}
|
|
266
|
+
function cancelAgentTask(routeKey) {
|
|
267
|
+
const hadActiveTask = activeTokens.has(routeKey);
|
|
268
|
+
cancelledRoutes.add(routeKey);
|
|
269
|
+
endRouteQuery(routeKey);
|
|
270
|
+
return hadActiveTask;
|
|
271
|
+
}
|
|
272
|
+
function forceReleaseAgentRoute(routeKey) {
|
|
273
|
+
cancelledRoutes.add(routeKey);
|
|
274
|
+
endRouteQuery(routeKey);
|
|
275
|
+
}
|
|
233
276
|
const AGENT_KIT_PREAMBLE = `You are working in a Jay Stack project. The current working directory is the project root.
|
|
234
277
|
- Read agent-kit/plugins-index.yaml for installed plugins and materialized contract paths.
|
|
235
278
|
- Follow Jay Stack conventions for pages, routing, and headless component binding.
|
|
@@ -272,6 +315,31 @@ function buildChatPrompt(config, pageRoute, renderedUrl, userMessage) {
|
|
|
272
315
|
];
|
|
273
316
|
return lines.filter((l) => l !== null).join("\n");
|
|
274
317
|
}
|
|
318
|
+
function groupAddMenuItems(items) {
|
|
319
|
+
const byCategory = /* @__PURE__ */ new Map();
|
|
320
|
+
for (const item of items) {
|
|
321
|
+
const sub = item.subCategory ?? null;
|
|
322
|
+
let subMap = byCategory.get(item.category);
|
|
323
|
+
if (!subMap) {
|
|
324
|
+
subMap = /* @__PURE__ */ new Map();
|
|
325
|
+
byCategory.set(item.category, subMap);
|
|
326
|
+
}
|
|
327
|
+
const list = subMap.get(sub) ?? [];
|
|
328
|
+
list.push(item);
|
|
329
|
+
subMap.set(sub, list);
|
|
330
|
+
}
|
|
331
|
+
return [...byCategory.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([category, subMap]) => ({
|
|
332
|
+
category,
|
|
333
|
+
subCategories: [...subMap.entries()].sort(([a], [b]) => {
|
|
334
|
+
const sa = a ?? "";
|
|
335
|
+
const sb = b ?? "";
|
|
336
|
+
return sa.localeCompare(sb);
|
|
337
|
+
}).map(([subCategory, subItems]) => ({
|
|
338
|
+
subCategory,
|
|
339
|
+
items: subItems.sort((a, b) => a.title.localeCompare(b.title))
|
|
340
|
+
}))
|
|
341
|
+
}));
|
|
342
|
+
}
|
|
275
343
|
const REJECTED_ITEM_FIELDS = [
|
|
276
344
|
"kind",
|
|
277
345
|
"parameters",
|
|
@@ -503,31 +571,6 @@ function pluginNameFromItem(item) {
|
|
|
503
571
|
if (colon > 0) return item.id.slice(0, colon);
|
|
504
572
|
return null;
|
|
505
573
|
}
|
|
506
|
-
function groupAddMenuItems(items) {
|
|
507
|
-
const byCategory = /* @__PURE__ */ new Map();
|
|
508
|
-
for (const item of items) {
|
|
509
|
-
const sub = item.subCategory ?? null;
|
|
510
|
-
let subMap = byCategory.get(item.category);
|
|
511
|
-
if (!subMap) {
|
|
512
|
-
subMap = /* @__PURE__ */ new Map();
|
|
513
|
-
byCategory.set(item.category, subMap);
|
|
514
|
-
}
|
|
515
|
-
const list = subMap.get(sub) ?? [];
|
|
516
|
-
list.push(item);
|
|
517
|
-
subMap.set(sub, list);
|
|
518
|
-
}
|
|
519
|
-
return [...byCategory.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([category, subMap]) => ({
|
|
520
|
-
category,
|
|
521
|
-
subCategories: [...subMap.entries()].sort(([a], [b]) => {
|
|
522
|
-
const sa = a ?? "";
|
|
523
|
-
const sb = b ?? "";
|
|
524
|
-
return sa.localeCompare(sb);
|
|
525
|
-
}).map(([subCategory, subItems]) => ({
|
|
526
|
-
subCategory,
|
|
527
|
-
items: subItems.sort((a, b) => a.title.localeCompare(b.title))
|
|
528
|
-
}))
|
|
529
|
-
}));
|
|
530
|
-
}
|
|
531
574
|
async function listAddMenuItems(projectRoot) {
|
|
532
575
|
const addMenuDir = path.join(projectRoot, ADD_MENU_DIR);
|
|
533
576
|
const warnings = [];
|
|
@@ -1155,7 +1198,10 @@ const submitTaskAction = makeJayStream("aiditor.submitTask").withFiles().withHan
|
|
|
1155
1198
|
}
|
|
1156
1199
|
yield { type: "status", message: "Running agent..." };
|
|
1157
1200
|
const systemPrompt = loadAgentKitSystemPrompt(projectDir);
|
|
1158
|
-
const routeKey =
|
|
1201
|
+
const routeKey = resolveAgentContextKey({
|
|
1202
|
+
pageRoute: input.pageRoute ?? "/",
|
|
1203
|
+
renderedUrl: input.renderedUrl
|
|
1204
|
+
});
|
|
1159
1205
|
const sessionPlan = await getOrCreateSessionIdForRoute(
|
|
1160
1206
|
projectDir,
|
|
1161
1207
|
routeKey
|
|
@@ -1176,6 +1222,7 @@ const submitTaskAction = makeJayStream("aiditor.submitTask").withFiles().withHan
|
|
|
1176
1222
|
persistSession: true,
|
|
1177
1223
|
systemPrompt
|
|
1178
1224
|
};
|
|
1225
|
+
const cancelToken = beginCancellableAgentTask(routeKey);
|
|
1179
1226
|
try {
|
|
1180
1227
|
async function* streamAgentQuery(opts) {
|
|
1181
1228
|
for await (const message of query({
|
|
@@ -1185,6 +1232,9 @@ const submitTaskAction = makeJayStream("aiditor.submitTask").withFiles().withHan
|
|
|
1185
1232
|
...opts
|
|
1186
1233
|
}
|
|
1187
1234
|
})) {
|
|
1235
|
+
if (isAgentTaskCancelled(routeKey)) {
|
|
1236
|
+
return;
|
|
1237
|
+
}
|
|
1188
1238
|
for (const chunk of transformSDKMessage(message)) {
|
|
1189
1239
|
yield chunk;
|
|
1190
1240
|
}
|
|
@@ -1226,10 +1276,24 @@ const submitTaskAction = makeJayStream("aiditor.submitTask").withFiles().withHan
|
|
|
1226
1276
|
}
|
|
1227
1277
|
}
|
|
1228
1278
|
} finally {
|
|
1279
|
+
endCancellableAgentTask(routeKey, cancelToken);
|
|
1229
1280
|
endRouteQuery(routeKey);
|
|
1230
1281
|
}
|
|
1231
1282
|
yield { type: "done" };
|
|
1232
1283
|
});
|
|
1284
|
+
const cancelAgentTaskAction = makeJayQuery(
|
|
1285
|
+
"aiditor.cancelAgentTask"
|
|
1286
|
+
).withHandler(async (input) => {
|
|
1287
|
+
const routeKey = resolveAgentContextKey({
|
|
1288
|
+
pageRoute: input.pageRoute ?? "/",
|
|
1289
|
+
renderedUrl: input.renderedUrl
|
|
1290
|
+
});
|
|
1291
|
+
const cancelled = cancelAgentTask(routeKey);
|
|
1292
|
+
if (!cancelled) {
|
|
1293
|
+
forceReleaseAgentRoute(routeKey);
|
|
1294
|
+
}
|
|
1295
|
+
return { cancelled: true };
|
|
1296
|
+
});
|
|
1233
1297
|
class AddPagePromptLoadError extends Error {
|
|
1234
1298
|
constructor(message) {
|
|
1235
1299
|
super(message);
|
|
@@ -2055,7 +2119,7 @@ When the image is a formal Figma **design definitions** board, apply these rules
|
|
|
2055
2119
|
${designDefinitionsBody}`;
|
|
2056
2120
|
});
|
|
2057
2121
|
}
|
|
2058
|
-
const
|
|
2122
|
+
const briefFillModelOverride = process.env.AIDITOR_BRIEF_FILL_MODEL?.trim();
|
|
2059
2123
|
const ALLOWED_IMAGE_MIMES = /* @__PURE__ */ new Set([
|
|
2060
2124
|
"image/png",
|
|
2061
2125
|
"image/jpeg",
|
|
@@ -2218,7 +2282,7 @@ async function runBriefFillAgentQuery(input) {
|
|
|
2218
2282
|
maxTurns: BRIEF_FILL_MAX_TURNS,
|
|
2219
2283
|
persistSession: false,
|
|
2220
2284
|
systemPrompt,
|
|
2221
|
-
model:
|
|
2285
|
+
...briefFillModelOverride ? { model: briefFillModelOverride } : void 0,
|
|
2222
2286
|
thinking: { type: "disabled" }
|
|
2223
2287
|
}
|
|
2224
2288
|
})) {
|
|
@@ -2867,6 +2931,41 @@ function resolveYarnAddInvocation(projectDir, spec) {
|
|
|
2867
2931
|
cwd: resolvedProject
|
|
2868
2932
|
};
|
|
2869
2933
|
}
|
|
2934
|
+
function resolvePackageScriptInvocation(projectDir, scriptName) {
|
|
2935
|
+
const resolvedProject = path.resolve(projectDir);
|
|
2936
|
+
const workspaceRoot = findYarnWorkspaceRoot(resolvedProject);
|
|
2937
|
+
const root = workspaceRoot ?? resolvedProject;
|
|
2938
|
+
const runner = resolveYarnRunner(root);
|
|
2939
|
+
const projectPkg = readPackageJson(resolvedProject);
|
|
2940
|
+
const rootPkg = readPackageJson(root);
|
|
2941
|
+
const usesYarn = Boolean(rootPkg?.packageManager?.startsWith("yarn@")) || fs$1.existsSync(path.join(root, "yarn.lock")) || fs$1.existsSync(path.join(resolvedProject, "yarn.lock"));
|
|
2942
|
+
if (usesYarn) {
|
|
2943
|
+
const useWorkspaceCommand = workspaceRoot !== void 0 && path.resolve(root) !== resolvedProject && hasYarnWorkspaces(rootPkg) && typeof projectPkg?.name === "string" && projectPkg.name.length > 0;
|
|
2944
|
+
if (useWorkspaceCommand) {
|
|
2945
|
+
return {
|
|
2946
|
+
command: runner.command,
|
|
2947
|
+
args: [
|
|
2948
|
+
...runner.prefixArgs,
|
|
2949
|
+
"workspace",
|
|
2950
|
+
projectPkg.name,
|
|
2951
|
+
scriptName
|
|
2952
|
+
],
|
|
2953
|
+
cwd: root
|
|
2954
|
+
};
|
|
2955
|
+
}
|
|
2956
|
+
const args = runner.prefixArgs.length > 0 ? [...runner.prefixArgs, scriptName] : [scriptName];
|
|
2957
|
+
return {
|
|
2958
|
+
command: runner.command,
|
|
2959
|
+
args,
|
|
2960
|
+
cwd: resolvedProject
|
|
2961
|
+
};
|
|
2962
|
+
}
|
|
2963
|
+
return {
|
|
2964
|
+
command: "npm",
|
|
2965
|
+
args: ["run", scriptName],
|
|
2966
|
+
cwd: resolvedProject
|
|
2967
|
+
};
|
|
2968
|
+
}
|
|
2870
2969
|
function parseSemver(version) {
|
|
2871
2970
|
const m = version.match(/^(\d+)\.(\d+)\.(\d+)/);
|
|
2872
2971
|
if (!m) return null;
|
|
@@ -2885,6 +2984,57 @@ function isNewerSemver(latest, installed) {
|
|
|
2885
2984
|
if (!a || !b) return false;
|
|
2886
2985
|
return compareSemver(a, b) > 0;
|
|
2887
2986
|
}
|
|
2987
|
+
async function* spawnCommandStream(command, args, cwd, options) {
|
|
2988
|
+
const child = spawn(command, args, {
|
|
2989
|
+
cwd,
|
|
2990
|
+
shell: options?.shell ?? false,
|
|
2991
|
+
env: process.env
|
|
2992
|
+
});
|
|
2993
|
+
const stdoutQueue = [];
|
|
2994
|
+
const stderrQueue = [];
|
|
2995
|
+
let closeCode = null;
|
|
2996
|
+
let spawnError;
|
|
2997
|
+
let notify;
|
|
2998
|
+
const wake = () => notify?.();
|
|
2999
|
+
child.stdout.on("data", (chunk) => {
|
|
3000
|
+
const text = chunk.toString();
|
|
3001
|
+
process.stdout.write(text);
|
|
3002
|
+
stdoutQueue.push({ type: "stdout", text });
|
|
3003
|
+
wake();
|
|
3004
|
+
});
|
|
3005
|
+
child.stderr.on("data", (chunk) => {
|
|
3006
|
+
const text = chunk.toString();
|
|
3007
|
+
process.stderr.write(text);
|
|
3008
|
+
stderrQueue.push({ type: "stderr", text });
|
|
3009
|
+
wake();
|
|
3010
|
+
});
|
|
3011
|
+
child.on("close", (code) => {
|
|
3012
|
+
closeCode = code;
|
|
3013
|
+
wake();
|
|
3014
|
+
});
|
|
3015
|
+
child.on("error", (err) => {
|
|
3016
|
+
spawnError = err.message;
|
|
3017
|
+
closeCode = 1;
|
|
3018
|
+
wake();
|
|
3019
|
+
});
|
|
3020
|
+
while (closeCode === null || stdoutQueue.length > 0 || stderrQueue.length > 0) {
|
|
3021
|
+
while (stdoutQueue.length > 0) {
|
|
3022
|
+
yield stdoutQueue.shift();
|
|
3023
|
+
}
|
|
3024
|
+
while (stderrQueue.length > 0) {
|
|
3025
|
+
yield stderrQueue.shift();
|
|
3026
|
+
}
|
|
3027
|
+
if (closeCode !== null) break;
|
|
3028
|
+
await new Promise((resolve) => {
|
|
3029
|
+
notify = resolve;
|
|
3030
|
+
});
|
|
3031
|
+
notify = void 0;
|
|
3032
|
+
}
|
|
3033
|
+
if (spawnError) {
|
|
3034
|
+
yield { type: "stderr", text: spawnError };
|
|
3035
|
+
}
|
|
3036
|
+
yield { type: "close", code: closeCode };
|
|
3037
|
+
}
|
|
2888
3038
|
async function spawnCommand(command, args, cwd, options) {
|
|
2889
3039
|
return new Promise((resolve) => {
|
|
2890
3040
|
const child = spawn(command, args, {
|
|
@@ -3642,6 +3792,71 @@ const writePluginSourceAction = makeJayQuery("aiditor.writePluginSource").withSe
|
|
|
3642
3792
|
await writePluginSource(projectRoot, input);
|
|
3643
3793
|
return { ok: true };
|
|
3644
3794
|
});
|
|
3795
|
+
const AIDITOR_PUBLISH_SCRIPT = "aiditor:publish";
|
|
3796
|
+
async function projectHasAiditorPublishScript(projectRoot) {
|
|
3797
|
+
try {
|
|
3798
|
+
const raw = await fs.readFile(
|
|
3799
|
+
path.join(projectRoot, "package.json"),
|
|
3800
|
+
"utf-8"
|
|
3801
|
+
);
|
|
3802
|
+
const pkg = JSON.parse(raw);
|
|
3803
|
+
const script = pkg.scripts?.[AIDITOR_PUBLISH_SCRIPT];
|
|
3804
|
+
return typeof script === "string" && script.trim().length > 0;
|
|
3805
|
+
} catch {
|
|
3806
|
+
return false;
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3809
|
+
async function* streamAiditorPublishScript(projectRoot) {
|
|
3810
|
+
const hasScript = await projectHasAiditorPublishScript(projectRoot);
|
|
3811
|
+
if (!hasScript) {
|
|
3812
|
+
yield {
|
|
3813
|
+
type: "error",
|
|
3814
|
+
message: `package.json is missing an "${AIDITOR_PUBLISH_SCRIPT}" script.`
|
|
3815
|
+
};
|
|
3816
|
+
return;
|
|
3817
|
+
}
|
|
3818
|
+
const inv = resolvePackageScriptInvocation(
|
|
3819
|
+
projectRoot,
|
|
3820
|
+
AIDITOR_PUBLISH_SCRIPT
|
|
3821
|
+
);
|
|
3822
|
+
const commandLabel = [inv.command, ...inv.args].join(" ");
|
|
3823
|
+
yield {
|
|
3824
|
+
type: "output",
|
|
3825
|
+
stream: "stdout",
|
|
3826
|
+
text: `> ${commandLabel}
|
|
3827
|
+
`
|
|
3828
|
+
};
|
|
3829
|
+
for await (const chunk of spawnCommandStream(inv.command, inv.args, inv.cwd, {
|
|
3830
|
+
shell: inv.command === "npm"
|
|
3831
|
+
})) {
|
|
3832
|
+
if (chunk.type === "stdout" || chunk.type === "stderr") {
|
|
3833
|
+
yield { type: "output", stream: chunk.type, text: chunk.text };
|
|
3834
|
+
continue;
|
|
3835
|
+
}
|
|
3836
|
+
yield {
|
|
3837
|
+
type: "complete",
|
|
3838
|
+
success: chunk.code === 0,
|
|
3839
|
+
code: chunk.code
|
|
3840
|
+
};
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3843
|
+
const checkAiditorPublishAction = makeJayQuery(
|
|
3844
|
+
"aiditor.checkAiditorPublish"
|
|
3845
|
+
).withHandler(async () => {
|
|
3846
|
+
const projectRoot = process.cwd();
|
|
3847
|
+
const hasPublishScript = await projectHasAiditorPublishScript(projectRoot);
|
|
3848
|
+
return { hasPublishScript };
|
|
3849
|
+
});
|
|
3850
|
+
const runAiditorPublishAction = makeJayStream(
|
|
3851
|
+
"aiditor.runAiditorPublish"
|
|
3852
|
+
).withHandler(async function* () {
|
|
3853
|
+
const projectRoot = process.cwd();
|
|
3854
|
+
for await (const chunk of streamAiditorPublishScript(projectRoot)) {
|
|
3855
|
+
yield chunk;
|
|
3856
|
+
if (chunk.type === "error") return;
|
|
3857
|
+
}
|
|
3858
|
+
yield { type: "done" };
|
|
3859
|
+
});
|
|
3645
3860
|
const AIDITOR_ADD_MENU_DOC = "aiditor-add-menu.md";
|
|
3646
3861
|
const INSTRUCTIONS_LINK_LINE = "- [Add Menu integration](./aiditor-add-menu.md) — contribute catalog items for AIditor";
|
|
3647
3862
|
async function resolveTemplateDir(fromModuleUrl) {
|
|
@@ -3733,7 +3948,9 @@ const page = makeJayStackComponent().withProps();
|
|
|
3733
3948
|
export {
|
|
3734
3949
|
page as aiditorPage,
|
|
3735
3950
|
aiditorShell,
|
|
3951
|
+
cancelAgentTaskAction,
|
|
3736
3952
|
checkAddPageRouteAction,
|
|
3953
|
+
checkAiditorPublishAction,
|
|
3737
3954
|
checkPageAddPageBriefAction,
|
|
3738
3955
|
checkPluginUpdateAction,
|
|
3739
3956
|
ensureProjectPluginAction,
|
|
@@ -3751,6 +3968,7 @@ export {
|
|
|
3751
3968
|
reclassifyAddPageAssetAction,
|
|
3752
3969
|
rerunPluginSetupAction,
|
|
3753
3970
|
resolveAddMenuContractParamsAction,
|
|
3971
|
+
runAiditorPublishAction,
|
|
3754
3972
|
saveAddPageDraftAction,
|
|
3755
3973
|
setupAiditor,
|
|
3756
3974
|
startAddPageRequestAction,
|