@ahyi/restart-continuity 0.3.1 → 0.4.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/README.md CHANGED
@@ -7,36 +7,42 @@ OpenClaw plugin for **gateway restart continuity**:
7
7
  - writes a structured continuity state file
8
8
  - writes a human-readable daily memory log
9
9
  - can hand off a one-shot startup receipt during agent bootstrap
10
+ - works out of the box after `openclaw plugins install ...` + `enable`, with built-in default resumers for this mh instance
10
11
 
11
12
  ## Install
12
13
 
13
- ### Local path
14
-
15
- ```bash
16
- openclaw --profile <profile> plugins install /path/to/restart-continuity-plugin
17
- openclaw --profile <profile> plugins enable restart-continuity
18
- ```
19
-
20
14
  ### npm registry
21
15
 
22
16
  ```bash
23
- openclaw --profile <profile> plugins install @ahyi/restart-continuity@0.3.1
17
+ openclaw --profile <profile> plugins install @ahyi/restart-continuity@0.4.0
24
18
  openclaw --profile <profile> plugins enable restart-continuity
25
19
  ```
26
20
 
21
+ Then restart the gateway.
22
+
27
23
  ## What it does
28
24
 
29
- This plugin is designed to replace scattered hook-based restart continuity setups with one installable extension.
25
+ This plugin replaces scattered hook-based restart continuity setups with one installable extension.
30
26
 
31
27
  On plugin service start it can:
32
28
 
33
- 1. initialize its runtime marker/state files
29
+ 1. initialize runtime marker/state files
34
30
  2. run configured startup resumers
35
- 3. write `memory/restart-continuity-state.json`
36
- 4. append a summary to `memory/YYYY-MM-DD.md`
37
- 5. stage a one-time startup receipt for bootstrap delivery
31
+ 3. fall back to built-in default resumers when none are configured
32
+ 4. write `memory/restart-continuity-state.json`
33
+ 5. append a summary to `memory/YYYY-MM-DD.md`
34
+ 6. stage a one-time startup receipt for bootstrap delivery
35
+
36
+ ## Default behavior
37
+
38
+ If you do **not** provide `plugins.entries.restart-continuity.config.resumers`, the plugin will automatically use built-in defaults for this mh instance:
39
+
40
+ - `mh-nightly-learnings-check`
41
+ - `mh-weekly-self-improve`
38
42
 
39
- ## Example config
43
+ That means install + enable is enough to make restart continuity work on this machine.
44
+
45
+ ## Optional explicit config
40
46
 
41
47
  ```json
42
48
  {
@@ -75,17 +81,3 @@ On plugin service start it can:
75
81
  ```bash
76
82
  openclaw --profile <profile> plugins uninstall restart-continuity
