@triflux/remote 10.50.1 → 10.51.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.
Files changed (120) hide show
  1. package/cto/brief.mjs +0 -12
  2. package/cto/collect.mjs +16 -247
  3. package/cto/current.schema.json +4 -20
  4. package/cto/events.mjs +13 -294
  5. package/cto/hygiene.mjs +26 -346
  6. package/cto/lake-root.mjs +114 -16
  7. package/cto/status.mjs +33 -128
  8. package/hub/index.mjs +0 -8
  9. package/hub/store-adapter.mjs +1 -1
  10. package/hub/team/agent-map.json +0 -1
  11. package/hub/team/ansi.mjs +1 -35
  12. package/hub/team/backend.mjs +9 -145
  13. package/hub/team/cli/commands/attach.mjs +1 -17
  14. package/hub/team/cli/commands/control.mjs +12 -38
  15. package/hub/team/cli/commands/debug.mjs +1 -37
  16. package/hub/team/cli/commands/focus.mjs +5 -31
  17. package/hub/team/cli/commands/interrupt.mjs +6 -25
  18. package/hub/team/cli/commands/kill.mjs +1 -30
  19. package/hub/team/cli/commands/list.mjs +0 -16
  20. package/hub/team/cli/commands/send.mjs +6 -26
  21. package/hub/team/cli/commands/start/index.mjs +41 -133
  22. package/hub/team/cli/commands/start/parse-args.mjs +15 -40
  23. package/hub/team/cli/commands/start/start-headless.mjs +138 -105
  24. package/hub/team/cli/commands/start/start-mux.mjs +0 -3
  25. package/hub/team/cli/commands/status.mjs +2 -57
  26. package/hub/team/cli/commands/stop.mjs +14 -19
  27. package/hub/team/cli/help.mjs +4 -5
  28. package/hub/team/cli/manifest.mjs +5 -1
  29. package/hub/team/cli/render.mjs +0 -12
  30. package/hub/team/cli/services/hub-client.mjs +2 -88
  31. package/hub/team/cli/services/runtime-mode.mjs +27 -98
  32. package/hub/team/handoff.mjs +3 -34
  33. package/hub/team/headless.mjs +14 -755
  34. package/hub/team/orchestrator.mjs +4 -30
  35. package/hub/team/pane.mjs +6 -28
  36. package/hub/team/psmux.mjs +16 -403
  37. package/hub/team/remote-session.mjs +1 -2
  38. package/hub/team/session.mjs +8 -119
  39. package/hub/team/swarm-intent.mjs +0 -198
  40. package/hub/team/terminal-opener.mjs +11 -35
  41. package/hub/team/tui-core.mjs +1 -1
  42. package/hub/team/tui-viewer.mjs +2 -2
  43. package/hub/team/tui.mjs +8 -269
  44. package/hub/team/wt-manager.mjs +2 -2
  45. package/hub/workers/factory.mjs +4 -37
  46. package/hub/workers/lib/jsonrpc-ws-uds.mjs +0 -2
  47. package/package.json +1 -1
  48. package/scripts/lib/agent-route-policy.mjs +162 -14
  49. package/scripts/lib/claudemd-scanner.mjs +2 -199
  50. package/scripts/lib/cli-claude.mjs +0 -2
  51. package/scripts/lib/context.mjs +3 -19
  52. package/scripts/lib/env-probe.mjs +5 -64
  53. package/scripts/lib/gemini-profiles.mjs +2 -69
  54. package/scripts/lib/legacy-mcp-cleanup.mjs +14 -3
  55. package/scripts/lib/machine-profile.mjs +3 -17
  56. package/scripts/lib/mcp-filter.mjs +109 -53
  57. package/scripts/lib/mcp-health.mjs +2 -2
  58. package/scripts/lib/mcp-server-catalog.mjs +2 -2
  59. package/scripts/lib/psmux-info.mjs +25 -104
  60. package/scripts/lib/skill-template.mjs +0 -271
  61. package/cto/hygiene-actions.mjs +0 -355
  62. package/cto/hygiene-notify.mjs +0 -170
  63. package/hub/team/build-worker-prompt.mjs +0 -92
  64. package/hub/team/check-mcp-hub.mjs +0 -49
  65. package/hub/team/claude-native-bridge.mjs +0 -987
  66. package/hub/team/cli/commands/start/start-in-process.mjs +0 -50
  67. package/hub/team/cli/commands/start/start-wt.mjs +0 -86
  68. package/hub/team/cli/services/native-control.mjs +0 -145
  69. package/hub/team/codex-review.mjs +0 -520
  70. package/hub/team/conductor-mesh-bridge.mjs +0 -122
  71. package/hub/team/conductor.mjs +0 -1529
  72. package/hub/team/consensus-meta.mjs +0 -176
  73. package/hub/team/cto-pull.mjs +0 -31
  74. package/hub/team/daemon-pty-tmux-bridge.mjs +0 -146
  75. package/hub/team/dashboard.mjs +0 -322
  76. package/hub/team/event-log.mjs +0 -84
  77. package/hub/team/execution-mode.mjs +0 -324
  78. package/hub/team/extract-completion-payload.mjs +0 -110
  79. package/hub/team/headless-bridge-session.mjs +0 -17
  80. package/hub/team/health-probe.mjs +0 -435
  81. package/hub/team/interactive-native-launcher.mjs +0 -119
  82. package/hub/team/interactive-native-worker.mjs +0 -80
  83. package/hub/team/interactive-tui-transport.mjs +0 -479
  84. package/hub/team/launcher-template.mjs +0 -144
  85. package/hub/team/mcp-selector.mjs +0 -145
  86. package/hub/team/native-supervisor.mjs +0 -460
  87. package/hub/team/native.mjs +0 -727
  88. package/hub/team/recovery-store.mjs +0 -149
  89. package/hub/team/remote-probe.mjs +0 -292
  90. package/hub/team/remote-watcher.mjs +0 -506
  91. package/hub/team/runtime-strategy.mjs +0 -200
  92. package/hub/team/schemas/worker-completion.json +0 -39
  93. package/hub/team/sentinel-capture.mjs +0 -127
  94. package/hub/team/swarm-cli.mjs +0 -390
  95. package/hub/team/swarm-hypervisor.mjs +0 -2206
  96. package/hub/team/swarm-locks.mjs +0 -335
  97. package/hub/team/swarm-planner.mjs +0 -371
  98. package/hub/team/swarm-preflight.mjs +0 -366
  99. package/hub/team/swarm-reconciler.mjs +0 -242
  100. package/hub/team/tui-remote-adapter.mjs +0 -377
  101. package/hub/team/worker-completion-validator.mjs +0 -79
  102. package/hub/team/worktree-lifecycle.mjs +0 -639
  103. package/hub/team/wt-templates.json +0 -43
  104. package/hub/workers/antigravity-route-worker.mjs +0 -179
  105. package/hub/workers/gemini-worker.mjs +0 -217
  106. package/scripts/lib/agent-json.mjs +0 -27
  107. package/scripts/lib/async.mjs +0 -174
  108. package/scripts/lib/cli-agy.mjs +0 -85
  109. package/scripts/lib/cli-codex.mjs +0 -62
  110. package/scripts/lib/cli-gemini.mjs +0 -37
  111. package/scripts/lib/dynamic-route-cli.mjs +0 -107
  112. package/scripts/lib/env.mjs +0 -14
  113. package/scripts/lib/hub.mjs +0 -48
  114. package/scripts/lib/pid.mjs +0 -63
  115. package/scripts/lib/quota.mjs +0 -47
  116. package/scripts/lib/skill-state.mjs +0 -220
  117. package/scripts/lib/team.mjs +0 -75
  118. package/scripts/lib/timeout.mjs +0 -66
  119. package/scripts/lib/tmp.mjs +0 -26
  120. package/scripts/lib/toml.mjs +0 -132
