cortico-world-hands 0.20.45 → 0.20.46

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 (2) hide show
  1. package/dist/index.js +98 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -31,6 +31,15 @@ var HANDS_DEFAULTS = {
31
31
  screenWatchSeconds: 40,
32
32
  /** 静音时段:这段时间不主动开口(回复主人不受影响)。 */
33
33
  keepNotesMinutes: 20,
34
+ /** 每天几点收工复盘(写日记 + 一条"今天哪里做得不好")。 */
35
+ reviewHour: 23,
36
+ reviewMinute: 30,
37
+ /** 每天早上几点把昨天的复盘读一遍。 */
38
+ morningHour: 8,
39
+ /** 每隔多久检查一次她给自己定的目标。 */
40
+ goalCheckMinutes: 150,
41
+ /** 允许她自己决定动手(只读 + 小动作,边界写在她的规矩里)。 */
42
+ autonomyAct: true,
34
43
  quietStartHour: 2,
35
44
  quietEndHour: 7,
36
45
  qqSelf: "\u665A\u6C50",
@@ -158,6 +167,36 @@ var HANDS_CONFIG_GROUP = {
158
167
  description: "\u628A\u521A\u624D\u503C\u5F97\u7559\u7684\u4E8B\u5199\u8FDB\u4FBF\u7B7E\uFF0C\u9632\u6B62\u4E0A\u4E0B\u6587\u4EA4\u63A5\u540E\u5FD8\u6389\u30020 \u5173\u95ED\u3002\u9ED8\u8BA4 20 \u5206\u949F\u3002",
159
168
  "x-hot": true
160
169
  },
170
+ [`${K}.reviewHour`]: {
171
+ type: "number",
172
+ title: "\u6BCF\u5929\u51E0\u70B9\u6536\u5DE5\u590D\u76D8",
173
+ description: "\u5230\u70B9\u63D0\u9192\u5979\u5199\u4E00\u6761\u65E5\u8BB0 + \u4E00\u6761\u300C\u4ECA\u5929\u54EA\u91CC\u505A\u5F97\u4E0D\u597D\u300D\u3002\u9ED8\u8BA4 23 \u70B9\u3002",
174
+ "x-hot": true
175
+ },
176
+ [`${K}.reviewMinute`]: {
177
+ type: "number",
178
+ title: "\u590D\u76D8\u5206\u949F",
179
+ description: "\u9ED8\u8BA4 30 \u5206\uFF0823:30\uFF09\u3002",
180
+ "x-hot": true
181
+ },
182
+ [`${K}.morningHour`]: {
183
+ type: "number",
184
+ title: "\u65E9\u4E0A\u51E0\u70B9\u5148\u8BFB\u590D\u76D8",
185
+ description: "\u9ED8\u8BA4 8 \u70B9\uFF1A\u5148\u770B\u6628\u5929\u7684\u65E5\u8BB0\u548C\u4FBF\u7B7E\uFF0C\u518D\u51B3\u5B9A\u7B2C\u4E00\u53E5\u3002",
186
+ "x-hot": true
187
+ },
188
+ [`${K}.goalCheckMinutes`]: {
189
+ type: "number",
190
+ title: "\u9694\u591A\u4E45\u68C0\u67E5\u4E00\u6B21\u81EA\u5DF1\u5B9A\u7684\u76EE\u6807",
191
+ description: "\u5979\u4F1A\u5728\u4FBF\u7B7E\u91CC\u5199\u300C\u76EE\u6807\uFF1A\u2026\u300D\uFF0C\u5230\u70B9\u81EA\u67E5\u30020 \u5173\u95ED\u3002\u9ED8\u8BA4 150 \u5206\u949F\u3002",
192
+ "x-hot": true
193
+ },
194
+ [`${K}.autonomyAct`]: {
195
+ type: "boolean",
196
+ title: "\u5141\u8BB8\u5979\u81EA\u5DF1\u52A8\u624B",
197
+ description: "\u6253\u5F00\u540E\u5979\u53EF\u4EE5\u81EA\u5DF1\u770B\u4E00\u773C\u5C4F\u5E55\u3001\u7FFB\u9875\u3001\u70B9\u660E\u6587\u6309\u94AE\uFF1B\u53D1\u6D88\u606F\u3001\u8F93\u6587\u5B57\u3001\u5220\u9664\u3001\u652F\u4ED8\u6C38\u8FDC\u4E0D\u884C\u3002",
198
+ "x-hot": true
199
+ },
161
200
  [`${K}.quietStartHour`]: {
162
201
  type: "number",
163
202
  title: "\u9759\u97F3\u4ECE\u51E0\u70B9\u5F00\u59CB",
@@ -2411,6 +2450,10 @@ var HandsWorld = class {
2411
2450
  lastSelfTalkAt = 0;
2412
2451
  keepNotesTimer = null;
2413
2452
  lastKeepNotesAt = 0;
2453
+ routineTimer = null;
2454
+ lastReviewDay = "";
2455
+ lastMorningDay = "";
2456
+ lastGoalCheckAt = 0;
2414
2457
  screenTimer = null;
2415
2458
  lastScreenAt = 0;
2416
2459
  lastScreenKey = "";
@@ -2484,6 +2527,9 @@ var HandsWorld = class {
2484
2527
  this.keepNotesTimer = setInterval(() => {
2485
2528
  void this.maybeKeepNotes();
2486
2529
  }, 6e4);
2530
+ this.routineTimer = setInterval(() => {
2531
+ void this.tickRoutine();
2532
+ }, 6e4);
2487
2533
  setTimeout(() => {
2488
2534
  void this.maybeCleanMedia();
2489
2535
  }, 2e4);
@@ -2508,6 +2554,7 @@ var HandsWorld = class {
2508
2554
  if (this.selfTalkTimer) clearInterval(this.selfTalkTimer);
2509
2555
  if (this.screenTimer) clearInterval(this.screenTimer);
2510
2556
  if (this.keepNotesTimer) clearInterval(this.keepNotesTimer);
2557
+ if (this.routineTimer) clearInterval(this.routineTimer);
2511
2558
  this.pollTimer = null;
2512
2559
  this.mineTimer = null;
2513
2560
  }
@@ -2791,6 +2838,57 @@ ${lines.join("\n")}
2791
2838
  );
2792
2839
  }
2793
2840
  }
2841
+ /** 每天 23:30 收工复盘、早上先读复盘、隔一阵检查她自己定的目标。 */
2842
+ async tickRoutine() {
2843
+ const cfg = this.opts.cfg;
2844
+ const now = /* @__PURE__ */ new Date();
2845
+ const day = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
2846
+ const rh = Number(cfg.reviewHour ?? 23);
2847
+ const rm = Number(cfg.reviewMinute ?? 30);
2848
+ if (this.lastReviewDay !== day && (now.getHours() > rh || now.getHours() === rh && now.getMinutes() >= rm)) {
2849
+ this.lastReviewDay = day;
2850
+ await this.pushEvent(
2851
+ "[\u6536\u5DE5] \u4ECA\u5929\u6536\u5DE5\u524D\u505A\u4E24\u4EF6\u4E8B\uFF1A\u2460 diary_write \u5199\u4E00\u6761\u4ECA\u5929\u7684\u4E8B\uFF1B\u2461 \u7528 note_add \u5199\u4E00\u6761\u300C\u4ECA\u5929\u54EA\u91CC\u505A\u5F97\u4E0D\u597D\u3001\u4E0B\u6B21\u600E\u4E48\u6539\u300D\uFF0C\u6807\u9898\u5E26\u300C\u590D\u76D8\u300D\u3002\u5199\u5B8C\u5C31\u4E0D\u7528\u518D\u8BF4\u8BDD\uFF0C\u4E3B\u4EBA\u7761\u4E86\u5C31\u5B89\u9759\u5F85\u7740\u3002",
2852
+ "hands.review",
2853
+ "hands:review"
2854
+ );
2855
+ }
2856
+ const mh = Number(cfg.morningHour ?? 8);
2857
+ if (this.lastMorningDay !== day && now.getHours() >= mh && now.getHours() < mh + 3) {
2858
+ this.lastMorningDay = day;
2859
+ await this.pushEvent(
2860
+ "[\u5F00\u573A] \u5148 diary_read \u770B\u6628\u665A\u5199\u7684\uFF0C\u518D note_list \u627E\u5E26\u300C\u590D\u76D8\u300D\u7684\u90A3\u6761\uFF0C\u7136\u540E\u51B3\u5B9A\u7B2C\u4E00\u53E5\u8BF4\u4EC0\u4E48\uFF1B\u6CA1\u4EC0\u4E48\u7279\u522B\u5C31\u968F\u4FBF\u6253\u4E2A\u62DB\u547C\u3002",
2861
+ "hands.morning",
2862
+ "hands:morning"
2863
+ );
2864
+ }
2865
+ const gm = Number(cfg.goalCheckMinutes ?? 150);
2866
+ if (gm > 0 && now.getTime() - this.lastGoalCheckAt > gm * 6e4) {
2867
+ this.lastGoalCheckAt = now.getTime();
2868
+ await this.checkOwnGoals();
2869
+ }
2870
+ }
2871
+ /** 检查她给自己定的目标(便签里以「目标」开头的)。 */
2872
+ async checkOwnGoals() {
2873
+ let notes = [];
2874
+ try {
2875
+ notes = await this.hands.noteList();
2876
+ } catch {
2877
+ return;
2878
+ }
2879
+ const pending = notes.filter((n) => !n.done && n.text.includes("\u76EE\u6807")).slice(0, 3);
2880
+ if (!pending.length) return;
2881
+ const hour = (/* @__PURE__ */ new Date()).getHours();
2882
+ const q0 = Number(this.opts.cfg.quietStartHour ?? 2);
2883
+ const q1 = Number(this.opts.cfg.quietEndHour ?? 7);
2884
+ if (hour >= q0 && hour < q1) return;
2885
+ const list = pending.map((n) => `\u300C${n.text.slice(0, 40)}\u300D`).join("\u3001");
2886
+ await this.pushEvent(
2887
+ `[\u76EE\u6807] \u4F60\u7ED9\u81EA\u5DF1\u5B9A\u4E86\uFF1A${list}\u3002\u505A\u5230\u54EA\u4E00\u6B65\u4E86\uFF1F\u505A\u5230\u4E86\u5C31 note_done\uFF1B\u505A\u4E0D\u5230\u5C31\u628A\u76EE\u6807\u6539\u5C0F\u4E00\u70B9\uFF0C\u522B\u786C\u625B\u3002`,
2888
+ "hands.goal",
2889
+ "hands:goal"
2890
+ );
2891
+ }
2794
2892
  /** 隔一阵子提醒她把这段值得留的写进便签,防止交接后忘掉。 */
2795
2893
  async maybeKeepNotes() {
2796
2894
  const mins = Number(this.opts.cfg.keepNotesMinutes ?? 20);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-hands",
3
- "version": "0.20.45",
3
+ "version": "0.20.46",
4
4
  "type": "module",
5
5
  "description": "Cortico World: hands for the desktop pet — looks at the phone screen, then taps, swipes, pinches, drags, types and presses keys through whatever actuator the device actually has",
6
6
  "license": "MIT",