dsh-github-console 0.2.5 → 0.5.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/client.js CHANGED
@@ -240,6 +240,15 @@ window.__ModuleLoader__.load({
240
240
  const [commitMessage, setCommitMessage] = useState('')
241
241
 
242
242
  const [inbox, setInbox] = useState({ issues: null, pulls: null, runs: null, errors: [] })
243
+ const [pullDetail, setPullDetail] = useState(null)
244
+ const [commentDraft, setCommentDraft] = useState('')
245
+ const [reviewNote, setReviewNote] = useState('')
246
+ const [inlineTarget, setInlineTarget] = useState('')
247
+ const [runLog, setRunLog] = useState(null)
248
+ const [searchQuery, setSearchQuery] = useState('')
249
+ const [searchResults, setSearchResults] = useState(null)
250
+ const [commits, setCommits] = useState(null)
251
+ const [notifications, setNotifications] = useState(null)
243
252
 
244
253
  const [publishDir, setPublishDir] = useState('')
245
254
  const [report, setReport] = useState(null)
@@ -250,10 +259,16 @@ window.__ModuleLoader__.load({
250
259
  const [probe, setProbe] = useState(null)
251
260
  const [npmRun, setNpmRun] = useState(null)
252
261
  const [npmState, setNpmState] = useState(null)
262
+ const [releaseAsset, setReleaseAsset] = useState(null)
263
+ const [readiness, setReadiness] = useState(null)
253
264
  const [marketIndex, setMarketIndex] = useState(null)
254
265
  const [marketAttach, setMarketAttach] = useState(null)
255
266
  const [reposLoaded, setReposLoaded] = useState(false)
256
267
  const [reposTotal, setReposTotal] = useState(0)
268
+ const [patInput, setPatInput] = useState('')
269
+ const [authBusy, setAuthBusy] = useState('')
270
+ const [authMessage, setAuthMessage] = useState('')
271
+ const [device, setDevice] = useState(null)
257
272
  const [setupUrl, setSetupUrl] = useState('')
258
273
  const [discovered, setDiscovered] = useState(null)
259
274
  const [discoverError, setDiscoverError] = useState('')
@@ -457,8 +472,109 @@ window.__ModuleLoader__.load({
457
472
  })
458
473
  }
459
474
 
460
- const runPreflight = async (dirOverride) => {
461
- const dir = dirOverride || publishDir
475
+ const repoRef = () => {
476
+ const [owner, name] = String(selectedRepo || targetRepoFull()).split('/')
477
+ if (!owner || !name) {
478
+ setError('先选一个仓库(仓库页或发布页填写 owner/repo)')
479
+ return null
480
+ }
481
+ return { owner, name }
482
+ }
483
+
484
+ const openPull = (number) => {
485
+ const ref = repoRef()
486
+ if (!ref) return
487
+ void run('pull', async () => {
488
+ const detail = await api('pull/detail', { ...ref, number })
489
+ setPullDetail(detail)
490
+ setCommentDraft('')
491
+ setReviewNote('')
492
+ })
493
+ }
494
+
495
+ const sendPullComment = (inline) => {
496
+ const ref = repoRef()
497
+ if (!ref || !pullDetail) return
498
+ const body = inline ? inlineTarget.trim() : commentDraft.trim()
499
+ if (!body) {
500
+ setError('评论内容不能为空')
501
+ return
502
+ }
503
+ void run('comment', async () => {
504
+ const payload = { ...ref, number: pullDetail.number, body }
505
+ if (inline) {
506
+ const [path, line] = inline.split('#')
507
+ payload.path = path
508
+ payload.line = Number(line)
509
+ }
510
+ await api('pull/comment', payload)
511
+ if (inline) setInlineTarget('')
512
+ else setCommentDraft('')
513
+ const detail = await api('pull/detail', { ...ref, number: pullDetail.number })
514
+ setPullDetail(detail)
515
+ })
516
+ }
517
+
518
+ const sendReview = (event) => {
519
+ const ref = repoRef()
520
+ if (!ref || !pullDetail) return
521
+ void run('review', async () => {
522
+ await api('pull/review', { ...ref, number: pullDetail.number, event, body: reviewNote.trim() })
523
+ setReviewNote('')
524
+ const detail = await api('pull/detail', { ...ref, number: pullDetail.number })
525
+ setPullDetail(detail)
526
+ })
527
+ }
528
+
529
+ const runCodeSearch = () => {
530
+ if (!searchQuery.trim()) {
531
+ setError('先输入搜索词')
532
+ return
533
+ }
534
+ const ref = repoRef()
535
+ void run('search', async () => {
536
+ setSearchResults(await api('search/code', { q: searchQuery.trim(), ...(ref || {}) }))
537
+ })
538
+ }
539
+
540
+ const loadCommits = () => {
541
+ const ref = repoRef()
542
+ if (!ref) return
543
+ void run('commits', async () => {
544
+ setCommits(await api('commits', { ...ref, limit: 20 }))
545
+ })
546
+ }
547
+
548
+ const loadNotifications = () => {
549
+ void run('notice', async () => {
550
+ setNotifications(await api('notifications', { limit: 30 }))
551
+ })
552
+ }
553
+
554
+ const readAllNotifications = () => {
555
+ void run('notice-read', async () => {
556
+ await api('notifications/read', { all: true })
557
+ setNotifications(await api('notifications', { limit: 30 }))
558
+ })
559
+ }
560
+
561
+ const toggleIssue = (item) => { const ref = repoRef()
562
+ if (!ref) return
563
+ void run('issue', async () => {
564
+ await api('issue/update', { ...ref, number: item.number, state: item.state === 'open' ? 'closed' : 'open' })
565
+ loadInbox()
566
+ })
567
+ }
568
+
569
+ const showLog = (runId) => {
570
+ const ref = repoRef()
571
+ if (!ref) return
572
+ void run('log', async () => {
573
+ setRunLog(await api('actions/log', { ...ref, runId, tailLines: 80 }))
574
+ })
575
+ }
576
+
577
+ const runPreflight = async (dirOverride) => { const dir = dirOverride || publishDir
462
578
  if (!String(dir).trim()) {
463
579
  setError('先选一个插件目录:可以在上方「本地发现」里点体检,或在这里填绝对路径')
464
580
  return undefined
@@ -570,6 +686,33 @@ window.__ModuleLoader__.load({
570
686
  })
571
687
  }
572
688
 
689
+ const checkReadiness = () => {
690
+ const owner = targetOwner
691
+ const repo = String(repoTarget).trim()
692
+ if (!owner || !repo) {
693
+ setError('先完成第 2 步并填好仓库名')
694
+ return
695
+ }
696
+ void run('readiness', async () => {
697
+ const result = await api('market/readiness', { dir: publishDir, owner, repo })
698
+ setReadiness(result)
699
+ return result
700
+ })
701
+ }
702
+
703
+ const makeReleaseAsset = () => { const owner = targetOwner
704
+ const repo = String(repoTarget).trim()
705
+ if (!owner || !repo) {
706
+ setError('先完成第 2 步并填好仓库名')
707
+ return
708
+ }
709
+ void run('asset', async () => {
710
+ const result = await api('release/asset', { dir: publishDir, owner, repo })
711
+ setReleaseAsset(result)
712
+ return result
713
+ })
714
+ }
715
+
573
716
  const makeMarketIndex = () => { const owner = targetOwner
574
717
  const repo = String(repoTarget).trim()
575
718
  if (!owner || !repo) {
@@ -616,8 +759,90 @@ window.__ModuleLoader__.load({
616
759
  return data
617
760
  })
618
761
 
619
- const installUrl = status && status.app && status.app.slug
620
- ? `https://github.com/apps/${status.app.slug}/installations/new`
762
+ const useConnection = async (kind) => {
763
+ setAuthBusy(kind)
764
+ setAuthMessage('')
765
+ try {
766
+ await api('auth/use', { kind })
767
+ await refreshStatus()
768
+ setAuthMessage(`已切换到 ${kind}`)
769
+ } catch (failure) {
770
+ setAuthMessage(failure instanceof Error ? failure.message : String(failure))
771
+ } finally {
772
+ setAuthBusy('')
773
+ }
774
+ }
775
+
776
+ const savePat = async () => {
777
+ if (!patInput.trim()) {
778
+ setAuthMessage('先粘贴一个令牌')
779
+ return
780
+ }
781
+ setAuthBusy('pat')
782
+ setAuthMessage('')
783
+ try {
784
+ const result = await api('auth/pat', { token: patInput.trim() })
785
+ setPatInput('')
786
+ setAuthMessage(`已保存令牌(${result.login || '未知账号'} · ${result.fingerprint}),并设为当前连接`)
787
+ await refreshStatus()
788
+ } catch (failure) {
789
+ setAuthMessage(failure instanceof Error ? failure.message : String(failure))
790
+ } finally {
791
+ setAuthBusy('')
792
+ }
793
+ }
794
+
795
+ const clearPat = async () => {
796
+ setAuthBusy('pat-clear')
797
+ setAuthMessage('')
798
+ try {
799
+ await api('auth/pat/clear', {})
800
+ setAuthMessage('已删除本机保存的令牌')
801
+ await refreshStatus()
802
+ } catch (failure) {
803
+ setAuthMessage(failure instanceof Error ? failure.message : String(failure))
804
+ } finally {
805
+ setAuthBusy('')
806
+ }
807
+ }
808
+
809
+ // Device flow needs no callback URL, so it is independent of the web port.
810
+ const startDevice = async () => {
811
+ setAuthBusy('device')
812
+ setAuthMessage('')
813
+ try {
814
+ const started = await api('auth/device/start', {})
815
+ setDevice(started)
816
+ setAuthMessage(`在 ${started.verificationUri} 输入 ${started.userCode}(${Math.round(started.expiresIn / 60)} 分钟内有效)`)
817
+ const poll = async () => {
818
+ try {
819
+ const result = await api('auth/device/poll', { deviceCode: started.deviceCode })
820
+ if (result.status === 'ok') {
821
+ setDevice(null)
822
+ setAuthMessage('授权完成,已切换为「App 用户授权」:通知与代码搜索现在可用')
823
+ await refreshStatus()
824
+ return
825
+ }
826
+ if (result.status === 'expired' || result.status === 'denied') {
827
+ setDevice(null)
828
+ setAuthMessage(result.status === 'expired' ? '设备码已过期,请重新发起' : '授权被拒绝')
829
+ return
830
+ }
831
+ setTimeout(() => { void poll() }, result.slowDown ? 8000 : 5000)
832
+ } catch (failure) {
833
+ setDevice(null)
834
+ setAuthMessage(failure instanceof Error ? failure.message : String(failure))
835
+ }
836
+ }
837
+ setTimeout(() => { void poll() }, 5000)
838
+ } catch (failure) {
839
+ setAuthMessage(failure instanceof Error ? failure.message : String(failure))
840
+ } finally {
841
+ setAuthBusy('')
842
+ }
843
+ }
844
+
845
+ const installUrl = status && status.app && status.app.slug ? `https://github.com/apps/${status.app.slug}/installations/new`
621
846
  : 'https://github.com/settings/installations'
622
847
 
623
848
  // The saved installation may be gone (uninstalled on GitHub): compare it
@@ -629,6 +854,9 @@ window.__ModuleLoader__.load({
629
854
  status && status.installation && liveIds.length > 0 && !liveIds.includes(String(status.installation.id)),
630
855
  )
631
856
 
857
+ const authKind = status && status.auth ? status.auth.kind : 'none'
858
+ const authAccount = status && status.auth ? status.auth.account : ''
859
+
632
860
  const badge = status && status.configured
633
861
  ? status.installation ? `已连接 ${status.installation.account}` : 'App 已注册,尚未安装'
634
862
  : '未配置'
@@ -728,6 +956,131 @@ window.__ModuleLoader__.load({
728
956
  ? h('div', { style: S.warn }, status.network.hint)
729
957
  : null,
730
958
  ),
959
+ h('div', { style: S.card },
960
+ h('div', { style: { ...S.line, justifyContent: 'space-between' } },
961
+ h('strong', { style: { fontSize: 13 } }, '连接方式'),
962
+ h('span', { style: S.badge(authKind === 'app' || authKind === 'pat' || authKind === 'env') },
963
+ { app: 'GitHub App', pat: '个人访问令牌', env: '环境变量', none: '未连接' }[authKind] || authKind),
964
+ ),
965
+ h('p', { style: S.notice }, `当前账号:${authAccount || '—'}${status && status.auth && status.auth.readOnly ? ' · 只读模式' : ''}`),
966
+ h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap', margin: '6px 0' } },
967
+ [['app', 'GitHub App'], ['oauth', 'App 用户授权'], ['pat', '个人访问令牌'], ['env', `环境变量(${status && status.connections ? status.connections.env.name : 'GITHUB_TOKEN'})`]].map(([kind, label]) =>
968
+ h('button', {
969
+ key: kind,
970
+ style: authKind === kind ? { ...S.primary, padding: '4px 12px', fontSize: 12 } : { ...S.button, padding: '4px 12px', fontSize: 12 },
971
+ disabled: authBusy === kind,
972
+ onClick: () => useConnection(kind),
973
+ }, label),
974
+ ),
975
+ ),
976
+ h('div', { style: { display: 'flex', gap: 6, marginTop: 4, flexWrap: 'wrap' } },
977
+ h('input', {
978
+ style: { ...S.input, flex: 1, minWidth: 200 },
979
+ type: 'password',
980
+ value: patInput,
981
+ placeholder: status && status.connections && status.connections.pat.configured ? `已保存 ${status.connections.pat.fingerprint}(粘贴新值可替换)` : '粘贴个人访问令牌(ghp_… / github_pat_…)',
982
+ onChange: (event) => setPatInput(event.target.value),
983
+ }),
984
+ h('button', { style: S.button, disabled: authBusy === 'pat', onClick: savePat }, authBusy === 'pat' ? '验证中…' : '保存令牌'),
985
+ status && status.connections && status.connections.pat.configured
986
+ ? h('button', { style: S.danger, disabled: authBusy === 'pat-clear', onClick: clearPat }, '删除令牌')
987
+ : null,
988
+ ),
989
+ h('p', { style: S.notice }, '令牌只写入 DSH 凭据服务,面板只显示末四位;环境变量方式不落盘。通知中心与代码搜索只有用户令牌能做,App 安装令牌做不到。'),
990
+ h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginTop: 4 } },
991
+ h('button', {
992
+ style: S.primary,
993
+ disabled: authBusy === 'device' || Boolean(device),
994
+ onClick: startDevice,
995
+ }, authBusy === 'device' ? '申请中…' : device ? `等待授权:${device.userCode}` : '设备码授权(推荐,无需回调地址)'),
996
+ h('button', {
997
+ style: S.button,
998
+ disabled: authBusy === 'oauth',
999
+ onClick: async () => {
1000
+ setAuthBusy('oauth')
1001
+ setAuthMessage('')
1002
+ try {
1003
+ const result = await api('auth/oauth/start', {})
1004
+ window.open(result.url, '_blank', 'noreferrer')
1005
+ setAuthMessage(
1006
+ result.callbackRegistered
1007
+ ? '已打开 GitHub 授权页:同意后回来点「刷新状态」,再选「App 用户授权」。'
1008
+ : `先在 App 设置里加这个回调地址再授权:${result.callbackUrl}`,
1009
+ )
1010
+ } catch (failure) {
1011
+ setAuthMessage(failure instanceof Error ? failure.message : String(failure))
1012
+ } finally {
1013
+ setAuthBusy('')
1014
+ }
1015
+ },
1016
+ }, authBusy === 'oauth' ? '打开中…' : '授权 App 用户身份(拿通知与代码搜索)'),
1017
+ status && status.connections && status.connections.oauth && status.connections.oauth.configured
1018
+ ? h('button', {
1019
+ style: S.danger,
1020
+ onClick: async () => {
1021
+ await api('auth/oauth/clear', {})
1022
+ setAuthMessage('已删除用户授权')
1023
+ await refreshStatus()
1024
+ },
1025
+ }, '撤销用户授权')
1026
+ : null,
1027
+ ),
1028
+ authMessage ? h('p', { style: /失败|没有|拒绝|过期|不能|需要/.test(authMessage) ? S.warn : S.notice }, authMessage) : null,
1029
+ status && status.app && status.app.slug
1030
+ ? h('p', { style: S.notice },
1031
+ 'App 设置页(Device Flow / 回调地址都在这里):',
1032
+ h('a', {
1033
+ href: `https://github.com/settings/apps/${status.app.slug}`,
1034
+ target: '_blank',
1035
+ rel: 'noreferrer',
1036
+ style: { color: 'var(--dsw-alias-brand-primary)', overflowWrap: 'anywhere' },
1037
+ }, `github.com/settings/apps/${status.app.slug}`),
1038
+ )
1039
+ : null,
1040
+ device
1041
+ ? h('p', { style: S.notice },
1042
+ '在浏览器打开 ',
1043
+ h('a', { href: device.verificationUri, target: '_blank', rel: 'noreferrer', style: { color: 'var(--dsw-alias-brand-primary)' } }, device.verificationUri),
1044
+ ',输入 ',
1045
+ h(CopyValue, { value: device.userCode }),
1046
+ ' 并确认。插件会自动轮询结果。',
1047
+ )
1048
+ : null,
1049
+ h('p', { style: S.notice },
1050
+ '按钮没反应?直接打开这个页面授权(不依赖面板):',
1051
+ h('br'),
1052
+ h('a', {
1053
+ href: '/github-console/device',
1054
+ target: '_blank',
1055
+ rel: 'noreferrer',
1056
+ style: { color: 'var(--dsw-alias-brand-primary)', overflowWrap: 'anywhere' },
1057
+ }, `${typeof window !== 'undefined' ? window.location.origin : ''}/github-console/device`),
1058
+ ),
1059
+ status && status.auth && status.auth.capabilities
1060
+ ? h('div', { style: { marginTop: 6 } },
1061
+ h('div', { style: S.meta }, '当前连接的能力'),
1062
+ h('div', { style: { display: 'flex', gap: 10, flexWrap: 'wrap', marginTop: 4, fontSize: 12 } },
1063
+ [
1064
+ ['repoRead', '代码读'],
1065
+ ['repoWrite', '代码写'],
1066
+ ['pullWrite', 'PR 写'],
1067
+ ['issueWrite', 'Issue 写'],
1068
+ ['actionsWrite', 'Actions'],
1069
+ ['workflowsWrite', 'Workflow'],
1070
+ ['adminWrite', '管理'],
1071
+ ['notifications', '通知'],
1072
+ ['codeSearch', '代码搜索'],
1073
+ ].map(([key, label]) =>
1074
+ h('span', { key, style: { color: status.auth.capabilities[key] ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-label-secondary)' } },
1075
+ `${status.auth.capabilities[key] ? '✓' : '✕'} ${label}`),
1076
+ ),
1077
+ ),
1078
+ )
1079
+ : null,
1080
+ status && status.auth && status.auth.readOnly
1081
+ ? h('p', { style: S.warn }, `只读:${status.auth.readOnlyReason || '当前连接没有写权限'}`)
1082
+ : null,
1083
+ ),
731
1084
  // Next-step card: exactly one primary action per state, so a user who
732
1085
  // just registered is never told to register again.
733
1086
  h('div', { style: S.card },
@@ -806,6 +1159,34 @@ window.__ModuleLoader__.load({
806
1159
  h('input', { style: S.input, value: repoQuery, placeholder: '按 owner/name 过滤', onChange: (event) => setRepoQuery(event.target.value), onKeyDown: (event) => { if (event.key === 'Enter') void loadRepos() } }),
807
1160
  h('button', { style: S.button, disabled: busy === 'repos', onClick: loadRepos }, busy === 'repos' ? '查询中…' : '查询'),
808
1161
  ),
1162
+ h('div', { style: { display: 'flex', gap: 6, marginBottom: 8, flexWrap: 'wrap' } },
1163
+ h('input', { style: { ...S.input, flex: 1, minWidth: 180 }, value: searchQuery, placeholder: '代码搜索(需要用户连接;按当前仓库限定)', onChange: (event) => setSearchQuery(event.target.value), onKeyDown: (event) => { if (event.key === 'Enter') runCodeSearch() } }),
1164
+ h('button', { style: S.button, disabled: busy === 'search', onClick: runCodeSearch }, busy === 'search' ? '搜索中…' : '搜索'),
1165
+ h('button', { style: S.button, disabled: busy === 'commits', onClick: loadCommits }, busy === 'commits' ? '读取中…' : '提交历史'),
1166
+ ),
1167
+ searchResults
1168
+ ? h('div', { style: S.card },
1169
+ h('strong', { style: { fontSize: 13 } }, `代码搜索:${searchResults.total} 条`),
1170
+ searchResults.items.map((item) =>
1171
+ h('div', { key: item.sha + item.path, style: S.row },
1172
+ h('span', { style: S.name }, item.path),
1173
+ h('span', { style: S.meta }, item.repo),
1174
+ ),
1175
+ ),
1176
+ )
1177
+ : null,
1178
+ commits
1179
+ ? h('div', { style: S.card },
1180
+ h('strong', { style: { fontSize: 13 } }, `提交历史(${commits.items.length})`),
1181
+ commits.items.map((item) =>
1182
+ h('div', { key: item.sha, style: S.row },
1183
+ h('span', { style: { ...S.meta, width: 64 } }, item.short),
1184
+ h('span', { style: S.name }, item.message),
1185
+ h('span', { style: S.meta }, `${item.author} · ${(item.date || '').slice(0, 10)}`),
1186
+ ),
1187
+ ),
1188
+ )
1189
+ : null,
809
1190
  !reposLoaded
810
1191
  ? h('p', { style: S.notice }, '点「查询」列出 App 安装范围内的仓库。')
811
1192
  : repos.length === 0
@@ -881,6 +1262,27 @@ window.__ModuleLoader__.load({
881
1262
  inbox.errors && inbox.errors.length
882
1263
  ? inbox.errors.map((item, index) => h('div', { key: index, style: S.warn }, item))
883
1264
  : null,
1265
+ h('div', { style: S.card },
1266
+ h('div', { style: { ...S.line, justifyContent: 'space-between' } },
1267
+ h('strong', { style: { fontSize: 13 } }, '通知'),
1268
+ h('div', { style: { display: 'flex', gap: 6 } },
1269
+ h('button', { style: { ...S.button, padding: '1px 8px', fontSize: 11 }, disabled: busy === 'notice', onClick: loadNotifications }, '拉取'),
1270
+ h('button', { style: { ...S.button, padding: '1px 8px', fontSize: 11 }, disabled: busy === 'notice-read', onClick: readAllNotifications }, '全部已读'),
1271
+ ),
1272
+ ),
1273
+ h('p', { style: S.notice }, '通知只有「个人访问令牌 / 环境变量」连接能读;GitHub 不对 App 令牌开放这个接口。'),
1274
+ notifications
1275
+ ? notifications.items.length
1276
+ ? notifications.items.map((item) =>
1277
+ h('div', { key: item.id, style: S.row },
1278
+ h('span', { style: { ...S.meta, width: 64 } }, item.reason),
1279
+ h('span', { style: S.name }, item.title || item.type),
1280
+ h('span', { style: S.meta }, item.repo),
1281
+ ),
1282
+ )
1283
+ : h('p', { style: S.notice }, `没有未读通知(${notifications.count} 条)`)
1284
+ : null,
1285
+ ),
884
1286
  inbox.issues
885
1287
  ? h('div', { style: S.card },
886
1288
  h('strong', { style: { fontSize: 13 } }, `Issues (${inbox.issues.returned})`),
@@ -889,6 +1291,7 @@ window.__ModuleLoader__.load({
889
1291
  h('span', { style: { ...S.meta, width: 46 } }, `#${item.number}`),
890
1292
  h('span', { style: S.name }, item.title),
891
1293
  h('span', { style: S.meta }, item.isPullRequest ? 'PR' : item.user),
1294
+ h('button', { style: { ...S.button, padding: '1px 8px', fontSize: 11 }, disabled: busy === 'issue', onClick: () => toggleIssue(item) }, item.state === 'open' ? '关闭' : '重开'),
892
1295
  ),
893
1296
  ),
894
1297
  )
@@ -897,7 +1300,7 @@ window.__ModuleLoader__.load({
897
1300
  ? h('div', { style: S.card },
898
1301
  h('strong', { style: { fontSize: 13 } }, `Pull requests (${inbox.pulls.returned})`),
899
1302
  inbox.pulls.items.map((item) =>
900
- h('div', { key: item.number, style: S.row },
1303
+ h('div', { key: item.number, style: { ...S.row, cursor: 'pointer' }, onClick: () => openPull(item.number) },
901
1304
  h('span', { style: { ...S.meta, width: 46 } }, `#${item.number}`),
902
1305
  h('span', { style: S.name }, item.title),
903
1306
  h('span', { style: S.meta }, `${item.head} → ${item.base}`),
@@ -913,8 +1316,64 @@ window.__ModuleLoader__.load({
913
1316
  h('span', { style: S.name }, item.name),
914
1317
  h('span', { style: S.meta }, `${item.status}${item.conclusion ? ` / ${item.conclusion}` : ''}`),
915
1318
  h('span', { style: S.meta }, item.branch || ''),
1319
+ h('button', { style: { ...S.button, padding: '1px 8px', fontSize: 11 }, disabled: busy === 'log', onClick: () => showLog(item.id) }, '日志'),
1320
+ ),
1321
+ ),
1322
+ )
1323
+ : null,
1324
+ runLog
1325
+ ? h('div', { style: S.card },
1326
+ h('div', { style: { ...S.line, justifyContent: 'space-between' } },
1327
+ h('strong', { style: { fontSize: 13 } }, `日志 · ${runLog.name || runLog.runId}`),
1328
+ h('button', { style: { ...S.button, padding: '1px 8px', fontSize: 11 }, onClick: () => setRunLog(null) }, '关闭'),
1329
+ ),
1330
+ h('pre', { style: S.pre }, runLog.tail),
1331
+ )
1332
+ : null,
1333
+ pullDetail
1334
+ ? h('div', { style: S.card },
1335
+ h('div', { style: { ...S.line, justifyContent: 'space-between' } },
1336
+ h('strong', { style: { fontSize: 13 } }, `#${pullDetail.number} ${pullDetail.title}`),
1337
+ h('span', { style: S.badge(pullDetail.mergeableState === 'clean' || pullDetail.mergeable) }, `${pullDetail.state} · ${pullDetail.mergeableState || '?'}`),
1338
+ ),
1339
+ h('div', { style: S.line }, h('span', { style: S.label }, '分支'), h('span', { style: S.value }, `${pullDetail.head} → ${pullDetail.base}`)),
1340
+ h('div', { style: S.line }, h('span', { style: S.label }, '变更'), h('span', { style: S.value }, `+${pullDetail.additions} / -${pullDetail.deletions} · ${pullDetail.changedFiles} 个文件`)),
1341
+ pullDetail.body ? h('pre', { style: S.pre }, pullDetail.body) : null,
1342
+ pullDetail.files.map((file) =>
1343
+ h('div', { key: file.path, style: { marginTop: 8 } },
1344
+ h('div', { style: { ...S.meta } }, `${file.path} · ${file.status} +${file.additions}/-${file.deletions} · 行内评论示例:`, h('code', null, `${file.path}#1`)),
1345
+ h('pre', { style: { ...S.pre, maxHeight: 220 } }, file.patch || '(二进制或过大,无 patch)'),
916
1346
  ),
917
1347
  ),
1348
+ h('div', { style: { display: 'flex', gap: 6, marginTop: 10, flexWrap: 'wrap' } },
1349
+ h('input', { style: { ...S.input, flex: 1, minWidth: 200 }, value: inlineTarget, placeholder: '行内评论:path#line,例如 src/index.js#42', onChange: (event) => setInlineTarget(event.target.value) }),
1350
+ h('button', { style: S.button, disabled: busy === 'comment', onClick: () => sendPullComment(true) }, '行内评论'),
1351
+ ),
1352
+ h('div', { style: { display: 'flex', gap: 6, marginTop: 8, flexWrap: 'wrap' } },
1353
+ h('input', { style: { ...S.input, flex: 1, minWidth: 200 }, value: commentDraft, placeholder: '会话评论', onChange: (event) => setCommentDraft(event.target.value) }),
1354
+ h('button', { style: S.button, disabled: busy === 'comment', onClick: () => sendPullComment(false) }, '发表评论'),
1355
+ ),
1356
+ h('div', { style: { display: 'flex', gap: 6, marginTop: 8, flexWrap: 'wrap' } },
1357
+ h('input', { style: { ...S.input, flex: 1, minWidth: 200 }, value: reviewNote, placeholder: 'review 说明(请求修改必填)', onChange: (event) => setReviewNote(event.target.value) }),
1358
+ h('button', { style: S.primary, disabled: busy === 'review', onClick: () => sendReview('APPROVE') }, '批准'),
1359
+ h('button', { style: S.button, disabled: busy === 'review', onClick: () => sendReview('REQUEST_CHANGES') }, '请求修改'),
1360
+ h('button', { style: S.button, disabled: busy === 'review', onClick: () => sendReview('COMMENT') }, '仅评论'),
1361
+ ),
1362
+ h('div', { style: { display: 'flex', gap: 6, marginTop: 8, flexWrap: 'wrap' } },
1363
+ h('button', {
1364
+ style: S.danger,
1365
+ disabled: busy === 'merge',
1366
+ onClick: () => {
1367
+ if (!window.confirm(`合并 #${pullDetail.number}(squash)?`)) return
1368
+ void run('merge', async () => {
1369
+ const ref = repoRef()
1370
+ await api('pull/merge', { ...ref, number: pullDetail.number, method: 'squash', confirm: true })
1371
+ await openPull(pullDetail.number)
1372
+ })
1373
+ },
1374
+ }, '合并(squash)'),
1375
+ h('button', { style: { ...S.button, padding: '1px 8px', fontSize: 11 }, onClick: () => setPullDetail(null) }, '收起'),
1376
+ ),
918
1377
  )
919
1378
  : null,
920
1379
  )
@@ -977,7 +1436,7 @@ window.__ModuleLoader__.load({
977
1436
  h('p', { style: S.notice }, `发布会在仓库上设置 ${status && status.publish ? status.publish.topic : 'dsh-plugin'} topic,供插件市场索引抓取。`),
978
1437
  h('div', { style: { borderTop: '1px solid var(--dsw-alias-border-l1)', marginTop: 12, paddingTop: 10 } },
979
1438
  h('div', { style: { ...S.line, justifyContent: 'space-between' } },
980
- h('strong', { style: { fontSize: 12 } }, 'npm 发布(在 GitHub Actions 里跑)'),
1439
+ h('strong', { style: { fontSize: 12 } }, '可选:发到 npm(需要 npm 通行密钥)'),
981
1440
  npmState ? h('span', { style: S.badge(npmState.phase === 'ready') }, NPM_PHASE[npmState.phase] || npmState.phase) : null,
982
1441
  ),
983
1442
  h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginTop: 8 } },
@@ -992,7 +1451,8 @@ window.__ModuleLoader__.load({
992
1451
  ),
993
1452
  npmState && npmState.phase === 'needs-first-publish'
994
1453
  ? h('div', null,
995
- h('p', { style: S.notice }, 'npm 不允许给「还不存在」的包配置免密钥发布,所以第一次要人工跨一次。按顺序做:'),
1454
+ h('p', { style: S.warn }, '如果 npm 要求通行密钥而你的手机/电脑连不上:跳过 npm,用上面的「分发(不需要 npm)」。npm 只是额外渠道,不是 DSH 插件的必需项。'),
1455
+ h('p', { style: S.notice }, '仍然想发 npm 的话,按顺序做:'),
996
1456
  h('ol', { style: { ...S.notice, paddingLeft: 20, margin: '4px 0', lineHeight: 1.8 } },
997
1457
  (npmState.steps || []).map((step, index) => h('li', { key: index }, step)),
998
1458
  ),
@@ -1044,6 +1504,40 @@ window.__ModuleLoader__.load({
1044
1504
  ),
1045
1505
  h(PreflightView, { report }),
1046
1506
  h(StepsView, { job }),
1507
+ h('div', { style: S.card },
1508
+ h('strong', { style: { fontSize: 13 } }, '分发(不需要 npm)'),
1509
+ h('p', { style: S.notice }, '把插件打包成 .tgz 挂到这次 Release 上,并给出钉住提交的 git 地址。Market 索引用的也是同一个 git 源,所以 Discover 安装同样不需要 npm。'),
1510
+ h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap' } },
1511
+ h('button', { style: S.primary, disabled: busy === 'asset' || !targetOwner, onClick: makeReleaseAsset }, busy === 'asset' ? '打包中…' : '打包并挂到 Release'),
1512
+ h('button', { style: S.button, disabled: busy === 'readiness' || !targetOwner, onClick: checkReadiness }, busy === 'readiness' ? '检查中…' : '检查能否上 dshmarket'),
1513
+ ),
1514
+ readiness
1515
+ ? h('div', { style: { marginTop: 8 } },
1516
+ h('div', { style: { ...S.line, justifyContent: 'space-between' } },
1517
+ h('strong', { style: { fontSize: 12 } }, readiness.ready ? '可以提交到 dshmarket 了' : '还有阻断项未满足'),
1518
+ h('span', { style: S.badge(readiness.ready) }, readiness.ready ? 'ready' : 'blocked'),
1519
+ ),
1520
+ readiness.checks.map((item) =>
1521
+ h('div', { key: item.id, style: S.line },
1522
+ h('span', { style: { ...S.meta, width: 14, flex: '0 0 auto', color: item.level === 'block' ? 'var(--dsw-alias-state-error-primary)' : item.level === 'warn' ? 'var(--dsw-alias-state-warn-primary)' : 'var(--dsw-alias-label-secondary)' } }, item.level === 'pass' ? '✓' : item.level === 'block' ? '✕' : item.level === 'warn' ? '!' : '·'),
1523
+ h('span', { style: S.value }, item.title, item.detail ? h('span', { style: S.meta }, ` — ${item.detail}`) : null),
1524
+ ),
1525
+ ),
1526
+ readiness.entry && readiness.entry.tarball
1527
+ ? h(CopyValue, { label: '条目字段 tarball:', value: readiness.entry.tarball })
1528
+ : null,
1529
+ )
1530
+ : null,
1531
+ releaseAsset
1532
+ ? h('div', null,
1533
+ releaseAsset.asset && releaseAsset.asset.uploaded
1534
+ ? h('p', { style: S.notice }, `已上传 ${releaseAsset.asset.name}(${Math.round(releaseAsset.asset.size / 1024)} KB):`,
1535
+ h('a', { href: releaseAsset.asset.url, target: '_blank', rel: 'noreferrer', style: { marginLeft: 6, color: 'var(--dsw-alias-brand-primary)' } }, '下载'))
1536
+ : h('p', { style: S.warn }, `上传失败:${releaseAsset.asset ? releaseAsset.asset.reason : '未知原因'}`),
1537
+ releaseAsset.gitInstall ? h(CopyValue, { label: 'git 安装地址:', value: releaseAsset.gitInstall }) : null,
1538
+ )
1539
+ : null,
1540
+ ),
1047
1541
  )
1048
1542
  : null,
1049
1543
 
@@ -1116,12 +1610,10 @@ window.__ModuleLoader__.load({
1116
1610
  return h(
1117
1611
  'svg',
1118
1612
  { width: 16, height: 16, viewBox: '0 0 36 36', 'aria-hidden': true, style: { display: 'block', color: 'currentColor' } },
1119
- h('g', { fill: 'none', stroke: 'currentColor', strokeWidth: 2.6, strokeLinecap: 'round', strokeLinejoin: 'round' },
1120
- h('circle', { cx: 10, cy: 8.5, r: 3.4 }),
1121
- h('circle', { cx: 10, cy: 27.5, r: 3.4 }),
1122
- h('circle', { cx: 26, cy: 18, r: 3.4 }),
1123
- h('path', { d: 'M10 11.9v12.2' }),
1124
- h('path', { d: 'M13.2 10.6c6 1.4 9.4 3.8 9.4 7.4' }),
1613
+ h('g', { fill: 'currentColor' },
1614
+ h('path', { d: 'M18 17.2 22.9 22.1 18 27 13.1 22.1Z' }),
1615
+ h('rect', { x: 16.6, y: 11.8, width: 2.8, height: 6.6, rx: 1 }),
1616
+ h('path', { d: 'M18 9.4 21.9 13.5 14.1 13.5Z' }),
1125
1617
  ),
1126
1618
  )
1127
1619
  }
@@ -1130,9 +1622,10 @@ window.__ModuleLoader__.load({
1130
1622
  return h(
1131
1623
  'svg',
1132
1624
  { width: 16, height: 16, viewBox: '0 0 36 36', 'aria-hidden': true, style: { display: 'block', color: 'currentColor' } },
1133
- h('g', { fill: 'none', stroke: 'currentColor', strokeWidth: 2.6, strokeLinecap: 'round', strokeLinejoin: 'round' },
1134
- h('circle', { cx: 18, cy: 18, r: 8.5 }),
1135
- h('path', { d: 'M18 6.5v3.2M18 26.3v3.2M6.5 18h3.2M26.3 18h3.2M9.9 9.9l2.3 2.3M23.8 23.8l2.3 2.3M26.1 9.9l-2.3 2.3M12.2 23.8l-2.3 2.3' }),
1625
+ h('g', { fill: 'currentColor' },
1626
+ h('path', { d: 'M18 17.2 22.9 22.1 18 27 13.1 22.1Z' }),
1627
+ h('rect', { x: 16.6, y: 11.8, width: 2.8, height: 6.6, rx: 1 }),
1628
+ h('path', { d: 'M18 9.4 21.9 13.5 14.1 13.5Z' }),
1136
1629
  ),
1137
1630
  )
1138
1631
  }
package/cordis.patch.yml CHANGED
@@ -15,3 +15,6 @@
15
15
  caFile: ''
16
16
  requestTimeoutMs: 20000
17
17
  npmUser: 'artbnjk'
18
+ authMode: 'auto'
19
+ patEnvName: 'GITHUB_TOKEN'
20
+ readOnly: false