@@ -1,77 +1,45 @@
1
1
  import { execFileSync } from "node:child_process";
2
2
 
3
- export const PSMUX_RECOMMENDED_VERSION = "3.3.1";
4
- export const PSMUX_REQUIRED_COMMANDS = [
3
+ const PSMUX_RECOMMENDED_VERSION = "3.3.1";
4
+ const PSMUX_REQUIRED_COMMANDS = [
5
5
  "new-session",
6
6
  "attach-session",
7
7
  "kill-session",
8
8
  "capture-pane",
9
9
  ];
10
10
 
11
- export const PSMUX_OPTIONAL_COMMANDS = ["detach-client"];
11
+ const PSMUX_OPTIONAL_COMMANDS = ["detach-client"];
12
12
 
13
- // Windows 패키지 매니저 — winget/scoop/choco 는 Windows 전용
14
- export const PSMUX_INSTALL_COMMANDS = [
13
+ // Windows 전용 설치 명령
14
+ const PSMUX_INSTALL_COMMANDS = [
15
15
  "winget install psmux",
16
16
  "scoop install psmux",
17
17
  "choco install psmux",
18
18
  "cargo install psmux",
19
19
  ];
20
20
 
21
- export const PSMUX_UPDATE_COMMANDS = [
21
+ const PSMUX_UPDATE_COMMANDS = [
22
22
  "winget upgrade psmux",
23
23
  "scoop update psmux",
24
24
  "choco upgrade psmux",
25
25
  "cargo install psmux --force",
26
26
  ];
27
27
 
28
- // macOS 전용 — brew 가 표준, cargo 는 cross-platform fallback
29
- export const PSMUX_INSTALL_COMMANDS_DARWIN = [
30
- "brew install psmux",
31
- "cargo install psmux",
32
- ];
33
-
34
- export const PSMUX_UPDATE_COMMANDS_DARWIN = [
35
- "brew upgrade psmux",
36
- "cargo install psmux --force",
37
- ];
38
-
39
- // Linux 전용 — cargo 만 cross-platform 지원, distro 패키지는 미제공
40
- export const PSMUX_INSTALL_COMMANDS_LINUX = ["cargo install psmux"];
41
-
42
- export const PSMUX_UPDATE_COMMANDS_LINUX = ["cargo install psmux --force"];
43
-
44
- // PR #258 OS-primary 분기 정책: macOS/Linux 는 tmux 가 POSIX 표준 primary,
45
- // psmux 는 선택형이다. 따라서 macOS/Linux 에서 "psmux 미설치"는 fallback 사유가
46
- // 아니며, tmux 까지 없을 때만 native/in-process fallback 을 고려한다.
47
- export const PSMUX_FALLBACK_NOTE_DARWIN =
48
- "macOS 에서는 tmux 가 표준 멀티플렉서이며, " +
49
- "psmux 미설치는 fallback 사유가 아닙니다. tmux 도 없을 때만 in-process/native fallback 을 사용합니다.";
50
-
51
- export const PSMUX_FALLBACK_NOTE_LINUX =
52
- "Linux 에서는 tmux 가 표준 멀티플렉서이며, " +
53
- "psmux 미설치는 fallback 사유가 아닙니다. tmux 도 없을 때만 in-process/native fallback 을 사용합니다.";
54
-
55
- export function getPsmuxInstallCommandsFor(platform = process.platform) {
56
- if (platform === "darwin") return PSMUX_INSTALL_COMMANDS_DARWIN;
57
- if (platform === "linux") return PSMUX_INSTALL_COMMANDS_LINUX;
58
- // win32 또는 기타 (BSD 등) → Windows 풀 리스트로 폴백 (변경 전 동작 유지)
59
- return PSMUX_INSTALL_COMMANDS;
28
+ function getPsmuxInstallCommandsFor(platform = process.platform) {
29
+ if (platform === "win32") return PSMUX_INSTALL_COMMANDS;
30
+ return [platform === "darwin" ? "brew install tmux" : "apt install tmux"];
60
31
  }
61
32
 
62
- export function getPsmuxUpdateCommandsFor(platform = process.platform) {
63
- if (platform === "darwin") return PSMUX_UPDATE_COMMANDS_DARWIN;
64
- if (platform === "linux") return PSMUX_UPDATE_COMMANDS_LINUX;
65
- return PSMUX_UPDATE_COMMANDS;
33
+ function getPsmuxUpdateCommandsFor(platform = process.platform) {
34
+ if (platform === "win32") return PSMUX_UPDATE_COMMANDS;
35
+ return [
36
+ platform === "darwin"
37
+ ? "brew upgrade tmux"
38
+ : "apt install --only-upgrade tmux",
39
+ ];
66
40
  }
67
41
 
68
- export function getPsmuxFallbackNoteFor(platform = process.platform) {
69
- if (platform === "darwin") return PSMUX_FALLBACK_NOTE_DARWIN;
70
- if (platform === "linux") return PSMUX_FALLBACK_NOTE_LINUX;
71
- return null;
72
- }
73
-
74
- export function formatPsmuxCommandList(
42
+ function formatPsmuxCommandList(
75
43
  commands = PSMUX_INSTALL_COMMANDS,
76
44
  indent = "",
77
45
  ) {
@@ -82,10 +50,7 @@ export function formatPsmuxInstallGuidance(
82
50
  indent = "",
83
51
  platform = process.platform,
84
52
  ) {
85
- const commands = getPsmuxInstallCommandsFor(platform);
86
- const list = formatPsmuxCommandList(commands, indent);
87
- const note = getPsmuxFallbackNoteFor(platform);
88
- return note ? `${list}\n${indent}(${note})` : list;
53
+ return formatPsmuxCommandList(getPsmuxInstallCommandsFor(platform), indent);
89
54
  }
90
55
 
91
56
  export function formatPsmuxUpdateGuidance(
@@ -95,12 +60,12 @@ export function formatPsmuxUpdateGuidance(
95
60
  return formatPsmuxCommandList(getPsmuxUpdateCommandsFor(platform), indent);
96
61
  }
97
62
 
98
- export function parsePsmuxVersion(output = "") {
63
+ function parsePsmuxVersion(output = "") {
99
64
  const match = String(output).match(/psmux\s+v?(\d+\.\d+\.\d+)/i);
100
65
  return match?.[1] || null;
101
66
  }
102
67
 
103
- export function compareSemver(a, b) {
68
+ function compareSemver(a, b) {
104
69
  const left = String(a || "")
105
70
  .split(".")
106
71
  .map((part) => Number.parseInt(part, 10) || 0);
@@ -114,7 +79,7 @@ export function compareSemver(a, b) {
114
79
  return 0;
115
80
  }
116
81
 
117
- export function isRecommendedPsmuxVersion(version) {
82
+ function isRecommendedPsmuxVersion(version) {
118
83
  if (!version) return false;
119
84
  return compareSemver(version, PSMUX_RECOMMENDED_VERSION) >= 0;
120
85
  }
@@ -160,8 +125,8 @@ export function probePsmuxSupport(options = {}) {
160
125
  missingCommands,
161
126
  missingOptionalCommands,
162
127
  hasHelp: helpOutput.length > 0,
163
- installHint: formatPsmuxInstallGuidance(" "),
164
- updateHint: formatPsmuxUpdateGuidance(" "),
128
+ installHint: formatPsmuxInstallGuidance(" ", "win32"),
129
+ updateHint: formatPsmuxUpdateGuidance(" ", "win32"),
165
130
  };
166
131
  } catch {
167
132
  return {
@@ -173,52 +138,8 @@ export function probePsmuxSupport(options = {}) {
173
138
  missingCommands: [...PSMUX_REQUIRED_COMMANDS],
174
139
  missingOptionalCommands: [...PSMUX_OPTIONAL_COMMANDS],
175
140
  hasHelp: false,
176
- installHint: formatPsmuxInstallGuidance(" "),
177
- updateHint: formatPsmuxUpdateGuidance(" "),
178
- };
179
- }
180
- }
181
-
182
- export function probePrimaryMultiplexerSupport(options = {}) {
183
- const platform = options.platform || process.platform;
184
- const execFileSyncFn = options.execFileSyncFn || execFileSync;
185
-
186
- if (platform === "win32") {
187
- return {
188
- kind: "psmux",
189
- ...probePsmuxSupport(options),
190
- };
191
- }
192
-
193
- const bin = options.bin || "tmux";
194
- try {
195
- const versionOutput = execFileSyncFn(bin, ["-V"], {
196
- encoding: "utf8",
197
- timeout: 2000,
198
- stdio: ["ignore", "pipe", "pipe"],
199
- windowsHide: true,
200
- });
201
- return {
202
- ok: true,
203
- installed: true,
204
- kind: "tmux",
205
- version: String(versionOutput || "").trim() || null,
206
- recommendedVersion: null,
207
- recommended: true,
208
- missingCommands: [],
209
- missingOptionalCommands: [],
210
- };
211
- } catch (error) {
212
- return {
213
- ok: false,
214
- installed: false,
215
- kind: "tmux",
216
- version: null,
217
- recommendedVersion: null,
218
- recommended: false,
219
- missingCommands: ["tmux"],
220
- missingOptionalCommands: [],
221
- error: error?.message || String(error),
141
+ installHint: formatPsmuxInstallGuidance(" ", "win32"),
142
+ updateHint: formatPsmuxUpdateGuidance(" ", "win32"),
222
143
  };
223
144
  }
224
145
  }
@@ -1,31 +1,5 @@
1
- import { existsSync, readdirSync, readFileSync } from "node:fs";
2
- import {
3
- basename,
4
- extname,
5
- isAbsolute,
6
- join,
7
- relative,
8
- resolve,
9
- } from "node:path";
10
-
11
- const IF_TAG_RE = /{{\s*(#if\s+([A-Za-z0-9_.-]+)|\/if)\s*}}/g;
12
- const PARTIAL_RE = /{{>\s*([A-Za-z0-9_./-]+)\s*}}/g;
13
- const FILE_INCLUDE_RE = /{{#include\s+([A-Za-z0-9_./-]+)\s*}}/g;
14
- const VARIABLE_RE = /{{\s*([A-Za-z0-9_.-]+)\s*}}/g;
15
1
  const FRONTMATTER_RE = /^---\r?\n(?:([\s\S]*?)\r?\n)?---\r?\n?/;
16
2
 
17
- function isTruthy(value) {
18
- if (typeof value === "string") return value.trim().length > 0;
19
- return Boolean(value);
20
- }
21
-
22
- function normalizeVariable(context, key) {
23
- if (Object.hasOwn(context, key)) return context[key];
24
- const upper = key.toUpperCase();
25
- if (Object.hasOwn(context, upper)) return context[upper];
26
- return undefined;
27
- }
28
-
29
3
  function parseBoolean(raw) {
30
4
  if (typeof raw !== "string") return undefined;
31
5
  if (raw === "true") return true;
@@ -120,175 +94,6 @@ function parseFrontmatterBlock(block) {
120
94
  return data;
121
95
  }
122
96
 
123
- function evaluateConditionals(source, context) {
124
- const matcher = new RegExp(IF_TAG_RE.source, "g");
125
-
126
- function walk(startIndex, nested) {
127
- let output = "";
128
- let cursor = startIndex;
129
-
130
- while (true) {
131
- const found = matcher.exec(source);
132
- if (!found) {
133
- if (nested) throw new Error("Unclosed {{#if ...}} block in template");
134
- output += source.slice(cursor);
135
- return { output, index: source.length };
136
- }
137
-
138
- output += source.slice(cursor, found.index);
139
- cursor = matcher.lastIndex;
140
-
141
- const directive = found[1];
142
- const flag = found[2];
143
- if (directive.startsWith("#if")) {
144
- const nestedResult = walk(cursor, true);
145
- cursor = nestedResult.index;
146
- matcher.lastIndex = cursor;
147
- if (isTruthy(normalizeVariable(context, flag))) {
148
- output += nestedResult.output;
149
- }
150
- continue;
151
- }
152
-
153
- if (!nested) {
154
- throw new Error("Unexpected {{/if}} without matching {{#if ...}}");
155
- }
156
- return { output, index: cursor };
157
- }
158
- }
159
-
160
- return walk(0, false).output;
161
- }
162
-
163
- function renderPartials(source, context, partials, options, includeStack) {
164
- return source.replace(PARTIAL_RE, (_full, partialName) => {
165
- const partial = partials[partialName];
166
- if (partial == null) {
167
- throw new Error(`Missing partial: ${partialName}`);
168
- }
169
- if (includeStack.includes(partialName)) {
170
- const chain = [...includeStack, partialName].join(" -> ");
171
- throw new Error(`Circular partial include: ${chain}`);
172
- }
173
- return renderWithContext(partial, context, partials, options, [
174
- ...includeStack,
175
- partialName,
176
- ]);
177
- });
178
- }
179
-
180
- function normalizeIncludeName(includeName) {
181
- return includeName.replace(/\\/g, "/");
182
- }
183
-
184
- function resolveIncludeContent(includeName, options) {
185
- const normalizedName = normalizeIncludeName(includeName);
186
- if (Object.hasOwn(options.includes, normalizedName)) {
187
- return options.includes[normalizedName];
188
- }
189
- if (!options.includeBaseDir) {
190
- throw new Error(`Missing include: ${normalizedName}`);
191
- }
192
-
193
- const baseDir = resolve(options.includeBaseDir);
194
- const fullPath = resolve(baseDir, normalizedName);
195
- const relativePath = relative(baseDir, fullPath);
196
- const isInsideBaseDir =
197
- relativePath === "" ||
198
- (!relativePath.startsWith("..") && !isAbsolute(relativePath));
199
-
200
- if (!isInsideBaseDir || !existsSync(fullPath)) {
201
- throw new Error(`Missing include: ${normalizedName}`);
202
- }
203
-
204
- const content = readFileSync(fullPath, "utf8");
205
- options.includes[normalizedName] = content;
206
- return content;
207
- }
208
-
209
- function renderFileIncludes(source, context, partials, options, includeStack) {
210
- return source.replace(FILE_INCLUDE_RE, (_full, includeName) => {
211
- const normalizedName = normalizeIncludeName(includeName);
212
- const content = resolveIncludeContent(normalizedName, options);
213
- if (includeStack.includes(normalizedName)) {
214
- const chain = [...includeStack, normalizedName].join(" -> ");
215
- throw new Error(`Circular template include: ${chain}`);
216
- }
217
- return renderWithContext(content, context, partials, options, [
218
- ...includeStack,
219
- normalizedName,
220
- ]);
221
- });
222
- }
223
-
224
- function renderVariables(source, context) {
225
- return source.replace(VARIABLE_RE, (full, key) => {
226
- const value = normalizeVariable(context, key);
227
- if (value == null) {
228
- throw new Error(`Missing template variable: ${key}`);
229
- }
230
- return String(value);
231
- });
232
- }
233
-
234
- function renderWithContext(
235
- source,
236
- context,
237
- partials,
238
- options,
239
- includeStack = [],
240
- ) {
241
- const afterIf = evaluateConditionals(source, context);
242
- const afterPartials = renderPartials(
243
- afterIf,
244
- context,
245
- partials,
246
- options,
247
- includeStack,
248
- );
249
- const afterFileIncludes = renderFileIncludes(
250
- afterPartials,
251
- context,
252
- partials,
253
- options,
254
- includeStack,
255
- );
256
- return renderVariables(afterFileIncludes, context);
257
- }
258
-
259
- function readAllTemplateFiles(rootDir, currentDir = rootDir) {
260
- if (!rootDir || !existsSync(rootDir)) return [];
261
-
262
- const entries = readdirSync(currentDir, { withFileTypes: true }).sort(
263
- (left, right) => left.name.localeCompare(right.name),
264
- );
265
- const files = [];
266
-
267
- for (const entry of entries) {
268
- const fullPath = join(currentDir, entry.name);
269
- if (entry.isDirectory()) {
270
- files.push(...readAllTemplateFiles(rootDir, fullPath));
271
- continue;
272
- }
273
-
274
- if (!entry.isFile()) continue;
275
- if (!entry.name.endsWith(".md") && !entry.name.endsWith(".tmpl")) continue;
276
-
277
- const relativePath = relative(rootDir, fullPath).replace(/\\/g, "/");
278
- const content = readFileSync(fullPath, "utf8");
279
- files.push({ fullPath, relativePath, content });
280
- }
281
-
282
- return files;
283
- }
284
-
285
- function setPartial(partials, key, value) {
286
- if (!key) return;
287
- if (!Object.hasOwn(partials, key)) {
288
- partials[key] = value;
289
- }
290
- }
291
-
292
97
  export function parseFrontmatter(source) {
293
98
  const match = source.match(FRONTMATTER_RE);
294
99
  if (!match) return { data: {}, body: source };
@@ -297,79 +102,3 @@ export function parseFrontmatter(source) {
297
102
  const body = source.slice(match[0].length);
298
103
  return { data, body };
299
104
  }
300
-
301
- export function buildSkillTemplateContext({
302
- frontmatter = {},
303
- skillDirName = "",
304
- } = {}) {
305
- const context = { ...frontmatter };
306
- const skillName = String(frontmatter.name || skillDirName || "").trim();
307
- const skillDescription = String(frontmatter.description || "").trim();
308
-
309
- let deep = frontmatter.DEEP ?? frontmatter.deep;
310
- if (typeof deep === "string") {
311
- const parsed = parseBoolean(deep.trim().toLowerCase());
312
- deep = parsed ?? deep;
313
- }
314
- if (typeof deep !== "boolean") {
315
- deep = /(^|[-_])deep($|[-_])/i.test(skillName);
316
- }
317
-
318
- context.SKILL_NAME = skillName;
319
- context.SKILL_DESCRIPTION = skillDescription;
320
- context.DEEP = deep;
321
- return context;
322
- }
323
-
324
- export function loadTemplatePartials(partialsDir) {
325
- const files = readAllTemplateFiles(partialsDir);
326
- const partials = {};
327
-
328
- for (const file of files) {
329
- const extension = extname(file.relativePath);
330
- const withoutExt = extension
331
- ? file.relativePath.slice(0, -extension.length)
332
- : file.relativePath;
333
- const normalized = withoutExt.replace(/\\/g, "/");
334
- const base = basename(normalized);
335
-
336
- setPartial(partials, normalized, file.content);
337
- setPartial(partials, base, file.content);
338
- }
339
-
340
- return partials;
341
- }
342
-
343
- export function loadSkillManifest(skillDir) {
344
- const manifestPath = join(skillDir, "skill.json");
345
- if (!existsSync(manifestPath)) return null;
346
-
347
- const raw = readFileSync(manifestPath, "utf8");
348
- return JSON.parse(raw);
349
- }
350
-
351
- export function parseFrontmatterWithManifest(source, skillDir) {
352
- const manifest = skillDir ? loadSkillManifest(skillDir) : null;
353
- const { data: yamlData, body } = parseFrontmatter(source);
354
-
355
- if (!manifest) return { data: yamlData, body };
356
-
357
- const merged = { ...yamlData };
358
- if (manifest.name) merged.name = manifest.name;
359
- if (manifest.description) merged.description = manifest.description;
360
- if (manifest.triggers) merged.triggers = manifest.triggers;
361
- if (manifest.argument_hint) merged["argument-hint"] = manifest.argument_hint;
362
- if (manifest.internal != null) merged.internal = manifest.internal;
363
- if (manifest.deprecated != null) merged.deprecated = manifest.deprecated;
364
- if (manifest.superseded_by) merged["superseded-by"] = manifest.superseded_by;
365
-
366
- return { data: merged, body };
367
- }
368
-
369
- export function renderSkillTemplate(template, context = {}, options = {}) {
370
- const { partials = {}, includes = {}, includeBaseDir = "" } = options;
371
- return renderWithContext(template, context, partials, {
372
- includeBaseDir,
373
- includes: { ...includes },
374
- });
375
- }