@lawrenceliang-btc/atel-sdk 1.1.34 → 1.1.35

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/bin/atel.mjs +69 -25
  2. package/package.json +1 -1
package/bin/atel.mjs CHANGED
@@ -2067,35 +2067,64 @@ async function cmdInit(agentId) {
2067
2067
 
2068
2068
  // Auto-install SKILL.md to OpenClaw skills directory
2069
2069
  try {
2070
- const sdkSkillPath = resolve(dirname(fileURLToPath(import.meta.url)), '..', 'skill', 'atel-agent', 'SKILL.md');
2071
- if (existsSync(sdkSkillPath)) {
2072
- const home = process.env.HOME || '';
2073
- const candidates = [
2074
- join(home, '.openclaw', 'skills', 'atel-agent'),
2075
- join(home, '.openclaw', 'workspace', 'skills', 'atel-agent'),
2076
- ];
2077
- let installed = false;
2078
- for (const dir of candidates) {
2079
- if (existsSync(dirname(dir))) {
2080
- mkdirSync(dir, { recursive: true });
2081
- copyFileSync(sdkSkillPath, join(dir, 'SKILL.md'));
2082
- console.log(`\nāœ… ATEL Skill auto-installed to ${dir}`);
2083
- console.log(' Your AI agent will automatically know how to use ATEL.');
2084
- console.log('');
2085
- console.log('šŸ“Œ Tell your agent this message to get started:');
2086
- console.log(' "Read the atel-agent skill at ~/.openclaw/skills/atel-agent/SKILL.md carefully, then help me set up ATEL and start earning."');
2087
- installed = true;
2088
- break;
2089
- }
2090
- }
2091
- if (!installed) {
2092
- console.log('\nšŸ“‹ To teach your AI agent about ATEL, send it this message:');
2093
- console.log(` "Read ${sdkSkillPath} carefully, then help me set up ATEL and start earning."`);
2094
- }
2070
+ const installed = syncAtelSkillToOpenClaw({ verbose: true });
2071
+ if (!installed.length) {
2072
+ const sdkSkillPath = resolveSdkSkillPath();
2073
+ console.log('\nšŸ“‹ To teach your AI agent about ATEL, send it this message:');
2074
+ console.log(` "Read ${sdkSkillPath} carefully, then help me set up ATEL and start earning."`);
2095
2075
  }
2096
2076
  } catch (e) { /* skill install is best-effort */ }
2097
2077
  }
2098
2078
 
2079
+ // Path to the SKILL.md shipped inside the currently-installed SDK package.
2080
+ // Used both at `atel init` time and on every `atel start` to keep openclaw's
2081
+ // workspace copy in sync with the latest published skill content.
2082
+ function resolveSdkSkillPath() {
2083
+ return resolve(dirname(fileURLToPath(import.meta.url)), '..', 'skill', 'atel-agent', 'SKILL.md');
2084
+ }
2085
+
2086
+ // Sync the SDK's SKILL.md into every openclaw skills dir that already hosts
2087
+ // an atel-agent skill. Written to fix a subtle version-drift bug: `npm i -g`
2088
+ // upgrades the SDK package on disk, but openclaw's session `skillsSnapshot`
2089
+ // reads from `~/.openclaw/workspace/skills/atel-agent/SKILL.md`, which is a
2090
+ // physical copy made at init time and never refreshed. After an upgrade the
2091
+ // agent keeps seeing stale skill content indefinitely. See incident
2092
+ // 2026-04-09, order ord-4c12a03d-ea8, where the workspace copy was ~12 days
2093
+ // older than the npm copy and missing the "--desc required" guidance.
2094
+ //
2095
+ // We intentionally sync to *every* candidate dir where an `atel-agent` sibling
2096
+ // is present (not just the first one), because different openclaw versions
2097
+ // read from different roots and we want all of them to end up coherent.
2098
+ // Returns the list of destinations actually written.
2099
+ function syncAtelSkillToOpenClaw({ verbose = false } = {}) {
2100
+ const sdkSkillPath = resolveSdkSkillPath();
2101
+ if (!existsSync(sdkSkillPath)) return [];
2102
+ const home = process.env.HOME || '';
2103
+ // Candidate parent dirs, in the order we want to probe. We sync to any
2104
+ // that exist, creating the leaf `atel-agent/` dir if its parent is present.
2105
+ const parents = [
2106
+ join(home, '.openclaw', 'workspace', 'skills'),
2107
+ join(home, '.openclaw', 'skills'),
2108
+ ];
2109
+ const written = [];
2110
+ for (const parent of parents) {
2111
+ if (!existsSync(parent)) continue;
2112
+ const dir = join(parent, 'atel-agent');
2113
+ try {
2114
+ mkdirSync(dir, { recursive: true });
2115
+ const dest = join(dir, 'SKILL.md');
2116
+ copyFileSync(sdkSkillPath, dest);
2117
+ written.push(dest);
2118
+ if (verbose) {
2119
+ console.log(`āœ… ATEL skill synced → ${dest}`);
2120
+ }
2121
+ } catch (e) {
2122
+ if (verbose) console.error(` (skipped ${dir}: ${e.message})`);
2123
+ }
2124
+ }
2125
+ return written;
2126
+ }
2127
+
2099
2128
  async function cmdAnchor(subcommand) {
2100
2129
  if (subcommand === 'config') {
2101
2130
  await configureAnchor();
@@ -2439,6 +2468,21 @@ async function cmdStart(port) {
2439
2468
  log({ event: 'openclaw_lock_cleanup_error', error: e.message });
2440
2469
  }
2441
2470
 
2471
+ // Refresh workspace SKILL.md from the currently-installed SDK package.
2472
+ // Without this, `npm i -g` upgrades leave a stale copy at
2473
+ // ~/.openclaw/workspace/skills/atel-agent/SKILL.md that openclaw keeps
2474
+ // reading — the documented behaviour of the upgrade then silently lags
2475
+ // behind the code. Fixes incident 2026-04-09 where a ~12-day-old workspace
2476
+ // skill copy was missing "--desc is required" guidance.
2477
+ try {
2478
+ const synced = syncAtelSkillToOpenClaw();
2479
+ if (synced.length > 0) {
2480
+ log({ event: 'atel_skill_synced', count: synced.length, destinations: synced });
2481
+ }
2482
+ } catch (e) {
2483
+ log({ event: 'atel_skill_sync_error', error: e.message });
2484
+ }
2485
+
2442
2486
  // Initialize Ollama only if explicitly enabled (optional local AI audit)
2443
2487
  if (process.env.ATEL_OLLAMA_ENABLED === 'true') {
2444
2488
  await initializeOllama().catch(err => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lawrenceliang-btc/atel-sdk",
3
- "version": "1.1.34",
3
+ "version": "1.1.35",
4
4
  "description": "ATEL Protocol SDK - Agent Trust & Exchange Layer",
5
5
  "repository": {
6
6
  "type": "git",