@dsh-workbench/shared 0.3.5 → 0.3.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/api/context-ref.d.ts +0 -12
- package/dist/api/context-ref.js +0 -40
- package/dist/api/facts.d.ts +0 -6
- package/dist/api/facts.js +0 -8
- package/dist/api/long-task.d.ts +33 -4
- package/dist/api/long-task.js +34 -2
- package/dist/components/ConfirmBar.css +26 -0
- package/dist/components/ConfirmBar.d.ts +36 -0
- package/dist/components/ConfirmBar.js +26 -0
- package/dist/components/Form.d.ts +7 -5
- package/dist/components/Form.js +5 -3
- package/dist/components/FormNodes.d.ts +17 -13
- package/dist/components/FormNodes.js +13 -5
- package/dist/components/FormRows.css +31 -0
- package/dist/components/FormTypes.d.ts +39 -14
- package/dist/components/LongTaskRow.css +52 -0
- package/dist/components/LongTaskRow.d.ts +18 -2
- package/dist/components/LongTaskRow.js +33 -5
- package/dist/components/MockStrip.css +11 -1
- package/dist/components/StateDot.d.ts +5 -0
- package/dist/components/StateDot.js +10 -0
- package/dist/config/constants.d.ts +2 -0
- package/dist/config/constants.js +2 -0
- package/dist/host/__tests__/fakes.d.ts +41 -0
- package/dist/host/__tests__/fakes.js +76 -0
- package/dist/host/__tests__/preflight-fixtures.d.ts +19 -0
- package/dist/host/__tests__/preflight-fixtures.js +47 -0
- package/dist/host/board-fact.d.ts +8 -0
- package/dist/host/board-fact.js +16 -0
- package/dist/host/browser-read.js +2 -1
- package/dist/host/context-inject.d.ts +24 -0
- package/dist/host/context-inject.js +74 -0
- package/dist/host/context-ref.d.ts +13 -0
- package/dist/host/context-ref.js +41 -0
- package/dist/host/diy-debug.d.ts +80 -0
- package/dist/host/diy-debug.js +88 -0
- package/dist/host/diy-record.d.ts +135 -0
- package/dist/host/diy-record.js +162 -0
- package/dist/host/events.d.ts +9 -0
- package/dist/host/events.js +70 -0
- package/dist/host/facts.d.ts +6 -0
- package/dist/host/facts.js +9 -0
- package/dist/host/git.js +1 -1
- package/dist/host/http.d.ts +2 -2
- package/dist/host/http.js +3 -3
- package/dist/host/long-task.d.ts +12 -0
- package/dist/host/long-task.js +34 -5
- package/dist/host/mount-units.d.ts +52 -0
- package/dist/host/mount-units.js +186 -0
- package/dist/host/opencli-runtime.js +1 -1
- package/dist/host/opencli-window.js +1 -1
- package/dist/host/opencli.js +2 -1
- package/dist/host/panel-state.d.ts +120 -0
- package/dist/host/panel-state.js +176 -0
- package/dist/host/plugin-source.js +1 -1
- package/dist/host/preflight.d.ts +58 -0
- package/dist/host/preflight.js +233 -0
- package/dist/host/probe-cache.d.ts +6 -0
- package/dist/host/probe-cache.js +19 -0
- package/dist/host/probe-libs.d.ts +45 -0
- package/dist/host/probe-libs.js +61 -0
- package/dist/host/probe-units.d.ts +17 -0
- package/dist/host/probe-units.js +102 -0
- package/dist/host/probe-verdict.d.ts +7 -0
- package/dist/host/probe-verdict.js +143 -0
- package/dist/host/shell-text.d.ts +13 -0
- package/dist/host/shell-text.js +20 -0
- package/dist/host/tool-approval.d.ts +1 -0
- package/dist/host/tool-scope.d.ts +32 -0
- package/dist/host/tool-scope.js +84 -0
- package/dist/host/unit-declaration.d.ts +65 -0
- package/dist/host/unit-declaration.js +213 -0
- package/dist/host/unit-face.d.ts +1 -0
- package/dist/host/unit-readiness.d.ts +7 -0
- package/dist/host/unit-readiness.js +5 -0
- package/dist/host/unit-registry.d.ts +9 -0
- package/dist/host/unit-registry.js +33 -0
- package/dist/host/version-range.d.ts +2 -0
- package/dist/host/version-range.js +73 -0
- package/dist/host.d.ts +7 -4
- package/dist/host.js +7 -4
- package/dist/i18n/en.js +6 -0
- package/dist/i18n/index.d.ts +7 -1
- package/dist/i18n/zh.d.ts +6 -0
- package/dist/i18n/zh.js +6 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -4
- package/dist/lib/board-fact.d.ts +0 -7
- package/dist/lib/board-fact.js +0 -15
- package/dist/lib/diy-record.d.ts +38 -1
- package/dist/lib/diy-record.js +66 -0
- package/dist/lib/text.d.ts +0 -13
- package/dist/lib/text.js +0 -20
- package/dist/testing/declaration.js +1 -1
- package/package.json +1 -1
- package/src/api/__tests__/facts.test.ts +0 -13
- package/src/api/__tests__/long-task.test.ts +41 -1
- package/src/api/context-ref.ts +0 -39
- package/src/api/facts.ts +0 -9
- package/src/api/long-task.ts +46 -4
- package/src/components/ConfirmBar.css +26 -0
- package/src/components/ConfirmBar.test.tsx +130 -0
- package/src/components/ConfirmBar.tsx +63 -0
- package/src/components/Form.test.tsx +15 -0
- package/src/components/Form.tsx +7 -5
- package/src/components/FormNodes.tsx +50 -26
- package/src/components/FormRows.css +31 -0
- package/src/components/FormRows.test.tsx +71 -1
- package/src/components/FormTypes.test.ts +31 -0
- package/src/components/FormTypes.ts +46 -15
- package/src/components/FormWiring.test.tsx +1 -0
- package/src/components/LongTaskRow.css +52 -0
- package/src/components/LongTaskRow.tsx +59 -4
- package/src/components/__tests__/long-task-row.test.ts +115 -0
- package/src/config/constants.ts +3 -0
- package/src/host/__tests__/board-fact.test.ts +47 -0
- package/src/{lib → host/__tests__}/diy-debug.test.ts +1 -1
- package/src/{lib → host/__tests__}/diy-record.test.ts +137 -1
- package/src/host/__tests__/facts.test.ts +13 -0
- package/src/host/__tests__/long-task.test.ts +306 -0
- package/src/{lib → host/__tests__}/panel-state.test.ts +1 -1
- package/src/host/__tests__/preflight-route.test.ts +33 -0
- package/src/host/__tests__/shell-text.test.ts +44 -0
- package/src/host/board-fact.ts +14 -0
- package/src/host/browser-read.ts +2 -1
- package/src/host/context-ref.ts +40 -0
- package/src/{lib → host}/diy-record.ts +95 -1
- package/src/host/facts.ts +10 -0
- package/src/host/git.ts +1 -1
- package/src/host/http.ts +4 -4
- package/src/host/long-task.ts +52 -7
- package/src/host/opencli-runtime.ts +1 -1
- package/src/host/opencli-window.ts +1 -1
- package/src/host/opencli.ts +2 -1
- package/src/host/plugin-source.ts +1 -1
- package/src/host/shell-text.ts +21 -0
- package/src/host/tool-approval.ts +1 -0
- package/src/{api → host}/unit-declaration.ts +1 -1
- package/src/host/unit-face.ts +1 -0
- package/src/host.ts +7 -4
- package/src/i18n/en.ts +7 -0
- package/src/i18n/zh.ts +6 -0
- package/src/index.ts +1 -4
- package/src/lib/board-fact.test.ts +1 -33
- package/src/lib/board-fact.ts +0 -13
- package/src/lib/text.test.ts +1 -43
- package/src/lib/text.ts +0 -22
- package/src/testing/declaration.ts +1 -1
- package/dist/lib/lint-probe.d.ts +0 -1
- package/dist/lib/lint-probe.js +0 -6
- /package/src/{api → host}/__tests__/unit-declaration.test.ts +0 -0
- /package/src/{lib → host}/diy-debug.ts +0 -0
- /package/src/{lib → host}/panel-state.ts +0 -0
package/src/i18n/zh.ts
CHANGED
|
@@ -38,6 +38,7 @@ export const zh = {
|
|
|
38
38
|
'session.actions': '{name} 的操作',
|
|
39
39
|
'status.idle': '空闲',
|
|
40
40
|
'status.running': '进行中',
|
|
41
|
+
'status.longTask': '长任务在跑',
|
|
41
42
|
'status.waitingApproval': '等待审批',
|
|
42
43
|
'status.planReview': '计划待审',
|
|
43
44
|
'status.waitingAnswer': '等待回答',
|
|
@@ -51,6 +52,8 @@ export const zh = {
|
|
|
51
52
|
'project.attention.warning.other': '{n} 个会话在等你点头',
|
|
52
53
|
'project.attention.running.one': '1 个会话在跑',
|
|
53
54
|
'project.attention.running.other': '{n} 个会话在跑',
|
|
55
|
+
'project.attention.longTask.one': '1 个长任务在跑',
|
|
56
|
+
'project.attention.longTask.other': '{n} 个长任务在跑',
|
|
54
57
|
'project.attention.done.one': '1 个会话跑完没看',
|
|
55
58
|
'project.attention.done.other': '{n} 个会话跑完没看',
|
|
56
59
|
'project.attention.state.warning': '待审批',
|
|
@@ -436,6 +439,7 @@ export const zh = {
|
|
|
436
439
|
'record.waiting.note': '请在那一页按「开始录制」,做完按「结束录制」(录完不替你切回来)',
|
|
437
440
|
'record.recording': '录制中',
|
|
438
441
|
'record.recording.note': '做完按「结束录制」;浮条没了按「停」,让 agent 先取再收',
|
|
442
|
+
'record.recording.shots': ';想留一张现场就按浮条上的「截图」(已拍 {n} 张)',
|
|
439
443
|
'record.finished': '录制完成',
|
|
440
444
|
'record.finished.note': '这一段录完了 —— agent 会自己来取并收工,不用你点',
|
|
441
445
|
'record.act.cancel': '取消',
|
|
@@ -446,6 +450,8 @@ export const zh = {
|
|
|
446
450
|
'approval.record.noUrl': '没给站点地址(这次会被当场拒)',
|
|
447
451
|
'approval.record.oneAction': '一次操作',
|
|
448
452
|
'approval.record.noSwitch': '录完不会替你切回来(左栏底部会亮一条状态)',
|
|
453
|
+
'approval.longTask.what': '要停的那一趟',
|
|
454
|
+
'approval.longTask.signal': '停了只是让外壳发出中断信号 —— 平台侧那趟活儿的收尾看模块自己',
|
|
449
455
|
} as const;
|
|
450
456
|
|
|
451
457
|
/** 中文词表的键类型:`en` 与模块词表都得覆盖同一批键。 */
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,6 @@ export * from './api/facts.js';
|
|
|
7
7
|
export * from './api/host-write.js';
|
|
8
8
|
export * from './api/long-task.js';
|
|
9
9
|
export * from './api/unit-board.js';
|
|
10
|
-
export * from './api/unit-declaration.js';
|
|
11
10
|
export * from './api/unit.js';
|
|
12
11
|
export * from './api/workbench-client.js';
|
|
13
12
|
export * from './api/workbench-contract.js';
|
|
@@ -19,6 +18,7 @@ export * from './components/CardAnchor.js';
|
|
|
19
18
|
export * from './components/CardBoundary.js';
|
|
20
19
|
export * from './components/CardHead.js';
|
|
21
20
|
export * from './components/ChoiceGroup.js';
|
|
21
|
+
export * from './components/ConfirmBar.js';
|
|
22
22
|
export * from './components/Field.js';
|
|
23
23
|
export * from './components/Form.js';
|
|
24
24
|
export * from './components/FormActions.js';
|
|
@@ -49,10 +49,7 @@ export * from './i18n/zh.js';
|
|
|
49
49
|
export * from './lib/blocker-action.js';
|
|
50
50
|
export * from './lib/board-fact.js';
|
|
51
51
|
export * from './lib/busy.js';
|
|
52
|
-
export * from './lib/diy-debug.js';
|
|
53
|
-
export * from './lib/diy-record.js';
|
|
54
52
|
export * from './lib/form-problem.js';
|
|
55
|
-
export * from './lib/panel-state.js';
|
|
56
53
|
export * from './lib/react.js';
|
|
57
54
|
export * from './lib/text.js';
|
|
58
55
|
export * from './lib/ui.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
2
|
+
import { boardSituation, insideWorkshop, type BoardProbe } from './board-fact.js';
|
|
3
3
|
|
|
4
4
|
const WORKSHOP = '/w/workbench/diy';
|
|
5
5
|
const FL0XIN = '/w/floxin-app';
|
|
@@ -16,38 +16,6 @@ const probe = (over: Partial<BoardProbe> = {}): BoardProbe => ({
|
|
|
16
16
|
|
|
17
17
|
const gone = { bar: false, board: '', open: false, drawn: false } as const;
|
|
18
18
|
|
|
19
|
-
describe('板事实:一份判据,两边共用', () => {
|
|
20
|
-
it('★★ 画着的就是工坊那块板(含子路径)⇒ workshop', () => {
|
|
21
|
-
expect(boardFactOf(probe(), WORKSHOP)).toBe('workshop');
|
|
22
|
-
expect(boardFactOf(probe({ board: `${WORKSHOP}/packages` }), WORKSHOP)).toBe('workshop');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('★★ 画的是别的项目的板 ⇒ other(前缀像但没落在里面也算 other)', () => {
|
|
26
|
-
expect(boardFactOf(probe({ board: '/w/project' }), WORKSHOP)).toBe('other');
|
|
27
|
-
expect(boardFactOf(probe({ board: `${WORKSHOP}-other` }), WORKSHOP)).toBe('other');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('★★ 那块板没画在屏上 ⇒ hidden:不挂、没声明开着、量出来不可见,三条里任一条不成立都算', () => {
|
|
31
|
-
expect(boardFactOf(probe({ bar: false }), WORKSHOP)).toBe('hidden');
|
|
32
|
-
expect(boardFactOf(probe({ open: false }), WORKSHOP)).toBe('hidden');
|
|
33
|
-
expect(boardFactOf(probe({ drawn: false }), WORKSHOP)).toBe('hidden');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('★★ 工作台没答话(旧外壳 / 夹具页)⇒ unknown:放行,但不许当成"就是工坊板"', () => {
|
|
37
|
-
expect(boardFactOf(probe({ workbench: false }), WORKSHOP)).toBe('unknown');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('★ 画着板但说不清是哪块、或不知道工坊在哪 ⇒ unknown', () => {
|
|
41
|
-
expect(boardFactOf(probe({ board: '' }), WORKSHOP)).toBe('unknown');
|
|
42
|
-
expect(boardFactOf(probe(), null)).toBe('unknown');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('★★ 顺序要紧:没画在屏上,就别去猜是哪块板', () => {
|
|
46
|
-
expect(boardFactOf(probe({ board: WORKSHOP, drawn: false }), WORKSHOP)).toBe('hidden');
|
|
47
|
-
expect(boardFactOf(probe({ workbench: false, bar: false }), WORKSHOP)).toBe('unknown');
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
19
|
describe('干不了活是为什么:先看人在不在工坊,再看板画没画在屏上', () => {
|
|
52
20
|
it('★★ 在位 ⇒ ok(跟 boardFactOf === "workshop" 是同一个条件)', () => {
|
|
53
21
|
expect(boardSituation(probe(), WORKSHOP)).toBe('ok');
|
package/src/lib/board-fact.ts
CHANGED
|
@@ -41,19 +41,6 @@ export function insideWorkshop(root: string, target: string): boolean {
|
|
|
41
41
|
return target.startsWith(base);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
/**
|
|
45
|
-
* 把一次探针读数归成椅面归属。
|
|
46
|
-
* @param probe - 探针读数。
|
|
47
|
-
* @param workshop - 当前工作区根路径;`null` 表示还不知道当前是哪个工作区。
|
|
48
|
-
* @returns 外壳不在、或板路径与工作区缺一 → `unknown`;右栏没开或没画出来 → `hidden`;板在本工作区 → `workshop`,否则 `other`。
|
|
49
|
-
*/
|
|
50
|
-
export function boardFactOf(probe: BoardProbe, workshop: string | null): BoardFactState {
|
|
51
|
-
if (!probe.workbench) return 'unknown';
|
|
52
|
-
if (!probe.bar || !probe.open || !probe.drawn) return 'hidden';
|
|
53
|
-
if (probe.board === '' || workshop === null) return 'unknown';
|
|
54
|
-
return insideWorkshop(workshop, probe.board) ? 'workshop' : 'other';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
44
|
/**
|
|
58
45
|
* 把探针读数归成左栏那句人话的档位。
|
|
59
46
|
* @param probe - 探针读数。
|
package/src/lib/text.test.ts
CHANGED
|
@@ -1,47 +1,5 @@
|
|
|
1
|
-
import { execFileSync } from 'node:child_process';
|
|
2
1
|
import { describe, expect, it } from 'vitest';
|
|
3
|
-
import { excerpt, parseJsonLoose
|
|
4
|
-
|
|
5
|
-
function shellSees(value: string): string {
|
|
6
|
-
return execFileSync('/bin/sh', ['-c', `printf '%s' ${quoteShellArg(value)}`], {
|
|
7
|
-
encoding: 'utf8',
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
describe('quoteShellArg', () => {
|
|
12
|
-
it('普通值原样往返', () => {
|
|
13
|
-
expect(shellSees('example-monorepo')).toBe('example-monorepo');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('含空格的路径不被拆成两个参数', () => {
|
|
17
|
-
expect(shellSees('/Volumes/My Projects/app')).toBe('/Volumes/My Projects/app');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('单引号被正确转义(否则就是注入面)', () => {
|
|
21
|
-
expect(shellSees("it's")).toBe("it's");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('shell 元字符按字面量传递', () => {
|
|
25
|
-
for (const raw of ['$(whoami)', '`id`', 'a; rm -rf /', 'a && b', '*', '"double"', '\\n']) {
|
|
26
|
-
expect(shellSees(raw), raw).toBe(raw);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('tailLines', () => {
|
|
32
|
-
it('取末尾若干行并去掉首尾空行', () => {
|
|
33
|
-
expect(tailLines('\n a \n b \n', 2)).toBe('a \n b');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('行数不够时全给', () => {
|
|
37
|
-
expect(tailLines('only', 6)).toBe('only');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('空输入给空串', () => {
|
|
41
|
-
expect(tailLines(undefined, 3)).toBe('');
|
|
42
|
-
expect(tailLines(' ', 3)).toBe('');
|
|
43
|
-
});
|
|
44
|
-
});
|
|
2
|
+
import { excerpt, parseJsonLoose } from './text.js';
|
|
45
3
|
|
|
46
4
|
describe('parseJsonLoose', () => {
|
|
47
5
|
it('干净 JSON 直接解析', () => {
|
package/src/lib/text.ts
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 把一个值裹成 shell 里的单引号字面量(值里的单引号一并转义),保证元字符按字面量传递。
|
|
3
|
-
* @param value - 任意值;不是字符串的先 `String()`。
|
|
4
|
-
* @returns 可安全拼进 `/bin/sh -c` 的一段文本 —— 含空格 / `$()` / `;` / 通配符的值都不会被当成语法。
|
|
5
|
-
*/
|
|
6
|
-
export function quoteShellArg(value: unknown): string {
|
|
7
|
-
return `'${String(value).replace(/'/g, `'\\''`)}'`;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 取一段文本的末尾若干行(如命令输出),顺带去掉首尾空白。
|
|
12
|
-
* @param text - 原文;`null` / `undefined` 当空串。
|
|
13
|
-
* @param lines - 最多留几行,默认 6;0 给全篇、负数从开头砍掉那么多行(都是 `slice` 语义),调用方传正数。
|
|
14
|
-
* @returns 末尾若干行、去首尾空行后的文本;原文行数不够就全给,空输入给空串。
|
|
15
|
-
*/
|
|
16
|
-
export function tailLines(text: string | null | undefined, lines = 6): string {
|
|
17
|
-
const all = String(text ?? '')
|
|
18
|
-
.trim()
|
|
19
|
-
.split('\n');
|
|
20
|
-
return all.slice(-lines).join('\n');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
1
|
function candidateStarts(raw: string): number[] {
|
|
24
2
|
const starts: number[] = [];
|
|
25
3
|
for (let index = 0; index < raw.length; index += 1) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import type { UnitManifest } from '../api/unit.js';
|
|
4
|
-
import { readDeclaration } from '../
|
|
4
|
+
import { readDeclaration } from '../host/unit-declaration.js';
|
|
5
5
|
|
|
6
6
|
export function declarationOfPackage(pkg: string, packageJson: URL | string): UnitManifest {
|
|
7
7
|
const at = typeof packageJson === 'string' ? packageJson : fileURLToPath(packageJson);
|
package/dist/lib/lint-probe.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useLintProbe(): number;
|
package/dist/lib/lint-probe.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|