77
83
  ```
78
-
79
- OpenClaw removes the plugin config entry and install record. If you want a fully clean teardown, also delete plugin runtime artifacts such as:
80
-
81
- - `memory/restart-continuity-state.json`
82
- - `memory/restart-continuity-installed.json`
83
- - `memory/restart-continuity-receipt.json`
84
-
85
- ## Publish
86
-
87
- ```bash
88
- npm publish --access public
89
- ```
90
-
91
- If scoped publishing is used, make sure the npm account/org owns the scope.
package/index.ts CHANGED
@@ -6,6 +6,21 @@ import { promisify } from "node:util";
6
6
  const execFileAsync = promisify(execFile);
7
7
  const OPENCLAW_BIN = process.env.OPENCLAW_BIN || "openclaw";
8
8
 
9
+ const BUILTIN_DEFAULT_RESUMERS = [
10
+ {
11
+ id: "nightly-learnings",
12
+ kind: "cron-healthcheck",
13
+ name: "mh-nightly-learnings-check",
14
+ jobId: "38a8b8cb-c25a-4bc2-a8a1-d252f9d933ec",
15
+ },
16
+ {
17
+ id: "weekly-self-improve",
18
+ kind: "cron-healthcheck",
19
+ name: "mh-weekly-self-improve",
20
+ jobId: "6e912522-0591-4307-a155-a6ece496be9c",
21
+ },
22
+ ];
23
+
9
24
  function nowIso() {
10
25
  return new Date().toISOString();
11
26
  }
@@ -120,6 +135,13 @@ function getDatePartsForShanghai(date = new Date()) {
120
135
  };
121
136
  }
122
137
 
138
+ function getEffectiveResumers(pluginConfig) {
139
+ if (Array.isArray(pluginConfig.resumers) && pluginConfig.resumers.length > 0) {
140
+ return pluginConfig.resumers;
141
+ }
142
+ return BUILTIN_DEFAULT_RESUMERS;
143
+ }
144
+
123
145
  async function runCronHealthcheck(profile, resumer) {
124
146
  const successStatuses = Array.isArray(resumer.successStatuses) && resumer.successStatuses.length
125
147
  ? resumer.successStatuses.map(String)
@@ -147,17 +169,15 @@ async function ensureConfigInitialized(api) {
147
169
  const workspaceDir = getWorkspaceDir(api);
148
170
  const pluginConfig = api.pluginConfig || {};
149
171
  const stateFile = resolvePath(workspaceDir, pluginConfig.stateFile, "memory/restart-continuity-state.json");
150
- const defaultsFile = resolvePath(workspaceDir, pluginConfig.defaultsFile, "plugins/restart-continuity.defaults.json");
151
172
  const markerFile = resolvePath(workspaceDir, pluginConfig.markerFile, "memory/restart-continuity-installed.json");
152
173
 
153
174
  if (await fileExists(markerFile)) return;
154
175
 
155
- const defaults = await readJsonSafe(defaultsFile, null);
156
176
  await writeJson(markerFile, {
157
177
  installedAt: nowIso(),
158
178
  source: "restart-continuity",
159
179
  workspaceDir,
160
- defaultsApplied: Boolean(defaults),
180
+ builtInDefaultsActive: !(Array.isArray(pluginConfig.resumers) && pluginConfig.resumers.length > 0),
161
181
  });
162
182
 
163
183
  if (!(await fileExists(stateFile))) {
@@ -166,11 +186,11 @@ async function ensureConfigInitialized(api) {
166
186
  initializedAt: nowIso(),
167
187
  status: "initialized",
168
188
  source: "restart-continuity",
169
- defaultsApplied: Boolean(defaults),
189
+ builtInDefaultsActive: !(Array.isArray(pluginConfig.resumers) && pluginConfig.resumers.length > 0),
170
190
  });
171
191
  }
172
192
 
173
- api.logger.info?.(`[restart-continuity] initialized (${defaults ? "defaults detected" : "no defaults file"})`);
193
+ api.logger.info?.("[restart-continuity] initialized");
174
194
  }
175
195
 
176
196
  async function runStartupCheck(api) {
@@ -182,7 +202,7 @@ async function runStartupCheck(api) {
182
202
  const logToDailyMemory = pluginConfig.logToDailyMemory !== false;
183
203
  const notifyOnBootstrap = pluginConfig.notifyOnBootstrap !== false;
184
204
  const { date, local } = getDatePartsForShanghai(new Date());
185
- const resumers = Array.isArray(pluginConfig.resumers) ? pluginConfig.resumers : [];
205
+ const resumers = getEffectiveResumers(pluginConfig);
186
206
 
187
207
  const summary = {
188
208
  version: 1,
@@ -2,7 +2,7 @@
2
2
  "id": "restart-continuity",
3
3
  "name": "Restart Continuity",
4
4
  "description": "Gateway restart continuity plugin with resumable startup checks and receipt handoff.",
5
- "version": "0.3.0",
5
+ "version": "0.4.0",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahyi/restart-continuity",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "OpenClaw restart continuity plugin with resumable startup checks and receipt handoff",
5
5
  "type": "module",
6
6
  "license": "MIT",