happy-imou-cloud 2.0.20 → 2.0.22
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/bin/happy-cloud.mjs +1 -1
- package/dist/{BaseReasoningProcessor-B9z785Pi.cjs → BaseReasoningProcessor-CJVv1aNR.cjs} +3 -3
- package/dist/{BaseReasoningProcessor-iTk5q5Vy.mjs → BaseReasoningProcessor-mIqqngd3.mjs} +3 -3
- package/dist/ProviderSelectionHandler-BjLyIfSR.mjs +673 -0
- package/dist/ProviderSelectionHandler-e4zL4Y5_.cjs +680 -0
- package/dist/{api-BKnzORe4.cjs → api-DP-RQUao.cjs} +88 -3
- package/dist/{api-_Y2kzqZL.mjs → api-DrijKeDb.mjs} +86 -4
- package/dist/{command-BDkgHdQU.mjs → command--vV6BSsL.mjs} +3 -3
- package/dist/{command-BBNzMWEG.cjs → command-BZphfJrt.cjs} +3 -3
- package/dist/{index-Bg4KLXYY.mjs → index-BIki80pQ.mjs} +8 -8
- package/dist/{index-0TIyXMQu.cjs → index-CqCEZDFi.cjs} +11 -11
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +3 -3
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +393 -36
- package/dist/lib.d.mts +393 -36
- package/dist/lib.mjs +1 -1
- package/dist/{persistence-BCkHc68b.mjs → persistence-C3NBdZdz.mjs} +1 -1
- package/dist/{persistence-D5uolhHo.cjs → persistence-yVTbf_Ng.cjs} +1 -1
- package/dist/{registerKillSessionHandler-DJMH-gar.mjs → registerKillSessionHandler-CHEj7UjN.mjs} +3 -3
- package/dist/{registerKillSessionHandler-BMUE5Oaj.cjs → registerKillSessionHandler-QmBN446A.cjs} +3 -3
- package/dist/{runClaude-BUhD2jR2.cjs → runClaude-BuI6OOEv.cjs} +72 -9
- package/dist/{runClaude-BMv-eao6.mjs → runClaude-D0DD_Ya5.mjs} +72 -9
- package/dist/{runCodex-DyNSDN6X.cjs → runCodex-1jTTmCvq.cjs} +84 -14
- package/dist/{runCodex-DwnLnXWK.mjs → runCodex-BzZ0jODI.mjs} +84 -14
- package/dist/{runGemini-UKpRbyNY.cjs → runGemini-1gJRE8oT.cjs} +5 -5
- package/dist/{runGemini-uVHDcJ09.mjs → runGemini-Bx2SYAyG.mjs} +5 -5
- package/package.json +1 -1
- package/scripts/build.mjs +66 -66
- package/scripts/devtools/README.md +9 -9
- package/scripts/e2e/fake-codex-acp-agent.mjs +139 -139
- package/scripts/e2e/local-server-session-roundtrip.mjs +1063 -1063
- package/scripts/release-smoke.mjs +3 -3
- package/dist/ProviderSelectionHandler-DUBEXkmo.cjs +0 -265
- package/dist/ProviderSelectionHandler-s79sTquD.mjs +0 -261
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { l as logger,
|
|
3
|
-
import { B as BasePermissionHandler, h as hashObject, d as MessageBuffer, C as ConversationHistory$1, w as waitForResponseCompleteWithAbort, r as registerKillSessionHandler, l as launchRuntimeHandleWithFactoryResult, i as inferToolResultError, j as forwardAgentMessageToProviderSession, f as closeProviderSession, e as ensureManagedProviderMachine, M as MissingMachineIdError, b as MessageQueue2, s as syncControlledByUserState } from './registerKillSessionHandler-
|
|
4
|
-
import { f as formatDisplayMessage, v as validateCodexAcpSpawn, d as createCodexBackend, t as truncateDisplayMessage, b as stopCaffeinate } from './index-
|
|
2
|
+
import { l as logger, f as connectionState, A as ApiClient } from './api-DrijKeDb.mjs';
|
|
3
|
+
import { B as BasePermissionHandler, h as hashObject, d as MessageBuffer, C as ConversationHistory$1, w as waitForResponseCompleteWithAbort, r as registerKillSessionHandler, l as launchRuntimeHandleWithFactoryResult, i as inferToolResultError, j as forwardAgentMessageToProviderSession, f as closeProviderSession, e as ensureManagedProviderMachine, M as MissingMachineIdError, b as MessageQueue2, s as syncControlledByUserState } from './registerKillSessionHandler-CHEj7UjN.mjs';
|
|
4
|
+
import { f as formatDisplayMessage, v as validateCodexAcpSpawn, d as createCodexBackend, t as truncateDisplayMessage, b as stopCaffeinate } from './index-BIki80pQ.mjs';
|
|
5
5
|
import 'cross-spawn';
|
|
6
6
|
import '@agentclientprotocol/sdk';
|
|
7
7
|
import 'ps-list';
|
|
@@ -14,7 +14,7 @@ import 'node:path';
|
|
|
14
14
|
import 'node:os';
|
|
15
15
|
import 'node:child_process';
|
|
16
16
|
import 'node:readline';
|
|
17
|
-
import './persistence-
|
|
17
|
+
import './persistence-C3NBdZdz.mjs';
|
|
18
18
|
import 'node:fs/promises';
|
|
19
19
|
import 'fs/promises';
|
|
20
20
|
import 'crypto';
|
|
@@ -25,8 +25,8 @@ import 'tweetnacl';
|
|
|
25
25
|
import 'open';
|
|
26
26
|
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
27
27
|
import { useStdout, useInput, Box, Text, render } from 'ink';
|
|
28
|
-
import { c as createKeepAliveController, P as ProviderSelectionHandler, r as runModeLoop } from './ProviderSelectionHandler-
|
|
29
|
-
import { B as BaseReasoningProcessor, b as bootstrapManagedProviderSession } from './BaseReasoningProcessor-
|
|
28
|
+
import { c as createKeepAliveController, P as ProviderSelectionHandler, b as buildHappyOrgTurnPrompt, f as finalizeHappyOrgTurn, r as runModeLoop, a as resolveHappyOrgQueuedTurn } from './ProviderSelectionHandler-BjLyIfSR.mjs';
|
|
29
|
+
import { B as BaseReasoningProcessor, b as bootstrapManagedProviderSession } from './BaseReasoningProcessor-mIqqngd3.mjs';
|
|
30
30
|
import 'zod';
|
|
31
31
|
import 'socket.io-client';
|
|
32
32
|
import 'expo-server-sdk';
|
|
@@ -486,7 +486,16 @@ function resolveCodexAcpExecutionMode(mode) {
|
|
|
486
486
|
};
|
|
487
487
|
}
|
|
488
488
|
function getCodexExecutionFingerprint(mode) {
|
|
489
|
-
return hashObject(
|
|
489
|
+
return hashObject({
|
|
490
|
+
...resolveCodexAcpExecutionMode(mode),
|
|
491
|
+
happyOrg: mode.happyOrg ? {
|
|
492
|
+
taskId: mode.happyOrg.context.taskId,
|
|
493
|
+
organizationId: mode.happyOrg.context.organizationId,
|
|
494
|
+
memberAgentId: mode.happyOrg.context.memberAgentId,
|
|
495
|
+
supervisorAgentId: mode.happyOrg.context.supervisorAgentId,
|
|
496
|
+
reopenContext: mode.happyOrg.reopenContext ?? null
|
|
497
|
+
} : null
|
|
498
|
+
});
|
|
490
499
|
}
|
|
491
500
|
|
|
492
501
|
function normalizeCodexBackendError(error) {
|
|
@@ -565,6 +574,7 @@ async function codexRemoteLauncher(session) {
|
|
|
565
574
|
let currentAssistantMessageId = null;
|
|
566
575
|
let currentThinkingMessageId = null;
|
|
567
576
|
let fatalRuntimeStopError = null;
|
|
577
|
+
let currentHappyOrgTurn = null;
|
|
568
578
|
const permissionHandler = new CodexPermissionHandler(session.client);
|
|
569
579
|
const selectionHandler = new CodexSelectionHandler(session.client);
|
|
570
580
|
const conversationHistory = new ConversationHistory$1({ maxMessages: 20, maxCharacters: 5e4 });
|
|
@@ -597,6 +607,7 @@ async function codexRemoteLauncher(session) {
|
|
|
597
607
|
shouldCommitAccumulatedResponse = false;
|
|
598
608
|
currentAssistantMessageId = null;
|
|
599
609
|
currentThinkingMessageId = null;
|
|
610
|
+
currentHappyOrgTurn = null;
|
|
600
611
|
session.onThinkingChange(false);
|
|
601
612
|
};
|
|
602
613
|
const abortActiveTurn = () => {
|
|
@@ -636,6 +647,13 @@ async function codexRemoteLauncher(session) {
|
|
|
636
647
|
id: randomUUID()
|
|
637
648
|
});
|
|
638
649
|
};
|
|
650
|
+
const emitTurnReport = (report) => {
|
|
651
|
+
session.runtimeSession.sendCodexMessage({
|
|
652
|
+
type: "turn-report",
|
|
653
|
+
id: randomUUID(),
|
|
654
|
+
report
|
|
655
|
+
});
|
|
656
|
+
};
|
|
639
657
|
const handleUnexpectedRuntimeStop = (detail) => {
|
|
640
658
|
if (shouldExit || fatalRuntimeStopError) {
|
|
641
659
|
return;
|
|
@@ -658,17 +676,33 @@ async function codexRemoteLauncher(session) {
|
|
|
658
676
|
}
|
|
659
677
|
emitStatusMessage(reason);
|
|
660
678
|
};
|
|
661
|
-
const emitFinalAssistantMessage = () => {
|
|
662
|
-
|
|
679
|
+
const emitFinalAssistantMessage = (finalMessageText) => {
|
|
680
|
+
const finalMessage = (finalMessageText ?? accumulatedResponse).trim();
|
|
681
|
+
if (!finalMessage) {
|
|
663
682
|
return;
|
|
664
683
|
}
|
|
665
|
-
|
|
666
|
-
|
|
684
|
+
if (currentAssistantMessageId) {
|
|
685
|
+
messageBuffer.updateMessage(currentAssistantMessageId, finalMessage, { mode: "replace" });
|
|
686
|
+
}
|
|
687
|
+
conversationHistory.addAssistantMessage(finalMessage);
|
|
688
|
+
if (currentHappyOrgTurn) {
|
|
689
|
+
session.runtimeSession.sendCodexMessage({
|
|
690
|
+
type: "message",
|
|
691
|
+
message: finalMessage,
|
|
692
|
+
id: randomUUID()
|
|
693
|
+
});
|
|
694
|
+
} else {
|
|
695
|
+
accumulatedResponse = finalMessage;
|
|
696
|
+
emitPendingAssistantMessageDelta({ force: true });
|
|
697
|
+
}
|
|
667
698
|
accumulatedResponse = "";
|
|
668
699
|
emittedResponseLength = 0;
|
|
669
700
|
isResponseInProgress = false;
|
|
670
701
|
};
|
|
671
|
-
const emitPendingAssistantMessageDelta = () => {
|
|
702
|
+
const emitPendingAssistantMessageDelta = (opts) => {
|
|
703
|
+
if (currentHappyOrgTurn && !opts?.force) {
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
672
706
|
const nextMessage = accumulatedResponse.slice(emittedResponseLength);
|
|
673
707
|
if (!nextMessage.trim()) {
|
|
674
708
|
return false;
|
|
@@ -968,6 +1002,8 @@ async function codexRemoteLauncher(session) {
|
|
|
968
1002
|
readyAlreadySent = false;
|
|
969
1003
|
messageBuffer.addMessage(message.message, "user");
|
|
970
1004
|
const turnSignal = abortController.signal;
|
|
1005
|
+
let turnStatus = "task_complete";
|
|
1006
|
+
currentHappyOrgTurn = message.mode.happyOrg ?? null;
|
|
971
1007
|
try {
|
|
972
1008
|
turnInFlight = true;
|
|
973
1009
|
shouldCommitAccumulatedResponse = false;
|
|
@@ -982,6 +1018,9 @@ async function codexRemoteLauncher(session) {
|
|
|
982
1018
|
promptToSend = historyContext + promptToSend;
|
|
983
1019
|
logger.debug(`[Codex] Injected conversation history context (${historyContext.length} chars)`);
|
|
984
1020
|
}
|
|
1021
|
+
if (message.mode.happyOrg) {
|
|
1022
|
+
promptToSend = buildHappyOrgTurnPrompt(promptToSend, message.mode.happyOrg);
|
|
1023
|
+
}
|
|
985
1024
|
conversationHistory.addUserMessage(message.message);
|
|
986
1025
|
await activeRuntimeHandle.sendPrompt(promptToSend);
|
|
987
1026
|
await waitForResponseCompleteWithAbort(activeRuntimeHandle.backend, turnSignal);
|
|
@@ -993,6 +1032,7 @@ async function codexRemoteLauncher(session) {
|
|
|
993
1032
|
const isAbortError = error instanceof Error && error.name === "AbortError";
|
|
994
1033
|
const isExpectedInterruption = isAbortError || turnSignal.aborted || shouldExit;
|
|
995
1034
|
if (isExpectedInterruption) {
|
|
1035
|
+
turnStatus = "turn_aborted";
|
|
996
1036
|
session.runtimeSession.sendCodexMessage({
|
|
997
1037
|
type: "turn_aborted",
|
|
998
1038
|
id: randomUUID()
|
|
@@ -1009,8 +1049,24 @@ async function codexRemoteLauncher(session) {
|
|
|
1009
1049
|
}
|
|
1010
1050
|
} finally {
|
|
1011
1051
|
turnInFlight = false;
|
|
1052
|
+
const finalizedTurn = finalizeHappyOrgTurn({
|
|
1053
|
+
metadata: session.runtimeSession.getMetadataSnapshot?.() ?? null,
|
|
1054
|
+
queuedTurn: message.mode.happyOrg,
|
|
1055
|
+
responseText: accumulatedResponse,
|
|
1056
|
+
turnStatus
|
|
1057
|
+
});
|
|
1058
|
+
if (finalizedTurn.nextMetadata && typeof session.runtimeSession.updateMetadata === "function") {
|
|
1059
|
+
session.runtimeSession.updateMetadata(() => finalizedTurn.nextMetadata);
|
|
1060
|
+
}
|
|
1061
|
+
if (finalizedTurn.report) {
|
|
1062
|
+
emitTurnReport(finalizedTurn.report);
|
|
1063
|
+
}
|
|
1064
|
+
if (finalizedTurn.terminateMessage) {
|
|
1065
|
+
emitStatusMessage(finalizedTurn.terminateMessage);
|
|
1066
|
+
}
|
|
1067
|
+
accumulatedResponse = finalizedTurn.cleanedText;
|
|
1012
1068
|
if (shouldCommitAccumulatedResponse) {
|
|
1013
|
-
emitFinalAssistantMessage();
|
|
1069
|
+
emitFinalAssistantMessage(finalizedTurn.cleanedText);
|
|
1014
1070
|
}
|
|
1015
1071
|
if (!shouldExit) {
|
|
1016
1072
|
session.runtimeSession.sendCodexMessage({
|
|
@@ -1175,6 +1231,19 @@ async function runCodex(opts) {
|
|
|
1175
1231
|
let currentPermissionMode = initialPermissionMode;
|
|
1176
1232
|
let currentModel;
|
|
1177
1233
|
sessionClient.onUserMessage((message) => {
|
|
1234
|
+
const happyOrgResult = resolveHappyOrgQueuedTurn({
|
|
1235
|
+
metadata: sessionClient.getMetadataSnapshot?.() ?? metadata,
|
|
1236
|
+
message
|
|
1237
|
+
});
|
|
1238
|
+
if (happyOrgResult.nextMetadata) {
|
|
1239
|
+
sessionClient.updateMetadata(() => happyOrgResult.nextMetadata);
|
|
1240
|
+
}
|
|
1241
|
+
if (happyOrgResult.blocked) {
|
|
1242
|
+
if (happyOrgResult.statusMessage) {
|
|
1243
|
+
sessionClient.sendSessionEvent({ type: "message", message: happyOrgResult.statusMessage });
|
|
1244
|
+
}
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1178
1247
|
const previousPermissionMode = currentPermissionMode;
|
|
1179
1248
|
let messagePermissionMode = previousPermissionMode;
|
|
1180
1249
|
if (message.meta?.permissionMode) {
|
|
@@ -1193,7 +1262,8 @@ async function runCodex(opts) {
|
|
|
1193
1262
|
}
|
|
1194
1263
|
messageQueue.push(message.content.text, {
|
|
1195
1264
|
permissionMode: permissionResolution.resolvedPermissionMode,
|
|
1196
|
-
model: messageModel
|
|
1265
|
+
model: messageModel,
|
|
1266
|
+
happyOrg: happyOrgResult.queuedTurn
|
|
1197
1267
|
});
|
|
1198
1268
|
});
|
|
1199
1269
|
codexSession = new CodexSession({
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
var ink = require('ink');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var node_crypto = require('node:crypto');
|
|
6
|
-
var api = require('./api-
|
|
7
|
-
var registerKillSessionHandler = require('./registerKillSessionHandler-
|
|
8
|
-
var index = require('./index-
|
|
9
|
-
var BaseReasoningProcessor = require('./BaseReasoningProcessor-
|
|
6
|
+
var api = require('./api-DP-RQUao.cjs');
|
|
7
|
+
var registerKillSessionHandler = require('./registerKillSessionHandler-QmBN446A.cjs');
|
|
8
|
+
var index = require('./index-CqCEZDFi.cjs');
|
|
9
|
+
var BaseReasoningProcessor = require('./BaseReasoningProcessor-CJVv1aNR.cjs');
|
|
10
10
|
require('cross-spawn');
|
|
11
11
|
require('@agentclientprotocol/sdk');
|
|
12
12
|
require('ps-list');
|
|
@@ -17,7 +17,7 @@ require('node:child_process');
|
|
|
17
17
|
require('node:readline');
|
|
18
18
|
require('tweetnacl');
|
|
19
19
|
require('axios');
|
|
20
|
-
require('./persistence-
|
|
20
|
+
require('./persistence-yVTbf_Ng.cjs');
|
|
21
21
|
require('open');
|
|
22
22
|
require('chalk');
|
|
23
23
|
require('fs');
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useStdout, useInput, Box, Text, render } from 'ink';
|
|
2
2
|
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import { l as logger,
|
|
5
|
-
import { B as BasePermissionHandler, C as ConversationHistory$1, e as ensureManagedProviderMachine, M as MissingMachineIdError, s as syncControlledByUserState, b as MessageQueue2, h as hashObject, d as MessageBuffer, r as registerKillSessionHandler, w as waitForResponseCompleteWithAbort, f as closeProviderSession, l as launchRuntimeHandleWithFactoryResult, i as inferToolResultError, j as forwardAgentMessageToProviderSession } from './registerKillSessionHandler-
|
|
6
|
-
import { g as getInitialGeminiModel, r as readGeminiLocalConfig, G as GEMINI_MODEL_ENV, s as saveGeminiModelToConfig, a as createGeminiBackend, b as stopCaffeinate } from './index-
|
|
7
|
-
import { B as BaseReasoningProcessor, b as bootstrapManagedProviderSession } from './BaseReasoningProcessor-
|
|
4
|
+
import { l as logger, f as connectionState, A as ApiClient } from './api-DrijKeDb.mjs';
|
|
5
|
+
import { B as BasePermissionHandler, C as ConversationHistory$1, e as ensureManagedProviderMachine, M as MissingMachineIdError, s as syncControlledByUserState, b as MessageQueue2, h as hashObject, d as MessageBuffer, r as registerKillSessionHandler, w as waitForResponseCompleteWithAbort, f as closeProviderSession, l as launchRuntimeHandleWithFactoryResult, i as inferToolResultError, j as forwardAgentMessageToProviderSession } from './registerKillSessionHandler-CHEj7UjN.mjs';
|
|
6
|
+
import { g as getInitialGeminiModel, r as readGeminiLocalConfig, G as GEMINI_MODEL_ENV, s as saveGeminiModelToConfig, a as createGeminiBackend, b as stopCaffeinate } from './index-BIki80pQ.mjs';
|
|
7
|
+
import { B as BaseReasoningProcessor, b as bootstrapManagedProviderSession } from './BaseReasoningProcessor-mIqqngd3.mjs';
|
|
8
8
|
import 'cross-spawn';
|
|
9
9
|
import '@agentclientprotocol/sdk';
|
|
10
10
|
import 'ps-list';
|
|
@@ -15,7 +15,7 @@ import 'node:child_process';
|
|
|
15
15
|
import 'node:readline';
|
|
16
16
|
import 'tweetnacl';
|
|
17
17
|
import 'axios';
|
|
18
|
-
import './persistence-
|
|
18
|
+
import './persistence-C3NBdZdz.mjs';
|
|
19
19
|
import 'open';
|
|
20
20
|
import 'chalk';
|
|
21
21
|
import 'fs';
|
package/package.json
CHANGED
package/scripts/build.mjs
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { spawnSync } from 'node:child_process';
|
|
4
|
-
import { existsSync, readFileSync, rmSync } from 'node:fs';
|
|
5
|
-
import { dirname, resolve } from 'node:path';
|
|
6
|
-
import { fileURLToPath } from 'node:url';
|
|
7
|
-
|
|
8
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
const packageRoot = resolve(here, '..');
|
|
10
|
-
const workspaceRoot = resolve(packageRoot, '..', '..');
|
|
11
|
-
const packageJson = JSON.parse(readFileSync(resolve(packageRoot, 'package.json'), 'utf8'));
|
|
12
|
-
|
|
13
|
-
function resolveTool(binName, packageSpecs) {
|
|
14
|
-
const suffix = process.platform === 'win32' ? '.cmd' : '';
|
|
15
|
-
const packageLocalBin = resolve(packageRoot, 'node_modules', '.bin', `${binName}${suffix}`);
|
|
16
|
-
const workspaceLocalBin = resolve(workspaceRoot, 'node_modules', '.bin', `${binName}${suffix}`);
|
|
17
|
-
|
|
18
|
-
if (existsSync(packageLocalBin)) {
|
|
19
|
-
return {
|
|
20
|
-
command: packageLocalBin,
|
|
21
|
-
prefixArgs: [],
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (existsSync(workspaceLocalBin)) {
|
|
26
|
-
return {
|
|
27
|
-
command: workspaceLocalBin,
|
|
28
|
-
prefixArgs: [],
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
command: 'npx',
|
|
34
|
-
prefixArgs: ['-y', ...packageSpecs.flatMap((packageSpec) => ['-p', packageSpec]), binName],
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function runStep(name, command, args) {
|
|
39
|
-
console.log(`\n[build] ${name}`);
|
|
40
|
-
console.log(`> ${command} ${args.join(' ')}`);
|
|
41
|
-
|
|
42
|
-
const result = spawnSync(command, args, {
|
|
43
|
-
cwd: packageRoot,
|
|
44
|
-
stdio: 'inherit',
|
|
45
|
-
shell: process.platform === 'win32',
|
|
46
|
-
env: process.env,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
if (result.status !== 0) {
|
|
50
|
-
throw new Error(`[build] Step failed: ${name}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function runTool(name, tool, args) {
|
|
55
|
-
runStep(name, tool.command, [...tool.prefixArgs, ...args]);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const tsc = resolveTool('tsc', [`typescript@${packageJson.devDependencies.typescript}`]);
|
|
59
|
-
const pkgroll = resolveTool('pkgroll', [
|
|
60
|
-
`pkgroll@${packageJson.devDependencies.pkgroll}`,
|
|
61
|
-
`typescript@${packageJson.devDependencies.typescript}`,
|
|
62
|
-
]);
|
|
63
|
-
|
|
64
|
-
rmSync(resolve(packageRoot, 'dist'), { recursive: true, force: true });
|
|
65
|
-
runTool('typecheck', tsc, ['--noEmit']);
|
|
66
|
-
runTool('bundle', pkgroll, []);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import { existsSync, readFileSync, rmSync } from 'node:fs';
|
|
5
|
+
import { dirname, resolve } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const packageRoot = resolve(here, '..');
|
|
10
|
+
const workspaceRoot = resolve(packageRoot, '..', '..');
|
|
11
|
+
const packageJson = JSON.parse(readFileSync(resolve(packageRoot, 'package.json'), 'utf8'));
|
|
12
|
+
|
|
13
|
+
function resolveTool(binName, packageSpecs) {
|
|
14
|
+
const suffix = process.platform === 'win32' ? '.cmd' : '';
|
|
15
|
+
const packageLocalBin = resolve(packageRoot, 'node_modules', '.bin', `${binName}${suffix}`);
|
|
16
|
+
const workspaceLocalBin = resolve(workspaceRoot, 'node_modules', '.bin', `${binName}${suffix}`);
|
|
17
|
+
|
|
18
|
+
if (existsSync(packageLocalBin)) {
|
|
19
|
+
return {
|
|
20
|
+
command: packageLocalBin,
|
|
21
|
+
prefixArgs: [],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (existsSync(workspaceLocalBin)) {
|
|
26
|
+
return {
|
|
27
|
+
command: workspaceLocalBin,
|
|
28
|
+
prefixArgs: [],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
command: 'npx',
|
|
34
|
+
prefixArgs: ['-y', ...packageSpecs.flatMap((packageSpec) => ['-p', packageSpec]), binName],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function runStep(name, command, args) {
|
|
39
|
+
console.log(`\n[build] ${name}`);
|
|
40
|
+
console.log(`> ${command} ${args.join(' ')}`);
|
|
41
|
+
|
|
42
|
+
const result = spawnSync(command, args, {
|
|
43
|
+
cwd: packageRoot,
|
|
44
|
+
stdio: 'inherit',
|
|
45
|
+
shell: process.platform === 'win32',
|
|
46
|
+
env: process.env,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (result.status !== 0) {
|
|
50
|
+
throw new Error(`[build] Step failed: ${name}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function runTool(name, tool, args) {
|
|
55
|
+
runStep(name, tool.command, [...tool.prefixArgs, ...args]);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const tsc = resolveTool('tsc', [`typescript@${packageJson.devDependencies.typescript}`]);
|
|
59
|
+
const pkgroll = resolveTool('pkgroll', [
|
|
60
|
+
`pkgroll@${packageJson.devDependencies.pkgroll}`,
|
|
61
|
+
`typescript@${packageJson.devDependencies.typescript}`,
|
|
62
|
+
]);
|
|
63
|
+
|
|
64
|
+
rmSync(resolve(packageRoot, 'dist'), { recursive: true, force: true });
|
|
65
|
+
runTool('typecheck', tsc, ['--noEmit']);
|
|
66
|
+
runTool('bundle', pkgroll, []);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# CLI Devtools
|
|
2
|
-
|
|
3
|
-
这组脚本用于 CLI 本地开发辅助。
|
|
4
|
-
|
|
5
|
-
当前包含:
|
|
6
|
-
|
|
7
|
-
- mock credentials 生成器
|
|
8
|
-
|
|
9
|
-
新增 CLI 专属开发脚本应优先放在这里。
|
|
1
|
+
# CLI Devtools
|
|
2
|
+
|
|
3
|
+
这组脚本用于 CLI 本地开发辅助。
|
|
4
|
+
|
|
5
|
+
当前包含:
|
|
6
|
+
|
|
7
|
+
- mock credentials 生成器
|
|
8
|
+
|
|
9
|
+
新增 CLI 专属开发脚本应优先放在这里。
|