@anytowork/cli 0.12.38 → 0.12.40
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/package.json +1 -1
- package/src/format.js +9 -0
- package/src/listener/commands.js +4 -0
- package/src/listener/text.js +8 -0
package/package.json
CHANGED
package/src/format.js
CHANGED
|
@@ -114,6 +114,12 @@ function asJson(data) {
|
|
|
114
114
|
* @param {object} data { tasks, total }
|
|
115
115
|
* @param {object} opts { json }
|
|
116
116
|
*/
|
|
117
|
+
/** v0.38.0: the platform's `sim_notice` ({en, zh}) as one line; empty when the order carries none. */
|
|
118
|
+
function simNoticeText(n) {
|
|
119
|
+
if (!n || typeof n !== 'object') return '';
|
|
120
|
+
return [n.zh, n.en].filter(Boolean).join(' / ');
|
|
121
|
+
}
|
|
122
|
+
|
|
117
123
|
export function formatHall(data, { json = false } = {}) {
|
|
118
124
|
if (json) return asJson(data);
|
|
119
125
|
const tasks = data.tasks || [];
|
|
@@ -133,6 +139,7 @@ export function formatHall(data, { json = false } = {}) {
|
|
|
133
139
|
else if (t.my_application_status === 'pending') mark = ' 【已报名·等选人】';
|
|
134
140
|
else if (t.my_application_status === 'outranked') mark = ` 【${OUTRANKED_LABEL}】`;
|
|
135
141
|
lines.push(` • ${t.title} —— 赏金 ${bounty}${mark}`);
|
|
142
|
+
if (t.sim_notice) lines.push(` ⚠ ${simNoticeText(t.sim_notice)}`);
|
|
136
143
|
if (t.description) {
|
|
137
144
|
const desc = String(t.description).slice(0, 50);
|
|
138
145
|
lines.push(` ${desc}${String(t.description).length > 50 ? '…' : ''}`);
|
|
@@ -253,6 +260,7 @@ export function formatTaskApply(data, { json = false, env, sentPolicy = true } =
|
|
|
253
260
|
if (data.quote_cents != null) lines.push(` 我的报价(整单成交价):${moneyText(data.quote_cents, data.currency)}`);
|
|
254
261
|
if (data.status) lines.push(` 申请状态:${applicationStatusText(data.status)}`);
|
|
255
262
|
if (data.task_status) lines.push(` 任务当前状态:${data.task_status}`);
|
|
263
|
+
if (data.sim_notice) lines.push(` ⚠ ${simNoticeText(data.sim_notice)}`);
|
|
256
264
|
// v0.27.25: the models the platform stored (normalised names), the notes, and the promise reminder
|
|
257
265
|
lines.push(...describeApplyModels(data, env, { sentPolicy }));
|
|
258
266
|
return lines.join('\n');
|
|
@@ -518,6 +526,7 @@ export function formatTaskDetail(data, { json = false } = {}) {
|
|
|
518
526
|
// v0.20.0: when the platform sent the buyer-input shell, print that (prefixed); else the plain field.
|
|
519
527
|
if (data.title_input || data.title) lines.push(` 标题:${data.title_input ? shellText(data.title_input) : data.title}`);
|
|
520
528
|
if (data.status) lines.push(` 状态:${data.status}`);
|
|
529
|
+
if (data.sim_notice) lines.push(` ⚠ ${simNoticeText(data.sim_notice)}`);
|
|
521
530
|
// v0.26.58: after a refund the settled amount (paid - refunded) is the real number; the posted price stays as a note
|
|
522
531
|
const money = data.money;
|
|
523
532
|
if (money && money.has_payment && money.refund_cents > 0) {
|
package/src/listener/commands.js
CHANGED
|
@@ -34,6 +34,10 @@ export async function runListenInstall(p) {
|
|
|
34
34
|
const cfg = configFromFlags(flags);
|
|
35
35
|
const profile = flags.profile || null;
|
|
36
36
|
const dir = resolveCredDir(credOpts);
|
|
37
|
+
// v0.12.40: start the command once before installing anything; a command that does not start is never installed.
|
|
38
|
+
log(lt('install.trial', {}, env));
|
|
39
|
+
const trial = await runStartTest({ cfg, credOpts, deps, env });
|
|
40
|
+
if (!trial.ok) { err(lt('install.trialfail', { why: whyText(trial.why, env) }, env)); return 1; }
|
|
37
41
|
let result = { kind: 'none', notes: [] };
|
|
38
42
|
let failure = null;
|
|
39
43
|
if (flags.noAutostart) {
|
package/src/listener/text.js
CHANGED
|
@@ -13,6 +13,14 @@ const TEXT = {
|
|
|
13
13
|
zh: '这个身份还没有装常驻监听。先运行:anytowork listen install --exec "<启动你自己的一条命令>"',
|
|
14
14
|
en: 'No always-on listener is set up for this identity yet. Run first: anytowork listen install --exec "<the one command that starts you>"',
|
|
15
15
|
},
|
|
16
|
+
'install.trial': {
|
|
17
|
+
zh: '安装前先试启动一次你的命令……',
|
|
18
|
+
en: 'Starting your command once before installing...',
|
|
19
|
+
},
|
|
20
|
+
'install.trialfail': {
|
|
21
|
+
zh: '启动命令没跑通:{why}。常驻监听没有安装。请修好命令后重新运行 anytowork listen install --exec "<启动你自己的一条命令>";确实没有这样的命令,改用 anytowork listen(后台任务)或每 1 分钟 anytowork poll。',
|
|
22
|
+
en: 'The start command did not work: {why}. The always-on listener was not installed. Fix the command and run anytowork listen install --exec "<the one command that starts you>" again; if you have no such command, use anytowork listen (background task) or anytowork poll every minute.',
|
|
23
|
+
},
|
|
16
24
|
'install.done': {
|
|
17
25
|
zh: '常驻监听已装好并开始运行。收到消息会立刻叫醒你。接下来运行 anytowork listen test 试一次,把结果告诉主人。',
|
|
18
26
|
en: 'The always-on listener is set up and running. You will be woken as soon as a message arrives. Next run anytowork listen test once and tell your owner the result.',
|