weaver-work-cli 0.1.60 → 0.1.61

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 (121) hide show
  1. package/dist/chunks/{archive-4SQAVTIB.js → archive-S2VKZWQ3.js} +2 -2
  2. package/dist/chunks/{archive-oa-W2UEJ67L.js → archive-oa-HEDSIUUY.js} +2 -2
  3. package/dist/chunks/{asset-EGZEABBI.js → asset-HYH4W357.js} +2 -2
  4. package/dist/chunks/{asset-idle-EBUZBB6M.js → asset-idle-N7REBNGL.js} +2 -2
  5. package/dist/chunks/{attachment-content-I6WHKGR2.js → attachment-content-VYYA75FR.js} +3 -3
  6. package/dist/chunks/{blog-2YKMWOWI.js → blog-SLMZZICV.js} +2 -2
  7. package/dist/chunks/{caizhilian-5NM4X5HG.js → caizhilian-RV43KKBT.js} +4 -4
  8. package/dist/chunks/{calendar-H4QTJCUY.js → calendar-DMVZ4OLY.js} +2 -2
  9. package/dist/chunks/{chunk-VLL6JOB4.js → chunk-6XSSAUNW.js} +4 -4
  10. package/dist/chunks/{chunk-VQWPQTEY.js → chunk-BIA2NKUG.js} +4 -4
  11. package/dist/chunks/{chunk-VMCCRWFO.js → chunk-BQYX2UX5.js} +2 -2
  12. package/dist/chunks/{chunk-XF7S6FQW.js → chunk-DTCQFTHW.js} +1 -1
  13. package/dist/chunks/{chunk-CPG6NLN4.js → chunk-E5YD5JWR.js} +1 -1
  14. package/dist/chunks/{chunk-PH7N4UFT.js → chunk-EGANE35F.js} +1 -1
  15. package/dist/chunks/{chunk-Z4IPY5GV.js → chunk-H6YOMI3U.js} +2 -2
  16. package/dist/chunks/{chunk-HHH4K3YY.js → chunk-ILALC2N6.js} +1 -1
  17. package/dist/chunks/{chunk-WINR2Q6K.js → chunk-KXJA42EA.js} +86 -19
  18. package/dist/chunks/{chunk-CQ4OVCKG.js → chunk-KY3R42RS.js} +2 -2
  19. package/dist/chunks/{chunk-WVH5ESDA.js → chunk-NRYDJN4J.js} +1 -1
  20. package/dist/chunks/{chunk-TGM7BWEH.js → chunk-P6TXQK75.js} +2 -2
  21. package/dist/chunks/{chunk-6YWHRXEQ.js → chunk-QBDXJS2W.js} +119 -9
  22. package/dist/chunks/{chunk-2IGZUMNG.js → chunk-SHX7XBYR.js} +180 -18
  23. package/dist/chunks/{chunk-P7RXQDCA.js → chunk-T2KVJFWJ.js} +4 -4
  24. package/dist/chunks/{chunk-FMNCSYIG.js → chunk-TEZHIB6T.js} +2 -2
  25. package/dist/chunks/{chunk-HMIIVM2L.js → chunk-UBGWIXU3.js} +97 -45
  26. package/dist/chunks/{chunk-5N222HK6.js → chunk-UBRWONP4.js} +2 -2
  27. package/dist/chunks/{chunk-7U5YHCW7.js → chunk-UQFPF4EX.js} +2 -2
  28. package/dist/chunks/{chunk-4GG72JAT.js → chunk-V2LASYKO.js} +2 -2
  29. package/dist/chunks/{chunk-BDBTZVYA.js → chunk-VBFBMM7G.js} +55 -55
  30. package/dist/chunks/{chunk-YHSOCGKO.js → chunk-VNYOUAWV.js} +11 -11
  31. package/dist/chunks/{chunk-SFM3M2L3.js → chunk-WIWDVETN.js} +19 -3
  32. package/dist/chunks/{chunk-44KJ7WFA.js → chunk-XT77MP54.js} +2 -2
  33. package/dist/chunks/{chunk-JFKMPRZB.js → chunk-YI2YMW5N.js} +50 -3
  34. package/dist/chunks/{conflict-QMDLS2EW.js → conflict-GFJRS6I7.js} +2 -2
  35. package/dist/chunks/{contract-LLRKMLQQ.js → contract-U3ZGNRWB.js} +2 -2
  36. package/dist/chunks/{cowork-2RDFBZWB.js → cowork-EX7PKIDK.js} +2 -2
  37. package/dist/chunks/{create-flow-5ODJ7WJO.js → create-flow-EJZD434E.js} +6 -6
  38. package/dist/chunks/{data-LVDFIRNG.js → data-FOODGAMF.js} +278 -121
  39. package/dist/chunks/{ebuilder-form-7WA6X6ZI.js → ebuilder-form-I2EOKODG.js} +3 -3
  40. package/dist/chunks/{ehr-52GBKNJR.js → ehr-TE4RFNID.js} +2 -2
  41. package/dist/chunks/{entry-mode-73BJML22.js → entry-mode-ZOLSXEGX.js} +9 -5
  42. package/dist/chunks/{env-OHFS76HV.js → env-TID5NFR6.js} +2 -2
  43. package/dist/chunks/{esb-HJSXCEOM.js → esb-7L6MHYLB.js} +4 -4
  44. package/dist/chunks/{factory-FRTA2LP4.js → factory-OG7BPMH5.js} +1 -1
  45. package/dist/chunks/{fna-OBACRT3J.js → fna-6V2ENR3Y.js} +2 -2
  46. package/dist/chunks/{group-chat-KBFRPCR2.js → group-chat-5DKPWIHL.js} +3 -3
  47. package/dist/chunks/{host-TTSGY5NZ.js → host-3DLYA54R.js} +3 -3
  48. package/dist/chunks/{host-KJT3G5D2.js → host-GOJHHTPY.js} +3 -3
  49. package/dist/chunks/{host-KOWUMNAY.js → host-OGBHL75G.js} +3 -3
  50. package/dist/chunks/{host-MFXRA2MY.js → host-ONZC6AE7.js} +3 -3
  51. package/dist/chunks/{host-W4JCNRFS.js → host-TJ5VVHM7.js} +3 -3
  52. package/dist/chunks/{host-2BKMPWDH.js → host-VTPAWDZV.js} +3 -3
  53. package/dist/chunks/{hrm-AK3WGBMN.js → hrm-2N7NFQDZ.js} +3 -3
  54. package/dist/chunks/{im-JZSBPO4Z.js → im-XCH47ZBN.js} +3 -3
  55. package/dist/chunks/{invoice-6XDMPCWB.js → invoice-XQRKMGNY.js} +3 -3
  56. package/dist/chunks/{jiuchuanhui-K4EQU6GK.js → jiuchuanhui-PL6DRPBM.js} +2 -2
  57. package/dist/chunks/{lazy-dispatch-GCA6HDOB.js → lazy-dispatch-UATEN7H7.js} +5 -5
  58. package/dist/chunks/{mail-IKVCQCVZ.js → mail-Q7Z4CQ4D.js} +2 -2
  59. package/dist/chunks/{meeting-ARHVWK7G.js → meeting-5E3BNARL.js} +13 -13
  60. package/dist/chunks/{minute-doc-547KSYKR.js → minute-doc-NXRE5C77.js} +4 -4
  61. package/dist/chunks/{okr-KV43FPPX.js → okr-3O3XNYOK.js} +2 -2
  62. package/dist/chunks/{operations-6NXJ7RTE.js → operations-EZWG72FH.js} +4 -4
  63. package/dist/chunks/performance-Y7CPNSOR.js +1295 -0
  64. package/dist/chunks/{plan-WOYR4WEG.js → plan-BLGPZF5M.js} +2 -2
  65. package/dist/chunks/{project-CQJKBUIL.js → project-6MZMLJMP.js} +2 -2
  66. package/dist/chunks/{reception-MPBU3JXC.js → reception-F2VT2X52.js} +2 -2
  67. package/dist/chunks/{recruit-stage-USTTRHOX.js → recruit-stage-4ETIBMIW.js} +2 -2
  68. package/dist/chunks/{registry-GURQG4ZV.js → registry-3FYSWV3U.js} +3 -3
  69. package/dist/chunks/{registry-SS5J2FZQ.js → registry-7RS74TCK.js} +4 -4
  70. package/dist/chunks/{registry-H5HQ5QNH.js → registry-I4DVPDMU.js} +11 -11
  71. package/dist/chunks/{room-recommend-3UBROMZE.js → room-recommend-GWCVKCXW.js} +4 -4
  72. package/dist/chunks/{schedule-FTUQML6O.js → schedule-6AN63MJQ.js} +4 -4
  73. package/dist/chunks/{smart-extract-APX2PNIN.js → smart-extract-SR4SJJKN.js} +3 -3
  74. package/dist/chunks/{workflow-WMPW3WSB.js → workflow-KF7FA2UQ.js} +7 -7
  75. package/dist/cmd/refs/index.js +124 -4
  76. package/dist/core/output.js +199 -26
  77. package/dist/core/refs.js +36 -0
  78. package/dist/index.js +38 -33
  79. package/dist/internal/e10/auth/xiaoe.js +25 -3
  80. package/dist/shortcuts/caizhilian/operations/files.js +86 -15
  81. package/dist/shortcuts/data/index.js +12 -2
  82. package/dist/shortcuts/data/manifest.js +4 -2
  83. package/dist/shortcuts/data/operations/attribution.js +229 -0
  84. package/dist/shortcuts/data/operations/ds.js +87 -90
  85. package/dist/shortcuts/data/operations/index.js +3 -1
  86. package/dist/shortcuts/index.js +5 -0
  87. package/dist/shortcuts/meeting/operations/eb/create-flow.js +84 -16
  88. package/dist/shortcuts/meeting/operations/eb/entry-mode.js +61 -7
  89. package/dist/shortcuts/performance/continuation.js +74 -0
  90. package/dist/shortcuts/performance/errors.js +65 -0
  91. package/dist/shortcuts/performance/host.js +105 -0
  92. package/dist/shortcuts/performance/index.js +109 -0
  93. package/dist/shortcuts/performance/manifest.js +30 -0
  94. package/dist/shortcuts/performance/operations/hrm-resolve.js +114 -0
  95. package/dist/shortcuts/performance/operations/registry.js +44 -0
  96. package/dist/shortcuts/performance/operations/scheme-detail.js +70 -0
  97. package/dist/shortcuts/performance/operations/scheme-draft.js +116 -0
  98. package/dist/shortcuts/performance/operations/scheme-publish.js +158 -0
  99. package/dist/shortcuts/performance/operations/types.js +32 -0
  100. package/dist/shortcuts/performance/scheme-validate.js +307 -0
  101. package/dist/shortcuts/performance/shared.js +158 -0
  102. package/docs/agent-io-channel-design.md +67 -3
  103. package/docs/data.md +2 -1
  104. package/package.json +1 -1
  105. package/scripts/xiaoe_env.py +6 -1
  106. package/skill-template/business-info.json +19 -0
  107. package/skill-template/domains/performance.md +18 -0
  108. package/skills/weaver-e10-caizhilian/SKILL.md +1 -1
  109. package/skills/weaver-e10-data/references/datasource.md +2 -1
  110. package/skills/weaver-e10-meeting/SKILL.md +5 -3
  111. package/skills/weaver-e10-performance/SKILL.md +202 -0
  112. package/skills/weaver-e10-performance/agents/openai.yaml +74 -0
  113. package/skills/weaver-e10-performance/references/default-assembly.md +108 -0
  114. package/skills/weaver-e10-performance/references/entity-resolution.md +69 -0
  115. package/skills/weaver-e10-performance/references/enums-and-normalization.md +80 -0
  116. package/skills/weaver-e10-performance/references/examples.md +146 -0
  117. package/skills/weaver-e10-performance/references/extraction-guide.md +144 -0
  118. package/skills/weaver-e10-performance/references/scheme-edit-req-fields.md +185 -0
  119. package/skills/weaver-e10-performance/references/scheme-setting-page.md +62 -0
  120. package/skills/weaver-e10-performance/scripts/parse_appraisal_doc.py +483 -0
  121. package/skills/weaver-e10-shared/references/json-output-contract.md +5 -0
