@yixinkj/ops 0.1.2 → 0.1.4

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 (3) hide show
  1. package/README.md +8 -2
  2. package/index.js +40 -52
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -6,6 +6,12 @@
6
6
  npx -y @yixinkj/ops@latest --help
7
7
  ```
8
8
 
9
- 当前为开发骨架,尚未发布 npm,业务注册表为空;本地可运行 `node index.js --help`。
9
+ 当前提供榜单监控(`toprank-radar`),支持 macOS Apple Silicon、macOS Intel 和 Windows x64。启动器需要 Node.js 18 或更新版本,首次使用会下载并校验对应平台的原生运行包,无需安装 Rust。
10
10
 
11
- OSS 使用 releases/yixin-ops/,备用发布仓库为 TimWuc/yixin-ops-releases,缓存使用 ~/.yixin-ops。授权公共层仍沿用现有授权服务及 ~/.yixin 配置。
11
+ ```sh
12
+ npx -y @yixinkj/ops@latest --toprank-radar --serve
13
+ ```
14
+
15
+ 未配置 API Key 时可以进入控制台,按首次授权提示粘贴直通车专用 Key,验证成功后保存。凭证仅使用 `YIXIN_OPS_API_KEY` 或 `~/.yixin-ops/auth/config.json`;环境变量不会自动持久化,不读取旧社群客户端的 Key 或配置。每次受保护操作均重新在线申请授权。
16
+
17
+ OSS 使用 `releases/yixin-ops/`,备用发布仓库为 `TimWuc/yixin-ops-releases`,版本缓存位于 `~/.yixin-ops/versions/`。历史采集数据与版本目录分开保存,升级时保留原数据及自定义数据路径。更新后请正常关闭并重新启动控制台;不要删除整个 `~/.yixin-ops` 目录。
package/index.js CHANGED
@@ -36,6 +36,10 @@ const RUNTIME_STATUS_POLL_MS = 500;
36
36
  const TERMINAL_RUN_STATUSES = new Set([
37
37
  'completed',
38
38
  'completed_partial',
39
+ 'waiting_verification',
40
+ 'interrupted',
41
+ 'resume_available',
42
+ 'already_running',
39
43
  'failed',
40
44
  'cancelled',
41
45
  'stalled'
@@ -593,47 +597,10 @@ function unblockWindowsBinaries(target, binDir = BIN_DIR) {
593
597
  }
594
598
  }
595
599
 
596
- function warmupBrowserBridge(target) {
597
- const bridge = browserBridgePath(target);
598
- if (!fs.existsSync(bridge)) {
599
- return;
600
- }
601
- console.error('[yixin-ops] 正在预热浏览器桥接,首次运行可能需要几秒钟...');
602
- const result = spawnSync(bridge, ['tabs'], {
603
- encoding: 'utf8',
604
- stdio: 'ignore',
605
- timeout: 15000,
606
- windowsHide: true
607
- });
608
- if (result.error || result.status !== 0) {
609
- const detail = result.error?.message || `退出码 ${result.status}`;
610
- console.error(
611
- `[yixin-ops] 浏览器桥接预热未完成,将继续启动 skill。若页面打开后长时间无响应,请重新运行当前命令。(${detail})`
612
- );
613
- }
614
- }
615
-
616
- function commandNeedsBrowserWarmup(argv) {
617
- const offlineFlags = new Set([
618
- '--create-report-patch-template',
619
- '--apply-report-patch',
620
- '--render-report',
621
- '--help',
622
- '-h',
623
- '--version',
624
- '-V',
625
- '--dry-run',
626
- '--smoke-auth',
627
- '--serve',
628
- '--start',
629
- '--init-db',
630
- '--list-tasks',
631
- '--list-targets',
632
- '--cycle-status',
633
- '--analysis-scopes',
634
- '--analyze'
635
- ]);
636
- return !argv.some((arg) => offlineFlags.has(arg));
600
+ // Runtime installation must not contact the business browser. The binary
601
+ // performs browser readiness checks only after operation authorization.
602
+ function commandNeedsBrowserWarmup(_argv) {
603
+ return false;
637
604
  }
638
605
 
639
606
  function verifyExtractedBinaries(binDir, target) {
@@ -703,7 +670,7 @@ function commitStagedInstall(stagingRoot) {
703
670
  }
704
671
  }
705
672
 
706
- function installFromArchive(archivePath, target, shouldWarmup = true) {
673
+ function installFromArchive(archivePath, target) {
707
674
  fs.mkdirSync(VERSIONS_ROOT, { recursive: true });
708
675
  const stagingPrefix = `.staging-v${VERSION}-${target.id}-`;
709
676
  for (const entry of fs.readdirSync(VERSIONS_ROOT)) {
@@ -731,10 +698,9 @@ function installFromArchive(archivePath, target, shouldWarmup = true) {
731
698
  } finally {
732
699
  fs.rmSync(stagingRoot, { recursive: true, force: true });
733
700
  }
734
- if (shouldWarmup) warmupBrowserBridge(target);
735
701
  }
736
702
 
737
- async function ensureInstalled(target, signal, skill, shouldWarmup = true) {
703
+ async function ensureInstalled(target, signal, skill) {
738
704
  const localDir = localRuntimeDir();
739
705
  if (localDir) {
740
706
  const localTarget = {
@@ -746,7 +712,6 @@ async function ensureInstalled(target, signal, skill, shouldWarmup = true) {
746
712
  };
747
713
  verifyExtractedBinaries(localDir, localTarget);
748
714
  prepareInstalledBinaries(localTarget, localDir);
749
- if (shouldWarmup) warmupBrowserBridge(localTarget);
750
715
  return;
751
716
  }
752
717
  if (isInstalled(target)) {
@@ -769,7 +734,7 @@ async function ensureInstalled(target, signal, skill, shouldWarmup = true) {
769
734
  try {
770
735
  console.error(`[yixin-ops] 正在安装 ${target.id} 二进制,版本 ${VERSION}`);
771
736
  await downloadFromSources(urls, archivePath, signal);
772
- installFromArchive(archivePath, target, shouldWarmup);
737
+ installFromArchive(archivePath, target);
773
738
  } catch (error) {
774
739
  throw withInstallHelp(error);
775
740
  } finally {
@@ -1058,6 +1023,32 @@ function parseChildJson(stdout) {
1058
1023
  }
1059
1024
  }
1060
1025
 
1026
+ function childCompletionState(result, current = {}) {
1027
+ const verification = result?.status === 'verification_required' ||
1028
+ result?.reason === 'verification_required' || result?.error_message === 'verification_required' ||
1029
+ result?.errors?.includes('verification_required') || current.stage === 'waiting_verification';
1030
+ if (verification) {
1031
+ return {status:'waiting_verification',stage:'waiting_verification',retryable:false,
1032
+ requires_user_action:true,next_step:result?.next_step || 'resume_last',
1033
+ cycle_id:result?.cycle_id ?? null,
1034
+ message:result?.message || '检测到 Alibaba 网站验证码,采集已暂停。请在浏览器手动完成验证后继续上次采集;若原验证页已关闭,请重新打开对应页面验证。'};
1035
+ }
1036
+ const state = result?.status;
1037
+ if (state === 'browser_attach_failed' && Number(result?.remaining || 0) > 0) {
1038
+ return {status:'interrupted',stage:'interrupted',retryable:false,next_step:'repeat_review_backfill',message:'评论补采已停止,已保存进度;请恢复浏览器连接后继续原补采。'};
1039
+ }
1040
+ if (state === 'interrupted' || state === 'resume_available') {
1041
+ return {status:state,stage:state,retryable:false,next_step:'resume_last',
1042
+ message:'采集尚未完成,已保存进度。请继续上次采集。'};
1043
+ }
1044
+ if (state === 'already_running') {
1045
+ return {status:state,stage:state,retryable:false,message:'已有采集正在运行,本次未启动新任务。'};
1046
+ }
1047
+ if (state === 'failed') return {status:'failed',stage:'skill_failed',retryable:false,message:'采集失败,请查看具体结果。'};
1048
+ if (state === 'partial') return {status:'completed_partial',stage:'completed_partial',retryable:false,message:'采集部分完成,请查看未完成项。'};
1049
+ return {status:'completed',stage:'completed',retryable:false,message:'Skill 已完成'};
1050
+ }
1051
+
1061
1052
  function runSkill(skill, target, argv, runState, cancellation) {
1062
1053
  return new Promise((resolve, reject) => {
1063
1054
  const child = spawn(skillBinaryPath(skill, target), argv, {
@@ -1119,8 +1110,7 @@ async function main() {
1119
1110
  await ensureInstalled(
1120
1111
  target,
1121
1112
  cancellation.signal,
1122
- skill,
1123
- commandNeedsBrowserWarmup(argv)
1113
+ skill
1124
1114
  );
1125
1115
  if (cancellation.signal.aborted) throw cancellation.signal.reason;
1126
1116
 
@@ -1131,11 +1121,8 @@ async function main() {
1131
1121
  const childResult = parseChildJson(result.stdout);
1132
1122
  const artifacts = childResult?.capture_paths || runState.current().artifacts;
1133
1123
  runState.finish({
1134
- status: 'completed',
1135
- stage: 'completed',
1136
- retryable: false,
1124
+ ...childCompletionState(childResult, runState.current()),
1137
1125
  exit_code: 0,
1138
- message: 'Skill 已完成',
1139
1126
  ...(artifacts ? { artifacts } : {}),
1140
1127
  ...(childResult ? { result: childResult } : {})
1141
1128
  });
@@ -1194,6 +1181,7 @@ if (isDirectExecution()) {
1194
1181
 
1195
1182
  export {
1196
1183
  acquireInstallLock,
1184
+ childCompletionState,
1197
1185
  commandNeedsBrowserWarmup,
1198
1186
  createRunState,
1199
1187
  detectTarget,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yixinkj/ops",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Yixin operations native CLI launcher.",
5
5
  "type": "module",
6
6
  "bin": {