relayax-cli 0.2.26 → 0.2.28

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.
@@ -1,13 +1,22 @@
1
+ /**
2
+ * bin/relay-preamble.sh 스크립트를 생성한다.
3
+ * relay CLI가 있으면 사용, 없으면 curl fallback.
4
+ */
5
+ export declare function generatePreambleScript(slug: string, apiUrl: string): string;
6
+ /**
7
+ * SKILL.md / command에 삽입할 preamble 마크다운.
8
+ * 단순히 relay ping을 호출한다.
9
+ */
1
10
  export declare function generatePreamble(slug: string): string;
11
+ /**
12
+ * teamDir에 bin/relay-preamble.sh를 생성한다.
13
+ */
14
+ export declare function generatePreambleBin(teamDir: string, slug: string, apiUrl: string): void;
2
15
  /**
3
16
  * frontmatter(---...---) 뒤에 preamble을 삽입한다.
4
- * frontmatter가 없으면 파일 맨 앞에 삽입한다.
5
17
  */
6
18
  export declare function injectPreamble(filePath: string, slug: string): void;
7
19
  /**
8
20
  * 팀의 사용자 진입점 파일에 preamble을 주입한다.
9
- * - 루트 SKILL.md
10
- * - user-invocable: true인 서브 스킬 SKILL.md
11
- * - commands/*.md
12
21
  */
13
22
  export declare function injectPreambleToTeam(teamDir: string, slug: string): number;
@@ -3,28 +3,77 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generatePreambleScript = generatePreambleScript;
6
7
  exports.generatePreamble = generatePreamble;
8
+ exports.generatePreambleBin = generatePreambleBin;
7
9
  exports.injectPreamble = injectPreamble;
8
10
  exports.injectPreambleToTeam = injectPreambleToTeam;
9
11
  const fs_1 = __importDefault(require("fs"));
10
12
  const path_1 = __importDefault(require("path"));
11
13
  const PREAMBLE_START = '<!-- RELAY_PREAMBLE_START - DO NOT EDIT -->';
12
14
  const PREAMBLE_END = '<!-- RELAY_PREAMBLE_END -->';
15
+ /**
16
+ * bin/relay-preamble.sh 스크립트를 생성한다.
17
+ * relay CLI가 있으면 사용, 없으면 curl fallback.
18
+ */
19
+ function generatePreambleScript(slug, apiUrl) {
20
+ const registrySlug = slug.startsWith('@') ? slug.slice(1) : slug;
21
+ return `#!/usr/bin/env bash
22
+ # relay-preamble.sh — auto-generated by relay publish
23
+ set +e
24
+
25
+ DEVICE_HASH=$(echo "$HOSTNAME:$USER" | shasum -a 256 | cut -d' ' -f1)
26
+
27
+ # Usage ping
28
+ if command -v relay &>/dev/null; then
29
+ relay ping "${slug}" --quiet 2>/dev/null &
30
+ else
31
+ curl -sf -X POST "${apiUrl}/api/registry/${registrySlug}/ping" \\
32
+ -H "Content-Type: application/json" \\
33
+ -d "{\\"device_hash\\":\\"$DEVICE_HASH\\"}" \\
34
+ 2>/dev/null &
35
+ fi
36
+
37
+ # Update check
38
+ if command -v relay &>/dev/null; then
39
+ _UPD=$(relay check-update "${slug}" --quiet 2>/dev/null || true)
40
+ [ -n "$_UPD" ] && echo "$_UPD" || true
41
+ fi
42
+
43
+ echo "RELAY_READY: ${slug}"
44
+ `;
45
+ }
46
+ /**
47
+ * SKILL.md / command에 삽입할 preamble 마크다운.
48
+ * 단순히 relay ping을 호출한다.
49
+ */
13
50
  function generatePreamble(slug) {
51
+ const teamPath = slug.startsWith('@') ? slug.slice(1) : slug;
14
52
  return `${PREAMBLE_START}
15
53
  ## Preamble (run first)
16
54
 
17
55
  \`\`\`bash
18
- relay check-update ${slug} --quiet 2>/dev/null
56
+ bash "$HOME/.relay/teams/${teamPath}/bin/relay-preamble.sh" 2>/dev/null || true
19
57
  \`\`\`
20
58
 
21
59
  If output shows \`CLI_UPGRADE_AVAILABLE <old> <new>\`: tell user "relay v{new} available. Run: npm update -g relayax-cli"
22
60
  If output shows \`TEAM_UPGRADE_AVAILABLE\`: tell user "${slug} v{new} available (by @{author}). Run: relay update ${slug}"
23
61
  ${PREAMBLE_END}`;
24
62
  }
63
+ /**
64
+ * teamDir에 bin/relay-preamble.sh를 생성한다.
65
+ */
66
+ function generatePreambleBin(teamDir, slug, apiUrl) {
67
+ const binDir = path_1.default.join(teamDir, 'bin');
68
+ if (!fs_1.default.existsSync(binDir)) {
69
+ fs_1.default.mkdirSync(binDir, { recursive: true });
70
+ }
71
+ const scriptPath = path_1.default.join(binDir, 'relay-preamble.sh');
72
+ fs_1.default.writeFileSync(scriptPath, generatePreambleScript(slug, apiUrl));
73
+ fs_1.default.chmodSync(scriptPath, 0o755);
74
+ }
25
75
  /**
26
76
  * frontmatter(---...---) 뒤에 preamble을 삽입한다.
27
- * frontmatter가 없으면 파일 맨 앞에 삽입한다.
28
77
  */
29
78
  function injectPreamble(filePath, slug) {
30
79
  const content = fs_1.default.readFileSync(filePath, 'utf-8');
@@ -55,19 +104,10 @@ function injectPreamble(filePath, slug) {
55
104
  }
56
105
  /**
57
106
  * 팀의 사용자 진입점 파일에 preamble을 주입한다.
58
- * - 루트 SKILL.md
59
- * - user-invocable: true인 서브 스킬 SKILL.md
60
- * - commands/*.md
61
107
  */
62
108
  function injectPreambleToTeam(teamDir, slug) {
63
109
  let count = 0;
64
- // 1. 루트 SKILL.md
65
- const rootSkill = path_1.default.join(teamDir, 'SKILL.md');
66
- if (fs_1.default.existsSync(rootSkill)) {
67
- injectPreamble(rootSkill, slug);
68
- count++;
69
- }
70
- // 2. user-invocable 서브 스킬 SKILL.md만 (skills/**/SKILL.md)
110
+ // 1. user-invocable 서브 스킬 SKILL.md
71
111
  const skillsDir = path_1.default.join(teamDir, 'skills');
72
112
  if (fs_1.default.existsSync(skillsDir)) {
73
113
  function walkSkills(dir) {
@@ -87,7 +127,7 @@ function injectPreambleToTeam(teamDir, slug) {
87
127
  }
88
128
  walkSkills(skillsDir);
89
129
  }
90
- // 3. commands/*.md
130
+ // 2. commands/*.md
91
131
  const commandsDir = path_1.default.join(teamDir, 'commands');
92
132
  if (fs_1.default.existsSync(commandsDir)) {
93
133
  for (const entry of fs_1.default.readdirSync(commandsDir, { withFileTypes: true })) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "relayax-cli",
3
- "version": "0.2.26",
3
+ "version": "0.2.28",
4
4
  "description": "RelayAX Agent Team Marketplace CLI - Install and manage agent teams",
5
5
  "main": "dist/index.js",
6
6
  "bin": {