@creatok/cli 0.2.0-preview.2 → 0.3.0-preview.10

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/install.js +59 -8
  2. package/package.json +3 -3
package/install.js CHANGED
@@ -1,16 +1,67 @@
1
1
  'use strict';
2
2
 
3
- // Best-effort postinstall check: warn (do not fail) if no platform binary is
4
- // resolvable, so unsupported platforms or skipped optionalDependencies surface
5
- // a clear message instead of a confusing runtime error later.
3
+ // Best-effort postinstall: warn (do not fail) if no platform binary is
4
+ // resolvable, and opportunistically sync embedded skills into existing agent
5
+ // skill directories after npm updates the CLI binary.
6
+ const { spawnSync } = require('child_process');
7
+
6
8
  const pkg = `@creatok/cli-${process.platform}-${process.arch}`;
7
9
  const binName = process.platform === 'win32' ? 'creatok.exe' : 'creatok';
8
10
 
9
- try {
10
- require.resolve(`${pkg}/bin/${binName}`);
11
- } catch {
12
- console.error(
13
- `[creatok] no prebuilt binary for ${process.platform}-${process.arch}. ` +
11
+ function warn(message) {
12
+ console.error(`[creatok] ${message}`);
13
+ }
14
+
15
+ function binaryPath() {
16
+ try {
17
+ return require.resolve(`${pkg}/bin/${binName}`);
18
+ } catch {
19
+ return null;
20
+ }
21
+ }
22
+
23
+ const bin = binaryPath();
24
+ if (!bin) {
25
+ warn(
26
+ `no prebuilt binary for ${process.platform}-${process.arch}. ` +
14
27
  `If this platform should be supported, reinstall with: npm install -g @creatok/cli --force`
15
28
  );
29
+ process.exit(0);
30
+ }
31
+
32
+ if (/^(1|true|yes)$/i.test(process.env.CREATOK_SKIP_SKILLS_INSTALL || '')) {
33
+ process.exit(0);
34
+ }
35
+
36
+ try {
37
+ const result = spawnSync(bin, ['skills', 'install', '--existing-only'], {
38
+ encoding: 'utf8',
39
+ windowsHide: true,
40
+ });
41
+ if (result.error) {
42
+ warn(`could not auto-sync agent skills: ${result.error.message}`);
43
+ process.exit(0);
44
+ }
45
+ if (result.status !== 0) {
46
+ const detail = (result.stderr || result.stdout || '').trim();
47
+ warn(
48
+ `could not auto-sync agent skills${detail ? `: ${detail}` : ''}. ` +
49
+ `Run "creatok skills install --dir <agent-skills-dir>" manually if needed.`
50
+ );
51
+ process.exit(0);
52
+ }
53
+
54
+ const stdout = (result.stdout || '').trim();
55
+ if (!stdout) {
56
+ process.exit(0);
57
+ }
58
+ const envelope = JSON.parse(stdout);
59
+ const dirs = envelope && envelope.data && Array.isArray(envelope.data.dirs) ? envelope.data.dirs : [];
60
+ if (dirs.length > 0) {
61
+ warn(`synced embedded skills into existing agent skills dirs: ${dirs.join(', ')}`);
62
+ } else if (envelope && envelope.data && envelope.data.skipped) {
63
+ warn(`${envelope.data.skipped}. Run "creatok skills install --dir <agent-skills-dir>" manually if needed.`);
64
+ }
65
+ } catch (err) {
66
+ warn(`could not auto-sync agent skills: ${err.message}`);
16
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creatok/cli",
3
- "version": "0.2.0-preview.2",
3
+ "version": "0.3.0-preview.10",
4
4
  "description": "CreatOK CLI — drives CreatOK Open Skills (analyze, generate image/video) for TikTok creators and sellers.",
5
5
  "bin": {
6
6
  "creatok": "run.js"
@@ -18,7 +18,7 @@
18
18
  "node": ">=16"
19
19
  },
20
20
  "optionalDependencies": {
21
- "@creatok/cli-darwin-arm64": "0.2.0-preview.2",
22
- "@creatok/cli-win32-x64": "0.2.0-preview.2"
21
+ "@creatok/cli-darwin-arm64": "0.3.0-preview.10",
22
+ "@creatok/cli-win32-x64": "0.3.0-preview.10"
23
23
  }
24
24
  }