@pluginfinity/engine 0.1.0 → 0.1.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/frontmatter.js CHANGED
@@ -45,12 +45,13 @@ const toolNames = (value) => {
45
45
  };
46
46
  /**
47
47
  * A Claude Code MCP tool name, `mcp__<server>__<tool>`, in the target's MCP
48
- * spelling. A server named `plugin_…` belongs to another plugin, whose name on
49
- * the target is unknown, so it passes through, as does any other tool name.
48
+ * spelling, or `undefined` when it is not one the target can spell: any other
49
+ * name, or a server named `plugin_…`, which belongs to another plugin whose
50
+ * server name on the target is unknown.
50
51
  */
51
52
  const mcpToolName = (target, name) => {
52
53
  const match = /^mcp__(.+?)__(.+)$/.exec(name);
53
- if (match === null || (match[1] ?? "").startsWith("plugin_")) return name;
54
+ if (match === null || (match[1] ?? "").startsWith("plugin_")) return void 0;
54
55
  return target.tools.mcp.replace("{server}", match[1] ?? "").replace("{tool}", match[2] ?? "");
55
56
  };
56
57
  /**
@@ -112,7 +113,8 @@ const mapFrontmatter = (target, map, hostFields, base, block) => {
112
113
  });
113
114
  continue;
114
115
  }
115
- const mapped = target.tools.names[name] ?? mcpToolName(target, name);
116
+ const mapped = target.tools.names[name] ?? mcpToolName(target, name) ?? (target.tools.unlisted === "keep" ? name : void 0);
117
+ if (mapped === void 0) continue;
116
118
  if (typeof mapped === "string") {
117
119
  if (!names.includes(mapped)) names.push(mapped);
118
120
  } else if (mapped._tag === "unresolved") unresolved.push({
package/hooks.js CHANGED
@@ -63,12 +63,31 @@ const hookCommand = (entry, root, invoke) => {
63
63
  const args = (entry.args ?? []).map(shellQuote);
64
64
  return [...invoke === "bash" ? ["bash", path] : [path], ...args].join(" ");
65
65
  };
66
+ /**
67
+ * A `script` entry in exec form, for a host that spawns `command` with `args`
68
+ * and no shell: `bash` with the script path as its first argument, or under
69
+ * `scripts.invoke: "exec"` the script itself. The root placeholder is
70
+ * substituted by the host in `args`, and no shell ever parses the path.
71
+ *
72
+ * @public
73
+ */
74
+ const hookExec = (entry, root, invoke) => {
75
+ const path = `${root}/${entry.script}`;
76
+ const args = [...entry.args ?? []];
77
+ return invoke === "bash" ? {
78
+ command: "bash",
79
+ args: [path, ...args]
80
+ } : {
81
+ command: path,
82
+ args
83
+ };
84
+ };
66
85
  const FORMATS = {
67
- "claude-hooks-json": (events, command) => ({ hooks: Object.fromEntries(events.map(({ name, entries }) => [name, entries.map((entry) => ({
86
+ "claude-hooks-json": (events, command, exec) => ({ hooks: Object.fromEntries(events.map(({ name, entries }) => [name, entries.map((entry) => ({
68
87
  ...entry.matcher === void 0 ? {} : { matcher: entry.matcher },
69
88
  hooks: [{
70
89
  type: "command",
71
- command: command(entry),
90
+ ..."script" in entry ? exec(entry) : { command: command(entry) },
72
91
  ...entry.timeout === void 0 ? {} : { timeout: entry.timeout }
73
92
  }]
74
93
  }))])) }),
@@ -92,8 +111,8 @@ const renderHooks = (target, events, invoke) => {
92
111
  if (events.length === 0) return void 0;
93
112
  const root = target.pluginRoot.hooks;
94
113
  if (typeof root !== "string") throw new Error(`target has no plugin-root spelling for hook commands: ${root.note}`);
95
- return `${JSON.stringify(FORMATS[target.hooks.format](events, (entry) => hookCommand(entry, root, invoke)), null, " ")}\n`;
114
+ return `${JSON.stringify(FORMATS[target.hooks.format](events, (entry) => hookCommand(entry, root, invoke), (entry) => hookExec(entry, root, invoke)), null, " ")}\n`;
96
115
  };
97
116
 
98
117
  //#endregion
99
- export { hookCommand, hookCommandFiles, hookScripts, renderHooks, targetHooks };
118
+ export { hookCommand, hookCommandFiles, hookExec, hookScripts, renderHooks, targetHooks };
package/index.d.ts CHANGED
@@ -761,6 +761,20 @@ export declare const hookCommandFiles: (events: ReadonlyArray<TargetHookEvent>)
761
761
  * @public
762
762
  */
763
763
  export declare const hookCommand: (entry: HookEntry, root: string, invoke: "bash" | "exec") => string;
764
+ /**
765
+ * A `script` entry in exec form, for a host that spawns `command` with `args`
766
+ * and no shell: `bash` with the script path as its first argument, or under
767
+ * `scripts.invoke: "exec"` the script itself. The root placeholder is
768
+ * substituted by the host in `args`, and no shell ever parses the path.
769
+ *
770
+ * @public
771
+ */
772
+ export declare const hookExec: (entry: Extract<HookEntry, {
773
+ readonly script: string;
774
+ }>, root: string, invoke: "bash" | "exec") => {
775
+ readonly command: string;
776
+ readonly args: ReadonlyArray<string>;
777
+ };
764
778
  /**
765
779
  * Render a target's hooks file as JSON text, or `undefined` when the target
766
780
  * builds no hooks.
package/index.js CHANGED
@@ -8,10 +8,10 @@ import { preparePlugins, selectConfigPaths } from "./selection.js";
8
8
  import { ENGINE_VERSION } from "./version.js";
9
9
  import { CheckGroup, CheckSeverity, CheckStatus, DEFAULT_CHECK_TIMEOUT, DoctorCheck, DoctorReport, NODE_FLOOR, runDoctor } from "./doctor.js";
10
10
  import { EmitPlan, GENERATED_MODE, applyEmit, planEmit } from "./emit.js";
11
- import { hookCommand, hookCommandFiles, hookScripts, renderHooks, targetHooks } from "./hooks.js";
11
+ import { hookCommand, hookCommandFiles, hookExec, hookScripts, renderHooks, targetHooks } from "./hooks.js";
12
12
  import { renderManifest, serializeManifest } from "./manifest.js";
13
13
  import { SKILL_DESCRIPTION_MAX, readSkills, renderSkill } from "./skills.js";
14
14
  import { build, validate } from "./operations.js";
15
15
  import { ToolDiscoveryLive } from "./tools.js";
16
16
 
17
- export { BuildStale, CONFIG_FILE_NAMES, CheckGroup, CheckSeverity, CheckStatus, ComponentInvalid, ComponentsInvalid, ConfigAmbiguous, ConfigDiscovery, ConfigInvalid, ConfigIssue, ConfigLoadFailed, ConfigLoader, ConfigNotFound, DEFAULT_CHECK_TIMEOUT, DoctorCheck, DoctorReport, ENGINE_VERSION, EmitPlan, GENERATED_MODE, HookEventUnsupported, HookScriptInvalid, HookScriptProblem, HostRejected, NODE_FLOOR, NotImplemented, PackageVersionMissing, PathConflict, SKILL_DESCRIPTION_MAX, TargetDrift, TargetNotEnabled, ToolDiscoveryLive, UnknownTarget, appendSections, applyEmit, applyHostBlocks, build, hookCommand, hookCommandFiles, hookScripts, isBuildError, isConfigError, mapFrontmatter, planEmit, preparePlugins, readAgents, readSkills, referenceLines, renderAgent, renderHooks, renderManifest, renderSkill, runDoctor, selectConfigPaths, serializeManifest, splitFrontmatter, targetHooks, validate };
17
+ export { BuildStale, CONFIG_FILE_NAMES, CheckGroup, CheckSeverity, CheckStatus, ComponentInvalid, ComponentsInvalid, ConfigAmbiguous, ConfigDiscovery, ConfigInvalid, ConfigIssue, ConfigLoadFailed, ConfigLoader, ConfigNotFound, DEFAULT_CHECK_TIMEOUT, DoctorCheck, DoctorReport, ENGINE_VERSION, EmitPlan, GENERATED_MODE, HookEventUnsupported, HookScriptInvalid, HookScriptProblem, HostRejected, NODE_FLOOR, NotImplemented, PackageVersionMissing, PathConflict, SKILL_DESCRIPTION_MAX, TargetDrift, TargetNotEnabled, ToolDiscoveryLive, UnknownTarget, appendSections, applyEmit, applyHostBlocks, build, hookCommand, hookCommandFiles, hookExec, hookScripts, isBuildError, isConfigError, mapFrontmatter, planEmit, preparePlugins, readAgents, readSkills, referenceLines, renderAgent, renderHooks, renderManifest, renderSkill, runDoctor, selectConfigPaths, serializeManifest, splitFrontmatter, targetHooks, validate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluginfinity/engine",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "description": "The pluginfinity build pipeline shared by every pluginfinity front end: config discovery, read, transform per target, emit and check.",
6
6
  "keywords": [
@@ -40,8 +40,8 @@
40
40
  "@effected/semver": "^0.11.0",
41
41
  "@effected/walker": "^0.15.0",
42
42
  "@effected/yaml": "^0.19.0",
43
- "@pluginfinity/core": "0.1.0",
44
- "@pluginfinity/targets": "0.1.0",
43
+ "@pluginfinity/core": "0.1.1",
44
+ "@pluginfinity/targets": "0.1.1",
45
45
  "jiti": "^2.6.1"
46
46
  },
47
47
  "peerDependencies": {
package/version.js CHANGED
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * @public
14
14
  */
15
- const ENGINE_VERSION = "0.1.0";
15
+ const ENGINE_VERSION = "0.1.1";
16
16
 
17
17
  //#endregion
18
18
  export { ENGINE_VERSION };