@petercjl/ecom-cli 0.3.0 → 0.3.1

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/capabilities.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "package": "@petercjl/ecom-cli",
4
- "version": "0.3.0",
4
+ "version": "0.3.1",
5
5
  "skills": [
6
6
  "ecom-cli"
7
7
  ],
@@ -5,6 +5,16 @@ import crypto from 'node:crypto';
5
5
  import {spawnSync} from 'node:child_process';
6
6
  import {root,pkg,fail,exists,tree,writeNew} from './common.mjs';
7
7
  const receiptName='.ecom-receipt.json';
8
+ const runtimeNames=['package.json','capabilities.json','bin','lib','scripts','skills','README.md','INSTALL.md','UPDATE.md','LICENSE'];
9
+ function runtimeFiles(base) {
10
+ const files={};
11
+ for(const name of runtimeNames) {
12
+ const item=path.join(base,name);
13
+ if(fs.lstatSync(item).isDirectory())Object.assign(files,tree(item,name+'/'));
14
+ else files[name]=crypto.createHash('sha256').update(fs.readFileSync(item)).digest('hex');
15
+ }
16
+ return files;
17
+ }
8
18
  function legacyBackup(target,backup) {
9
19
  return typeof backup==='string'&&path.dirname(backup)===path.dirname(target)&&path.basename(backup).startsWith(path.basename(target)+'.ecom-backup-')&&exists(backup);
10
20
  }
@@ -39,8 +49,10 @@ export function status(options,base=root) {
39
49
  const files=installed?tree(target):{}, old=managed?receipt.files:{}, edited=managed && JSON.stringify(files)!==JSON.stringify(old);
40
50
  const identity=source(base), canonical=tree(identity.path);
41
51
  const canonicalCurrent=managed && Object.entries(canonical).every(([name,hash])=>files[name]===hash) && Object.keys(files).filter(n=>!n.startsWith('.runtime/')).length===Object.keys(canonical).length;
52
+ const canonicalRuntime=runtimeFiles(base);
53
+ const runtimeCurrent=managed&&Object.entries(canonicalRuntime).every(([name,hash])=>files['.runtime/'+name]===hash)&&Object.keys(files).filter(n=>n.startsWith('.runtime/')).length===Object.keys(canonicalRuntime).length;
42
54
  let runtimeVersion;try{runtimeVersion=JSON.parse(fs.readFileSync(path.join(target,'.runtime/package.json'),'utf8')).version;}catch{}
43
- const current=!!(managed&&!edited&&canonicalCurrent&&runtimeVersion===identity.version&&receipt.version===identity.version);
55
+ const current=!!(managed&&!edited&&canonicalCurrent&&runtimeCurrent&&runtimeVersion===identity.version&&receipt.version===identity.version);
44
56
  const layoutRecovery=managed&&legacyBackup(target,receipt.backup);
45
57
  return {...identity,target,installed,managed,current,edited:!!edited,adapter:'generic',agent:options.agent,entry:path.join(target,'.runtime/bin/ecom-cli.mjs'),verification:{verified:current,algorithm:'sha256'},recovery:{required:installed&&(!current||layoutRecovery),action:edited?'Preserve local edits; reconcile them before update':layoutRecovery?'Run skill update using this new entry to relocate legacy backups outside host discovery':'Run skill update for this exact target'},hostDiscovery:{authority:'host',verified:false},...(managed?{installedVersion:receipt.version,backup:receipt.backup??null,migratedBackups:receipt.migratedBackups??[]}:{})};
46
58
  }
@@ -61,7 +73,7 @@ export function installSkill(options,base=root) {
61
73
  tree(base);
62
74
  fs.cpSync(source(base).path,staging,{recursive:true,errorOnExist:true,force:false});
63
75
  const runtime=path.join(staging,'.runtime');fs.mkdirSync(runtime);
64
- for(const name of ['package.json','capabilities.json','bin','lib','scripts','skills','README.md','INSTALL.md','UPDATE.md','LICENSE']) {
76
+ for(const name of runtimeNames) {
65
77
  fs.cpSync(path.join(base,name),path.join(runtime,name),{recursive:true,errorOnExist:true,force:false});
66
78
  }
67
79
  const manifest=source(base);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@petercjl/ecom-cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Agent CLI and portable Skill for Ecom browser containers",
5
5
  "type": "module",
6
6
  "license": "MPL-2.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@petercjl/ecom-cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "private": true,
5
5
  "type": "module"
6
6
  }