@@ -0,0 +1,74 @@
1
+ import { CONTINUATION_TTL_MS } from '../../core/continuation-ttl.js';
2
+ import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
3
+ import { existsSync } from 'node:fs';
4
+ import { chmod, mkdir, readFile, writeFile } from 'node:fs/promises';
5
+ import { homedir } from 'node:os';
6
+ import { resolve } from 'node:path';
7
+ import { pfValidationError } from './errors.js';
8
+ function stateRoot(ctx) {
9
+ const configured = ctx?.config?.path();
10
+ if (configured)
11
+ return resolve(configured, '..');
12
+ return process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), '.weaver-work-cli');
13
+ }
14
+ async function loadKey(ctx) {
15
+ const keysDir = resolve(stateRoot(ctx), 'keys');
16
+ const filename = resolve(keysDir, 'performance-continuation.key');
17
+ await mkdir(keysDir, { recursive: true, mode: 0o700 });
18
+ if (existsSync(filename))
19
+ return readFile(filename);
20
+ const key = randomBytes(32);
21
+ try {
22
+ await writeFile(filename, key, { flag: 'wx', mode: 0o600 });
23
+ if (process.platform !== 'win32')
24
+ await chmod(filename, 0o600).catch(() => undefined);
25
+ return key;
26
+ }
27
+ catch {
28
+ return readFile(filename);
29
+ }
30
+ }
31
+ function encode(value) {
32
+ return Buffer.from(JSON.stringify(value)).toString('base64url');
33
+ }
34
+ function signature(payload, key) {
35
+ return createHmac('sha256', key).update(payload).digest('base64url');
36
+ }
37
+ export function createPerformanceContinuationSigner(ctx) {
38
+ return {
39
+ async issue(payload, ttlMs = CONTINUATION_TTL_MS) {
40
+ const issuedAt = Date.now();
41
+ const body = encode({ ...payload, issuedAt, expiresAt: issuedAt + ttlMs });
42
+ const sig = signature(body, await loadKey(ctx));
43
+ return `${body}.${sig}`;
44
+ },
45
+ async verify(token, expectedOperation) {
46
+ if (typeof token !== 'string' || !token.includes('.')) {
47
+ throw pfValidationError('continuation_invalid', 'continuation 无效');
48
+ }
49
+ const [body, provided] = token.split('.');
50
+ const expected = signature(body, await loadKey(ctx));
51
+ const valid = provided.length === expected.length
52
+ && timingSafeEqual(Buffer.from(provided), Buffer.from(expected));
53
+ if (!valid)
54
+ throw pfValidationError('continuation_invalid', 'continuation 签名校验失败');
55
+ let payload;
56
+ try {
57
+ payload = JSON.parse(Buffer.from(body, 'base64url').toString('utf8'));
58
+ }
59
+ catch {
60
+ throw pfValidationError('continuation_invalid', 'continuation 载荷解析失败');
61
+ }
62
+ if (!payload || typeof payload !== 'object') {
63
+ throw pfValidationError('continuation_invalid', 'continuation 载荷必须是对象');
64
+ }
65
+ if (typeof payload.expiresAt === 'number' && Date.now() > payload.expiresAt) {
66
+ throw pfValidationError('continuation_expired', 'continuation 已过期,请重新 prepare');
67
+ }
68
+ if (payload.operation && String(payload.operation) !== String(expectedOperation)) {
69
+ throw pfValidationError('continuation_operation_mismatch', `continuation 属于操作 ${String(payload.operation)},不能用于 ${expectedOperation}`);
70
+ }
71
+ return payload;
72
+ },
73
+ };
74
+ }
@@ -0,0 +1,65 @@
1
+ import { CliError, ExitCode } from '../../core/errors.js';
2
+ /**
3
+ * performance 模块错误类型。
4
+ * 形态与 recruit-stage 模块一致(type/subtype/details/partialData),
5
+ * 前缀 pf 避免与其他模块的错误类型混淆。
6
+ */
7
+ export class PerformanceCliError extends CliError {
8
+ type;
9
+ subtype;
10
+ code;
11
+ retryable;
12
+ stage;
13
+ details;
14
+ partialData;
15
+ constructor(type, subtype, message, options = {}) {
16
+ super(message, options.exitCode ?? ExitCode.InternalError);
17
+ this.name = 'PerformanceCliError';
18
+ this.type = type;
19
+ this.subtype = subtype;
20
+ this.code = options.code;
21
+ this.retryable = options.retryable ?? false;
22
+ this.stage = options.stage;
23
+ this.details = options.details;
24
+ this.partialData = options.partialData;
25
+ }
26
+ }
27
+ export function pfValidationError(subtype, message, details) {
28
+ return new PerformanceCliError('validation', subtype, message, {
29
+ details,
30
+ exitCode: ExitCode.UsageError,
31
+ });
32
+ }
33
+ export function pfAuthError(subtype, message, details) {
34
+ return new PerformanceCliError('authentication', subtype, message, {
35
+ details,
36
+ exitCode: ExitCode.AuthError,
37
+ });
38
+ }
39
+ export function pfNetworkError(subtype, message, options = {}) {
40
+ return new PerformanceCliError('network', subtype, message, {
41
+ ...options,
42
+ retryable: options.retryable ?? true,
43
+ exitCode: ExitCode.NetworkError,
44
+ });
45
+ }
46
+ export function pfConfirmationError(action, details) {
47
+ return new PerformanceCliError('confirmation', 'required', '该操作需要明确确认', {
48
+ details: { action, ...details },
49
+ exitCode: ExitCode.ConfirmationRequired,
50
+ });
51
+ }
52
+ /** 业务失败(接口 status/fail/code 判定失败的主通道)。 */
53
+ export function pfFail(message, details) {
54
+ return new PerformanceCliError('api', 'business_error', message, {
55
+ details,
56
+ exitCode: ExitCode.GeneralError,
57
+ });
58
+ }
59
+ export function pfPartialError(message, partialData, details) {
60
+ return new PerformanceCliError('partial', 'write_uncertain', message, {
61
+ details,
62
+ partialData,
63
+ exitCode: ExitCode.Partial,
64
+ });
65
+ }
@@ -0,0 +1,105 @@
1
+ import { E10_SESSION_EXPIRED_MESSAGE } from '../../internal/e10/auth/messages.js';
2
+ import { requireE10Session } from '../../internal/e10/context.js';
3
+ import { getActiveProfile } from '../../internal/e10/auth/session.js';
4
+ import { E10ApiError, createE10RequestRuntime } from '../../internal/e10/request-runtime.js';
5
+ import { isE10SessionExpiredResponse } from '../../internal/e10/auth-recovery.js';
6
+ import { pfAuthError, pfNetworkError, PerformanceCliError, pfValidationError } from './errors.js';
7
+ function inferProfile(ctx) {
8
+ const options = ctx.getGlobalOptions();
9
+ return options.profile || getActiveProfile();
10
+ }
11
+ export function assertPath(requestPath) {
12
+ if (typeof requestPath !== 'string' || !requestPath.startsWith('/') || requestPath.startsWith('//')) {
13
+ throw pfValidationError('path_invalid', '请求路径必须是相对绝对路径');
14
+ }
15
+ if (/^https?:/i.test(requestPath) || /[\r\n]/.test(requestPath) || requestPath.includes('/../')) {
16
+ throw pfValidationError('path_invalid', '请求路径不允许跨域或路径逃逸');
17
+ }
18
+ if (!requestPath.startsWith('/api/')) {
19
+ throw pfValidationError('path_not_allowed', '只能调用 /api/ 路径');
20
+ }
21
+ }
22
+ /**
23
+ * 绩效方案接口(/api/workrelate/performance/*)统一返回 WeaResult(code/msg/status/fail/data),
24
+ * 本 host 不做业务成功判定,业务判定在各 operation 内统一走 assertWeaResult。
25
+ */
26
+ export function createPerformanceHost(ctx, dependencies = {}) {
27
+ let e10Session = null;
28
+ let sessionContext = null;
29
+ const requireSession = dependencies.requireSession
30
+ || ((innerCtx) => requireE10Session(innerCtx, { skipProfileEnrichment: true }));
31
+ async function ensureSession() {
32
+ if (!e10Session) {
33
+ e10Session = await requireSession(ctx);
34
+ sessionContext = {
35
+ baseUrl: e10Session.getBaseUrl(),
36
+ profile: inferProfile(ctx),
37
+ userId: e10Session.userId,
38
+ tenantKey: e10Session.tenantKey,
39
+ eteamsId: e10Session.eteamsId,
40
+ };
41
+ }
42
+ return e10Session;
43
+ }
44
+ async function getSession() {
45
+ await ensureSession();
46
+ return sessionContext;
47
+ }
48
+ async function runtime() {
49
+ return createE10RequestRuntime(ctx, await ensureSession(), {
50
+ interceptors: dependencies.interceptors,
51
+ fetch: dependencies.fetch,
52
+ });
53
+ }
54
+ async function request(request) {
55
+ const { method, path, query, body, operation, headers: extraHeaders = {}, timeoutMs = 30_000, } = request;
56
+ assertPath(path);
57
+ const resolvedMethod = method || (body === undefined ? 'GET' : 'POST');
58
+ let response;
59
+ try {
60
+ response = await (await runtime()).requestJson({
61
+ module: 'performance',
62
+ operation,
63
+ method: resolvedMethod,
64
+ path,
65
+ query,
66
+ body,
67
+ headers: { 'X-Requested-With': 'XMLHttpRequest', ...extraHeaders },
68
+ timeoutMs,
69
+ });
70
+ }
71
+ catch (error) {
72
+ if (error instanceof E10ApiError && error.type === 'network') {
73
+ throw pfNetworkError(error.subtype, error.message, {
74
+ retryable: error.retryable,
75
+ details: error.details,
76
+ });
77
+ }
78
+ throw error;
79
+ }
80
+ if (isE10SessionExpiredResponse(response)) {
81
+ throw pfAuthError('session_expired', E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
82
+ }
83
+ if (response.parseError) {
84
+ if (response.status < 200 || response.status >= 300) {
85
+ throw new PerformanceCliError('api', 'http_error', `泛微接口 HTTP ${response.status}`, {
86
+ code: response.status,
87
+ details: { status: response.status },
88
+ exitCode: 1,
89
+ });
90
+ }
91
+ throw pfNetworkError('protocol', `接口返回不是合法 JSON(HTTP ${response.status})`, { retryable: false });
92
+ }
93
+ if (response.status < 200 || response.status >= 300) {
94
+ throw new PerformanceCliError('api', 'http_error', `泛微接口 HTTP ${response.status}`, {
95
+ code: response.status,
96
+ details: { status: response.status, message: response.value?.msg },
97
+ exitCode: 1,
98
+ });
99
+ }
100
+ // 运行时对响应做了 parseJsonPreservingBigInts(16+ 位整数加引号保精度),
101
+ // 业务代码拿到的长 id 已是字符串形态。
102
+ return response.value;
103
+ }
104
+ return { request, getSession };
105
+ }
@@ -0,0 +1,109 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { ExitCode, isCliError, toErrorEnvelope } from '../../core/errors.js';
3
+ import { createPerformanceContinuationSigner } from './continuation.js';
4
+ import { createPerformanceHost } from './host.js';
5
+ import { performanceManifest } from './manifest.js';
6
+ import { executePerformanceOperation } from './operations/registry.js';
7
+ import { pfValidationError } from './errors.js';
8
+ function asOptions(value) {
9
+ return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
10
+ }
11
+ async function readStdin() {
12
+ const chunks = [];
13
+ for await (const chunk of process.stdin) {
14
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
15
+ }
16
+ return Buffer.concat(chunks).toString('utf8');
17
+ }
18
+ /** Windows PowerShell 管道可能写入 UTF-8 BOM,JSON.parse 不接受前导 BOM,先剥离。 */
19
+ function stripBom(value) {
20
+ return value.replace(/^\uFEFF+/, '');
21
+ }
22
+ async function inputFrom(options) {
23
+ const opts = asOptions(options);
24
+ let input = {};
25
+ if (opts.input && opts.inputJson) {
26
+ throw pfValidationError('input_conflict', '不能同时传 --input 和 --input-json');
27
+ }
28
+ if (opts.inputJson) {
29
+ input = parseJsonInput(String(opts.inputJson), '--input-json');
30
+ }
31
+ if (opts.input) {
32
+ let raw;
33
+ try {
34
+ raw = stripBom(opts.input === '-' ? await readStdin() : await readFile(String(opts.input), 'utf8'));
35
+ }
36
+ catch {
37
+ throw pfValidationError('input_unreadable', `无法读取 --input:${String(opts.input)}`);
38
+ }
39
+ input = parseJsonInput(raw, '--input');
40
+ }
41
+ return input;
42
+ }
43
+ function parseJsonInput(raw, label) {
44
+ try {
45
+ const parsed = JSON.parse(stripBom(raw));
46
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
47
+ throw new Error('input must be an object');
48
+ }
49
+ return parsed;
50
+ }
51
+ catch {
52
+ throw pfValidationError('input_invalid', `${label} 不是合法 JSON 对象`);
53
+ }
54
+ }
55
+ export function successEnvelope(operation, result) {
56
+ return {
57
+ schemaVersion: 1,
58
+ ok: true,
59
+ operation,
60
+ data: result.data === undefined ? null : result.data,
61
+ ...(result.meta ? { meta: result.meta } : {}),
62
+ warnings: [],
63
+ };
64
+ }
65
+ function failureEnvelope(error) {
66
+ const structured = error;
67
+ return {
68
+ schemaVersion: 1,
69
+ ok: false,
70
+ ...(structured?.partialData === undefined ? {} : { data: structured.partialData }),
71
+ error: toErrorEnvelope(error),
72
+ };
73
+ }
74
+ async function executeAndPrint(ctx, operation, input) {
75
+ try {
76
+ const host = createPerformanceHost(ctx);
77
+ const result = await executePerformanceOperation(operation, input, {
78
+ ctx,
79
+ host,
80
+ continuation: createPerformanceContinuationSigner(ctx),
81
+ });
82
+ ctx.output.write(successEnvelope(operation, result), { json: true });
83
+ }
84
+ catch (error) {
85
+ console.error(JSON.stringify(failureEnvelope(error), null, 2));
86
+ process.exitCode = isCliError(error) ? error.exitCode : ExitCode.GeneralError;
87
+ }
88
+ }
89
+ export const performanceShortcut = {
90
+ name: 'performance',
91
+ description: '泛微E10绩效方案(文档导入 → 草稿 → 确认发布)CLI',
92
+ category: 'shortcut',
93
+ register({ program, action }) {
94
+ const pf = program.command('performance').description('泛微E10绩效方案(实体解析/落草稿/回读核对/确认发布)');
95
+ pf.command('schema')
96
+ .description('Print performance operation manifest for agents')
97
+ .action(action((ctx) => {
98
+ ctx.output.write(performanceManifest, { json: true });
99
+ }));
100
+ pf.command('run')
101
+ .description('Run a performance operation with JSON input')
102
+ .argument('<operation>', 'operation name, e.g. performance.scheme.draft.prepare')
103
+ .option('--input <path>', 'JSON input file, or - for stdin')
104
+ .option('--input-json <json>', 'inline JSON input object')
105
+ .action(action(async (ctx, operation, options) => {
106
+ await executeAndPrint(ctx, String(operation), await inputFrom(options));
107
+ }));
108
+ },
109
+ };
@@ -0,0 +1,30 @@
1
+ import { performanceOperationDefinitions } from './operations/registry.js';
2
+ /**
3
+ * 绩效方案(performance)模块清单。
4
+ * 面向「绩效考核文档 → 绩效方案」场景:实体解析 → 落草稿 → 回读核对 → 确认后发布。
5
+ * 文档解析(docx/xlsx/pdf → 结构化字段)保留在 Agent Skill 侧(scripts/parse_appraisal_doc.py),
6
+ * CLI 只承载需要登录态与写门禁的系统交互。
7
+ */
8
+ function buildOperations() {
9
+ return performanceOperationDefinitions().map((definition) => ({
10
+ name: definition.name,
11
+ resource: definition.resource,
12
+ summary: definition.summary,
13
+ ...(definition.capability ? { capability: definition.capability } : {}),
14
+ risk: definition.risk,
15
+ ...(definition.requiresConfirmation ? { requiresConfirmation: true } : {}),
16
+ inputSchema: definition.inputSchema,
17
+ }));
18
+ }
19
+ export const performanceManifest = {
20
+ schemaVersion: 1,
21
+ name: 'performance',
22
+ title: '泛微E10绩效方案(文档导入 → 草稿 → 确认发布)',
23
+ version: '0.1.0',
24
+ host: 'e10-performance',
25
+ status: 'builtin',
26
+ sourceSkill: 'weaver-e10-performance',
27
+ capabilities: ['performance.hrm.resolve', 'performance.scheme.detail', 'performance.scheme.draft', 'performance.scheme.publish'],
28
+ operations: buildOperations(),
29
+ withheldOperations: [],
30
+ };
@@ -0,0 +1,114 @@
1
+ import { pfValidationError } from '../errors.js';
2
+ import { pfSuccess, schemaOf } from './types.js';
3
+ /** 实体类型 → 浏览器接口路径 + 建议 targetType(契约见 api-hrm-search.md,2026-10-28 实测)。 */
4
+ const ENTITY_TYPES = {
5
+ resource: {
6
+ path: '/api/hrm/common/browser/complete/resource',
7
+ label: '人员',
8
+ targetTypes: [{ targetType: 1, when: '考核对象或具名评分人(fixedMan 的 operater)' }],
9
+ body: {
10
+ browserMultiple: true,
11
+ authWecahtBook: false,
12
+ wxDepNeedConvertCount: 0,
13
+ wxEmpNeedConvertCount: 0,
14
+ wxTotalNeedConvertCount: 0,
15
+ hideParttime: true,
16
+ newly: 0,
17
+ },
18
+ },
19
+ department: {
20
+ path: '/api/hrm/common/browser/complete/department',
21
+ label: '部门',
22
+ targetTypes: [
23
+ { targetType: 2, when: '仅本部门' },
24
+ { targetType: 3, when: '「含下级/含子部门」' },
25
+ ],
26
+ body: { browserMultiple: true, virtualType: 'ALL', newly: 0 },
27
+ },
28
+ subcompany: {
29
+ path: '/api/hrm/common/browser/complete/subcompany',
30
+ label: '分部',
31
+ targetTypes: [
32
+ { targetType: 5, when: '仅本分部' },
33
+ { targetType: 6, when: '「含下级」' },
34
+ ],
35
+ body: { browserMultiple: true, virtualType: 'ALL', newly: 0 },
36
+ },
37
+ role: {
38
+ path: '/api/hrm/common/browser/complete/role',
39
+ label: '角色',
40
+ targetTypes: [{ targetType: 10, when: '角色(还需向用户确认 role_level 角色级别)' }],
41
+ body: { browserMultiple: true, newly: 0 },
42
+ },
43
+ position: {
44
+ path: '/api/hrm/common/browser/complete/position',
45
+ label: '岗位',
46
+ targetTypes: [
47
+ { targetType: 12, when: '岗位+指定部门(文档写明具体部门)' },
48
+ { targetType: 13, when: '岗位+指定分部(文档写明具体分部)' },
49
+ { targetType: 1311, when: '岗位+总部(默认,不限范围时用这个)' },
50
+ ],
51
+ body: { browserMultiple: true, newly: 0 },
52
+ },
53
+ };
54
+ /**
55
+ * hrm.resolve:按关键字搜索组织实体(人员/部门/分部/角色/岗位五合一个命令)。
56
+ * 搜索是模糊匹配;调用方应根据业务用途处理同名候选。
57
+ */
58
+ async function resolve(args, env) {
59
+ const entityType = String(args.entityType || '');
60
+ const spec = ENTITY_TYPES[entityType];
61
+ if (!spec) {
62
+ throw pfValidationError('entity_type_unknown', `不支持的实体类型:${entityType || '(空)'}。支持:${Object.keys(ENTITY_TYPES).join('/')}`, {
63
+ supported: Object.keys(ENTITY_TYPES),
64
+ });
65
+ }
66
+ const keyword = String(args.keyword ?? '').trim();
67
+ if (!keyword) {
68
+ throw pfValidationError('keyword_missing', '缺少搜索关键字 keyword');
69
+ }
70
+ const response = await env.host.request({
71
+ path: spec.path,
72
+ body: { ...spec.body, searchValue: keyword },
73
+ operation: 'performance.hrm.resolve',
74
+ });
75
+ const list = Array.isArray(response?.data?.data) ? response.data.data : [];
76
+ const candidates = list.map((item) => ({
77
+ id: item?.id,
78
+ name: item?.name ?? null,
79
+ title: item?.title ?? null,
80
+ contentDesc: item?.contentDesc ?? null,
81
+ statusCode: item?.statusCode ?? null,
82
+ }));
83
+ return pfSuccess('performance.hrm.resolve', {
84
+ entityType,
85
+ entityLabel: spec.label,
86
+ keyword,
87
+ candidateCount: candidates.length,
88
+ exactMatch: candidates.length === 1 && candidates[0]?.name === keyword ? candidates[0] : null,
89
+ candidates,
90
+ suggestedTargetTypes: spec.targetTypes,
91
+ usage: [
92
+ '命中唯一且 name 与文档名称完全一致 → 可直接采用其 id',
93
+ '考核范围已确定且多个候选名称完全一致 → 选返回顺序第一个,摘要展示名称、id 和范围;无精确匹配或具名评分人有歧义 → 请用户选择',
94
+ 'statusCode 非 normal 的人员候选标注状态,默认不选用',
95
+ 'id 为字符串;写入 SchemeEditReq 时按 targetType 组装 schemeLinkList 条目',
96
+ ],
97
+ });
98
+ }
99
+ export const hrmResolveOperations = [
100
+ {
101
+ name: 'performance.hrm.resolve',
102
+ resource: 'performance.hrm',
103
+ method: 'query',
104
+ action: 'hrm.resolve',
105
+ summary: '按关键字搜索组织实体(人员/部门/分部/角色/岗位),返回候选与建议 targetType',
106
+ capability: 'performance.hrm.resolve',
107
+ risk: 'read',
108
+ inputSchema: schemaOf({
109
+ entityType: { type: 'string', enum: Object.keys(ENTITY_TYPES), description: '实体类型:resource=人员/department=部门/subcompany=分部/role=角色/position=岗位' },
110
+ keyword: { type: 'string', description: '搜索关键字(模糊匹配)' },
111
+ }, { required: ['entityType', 'keyword'] }),
112
+ handler: resolve,
113
+ },
114
+ ];
@@ -0,0 +1,44 @@
1
+ import { PerformanceCliError } from '../errors.js';
2
+ import { schemeDraftOperations } from './scheme-draft.js';
3
+ import { schemePublishOperations } from './scheme-publish.js';
4
+ import { schemeDetailOperations } from './scheme-detail.js';
5
+ import { hrmResolveOperations } from './hrm-resolve.js';
6
+ const definitions = [
7
+ ...hrmResolveOperations,
8
+ ...schemeDetailOperations,
9
+ ...schemeDraftOperations,
10
+ ...schemePublishOperations,
11
+ ];
12
+ const registry = new Map();
13
+ for (const definition of definitions) {
14
+ if (registry.has(definition.name)) {
15
+ throw new Error(`duplicate performance operation: ${definition.name}`);
16
+ }
17
+ registry.set(definition.name, definition);
18
+ }
19
+ export function performanceOperationDefinitions() {
20
+ return [...registry.values()];
21
+ }
22
+ export function getPerformanceOperation(operation) {
23
+ const definition = registry.get(operation);
24
+ if (!definition) {
25
+ throw new PerformanceCliError('validation', 'operation_unknown', `绩效方案模块不支持操作:${operation}`, {
26
+ exitCode: 1,
27
+ });
28
+ }
29
+ return definition;
30
+ }
31
+ export async function executePerformanceOperation(operation, input, env) {
32
+ const definition = getPerformanceOperation(operation);
33
+ // 拒绝未声明参数:防「参数名写错被静默忽略」(与 recruit-stage 标准入口一致)。
34
+ const schema = definition.inputSchema;
35
+ if (schema && schema.additionalProperties === false) {
36
+ const known = Object.keys((schema.properties || {}));
37
+ const unknown = Object.keys(input || {}).filter((key) => !known.includes(key));
38
+ if (unknown.length > 0) {
39
+ throw new PerformanceCliError('validation', 'unknown_argument', `未知参数:${unknown.join('、')}。本操作支持的参数:${known.length ? known.join('、') : '(无)'}。`
40
+ + '参数名写错会被静默忽略并返回看似正常的结果,请按上面的参数名重传。', { exitCode: 1 });
41
+ }
42
+ }
43
+ return definition.handler(input, env);
44
+ }
@@ -0,0 +1,70 @@
1
+ import { pfValidationError } from '../errors.js';
2
+ import { assertWeaResult, normalizeId } from '../shared.js';
3
+ import { buildBonusPenaltyRows, buildIndicatorRows, describeTargets, summarizeScheme, TARGET_TYPE_LABELS } from '../scheme-validate.js';
4
+ import { pfSuccess, schemaOf } from './types.js';
5
+ const DETAIL_PATH = '/api/workrelate/performance/scheme/detail';
6
+ /**
7
+ * detail:回读方案(草稿态正常)。
8
+ * 返回精简核对视图(基本信息摘要 + 指标行数/权重合计 + 评分审批序列 + 缺失项提示 + detailId),
9
+ * 以及完整 data 原文(供 publish.prepare 组参或 Agent 深查;超大输出由全局 refs 机制接管)。
10
+ */
11
+ async function detail(args, env) {
12
+ if (args.id === undefined || args.id === null || args.id === '') {
13
+ throw pfValidationError('id_missing', '缺少方案 id');
14
+ }
15
+ const id = normalizeId(args.id, 'id');
16
+ const response = await env.host.request({
17
+ path: `${DETAIL_PATH}/${encodeURIComponent(id)}`,
18
+ method: 'GET',
19
+ operation: 'performance.scheme.detail',
20
+ });
21
+ const data = assertWeaResult(response, '读取方案详情');
22
+ if (!data || typeof data !== 'object') {
23
+ throw pfValidationError('detail_not_object', '方案详情返回 data 不是对象', { id });
24
+ }
25
+ const summary = summarizeScheme(data);
26
+ // 缺失项提示(服务端缺失项口径:常规指标/加减分项/评分人/审批人/生效日期是最常缺的五类)。
27
+ const missing = [];
28
+ if (!summary.indicatorCount)
29
+ missing.push('常规指标');
30
+ if (!summary.plusCount)
31
+ missing.push('加分项');
32
+ if (!summary.minusCount)
33
+ missing.push('减分项');
34
+ if (!summary.steps.length)
35
+ missing.push('评分/审批节点');
36
+ if (!summary.teffectTime)
37
+ missing.push('生效日期');
38
+ if (!data.detailId)
39
+ missing.push('detailId(异常:发布前必须先修复,见 publish.prepare)');
40
+ return pfSuccess('performance.scheme.detail', {
41
+ schemeId: String(id),
42
+ status: data.status ?? null,
43
+ applyStatus: data.applyStatus ?? null,
44
+ detailId: data.detailId === undefined || data.detailId === null ? null : String(data.detailId),
45
+ summary,
46
+ targets: describeTargets(data),
47
+ // 业务行:Agent 直接按此渲染表格,禁止只报计数
48
+ indicatorRows: buildIndicatorRows(data),
49
+ plusRows: buildBonusPenaltyRows(data, 'plus'),
50
+ minusRows: buildBonusPenaltyRows(data, 'minus'),
51
+ missing,
52
+ targetTypeLegend: TARGET_TYPE_LABELS,
53
+ data,
54
+ });
55
+ }
56
+ export const schemeDetailOperations = [
57
+ {
58
+ name: 'performance.scheme.detail',
59
+ resource: 'performance.scheme',
60
+ method: 'query',
61
+ action: 'scheme.detail',
62
+ summary: '回读方案详情(草稿态正常),返回精简核对视图 + 缺失项提示 + 完整原文',
63
+ capability: 'performance.scheme.detail',
64
+ risk: 'read',
65
+ inputSchema: schemaOf({
66
+ id: { type: 'string', description: '方案 id,字符串形式(18 位 Long 用数字会丢精度)' },
67
+ }, { required: ['id'] }),
68
+ handler: detail,
69
+ },
70
+ ];