@pluginfinity/engine 0.3.3 → 0.3.5
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/agents.js +1 -2
- package/body.js +1 -2
- package/component.js +1 -2
- package/discovery.js +1 -2
- package/doctor.js +1 -2
- package/emit.js +1 -2
- package/env-lib.generated.js +1 -2
- package/env.js +1 -2
- package/errors.js +1 -2
- package/frontmatter.js +1 -2
- package/hook-lib.generated.js +1 -2
- package/hook-lib.js +1 -2
- package/hook-output.js +1 -2
- package/hooks.js +1 -2
- package/index.d.ts +0 -42
- package/lib-files.js +1 -2
- package/loader.js +1 -2
- package/log-lib.generated.js +1 -2
- package/logs.js +1 -2
- package/manifest.js +1 -2
- package/monitor-lib.generated.js +1 -2
- package/monitors.js +1 -2
- package/notes.js +1 -2
- package/operations.js +1 -2
- package/package.json +7 -7
- package/selection.js +1 -2
- package/server-lib.generated.js +1 -2
- package/server-lib.js +1 -2
- package/servers.js +1 -2
- package/skills.js +1 -2
- package/tokens.js +1 -2
- package/tool-map.js +1 -2
- package/tools.js +1 -2
- package/version.js +2 -3
package/agents.js
CHANGED
|
@@ -5,7 +5,7 @@ import { renderTokens } from "./tokens.js";
|
|
|
5
5
|
import { AGENT_FIELDS, AgentFrontmatter } from "@pluginfinity/core";
|
|
6
6
|
import { Effect, FileSystem, Path } from "effect";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/agents.ts
|
|
9
9
|
/** Read and decode one agent file. */
|
|
10
10
|
const readAgent = (file, name, known) => Effect.gen(function* () {
|
|
11
11
|
const fs = yield* FileSystem.FileSystem;
|
|
@@ -97,5 +97,4 @@ const renderAgent = (target, id, agent, known, tokens) => Effect.gen(function* (
|
|
|
97
97
|
};
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
//#endregion
|
|
101
100
|
export { readAgents, renderAgent };
|
package/body.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/body.ts
|
|
2
2
|
/**
|
|
3
3
|
* The markers of a host block: a line holding only
|
|
4
4
|
* `<!-- pluginfinity:only <id> [<id>…] -->` opens one, and a line holding only
|
|
@@ -182,5 +182,4 @@ const fencedLines = (lines) => {
|
|
|
182
182
|
});
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
//#endregion
|
|
186
185
|
export { FENCE, applyHostBlocks, fencedLines, inlineCodeSpans, mapHostBlocks, stripInlineCode };
|
package/component.js
CHANGED
|
@@ -3,7 +3,7 @@ import { splitFrontmatter } from "./frontmatter.js";
|
|
|
3
3
|
import { Effect, Schema, SchemaIssue } from "effect";
|
|
4
4
|
import { Yaml } from "@effected/yaml";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/component.ts
|
|
7
7
|
const formatter = SchemaIssue.makeFormatterStandardSchemaV1();
|
|
8
8
|
/**
|
|
9
9
|
* One problem with a component, keyed by field or by `line N, column M`.
|
|
@@ -166,5 +166,4 @@ const JUNK = /* @__PURE__ */ new Set([
|
|
|
166
166
|
*/
|
|
167
167
|
const toLf = (text) => text.replaceAll("\r\n", "\n");
|
|
168
168
|
|
|
169
|
-
//#endregion
|
|
170
169
|
export { STRINGIFY, decodeComponent, frontmatterText, invalid, isJunk, issue, lineIssues, overlayIssues, toLf, unknownTargets };
|
package/discovery.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Effect, FileSystem, Path } from "effect";
|
|
|
3
3
|
import { GlobPattern } from "@effected/glob";
|
|
4
4
|
import { Walker, descend } from "@effected/walker";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/discovery.ts
|
|
7
7
|
/**
|
|
8
8
|
* The config file names discovery looks for, in preference order.
|
|
9
9
|
*
|
|
@@ -75,5 +75,4 @@ var ConfigDiscovery = class {
|
|
|
75
75
|
});
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
//#endregion
|
|
79
78
|
export { CONFIG_FILE_NAMES, ConfigDiscovery };
|
package/doctor.js
CHANGED
|
@@ -8,7 +8,7 @@ import { Tool, ToolDiscovery } from "@effected/commands";
|
|
|
8
8
|
import { CurrentDistribution, DistributionField, Remediation } from "@effected/engine";
|
|
9
9
|
import { SemVer } from "@effected/semver";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
// src/doctor.ts
|
|
12
12
|
/**
|
|
13
13
|
* The lowest Node.js version pluginfinity runs on: the `engines` floor.
|
|
14
14
|
*
|
|
@@ -278,5 +278,4 @@ const runDoctor = (input) => Effect.gen(function* () {
|
|
|
278
278
|
});
|
|
279
279
|
});
|
|
280
280
|
|
|
281
|
-
//#endregion
|
|
282
281
|
export { CheckGroup, CheckSeverity, CheckStatus, DEFAULT_CHECK_TIMEOUT, DoctorCheck, DoctorReport, NODE_FLOOR, runDoctor };
|
package/emit.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect, FileSystem, Path, Schema } from "effect";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/emit.ts
|
|
4
4
|
/**
|
|
5
5
|
* The mode every generated file is written with.
|
|
6
6
|
*
|
|
@@ -144,5 +144,4 @@ const applyEmit = (dir, files, plan) => Effect.scoped(Effect.gen(function* () {
|
|
|
144
144
|
}
|
|
145
145
|
}));
|
|
146
146
|
|
|
147
|
-
//#endregion
|
|
148
147
|
export { EmitPlan, GENERATED_MODE, applyEmit, planEmit };
|
package/env-lib.generated.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/env-lib.generated.ts
|
|
2
2
|
/** The session env library's files, embedded so a build needs no asset on disk. */
|
|
3
3
|
const ENV_LIB_FILES = [{
|
|
4
4
|
name: "env-run.sh",
|
|
@@ -8,5 +8,4 @@ const ENV_LIB_FILES = [{
|
|
|
8
8
|
content: "# shellcheck shell=sh\n# pluginfinity session env. `pluginfinity build` writes this file into every\n# target whose config declares `env`, at lib/pluginfinity/env.sh, with the\n# declarations block below filled in; do not edit a copy under builds/, the\n# next build overwrites it.\n#\n# POSIX sh. Writes nothing to stdout. Fails open: every problem is a log line\n# and the variables keep what the chain could resolve.\n#\n# From a skill script or a monitor, two lines apply the session's values. Build\n# the path from an absolute directory, before any cd: a relative $0 no longer\n# resolves after one.\n# _pf_lib_dir=\"$(cd \"$(dirname \"$0\")/../../../lib/pluginfinity\" && pwd)\" # skills/<s>/scripts/x.sh\n# . \"$_pf_lib_dir/env.sh\"\n# A script that resolves its own project sources first, changes directory, then\n# loads for that project:\n# _pf_env_manual=1; . \"$_pf_lib_dir/env.sh\"; cd \"$PROJECT_DIR\"; env_load \"\" \"$PROJECT_DIR\"\n#\n# Precedence, lowest first: the config default, the setup script's output,\n# <project>/.env, <project>/.env.local, the ambient environment (a declared\n# name already set when this file is sourced), then _pf_env_set at run time.\n# The SessionStart runner (env-run.sh) resolves the first five once and writes\n# the result to the session values file; a reader takes that file as\n# authoritative and evaluates the chain live (without setup) only for names the\n# file lacks, or when there is no file at all.\n#\n# State, under ${XDG_STATE_HOME:-$HOME/.local/state}/pluginfinity/<plugin>/\n# (directories and files created under umask 077):\n# session/<session id>/env one NAME=value line per declared name, the\n# resolved value; the value is literal to the\n# end of the line\n# session/<session id>/set provenance: one NAME per line for each name\n# last written by _pf_env_set (rung 6). A\n# SessionStart rerun under the same id keeps\n# these names' values and re-resolves the rest.\n# session/<session id>/done written by the runner when it has finished\n# session/<session id>/lock/ a mkdir lock around every read-merge-write of\n# env and set; lock/at holds its epoch seconds\n# project/<cksum of dir> line 1 the latest session id, line 2 the dir\n#\n# Locking: a writer waits up to about 5 s for the lock, removes one older than\n# 10 s (or with no lock/at after 2 s) as stale, and on timeout logs and writes\n# anyway (fail open).\n#\n# Claude runs an event's hooks in parallel, so a SessionStart hook may read\n# before the runner has finished. In SessionStart only (PLUGINFINITY_EVENT),\n# env_load with a session id but no values file waits up to 3 s for the\n# runner's done marker, then resolves live with a log line. Other events never\n# wait.\n#\n# Contract for callers (the hook library and the runner):\n# _pf_env_lib_dir set before sourcing to this file's directory when\n# _pf_lib_dir names another (the hook library's) directory.\n# _pf_env_manual=1 set before sourcing to skip the automatic env_load; the\n# caller then calls env_load itself.\n# _pf_env_component the log component (hook|script|monitor); guessed if unset.\n# env_load [<session id> [<project dir>]]\n# apply the chain into the current shell and export every\n# declared name. With no session id, CLAUDE_CODE_SESSION_ID\n# names the session when it is a valid id whose values file\n# exists; otherwise the project pointer for <project dir>\n# (default: CLAUDE_PROJECT_DIR or $PWD, walked up to the\n# nearest .git) does. A <project dir> of - means no project:\n# no pointer and no .env read. An invalid session id\n# (empty, ., /, .., a backslash, a control character) is\n# logged and nothing is read. Always returns 0.\n# env_reload env_load again with the arguments the last one got.\n# _pf_env_set NAME VALUE\n# rank-6 write: under the lock, update the session values\n# file (atomically) and record NAME in the set file,\n# export NAME in this shell and, on Claude with\n# CLAUDE_ENV_FILE set, append `export NAME='VALUE'` to it.\n# Returns 1, with a log line, for an undeclared name, a\n# value holding a newline, or no valid session from the last\n# env_load. It does not check the event: the caller does.\n# The hook library's hook_env_set wraps it and always\n# returns 0, so a refusal can never fail a hook.\n# _pf_env_declared NAME 0 when NAME is declared.\n\n# >>> pluginfinity env declarations (the build replaces this block)\n_pf_env_names=''\n_pf_env_setup=''\n_pf_env_setup_timeout=10\n# <<< pluginfinity env declarations\n\n_pf_env_dir=\"${_pf_env_lib_dir:-${_pf_lib_dir:-${_pf_log_dir:-.}}}\"\nif ! command -v pf_log >/dev/null 2>&1; then\n if [ -r \"$_pf_env_dir/log.sh\" ]; then\n _pf_log_dir=\"$_pf_env_dir\"\n # shellcheck source=/dev/null\n . \"$_pf_env_dir/log.sh\"\n else\n pf_log() { return 0; }\n pf_debug() { return 0; }\n pf_debug_on() { return 1; }\n fi\nfi\nif [ -z \"${PLUGINFINITY_PLUGIN:-}\" ] && [ -r \"$_pf_env_dir/host.sh\" ]; then\n # shellcheck source=/dev/null\n . \"$_pf_env_dir/host.sh\" 2>/dev/null || :\nfi\nif [ -z \"${_pf_env_component:-}\" ]; then\n if command -v hook_log >/dev/null 2>&1; then\n _pf_env_component=hook\n elif command -v monitor_log >/dev/null 2>&1; then\n _pf_env_component=monitor\n else\n _pf_env_component=script\n fi\nfi\n\n_pf_env_log() { pf_log \"$_pf_env_component\" \"env: $*\"; }\n_pf_env_debug() { pf_debug \"$_pf_env_component\" \"env: $*\"; }\n\n_pf_env_cr=$(printf '\\r')\n_pf_env_nl='\n'\n\n# 0 when $1 is a declared name. The character check keeps eval safe.\n_pf_env_declared() {\n case ${1:-} in\n '' | [0123456789]* | *[!ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*) return 1 ;;\n esac\n case \" $_pf_env_names \" in\n *\" $1 \"*) return 0 ;;\n esac\n return 1\n}\n\n# 0 when $1 looks like a variable name at all (declared or not).\n_pf_env_is_name() {\n case ${1:-} in\n '' | [0123456789]* | *[!ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]*) return 1 ;;\n esac\n return 0\n}\n\n# 0 when $1 is a usable session id: not empty, not ., no /, no .., no \\, no control character.\n_pf_env_valid_id() {\n case ${1:-} in\n '' | . | */* | *..* | *\\\\*) return 1 ;;\n esac\n [ \"$(printf '%s' \"$1\" | tr -d '[:cntrl:]')\" = \"$1\" ]\n}\n\n_pf_env_state_root() {\n printf '%s\\n' \"${XDG_STATE_HOME:-${HOME:-/nonexistent}/.local/state}/pluginfinity/${PLUGINFINITY_PLUGIN:-unknown}\"\n}\n\n# $1 as a physical path, or as given when it cannot be entered.\n_pf_env_physical() {\n (CDPATH='' cd -- \"$1\" 2>/dev/null && pwd -P) || printf '%s\\n' \"$1\"\n}\n\n# The project for directory $1: the nearest directory at or above it holding .git, else $1.\n_pf_env_project_of() {\n _pf_e_p=$(_pf_env_physical \"$1\")\n _pf_e_q=$_pf_e_p\n while [ -n \"$_pf_e_q\" ] && [ \"$_pf_e_q\" != / ] && [ \"$_pf_e_q\" != . ]; do\n if [ -e \"$_pf_e_q/.git\" ]; then\n printf '%s\\n' \"$_pf_e_q\"\n return 0\n fi\n _pf_e_q=$(dirname -- \"$_pf_e_q\")\n done\n printf '%s\\n' \"$_pf_e_p\"\n}\n\n# The project of a script with no session: CLAUDE_PROJECT_DIR, else $PWD, walked to .git.\n_pf_env_script_project() {\n _pf_env_project_of \"${CLAUDE_PROJECT_DIR:-$PWD}\"\n}\n\n_pf_env_key() {\n printf '%s' \"$1\" | cksum | awk '{ print $1 \"-\" $2 }'\n}\n\n_pf_env_pointer_path() { printf '%s/project/%s\\n' \"$(_pf_env_state_root)\" \"$(_pf_env_key \"$1\")\"; }\n_pf_env_session_dir() { printf '%s/session/%s\\n' \"$(_pf_env_state_root)\" \"$1\"; }\n_pf_env_values_path() { printf '%s/env\\n' \"$(_pf_env_session_dir \"$1\")\"; }\n\n# Sleep one tick (0.1 s) and count it in _pf_e_ticks; where sleep takes whole\n# seconds only, sleep 1 and count ten.\n_pf_env_nap() {\n if sleep 0.1 2>/dev/null; then\n _pf_e_ticks=$((_pf_e_ticks + 1))\n else\n sleep 1\n _pf_e_ticks=$((_pf_e_ticks + 10))\n fi\n}\n\n# Take the lock in session directory $1: mkdir with bounded retry (about 5 s).\n# A lock older than 10 s, or one whose at file is still missing after 2 s, is\n# stale and removed. On timeout, log and go on without it. Always returns 0.\n_pf_env_lock() {\n _pf_e_lk=\"$1/lock\"\n _pf_e_held=\n (umask 077 && mkdir -p \"$1\") 2>/dev/null || return 0\n _pf_e_ticks=0\n _pf_e_noat=0\n while [ \"$_pf_e_ticks\" -lt 50 ]; do\n if mkdir \"$_pf_e_lk\" 2>/dev/null; then\n date +%s >\"$_pf_e_lk/at\" 2>/dev/null || :\n _pf_e_held=1\n return 0\n fi\n _pf_e_at=$(cat \"$_pf_e_lk/at\" 2>/dev/null) || _pf_e_at=\n case $_pf_e_at in\n '' | *[!0123456789]*)\n _pf_e_noat=$((_pf_e_noat + 1))\n if [ \"$_pf_e_noat\" -gt 20 ]; then\n _pf_env_debug \"removing a lock with no time as stale\"\n rm -f \"$_pf_e_lk/at\" 2>/dev/null\n rmdir \"$_pf_e_lk\" 2>/dev/null\n _pf_e_noat=0\n continue\n fi\n ;;\n *)\n _pf_e_now=$(date +%s 2>/dev/null) || _pf_e_now=$_pf_e_at\n if [ $((_pf_e_now - _pf_e_at)) -gt 10 ]; then\n _pf_env_debug \"removing a stale lock\"\n rm -f \"$_pf_e_lk/at\" 2>/dev/null\n rmdir \"$_pf_e_lk\" 2>/dev/null\n continue\n fi\n ;;\n esac\n _pf_env_nap\n done\n _pf_env_log \"the session values lock is held too long; writing without it\"\n return 0\n}\n\n_pf_env_unlock() {\n if [ \"${_pf_e_held:-}\" = 1 ]; then\n rm -f \"$_pf_e_lk/at\" 2>/dev/null\n rmdir \"$_pf_e_lk\" 2>/dev/null\n fi\n _pf_e_held=\n return 0\n}\n\n# 0 when NAME $2 is listed in the set file of session directory $1.\n_pf_env_was_set() {\n [ -r \"$1/set\" ] || return 1\n while IFS= read -r _pf_e_sl || [ -n \"$_pf_e_sl\" ]; do\n [ \"$_pf_e_sl\" != \"$2\" ] || return 0\n done <\"$1/set\"\n return 1\n}\n\n# Under the caller's lock: the names the set file lists keep their value from the\n# values file in session directory $1 (a same-id SessionStart rerun).\n_pf_env_keep_set() {\n [ -r \"$1/set\" ] && [ -r \"$1/env\" ] || return 0\n while IFS= read -r _pf_e_l || [ -n \"$_pf_e_l\" ]; do\n _pf_e_k=${_pf_e_l%%=*}\n [ \"$_pf_e_k\" != \"$_pf_e_l\" ] || continue\n _pf_env_declared \"$_pf_e_k\" || continue\n _pf_env_was_set \"$1\" \"$_pf_e_k\" || continue\n _pf_e_v=${_pf_e_l#*=}\n eval \"_pf_env_val_$_pf_e_k=\\$_pf_e_v\"\n done <\"$1/env\"\n return 0\n}\n\n# The session id the pointer for project $1 names, when it names this very project.\n_pf_env_pointer_read() {\n _pf_e_f=$(_pf_env_pointer_path \"$1\")\n [ -r \"$_pf_e_f\" ] || return 1\n _pf_e_ps=\n _pf_e_pd=\n {\n IFS= read -r _pf_e_ps || :\n IFS= read -r _pf_e_pd || :\n } <\"$_pf_e_f\" 2>/dev/null || return 1\n [ \"$_pf_e_pd\" = \"$1\" ] || return 1\n _pf_env_valid_id \"$_pf_e_ps\" || return 1\n printf '%s\\n' \"$_pf_e_ps\"\n}\n\n# Every declared name back to its config default; nothing marked as read from a file.\n_pf_env_init() {\n for _pf_e_n in $_pf_env_names; do\n _pf_env_declared \"$_pf_e_n\" || continue\n eval \"_pf_env_val_$_pf_e_n=\\${_pf_env_default_$_pf_e_n:-}; _pf_env_got_$_pf_e_n=\"\n done\n}\n\n# Parse a .env file into the current values: KEY=value or export KEY=value,\n# one matching pair of quotes stripped, nothing expanded, declared names only.\n_pf_env_dotenv() {\n [ -e \"$1\" ] || return 0\n if [ ! -f \"$1\" ] || [ ! -r \"$1\" ]; then\n _pf_env_log \"cannot read $1; skipped\"\n return 0\n fi\n while IFS= read -r _pf_e_l || [ -n \"$_pf_e_l\" ]; do\n _pf_e_l=${_pf_e_l%\"$_pf_env_cr\"}\n _pf_e_l=${_pf_e_l#\"${_pf_e_l%%[! ]*}\"}\n case $_pf_e_l in\n 'export '* | 'export '*)\n _pf_e_l=${_pf_e_l#export}\n _pf_e_l=${_pf_e_l#\"${_pf_e_l%%[! ]*}\"}\n ;;\n esac\n _pf_e_k=${_pf_e_l%%=*}\n [ \"$_pf_e_k\" != \"$_pf_e_l\" ] || continue\n _pf_env_declared \"$_pf_e_k\" || continue\n _pf_e_v=${_pf_e_l#*=}\n case $_pf_e_v in\n \\\"*\\\")\n _pf_e_v=${_pf_e_v#\\\"}\n _pf_e_v=${_pf_e_v%\\\"}\n ;;\n \\'*\\')\n _pf_e_v=${_pf_e_v#\\'}\n _pf_e_v=${_pf_e_v%\\'}\n ;;\n esac\n eval \"_pf_env_val_$_pf_e_k=\\$_pf_e_v\"\n done <\"$1\"\n return 0\n}\n\n# The ambient values captured when this file was sourced (rung 5).\n_pf_env_ambient() {\n for _pf_e_n in $_pf_env_names; do\n _pf_env_declared \"$_pf_e_n\" || continue\n eval \"_pf_e_h=\\${_pf_env_hasamb_$_pf_e_n:-}\"\n [ \"$_pf_e_h\" = 1 ] || continue\n eval \"_pf_e_v=\\${_pf_env_amb_$_pf_e_n:-}\"\n case $_pf_e_v in\n *\"$_pf_env_nl\"*)\n _pf_env_log \"ambient $_pf_e_n holds a newline; ignored\"\n continue\n ;;\n esac\n eval \"_pf_env_val_$_pf_e_n=\\$_pf_e_v\"\n done\n return 0\n}\n\n# Rungs 3-5 over the current values, for project $1 (none when empty).\n_pf_env_live() {\n if [ -n \"${1:-}\" ]; then\n _pf_env_dotenv \"$1/.env\"\n _pf_env_dotenv \"$1/.env.local\"\n fi\n _pf_env_ambient\n}\n\n# Read a session values file over the current values, marking each name it holds.\n_pf_env_read_values() {\n while IFS= read -r _pf_e_l || [ -n \"$_pf_e_l\" ]; do\n _pf_e_k=${_pf_e_l%%=*}\n [ \"$_pf_e_k\" != \"$_pf_e_l\" ] || continue\n _pf_env_declared \"$_pf_e_k\" || continue\n _pf_e_v=${_pf_e_l#*=}\n eval \"_pf_env_val_$_pf_e_k=\\$_pf_e_v; _pf_env_got_$_pf_e_k=1\"\n done <\"$1\"\n return 0\n}\n\n# Every declared name not marked as read from the values file.\n_pf_env_missing() {\n for _pf_e_n in $_pf_env_names; do\n _pf_env_declared \"$_pf_e_n\" || continue\n eval \"_pf_e_g=\\${_pf_env_got_$_pf_e_n:-}\"\n [ \"$_pf_e_g\" = 1 ] || return 0\n done\n return 1\n}\n\n# Export the current values into this shell.\n_pf_env_apply() {\n for _pf_e_n in $_pf_env_names; do\n _pf_env_declared \"$_pf_e_n\" || continue\n eval \"$_pf_e_n=\\${_pf_env_val_$_pf_e_n:-}\"\n export \"${_pf_e_n?}\"\n done\n return 0\n}\n\n# Print $1 single-quoted for a shell, with no newline after it.\n_pf_env_squote() {\n _pf_e_r=$1\n _pf_e_o=\n while :; do\n case $_pf_e_r in\n *\\'*)\n _pf_e_o=\"$_pf_e_o${_pf_e_r%%\\'*}'\\\\''\"\n _pf_e_r=${_pf_e_r#*\\'}\n ;;\n *)\n _pf_e_o=\"$_pf_e_o$_pf_e_r\"\n break\n ;;\n esac\n done\n printf \"'%s'\" \"$_pf_e_o\"\n}\n\n# Append `export NAME='value'` for each NAME given, from the current values, to CLAUDE_ENV_FILE.\n# Only on Claude, and only when the host set CLAUDE_ENV_FILE.\n_pf_env_claude_export() {\n [ \"${PLUGINFINITY_HOST:-}\" = claude ] || return 0\n if [ -z \"${CLAUDE_ENV_FILE:-}\" ]; then\n _pf_env_log \"CLAUDE_ENV_FILE is not set; the Bash tool will not see the session values\"\n return 0\n fi\n for _pf_e_n in \"$@\"; do\n eval \"_pf_e_v=\\${_pf_env_val_$_pf_e_n:-}\"\n {\n printf 'export %s=' \"$_pf_e_n\"\n _pf_env_squote \"$_pf_e_v\"\n printf '\\n'\n } >>\"$CLAUDE_ENV_FILE\" 2>/dev/null || {\n _pf_env_log \"cannot append to CLAUDE_ENV_FILE\"\n return 0\n }\n done\n return 0\n}\n\n# Write the current values of every declared name to values file $1, atomically.\n_pf_env_write_values() {\n _pf_e_d=$(dirname -- \"$1\")\n (umask 077 && mkdir -p \"$_pf_e_d\") 2>/dev/null || {\n _pf_env_log \"cannot create $_pf_e_d; session values not written\"\n return 1\n }\n _pf_e_t=\"$1.tmp.$$\"\n (\n umask 077\n for _pf_e_n in $_pf_env_names; do\n _pf_env_declared \"$_pf_e_n\" || continue\n eval \"_pf_e_v=\\${_pf_env_val_$_pf_e_n:-}\"\n printf '%s=%s\\n' \"$_pf_e_n\" \"$_pf_e_v\"\n done >\"$_pf_e_t\"\n ) 2>/dev/null && mv -f \"$_pf_e_t\" \"$1\" 2>/dev/null && return 0\n rm -f \"$_pf_e_t\" 2>/dev/null\n _pf_env_log \"cannot write $1\"\n return 1\n}\n\nenv_load() {\n _pf_env_arg_sid=${1:-}\n _pf_env_arg_proj=${2:-}\n _pf_env_sid=\n _pf_env_file=\n [ -n \"$_pf_env_names\" ] || return 0\n case $_pf_env_arg_proj in\n -) _pf_env_proj= ;;\n '') _pf_env_proj=$(_pf_env_script_project) ;;\n *) _pf_env_proj=$_pf_env_arg_proj ;;\n esac\n if [ -n \"$_pf_env_arg_sid\" ]; then\n if _pf_env_valid_id \"$_pf_env_arg_sid\"; then\n _pf_env_sid=$_pf_env_arg_sid\n else\n _pf_env_log \"invalid session id; session values not read\"\n fi\n elif [ -n \"${CLAUDE_CODE_SESSION_ID:-}\" ] && _pf_env_valid_id \"$CLAUDE_CODE_SESSION_ID\" &&\n [ -e \"$(_pf_env_values_path \"$CLAUDE_CODE_SESSION_ID\")\" ]; then\n # Claude gives a skill script and a monitor CLAUDE_CODE_SESSION_ID, so prefer\n # its own session over the pointer, which names the project's latest one.\n # It equals the hook session_id (measured on Claude Code 2.1.291); an id\n # whose values file is missing falls back to the pointer. Copilot sets no\n # such variable for a script, so it always takes the pointer.\n _pf_env_sid=$CLAUDE_CODE_SESSION_ID\n elif [ -n \"$_pf_env_proj\" ] && _pf_e_s=$(_pf_env_pointer_read \"$_pf_env_proj\"); then\n _pf_env_sid=$_pf_e_s\n fi\n [ -z \"$_pf_env_sid\" ] || _pf_env_file=$(_pf_env_values_path \"$_pf_env_sid\")\n # In SessionStart a parallel runner may not have finished: wait for its done marker.\n if [ -n \"$_pf_env_arg_sid\" ] && [ -n \"$_pf_env_file\" ] && [ ! -e \"$_pf_env_file\" ] &&\n [ \"${PLUGINFINITY_EVENT:-}\" = SessionStart ]; then\n _pf_e_done=\"$(_pf_env_session_dir \"$_pf_env_sid\")/done\"\n _pf_e_ticks=0\n while [ ! -e \"$_pf_e_done\" ] && [ \"$_pf_e_ticks\" -lt 30 ]; do _pf_env_nap; done\n [ -e \"$_pf_e_done\" ] || _pf_env_log \"the env runner had not finished after 3s; resolving live\"\n fi\n _pf_env_init\n if [ -n \"$_pf_env_file\" ] && [ -r \"$_pf_env_file\" ]; then\n _pf_env_read_values \"$_pf_env_file\"\n if _pf_env_missing; then\n # A name the file lacks (declared after SessionStart) resolves live; file values win.\n _pf_env_init\n _pf_env_live \"$_pf_env_proj\"\n _pf_env_read_values \"$_pf_env_file\"\n fi\n else\n _pf_env_debug \"no session values; resolving live\"\n _pf_env_live \"$_pf_env_proj\"\n fi\n _pf_env_apply\n return 0\n}\n\nenv_reload() {\n env_load \"${_pf_env_arg_sid:-}\" \"${_pf_env_arg_proj:-}\"\n}\n\n_pf_env_set() {\n _pf_e_sn=${1:-}\n _pf_e_sv=${2-}\n if ! _pf_env_declared \"$_pf_e_sn\"; then\n _pf_env_log \"cannot set $_pf_e_sn: not a declared session variable\"\n return 1\n fi\n case $_pf_e_sv in\n *\"$_pf_env_nl\"*)\n _pf_env_log \"cannot set $_pf_e_sn: the value holds a newline\"\n return 1\n ;;\n esac\n if [ -z \"${_pf_env_file:-}\" ]; then\n _pf_env_log \"cannot set $_pf_e_sn: no session\"\n return 1\n fi\n # Under the lock, keep every other name as the file has it (a name it lacks keeps\n # its resolved value), then record NAME as set at rung 6.\n _pf_e_sd=$(dirname -- \"$_pf_env_file\")\n _pf_env_lock \"$_pf_e_sd\"\n if [ -r \"$_pf_env_file\" ]; then _pf_env_read_values \"$_pf_env_file\"; fi\n eval \"_pf_env_val_$_pf_e_sn=\\$_pf_e_sv\"\n if ! _pf_env_write_values \"$_pf_env_file\"; then\n _pf_env_unlock\n return 1\n fi\n if ! _pf_env_was_set \"$_pf_e_sd\" \"$_pf_e_sn\"; then\n (umask 077 && printf '%s\\n' \"$_pf_e_sn\" >>\"$_pf_e_sd/set\") 2>/dev/null ||\n _pf_env_log \"cannot record $_pf_e_sn in the set file\"\n fi\n _pf_env_unlock\n eval \"$_pf_e_sn=\\$_pf_e_sv\"\n export \"${_pf_e_sn?}\"\n _pf_env_claude_export \"$_pf_e_sn\"\n return 0\n}\n\n# Capture the ambient values once, before anything here exports a declared name.\nif [ \"${_pf_env_captured:-}\" != 1 ]; then\n _pf_env_captured=1\n for _pf_e_n in $_pf_env_names; do\n _pf_env_declared \"$_pf_e_n\" || continue\n eval \"_pf_e_h=\\${$_pf_e_n+x}\"\n if [ \"$_pf_e_h\" = x ]; then\n eval \"_pf_env_amb_$_pf_e_n=\\$$_pf_e_n; _pf_env_hasamb_$_pf_e_n=1\"\n else\n eval \"_pf_env_hasamb_$_pf_e_n=\"\n fi\n done\nfi\n\nif [ \"${_pf_env_manual:-}\" != 1 ]; then\n env_load\nfi\n:\n"
|
|
9
9
|
}];
|
|
10
10
|
|
|
11
|
-
//#endregion
|
|
12
11
|
export { ENV_LIB_FILES };
|
package/env.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ENV_LIB_FILES } from "./env-lib.generated.js";
|
|
2
2
|
import { CONFIG_NOTE_PATH } from "./notes.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/env.ts
|
|
5
5
|
/**
|
|
6
6
|
* Seconds the env runner gives the `setup` script before it discards its
|
|
7
7
|
* output and resolves without it.
|
|
@@ -124,5 +124,4 @@ const envWaitNotes = (id, events) => events.filter((event) => event.event === "S
|
|
|
124
124
|
name: "SessionStart"
|
|
125
125
|
}));
|
|
126
126
|
|
|
127
|
-
//#endregion
|
|
128
127
|
export { ENV_RUNNER_TIMEOUT, ENV_SETUP_TIMEOUT, ENV_WAIT_TIMEOUT_FLOOR, envLibFiles, envNotes, envRunnerEntry, envWaitNotes, renderEnvLib, withEnvRunner };
|
package/errors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { KNOWN_TARGET_IDS } from "@pluginfinity/targets";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/errors.ts
|
|
5
5
|
/**
|
|
6
6
|
* One problem found while decoding a config: where in the config, and what.
|
|
7
7
|
*
|
|
@@ -438,5 +438,4 @@ const BUILD_ERROR_TAGS = [
|
|
|
438
438
|
*/
|
|
439
439
|
const isBuildError = (error) => typeof error === "object" && error !== null && "_tag" in error && typeof error._tag === "string" && BUILD_ERROR_TAGS.includes(error._tag);
|
|
440
440
|
|
|
441
|
-
//#endregion
|
|
442
441
|
export { BuildStale, ComponentInvalid, ComponentsInvalid, ConfigAmbiguous, ConfigInvalid, ConfigIssue, ConfigLoadFailed, ConfigNotFound, HookEventUnsupported, HookScriptInvalid, HookScriptProblem, HostRejected, NotImplemented, PackageVersionMissing, PathConflict, ShippedFileInvalid, ShippedFileProblem, TargetDrift, TargetNotEnabled, UnknownTarget, isBuildError, isConfigError };
|
package/frontmatter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/frontmatter.ts
|
|
2
2
|
/**
|
|
3
3
|
* Split `text` at a frontmatter block that opens on the first line with `---`
|
|
4
4
|
* and closes at the next line holding only `---`; `undefined` when there is
|
|
@@ -218,5 +218,4 @@ const appendSections = (body, sections) => {
|
|
|
218
218
|
}, body);
|
|
219
219
|
};
|
|
220
220
|
|
|
221
|
-
//#endregion
|
|
222
221
|
export { appendSections, mapFrontmatter, splitFrontmatter, splitOwnMcp };
|
package/hook-lib.generated.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// src/hook-lib.generated.ts
|
|
2
2
|
/** The hook library's files, embedded so a build needs no asset on disk. */
|
|
3
3
|
const HOOK_LIB_FILES = [{
|
|
4
4
|
name: "hook.sh",
|
|
5
5
|
content: "# shellcheck shell=bash\n# pluginfinity hook library. `pluginfinity build` writes this file into every\n# target that has hooks; do not edit a copy under builds/, the next build\n# overwrites it.\n#\n# Source it first in a hook script, relative to the script:\n# . \"$(dirname \"$0\")/lib/pluginfinity/hook.sh\" # hooks/<name>.sh\n# . \"$(dirname \"$0\")/../lib/pluginfinity/hook.sh\" # hooks/<event>/<name>.sh\n#\n# Bash 3.2 compatible. Writes nothing when sourced. Needs jq.\n#\n# Do not install your own `trap ... EXIT`: it replaces the library's\n# fail-open / fail-closed trap, and a failing hook would then exit non-zero.\n\n_pf_fail_closed=0\n[ \"${PLUGINFINITY_FAIL_CLOSED:-0}\" = 1 ] && _pf_fail_closed=1\n_pf_event=\"\"\n_pf_marker=\"\"\n_pf_kind_prefix=\"\"\n\n# --- logging --------------------------------------------------------------\n\n_pf_lib_dir=$(cd \"$(dirname \"${BASH_SOURCE[0]}\")\" && pwd) || exit 0\n# The one logging standard lives at <root>/lib/pluginfinity. A build without it\n# must still fail open, so fall back to no-ops.\n_pf_log_dir=\"$_pf_lib_dir/../../../lib/pluginfinity\"\n# shellcheck source=/dev/null\n. \"$_pf_log_dir/log.sh\" 2>/dev/null || {\n pf_log() { :; }\n pf_debug() { :; }\n pf_debug_on() { return 1; }\n}\n\n# Append a line to the plugin's error log.\nhook_log() { pf_log hook \"$*\"; }\n\n# Append a line to the plugin's debug log when PLUGINFINITY_DEBUG=1.\nhook_debug() { pf_debug hook \"$*\"; }\n\n# Until the library is fully loaded a failure must still fail open: on Copilot\n# a non-zero exit from a preToolUse hook denies the tool.\n_pf_early_exit() {\n local code=$?\n [ \"$code\" -eq 0 ] || hook_log \"exited $code while loading the hook library\"\n _pf_cleanup\n exit 0\n}\n_pf_cleanup() {\n if [ -n \"$_pf_marker\" ]; then rm -f \"$_pf_marker\" 2>/dev/null || true; fi\n return 0\n}\ntrap _pf_early_exit EXIT\n\n# shellcheck source=/dev/null\n. \"$_pf_lib_dir/host.sh\" 2>/dev/null || {\n hook_log \"host.sh not loadable; hook skipped\"\n exit 0\n}\n\n# The tool map the build wrote for this host. A build without it keeps names\n# as they are.\n_PF_TOOLS=\"\"\n_PF_TOOLS_PLUGIN=\"\"\n_PF_TOOLS_MCP=\"\"\n_PF_TOOLS_SERVERS=\"\"\n_PF_TOOLS_UNLISTED=keep\n_PF_HAS_SKILLS=\"\"\n_PF_HAS_AGENTS=\"\"\n_PF_HAS_MONITORS=\"\"\n_PF_HAS_SERVERS=\"\"\n# A failed `.` aborts a shell on bash 3.2, so test the file first.\nif [ -r \"$_pf_lib_dir/tools.sh\" ]; then\n # shellcheck source=/dev/null\n . \"$_pf_lib_dir/tools.sh\" 2>/dev/null || true\nfi\n\n# --- input ----------------------------------------------------------------\n\n# Read the event once. A terminal on stdin (a hand run) reads as {}.\nif [ -t 0 ]; then\n _pf_input='{}'\nelse\n _pf_input=$(cat) || _pf_input=''\nfi\n\nif ! command -v jq >/dev/null 2>&1; then\n hook_log \"jq not found; hook skipped\"\n exit 0\nfi\n\n# Whether stdin held a JSON object. Anything else reads as {} from here on, so\n# hook_input never sees garbage; hook_require_input turns it into a no-op.\n_pf_input_ok=0\nif jq -e 'type == \"object\"' >/dev/null 2>&1 <<<\"$_pf_input\"; then\n _pf_input_ok=1\nelse\n _pf_input='{}'\nfi\n\n# Return when stdin was a JSON object; otherwise log it, answer with a no-op\n# and end the script.\nhook_require_input() {\n [ \"$_pf_input_ok\" = 1 ] && return 0\n hook_log \"malformed or empty JSON on stdin; skipping\"\n hook_noop\n exit 0\n}\n\n# One marker file records that a response went out, and holds its kind for the\n# debug log. It is a file, not a variable, so a response sent from a subshell\n# or a pipeline still counts.\n_pf_marker=$(mktemp \"${TMPDIR:-/tmp}/pluginfinity-emitted.XXXXXX\" 2>/dev/null) ||\n _pf_marker=\"${TMPDIR:-/tmp}/pluginfinity-emitted.$$\"\n: >\"$_pf_marker\" 2>/dev/null || true\n\n# A Claude field name, read from either payload form: as written, then the\n# camelCase spelling (tool_input from a toolArgs object or JSON string,\n# tool_name from toolName, anything else camelCased at the top level). A\n# tool_input key also falls back to Copilot's own spelling of it, since Copilot\n# keeps its key names (path, file_text, old_str, new_str) under Claude event\n# and tool names.\n_PF_INPUT_FILTER='\ndef camel: gsub(\"_(?<c>[a-z])\"; .c | ascii_upcase);\ndef args: if type == \"string\" then (fromjson? // .) else . end;\ndef alias: {file_path: \"path\", content: \"file_text\", old_string: \"old_str\", new_string: \"new_str\"};\n. as $in\n| ($path | if . == \"\" then [] else split(\".\") end) as $p\n| (try ($in | getpath($p)) catch null) as $v\n| (if $v != null then $v\n elif $p[0] == \"tool_input\" and ($p | length) == 2 and (alias[$p[1]] != null)\n and (try ($in | getpath([$p[0], alias[$p[1]]])) catch null) != null\n then ($in | getpath([$p[0], alias[$p[1]]]))\n elif $p[0] == \"tool_input\" then (try (($in.toolArgs | args) | getpath($p[1:])) catch null)\n elif $p[0] == \"tool_name\" then $in.toolName\n else (try ($in | getpath([$p[0] | camel] + $p[1:])) catch null) end)\n| if . == null then empty elif type == \"string\" then . else tojson end'\n\n# Print an input field by its Claude name (dotted for nested keys), or the\n# whole input as JSON with no argument. Prints nothing for a missing field.\nhook_input() { printf '%s' \"$_pf_input\" | jq -r --arg path \"${1:-}\" \"$_PF_INPUT_FILTER\" 2>/dev/null; }\n\n# --- failure policy -------------------------------------------------------\n\n_pf_has_emitted() { [ -s \"$_pf_marker\" ]; }\n\n_pf_closed_response() { # code\n local reason=\"${PLUGINFINITY_PLUGIN:-a plugin} hook failed (exit $1)\" body\n _pf_kind_prefix=\"fail-closed \"\n if hook_supports deny; then\n _pf_permission deny \"$reason\"\n elif hook_supports block; then\n body=$(jq -nc --arg r \"$reason\" '{decision: \"block\", reason: $r}') || return 1\n _pf_emit \"$body\" block\n fi\n}\n\n_pf_on_exit() {\n local code=$? outcome=none\n if [ \"$code\" -ne 0 ]; then\n hook_log \"exited $code during ${_pf_event:-an unknown event}\"\n if [ \"$_pf_fail_closed\" = 1 ] && ! _pf_has_emitted; then\n # A Stop hook that crashes while stop_hook_active is true must not block again, or it loops.\n case \"$_pf_event\" in\n Stop | SubagentStop)\n [ \"$(hook_input stop_hook_active)\" = true ] || _pf_closed_response \"$code\" || true\n ;;\n *) _pf_closed_response \"$code\" || true ;;\n esac\n fi\n fi\n if pf_debug_on; then\n if _pf_has_emitted; then outcome=$(cat \"$_pf_marker\" 2>/dev/null) || outcome=response; fi\n if [ \"$code\" -ne 0 ]; then outcome=\"$outcome (exit $code)\"; fi\n hook_debug \"outcome: $outcome\"\n fi\n _pf_cleanup\n exit 0\n}\n\n# Make a failure deny (PreToolUse) or block (where blocking is honoured)\n# instead of letting the action through.\nhook_fail_closed() { _pf_fail_closed=1; }\n\n# --- context --------------------------------------------------------------\n\n# The event's Claude name: PLUGINFINITY_EVENT (set on every Copilot entry by\n# the build), else the input's hook_event_name.\n# Prints nothing and returns 1 when neither is available.\nhook_event() {\n local ev=${PLUGINFINITY_EVENT:-}\n [ -n \"$ev\" ] || ev=$(hook_input hook_event_name)\n [ -n \"$ev\" ] || return 1\n printf '%s\\n' \"$ev\"\n}\n_pf_event=$(hook_event 2>/dev/null) || _pf_event=\"\"\n\n# claude or copilot.\nhook_host() { printf '%s\\n' \"$PLUGINFINITY_HOST\"; }\n\n# The build root this script runs from.\nhook_plugin_root() { (cd \"$_pf_lib_dir/../../..\" && pwd); }\n\n# The closest directory at or above $1 holding .git (a directory, or a file in\n# a worktree). Prints nothing and returns 1 when there is none.\n_pf_git_root() {\n local probe=$1\n while [ -n \"$probe\" ] && [ \"$probe\" != / ] && [ \"$probe\" != . ]; do\n if [ -e \"$probe/.git\" ]; then\n printf '%s\\n' \"$probe\"\n return 0\n fi\n probe=$(dirname \"$probe\")\n done\n return 1\n}\n\n# Where this call runs: the input's cwd walked up to the nearest .git, else the\n# cwd itself; with no cwd, CLAUDE_PROJECT_DIR (Claude), else $PWD walked up to\n# .git (Claude), else $PWD as is. On Copilot $PWD is always the plugin root, so\n# it is never walked: that would find the repo holding the plugin.\nhook_project_dir() {\n local dir root\n dir=$(hook_input cwd)\n # A relative cwd means nothing outside the host's own process; ignore it.\n if [ -n \"$dir\" ] && [ \"${dir#/}\" != \"$dir\" ]; then\n if root=$(_pf_git_root \"$dir\"); then\n printf '%s\\n' \"$root\"\n else\n printf '%s\\n' \"$dir\"\n fi\n return 0\n fi\n if [ \"$PLUGINFINITY_HOST\" = claude ]; then\n if [ -n \"${CLAUDE_PROJECT_DIR:-}\" ]; then\n printf '%s\\n' \"$CLAUDE_PROJECT_DIR\"\n return 0\n fi\n if root=$(_pf_git_root \"$PWD\"); then\n printf '%s\\n' \"$root\"\n return 0\n fi\n fi\n printf '%s\\n' \"$PWD\"\n}\n\n# The session's project: CLAUDE_PROJECT_DIR on Claude when set, else what\n# hook_project_dir finds. In a git worktree the two differ.\nhook_session_dir() {\n if [ \"$PLUGINFINITY_HOST\" = claude ] && [ -n \"${CLAUDE_PROJECT_DIR:-}\" ]; then\n printf '%s\\n' \"$CLAUDE_PROJECT_DIR\"\n return 0\n fi\n hook_project_dir\n}\n\n# cd into hook_project_dir, ignoring CDPATH and treating a leading dash as a path.\n# Writes nothing to stdout; on failure it logs through hook_log and returns non-zero.\nhook_cd_project() {\n local dir\n dir=$(hook_project_dir)\n CDPATH= cd -- \"$dir\" >/dev/null 2>&1 || {\n hook_log \"hook_cd_project: cannot cd to $dir\"\n return 1\n }\n}\n\n# Print the host's run-time spelling of a Claude run-time tool name and return\n# 0, or print nothing and return 1 when the host has none. An own MCP tool is\n# written mcp__plugin_<plugin>_<server>__<tool>, as Claude Code names it.\nhook_tool_name() {\n local name=${1:-} line plugin rest head seg server tool template\n [ -n \"$name\" ] || return 1\n while IFS= read -r line; do\n if [ \"${line%%=*}\" = \"$name\" ] && [ \"${line#*=}\" != \"$line\" ]; then\n printf '%s\\n' \"${line#*=}\"\n return 0\n fi\n done <<<\"$_PF_TOOLS\"\n plugin=${_PF_TOOLS_PLUGIN:-${PLUGINFINITY_PLUGIN:-}}\n case \"$name\" in\n \"mcp__plugin_${plugin}_\"*)\n rest=${name#\"mcp__plugin_${plugin}_\"}\n # Try each \"__\" as the server/tool boundary, as the build does.\n head=\"\"\n while [ \"${rest#*__}\" != \"$rest\" ]; do\n seg=${rest%%__*}\n rest=${rest#*__}\n server=\"${head:+${head}__}$seg\"\n tool=$rest\n head=$server\n [ -n \"$server\" ] && [ -n \"$tool\" ] && [ -n \"$_PF_TOOLS_MCP\" ] || continue\n case \" $_PF_TOOLS_SERVERS \" in\n *\" $server \"*)\n template=$_PF_TOOLS_MCP\n template=${template//\\{plugin\\}/$plugin}\n template=${template//\\{server\\}/$server}\n template=${template//\\{tool\\}/$tool}\n printf '%s\\n' \"$template\"\n return 0\n ;;\n esac\n done\n ;;\n esac\n [ \"$_PF_TOOLS_UNLISTED\" = keep ] || return 1\n printf '%s\\n' \"$name\"\n}\n\n# Whether this build ships a component: hook_has <monitor|skill|agent|server> <name>.\n# Returns 0 when it does, 1 when it does not (or tools.sh is missing), 2 for an\n# unknown kind. The lists are built per target, so a skill a target excludes and\n# a monitor on a host without monitors are absent.\nhook_has() {\n local kind=${1:-} name=${2:-} list\n case \"$kind\" in\n skill) list=$_PF_HAS_SKILLS ;;\n agent) list=$_PF_HAS_AGENTS ;;\n monitor) list=$_PF_HAS_MONITORS ;;\n server) list=$_PF_HAS_SERVERS ;;\n *)\n hook_log \"hook_has: unknown kind '$kind'\"\n return 2\n ;;\n esac\n [ -n \"$name\" ] || return 1\n case \" $list \" in\n *\" $name \"*) return 0 ;;\n esac\n return 1\n}\n\n# Print the run-time tool-name prefix of an own MCP server (Claude\n# mcp__plugin_<plugin>_<server>__, Copilot <server>-) and return 0, or print\n# nothing and return 1 for a server this plugin does not declare.\nhook_tool_prefix() {\n local server=${1:-} template plugin\n [ -n \"$server\" ] && [ -n \"$_PF_TOOLS_MCP\" ] || return 1\n case \" $_PF_TOOLS_SERVERS \" in\n *\" $server \"*) ;;\n *) return 1 ;;\n esac\n plugin=${_PF_TOOLS_PLUGIN:-${PLUGINFINITY_PLUGIN:-}}\n template=$_PF_TOOLS_MCP\n template=${template//\\{plugin\\}/$plugin}\n template=${template//\\{server\\}/$server}\n printf '%s\\n' \"${template%%\\{tool\\}*}\"\n}\n\n# Whether the host honours capability $1 on event $2 (default: this event).\n# Mirrors okf/references/{claude-code,copilot-cli}-plugin-format.md.\n# server-project asks about the host, not an event: whether an MCP server can\n# learn the project (Claude gives it CLAUDE_PROJECT_DIR and roots; Copilot\n# gives none, measured 2026-10-07), the question server_project_dir answers.\nhook_supports() {\n local cap=\"${1:-}\" event=\"${2:-$_pf_event}\"\n case \"$PLUGINFINITY_HOST:$cap\" in\n *:noop | *:raw) return 0 ;;\n claude:system_message)\n case \"$event\" in Notification | SessionEnd | PreCompact | ConfigChange) return 1 ;; esac\n return 0\n ;;\n *:deny | *:allow | *:ask) [ \"$event\" = PreToolUse ] && return 0 ;;\n claude:context)\n case \"$event\" in\n SessionStart | SubagentStart | PostModelSwitch | UserPromptSubmit | UserPromptExpansion | PreToolUse | \\\n PostToolUse | PostToolUseFailure | PostToolBatch | Stop | SubagentStop) return 0 ;;\n esac\n ;;\n copilot:context)\n case \"$event\" in SessionStart | SubagentStart | PostToolUse | Notification) return 0 ;; esac\n ;;\n claude:block)\n case \"$event\" in\n UserPromptSubmit | UserPromptExpansion | PostToolUse | PostToolBatch | Stop | \\\n SubagentStop | ConfigChange | PreCompact | TaskCreated | PreModelSwitch) return 0 ;;\n esac\n ;;\n copilot:block)\n case \"$event\" in Stop | SubagentStop) return 0 ;; esac\n ;;\n claude:server-project) return 0 ;;\n claude:env-shell)\n case \"$event\" in SessionStart | Setup | CwdChanged | FileChanged) return 0 ;; esac\n ;;\n esac\n return 1\n}\n\n# --- session env ---------------------------------------------------------\n\n# Whether env.sh is loaded: the build ships it only when the config declares env.\n_pf_env_loaded=0\n\n# Set a declared session variable (the run-time rung of the env chain): record\n# it in the session values file, export it in this hook and, on Claude, append\n# it to CLAUDE_ENV_FILE so the model's shell sees it. Only the events that can\n# produce a value (SessionStart, Setup, CwdChanged, FileChanged) may call it,\n# and only for a name the config declares. It always returns 0: a refusal (any\n# other event, an undeclared name, a value with a newline, a build with no env)\n# is a log line, or a debug line for an event that cannot produce, and changes\n# nothing, so it never aborts a `set -e` hook or denies a fail-closed one.\nhook_env_set() {\n local name=${1:-}\n if [ \"$_pf_env_loaded\" != 1 ]; then\n hook_log \"hook_env_set: no session env is declared in this build\"\n return 0\n fi\n case \"$_pf_event\" in\n SessionStart | Setup | CwdChanged | FileChanged) ;;\n *)\n hook_debug \"hook_env_set $name ignored: ${_pf_event:-an unknown event} does not produce session values\"\n return 0\n ;;\n esac\n _pf_env_set \"$name\" \"${2-}\" || true\n return 0\n}\n\n# Load env.sh and apply the session values. A failure here never aborts the hook, even under set -e.\n_pf_env_start() {\n local sid proj cwd errexit=0 nounset=0\n [ -r \"$_pf_log_dir/env.sh\" ] || return 0\n case $- in *e*) errexit=1 ;; esac\n case $- in *u*) nounset=1 ;; esac\n set +eu\n _pf_env_lib_dir=\"$_pf_log_dir\"\n _pf_env_manual=1\n _pf_env_component=hook\n # shellcheck source=/dev/null\n if . \"$_pf_log_dir/env.sh\" 2>/dev/null; then\n _pf_env_loaded=1\n sid=$(hook_input session_id)\n cwd=$(hook_input cwd)\n if [ \"$PLUGINFINITY_HOST\" = copilot ] && [ \"${cwd#/}\" = \"$cwd\" ]; then\n # The runner's rule: Copilot runs hooks from the plugin root, which is no\n # project, so with no absolute cwd read no .env (the session file or the defaults).\n proj=-\n else\n proj=$(_pf_env_project_of \"$(hook_project_dir)\")\n fi\n env_load \"$sid\" \"$proj\"\n else\n hook_log \"env.sh not loadable; session env skipped\"\n fi\n [ \"$errexit\" = 1 ] && set -e\n [ \"$nounset\" = 1 ] && set -u\n return 0\n}\n\n# --- output ---------------------------------------------------------------\n\n_pf_emit() { # json [kind]\n if [ -z \"${1:-}\" ]; then\n hook_log \"refused to send an empty response\"\n return 1\n fi\n if _pf_has_emitted; then\n hook_debug \"ignored a second response: $1\"\n return 0\n fi\n printf '%s' \"${_pf_kind_prefix}${2:-response}\" >\"$_pf_marker\" 2>/dev/null || true\n printf '%s\\n' \"$1\"\n}\n\n_pf_unsupported() { # function-name\n hook_debug \"$1 does nothing on $PLUGINFINITY_HOST for ${_pf_event:-an unknown event}\"\n hook_noop\n}\n\n_pf_permission() { # decision reason [updated-input-json]\n local key=updatedInput body u=null\n [ \"$PLUGINFINITY_HOST\" = copilot ] && key=modifiedArgs\n if [ -n \"${3:-}\" ]; then\n u=$(printf '%s' \"$3\" | jq -c . 2>/dev/null) || {\n hook_log \"hook_allow: not JSON: $3\"\n return 1\n }\n fi\n body=$(jq -nc --arg d \"$1\" --arg r \"${2:-}\" --argjson u \"$u\" --arg k \"$key\" \\\n '{permissionDecision: $d}\n + (if $r == \"\" then {} else {permissionDecisionReason: $r} end)\n + (if $u == null then {} else {($k): $u} end)' 2>/dev/null) || return 1\n if [ \"$PLUGINFINITY_HOST\" != copilot ]; then\n body=$(jq -nc --argjson b \"$body\" '{hookSpecificOutput: ({hookEventName: \"PreToolUse\"} + $b)}') || return 1\n fi\n _pf_emit \"$body\" \"$1\"\n}\n\n# Respond with nothing to change.\nhook_noop() { _pf_emit '{}' noop; }\n\n# Add text to the model's context.\nhook_context() {\n hook_supports context || {\n _pf_unsupported hook_context\n return 0\n }\n local body\n if [ \"$PLUGINFINITY_HOST\" = copilot ]; then\n body=$(jq -nc --arg c \"${1:-}\" '{additionalContext: $c}') || return 1\n else\n body=$(jq -nc --arg e \"$_pf_event\" --arg c \"${1:-}\" \\\n '{hookSpecificOutput: {hookEventName: $e, additionalContext: $c}}') || return 1\n fi\n _pf_emit \"$body\" context\n}\n\n# PreToolUse: refuse the tool call.\nhook_deny() {\n hook_supports deny || {\n _pf_unsupported hook_deny\n return 0\n }\n _pf_permission deny \"${1:-Blocked by ${PLUGINFINITY_PLUGIN:-a plugin}}\"\n}\n\n# PreToolUse: allow the tool call, with an optional reason and an optional\n# replacement input (JSON).\nhook_allow() {\n hook_supports allow || {\n _pf_unsupported hook_allow\n return 0\n }\n _pf_permission allow \"${1:-}\" \"${2:-}\"\n}\n\n# PreToolUse: ask the user.\nhook_ask() {\n hook_supports ask || {\n _pf_unsupported hook_ask\n return 0\n }\n _pf_permission ask \"${1:-}\"\n}\n\n# Block the event's action with a reason (Stop: keep working on it).\nhook_block() {\n hook_supports block || {\n _pf_unsupported hook_block\n return 0\n }\n local body\n body=$(jq -nc --arg r \"${1:-Blocked by ${PLUGINFINITY_PLUGIN:-a plugin}}\" '{decision: \"block\", reason: $r}') || return 1\n _pf_emit \"$body\" block\n}\n\n# Show the user a message.\nhook_system_message() {\n hook_supports system_message || {\n _pf_unsupported hook_system_message\n return 0\n }\n local body\n body=$(jq -nc --arg m \"${1:-}\" '{systemMessage: $m}') || return 1\n _pf_emit \"$body\" system_message\n}\n\n# Print the input the way Claude would send it. On Copilot: hook_event_name\n# from hook_event, snake_case top-level keys (toolName/toolArgs become\n# tool_name/tool_input, parsed when a string), and Copilot's tool_input key\n# names mapped to Claude's where the Claude key is absent. On Claude: the\n# input unchanged, with hook_event_name filled in when missing.\nhook_envelope() {\n if [ \"${1:-}\" != claude ]; then\n hook_log \"hook_envelope: unknown target: ${1:-none}\"\n return 1\n fi\n local event\n event=$(hook_event 2>/dev/null) || event=\"\"\n printf '%s' \"$_pf_input\" | jq -c --arg event \"$event\" --arg host \"$PLUGINFINITY_HOST\" '\ndef snake: gsub(\"(?<c>[A-Z])\"; \"_\" + (.c | ascii_downcase));\ndef args: if type == \"string\" then (fromjson? // .) else . end;\ndef alias: {path: \"file_path\", file_text: \"content\", old_str: \"old_string\", new_str: \"new_string\"};\ndef fix: if type == \"object\" then\n . as $o | reduce (keys_unsorted[]) as $k ($o;\n if alias[$k] != null and (has(alias[$k]) | not) then . + {(alias[$k]): $o[$k]} else . end)\n else . end;\n(if $host == \"copilot\" then\n with_entries(.key |= (if . == \"toolName\" then \"tool_name\" elif . == \"toolArgs\" then \"tool_input\" else snake end))\n | if has(\"tool_input\") then .tool_input |= (args | fix) else . end\n else . end)\n| if (has(\"hook_event_name\") | not) and $event != \"\" then . + {hook_event_name: $event} else . end' 2>/dev/null || {\n hook_log \"hook_envelope: input is not a JSON object\"\n return 1\n }\n}\n\n# Map one Claude-shaped hook response onto this host's emitters. First match\n# wins: permission decision, block, additional context, system message, then\n# noop. Fields that lose or have no mapping are written to the debug log.\nhook_relay() {\n local plan kind reason input text path\n plan=$(printf '%s' \"${1:-}\" | jq -c '\nif type != \"object\" then error(\"not an object\") else . end\n| (.hookSpecificOutput | if type == \"object\" then . else {} end) as $h\n| ($h.permissionDecision) as $d\n| (if ($d == \"allow\" or $d == \"deny\" or $d == \"ask\") then\n {kind: $d, reason: ($h.permissionDecisionReason // \"\"), input: (if $d == \"allow\" and ($h.updatedInput != null) then ($h.updatedInput | tojson) else \"\" end), text: \"\",\n used: [\"hookSpecificOutput.permissionDecision\", \"hookSpecificOutput.permissionDecisionReason\", \"hookSpecificOutput.updatedInput\"]}\n elif .decision == \"block\" then\n {kind: \"block\", reason: (.reason // \"\"), input: \"\", text: \"\", used: [\"decision\", \"reason\"]}\n elif ($h.additionalContext != null) then\n {kind: \"context\", reason: \"\", input: \"\", text: ($h.additionalContext | if type == \"string\" then . else tojson end), used: [\"hookSpecificOutput.additionalContext\"]}\n elif .systemMessage != null then\n {kind: \"system_message\", reason: \"\", input: \"\", text: (.systemMessage | if type == \"string\" then . else tojson end), used: [\"systemMessage\"]}\n else {kind: \"noop\", reason: \"\", input: \"\", text: \"\", used: []} end) as $p\n| ([paths | select((length == 1 and (.[0] != \"hookSpecificOutput\" or ($h | length) == 0)) or (length == 2 and .[0] == \"hookSpecificOutput\" and (($h | length) > 0)))\n | join(\".\")] | map(select(. != \"hookSpecificOutput.hookEventName\"))) as $all\n| $p + {dropped: ($all - $p.used)}' 2>/dev/null) || {\n hook_log \"hook_relay: not a JSON object\"\n return 1\n }\n kind=$(jq -r .kind <<<\"$plan\")\n reason=$(jq -r .reason <<<\"$plan\")\n input=$(jq -r .input <<<\"$plan\")\n text=$(jq -r .text <<<\"$plan\")\n while IFS= read -r path; do\n [ -n \"$path\" ] && hook_debug \"hook_relay dropped $path\"\n done <<<\"$(jq -r '.dropped[]' <<<\"$plan\")\"\n case \"$kind\" in\n allow) hook_allow \"$reason\" \"$input\" ;;\n deny) hook_deny \"$reason\" ;;\n ask) hook_ask \"$reason\" ;;\n block) hook_block \"$reason\" ;;\n context) hook_context \"$text\" ;;\n system_message) hook_system_message \"$text\" ;;\n *) hook_noop ;;\n esac\n}\n\n# Emit a host-specific JSON response verbatim, only on that host.\nhook_raw() {\n if [ \"${1:-}\" != \"$PLUGINFINITY_HOST\" ]; then\n hook_debug \"hook_raw for ${1:-no host} skipped on $PLUGINFINITY_HOST\"\n return 0\n fi\n local body\n body=$(printf '%s' \"${2:-}\" | jq -c . 2>/dev/null) || {\n hook_log \"hook_raw: not JSON: ${2:-}\"\n return 1\n }\n _pf_emit \"$body\" raw\n}\n\ntrap _pf_on_exit EXIT\n\nif pf_debug_on; then hook_debug \"input: ${_pf_input:0:4000}\"; fi\n\n# --- matcher ---------------------------------------------------------------\n\n# A host that ignores an event's matcher (Copilot on SessionStart, SessionEnd\n# and SubagentStop) has the build pass it as PLUGINFINITY_MATCHER. Apply\n# Claude's rules here: empty or `*` matches all; only [A-Za-z0-9_| ,-] is an\n# exact `|` list; anything else is an unanchored extended regex. No match ends\n# the script quietly, so nothing is emitted and the exit is 0.\n_pf_matcher_applies() { # matcher value\n local m=$1 v=$2 item\n local -a items\n { [ -z \"$m\" ] || [ \"$m\" = '*' ]; } && return 0\n if [[ ! \"$m\" =~ [^A-Za-z0-9_\\|\\ ,-] ]]; then\n IFS='|' read -r -a items <<<\"$m\"\n for item in \"${items[@]}\"; do\n [ \"$item\" = \"$v\" ] && return 0\n done\n return 1\n fi\n printf '%s' \"$v\" | grep -Eq -- \"$m\" 2>/dev/null\n}\n\nif [ -n \"${PLUGINFINITY_MATCHER+x}\" ]; then\n _pf_match_field=\"\"\n case \"$_pf_event\" in\n SessionStart) _pf_match_field=source ;;\n SessionEnd) _pf_match_field=reason ;;\n SubagentStop) _pf_match_field=agent_type ;;\n esac\n if [ -n \"$_pf_match_field\" ]; then\n _pf_match_value=$(hook_input \"$_pf_match_field\")\n if ! _pf_matcher_applies \"$PLUGINFINITY_MATCHER\" \"$_pf_match_value\"; then\n hook_debug \"matcher $PLUGINFINITY_MATCHER did not match $_pf_match_value\"\n exit 0\n fi\n fi\nfi\n\n# --- session env ------------------------------------------------------------\n\n# After the matcher, so a skipped hook does not pay for it. A build with no\n# env.sh has no session env and this does nothing.\n_pf_env_start\n"
|
|
6
6
|
}];
|
|
7
7
|
|
|
8
|
-
//#endregion
|
|
9
8
|
export { HOOK_LIB_FILES };
|
package/hook-lib.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HOOK_LIB_FILES } from "./hook-lib.generated.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/hook-lib.ts
|
|
4
4
|
/** Where every build that has hooks gets the hook library, relative to the build root. */
|
|
5
5
|
const HOOK_LIB_DIR = "hooks/lib/pluginfinity";
|
|
6
6
|
const singleQuote = (value) => `'${value.replaceAll("'", `'\\''`)}'`;
|
|
@@ -28,5 +28,4 @@ const hookLibFiles = (host, plugin, version, toolMap) => [
|
|
|
28
28
|
}
|
|
29
29
|
];
|
|
30
30
|
|
|
31
|
-
//#endregion
|
|
32
31
|
export { HOOK_LIB_DIR, hookLibFiles, renderHostFile };
|
package/hook-output.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/hook-output.ts
|
|
2
2
|
/** The hook library helpers whose output a host may ignore, by the `hooks.output` key that says where it is honoured. */
|
|
3
3
|
const HELPERS = [{
|
|
4
4
|
helper: "hook_context",
|
|
@@ -64,5 +64,4 @@ const ignoredOutput = (id, target, events, read) => {
|
|
|
64
64
|
return notes;
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
//#endregion
|
|
68
67
|
export { ignoredOutput };
|
package/hooks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/hooks.ts
|
|
2
2
|
/**
|
|
3
3
|
* The hooks a target builds, before rendering: the base `hooks` with the
|
|
4
4
|
* target's per-event overrides applied (an override replaces the base entries
|
|
@@ -212,5 +212,4 @@ const renderHooks = (target, events, invoke) => {
|
|
|
212
212
|
return `${JSON.stringify(FORMATS[target.hooks.format](events, (entry, env) => hookCommand(entry, root, invoke, env), (entry, env) => hookExec(entry, root, invoke, env), target.hooks.matcherIgnored), null, " ")}\n`;
|
|
213
213
|
};
|
|
214
214
|
|
|
215
|
-
//#endregion
|
|
216
215
|
export { commandFiles, entryEnv, hookCommand, hookCommandFiles, hookExec, hookScripts, renderHooks, sessionStartMatcher, shellEnvPrefix, targetHooks, widensSessionStart };
|
package/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { Duration, Effect, FileSystem, Layer, Path, PlatformError, Schema } from
|
|
|
4
4
|
import { Remediation } from "@effected/engine";
|
|
5
5
|
import { ToolDiscovery } from "@effected/commands";
|
|
6
6
|
import { ChildProcessSpawner } from "effect/process";
|
|
7
|
-
//#region src/emit.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* The mode every generated file is written with.
|
|
10
9
|
*
|
|
@@ -73,8 +72,6 @@ export declare const planEmit: (dir: string, files: ReadonlyArray<EmittedFile>)
|
|
|
73
72
|
* @public
|
|
74
73
|
*/
|
|
75
74
|
export declare const applyEmit: (dir: string, files: ReadonlyArray<EmittedFile>, plan: EmitPlan) => Effect.Effect<void, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/errors.d.ts
|
|
78
75
|
declare const ConfigIssue_base: Schema.Class<ConfigIssue, Schema.Struct<{
|
|
79
76
|
/** The dotted key path inside the config, `""` for the config as a whole. */
|
|
80
77
|
readonly key: Schema.String;
|
|
@@ -395,8 +392,6 @@ type BuildError = PackageVersionMissing | BuildStale | HostRejected | HookEventU
|
|
|
395
392
|
* @public
|
|
396
393
|
*/
|
|
397
394
|
export declare const isBuildError: (error: unknown) => error is BuildError;
|
|
398
|
-
//#endregion
|
|
399
|
-
//#region src/notes.d.ts
|
|
400
395
|
/**
|
|
401
396
|
* Every note kind, in the order they are sorted and printed.
|
|
402
397
|
*
|
|
@@ -436,8 +431,6 @@ interface BuildNote {
|
|
|
436
431
|
/** The field, tool or event name, e.g. `color`, `ToolSearch`, `Notification`, `lspServers.md.diagnostics`. */
|
|
437
432
|
readonly name: string;
|
|
438
433
|
}
|
|
439
|
-
//#endregion
|
|
440
|
-
//#region src/frontmatter.d.ts
|
|
441
434
|
/**
|
|
442
435
|
* A markdown file split at its YAML frontmatter: the frontmatter text without
|
|
443
436
|
* its fences, and the body after the closing fence, unchanged.
|
|
@@ -534,8 +527,6 @@ export declare const appendSections: (body: string, sections: ReadonlyArray<{
|
|
|
534
527
|
readonly field: string;
|
|
535
528
|
readonly value: unknown;
|
|
536
529
|
}>) => string;
|
|
537
|
-
//#endregion
|
|
538
|
-
//#region src/tokens.d.ts
|
|
539
530
|
/**
|
|
540
531
|
* What {@link renderTokens} needs to spell a plugin's tokens and links for
|
|
541
532
|
* one target.
|
|
@@ -653,8 +644,6 @@ export declare const renderTokens: (text: string, ctx: TokenContext) => {
|
|
|
653
644
|
} | {
|
|
654
645
|
readonly problems: ReadonlyArray<TokenProblem>;
|
|
655
646
|
};
|
|
656
|
-
//#endregion
|
|
657
|
-
//#region src/agents.d.ts
|
|
658
647
|
/**
|
|
659
648
|
* One agent as read from `agents/<name>.md`: its name, its decoded
|
|
660
649
|
* frontmatter and its body.
|
|
@@ -708,8 +697,6 @@ interface RenderedAgent {
|
|
|
708
697
|
* @public
|
|
709
698
|
*/
|
|
710
699
|
export declare const renderAgent: (target: Target, id: KnownTargetId, agent: SourceAgent, known: ReadonlyArray<string>, tokens: TokenContext) => Effect.Effect<RenderedAgent | undefined, ComponentInvalid | PlatformError.PlatformError, FileSystem.FileSystem>;
|
|
711
|
-
//#endregion
|
|
712
|
-
//#region src/body.d.ts
|
|
713
700
|
/**
|
|
714
701
|
* Why a body's host blocks are malformed, with the 1-based line it was found on.
|
|
715
702
|
*
|
|
@@ -733,8 +720,6 @@ export declare const applyHostBlocks: (text: string, target: string, known: Read
|
|
|
733
720
|
} | {
|
|
734
721
|
readonly problem: HostBlockProblem;
|
|
735
722
|
};
|
|
736
|
-
//#endregion
|
|
737
|
-
//#region src/discovery.d.ts
|
|
738
723
|
/**
|
|
739
724
|
* The config file names discovery looks for, in preference order.
|
|
740
725
|
*
|
|
@@ -760,8 +745,6 @@ export declare class ConfigDiscovery {
|
|
|
760
745
|
*/
|
|
761
746
|
static readonly all: (start: string) => Effect.Effect<ReadonlyArray<string>, ConfigAmbiguous, FileSystem.FileSystem | Path.Path>;
|
|
762
747
|
}
|
|
763
|
-
//#endregion
|
|
764
|
-
//#region src/loader.d.ts
|
|
765
748
|
/**
|
|
766
749
|
* A config that loaded, decoded and enables at least one target.
|
|
767
750
|
*
|
|
@@ -789,8 +772,6 @@ export declare class ConfigLoader {
|
|
|
789
772
|
*/
|
|
790
773
|
static readonly load: (path: string) => Effect.Effect<LoadedConfig, ConfigLoadFailed | ConfigInvalid | UnknownTarget, Path.Path>;
|
|
791
774
|
}
|
|
792
|
-
//#endregion
|
|
793
|
-
//#region src/selection.d.ts
|
|
794
775
|
/**
|
|
795
776
|
* Which configs an operation runs against. A front end builds it from
|
|
796
777
|
* `[path]`, `--config` and `--all`; using `--config` and `--all` together is
|
|
@@ -840,8 +821,6 @@ export declare const preparePlugins: (input: {
|
|
|
840
821
|
readonly selection: ConfigSelection;
|
|
841
822
|
readonly targets: ReadonlyArray<KnownTargetId>;
|
|
842
823
|
}) => Effect.Effect<ReadonlyArray<PreparedPlugin>, ConfigError, FileSystem.FileSystem | Path.Path>;
|
|
843
|
-
//#endregion
|
|
844
|
-
//#region src/doctor.d.ts
|
|
845
824
|
/**
|
|
846
825
|
* The lowest Node.js version pluginfinity runs on: the `engines` floor.
|
|
847
826
|
*
|
|
@@ -936,8 +915,6 @@ interface DoctorInput {
|
|
|
936
915
|
* @public
|
|
937
916
|
*/
|
|
938
917
|
export declare const runDoctor: (input: DoctorInput) => Effect.Effect<DoctorReport, never, ToolDiscovery | FileSystem.FileSystem | Path.Path>;
|
|
939
|
-
//#endregion
|
|
940
|
-
//#region src/hooks.d.ts
|
|
941
918
|
/**
|
|
942
919
|
* One event's hooks as a target builds them: the source event name, the
|
|
943
920
|
* target's name for it, and the entries.
|
|
@@ -1068,8 +1045,6 @@ export declare const widensSessionStart: (ignored: ReadonlyArray<string>, event:
|
|
|
1068
1045
|
* @public
|
|
1069
1046
|
*/
|
|
1070
1047
|
export declare const renderHooks: (target: Target, events: ReadonlyArray<TargetHookEvent>, invoke: "bash" | "exec") => string | undefined;
|
|
1071
|
-
//#endregion
|
|
1072
|
-
//#region src/env.d.ts
|
|
1073
1048
|
/**
|
|
1074
1049
|
* Seconds the env runner gives the `setup` script before it discards its
|
|
1075
1050
|
* output and resolves without it.
|
|
@@ -1146,8 +1121,6 @@ export declare const ENV_WAIT_TIMEOUT_FLOOR = 5;
|
|
|
1146
1121
|
* @public
|
|
1147
1122
|
*/
|
|
1148
1123
|
export declare const envWaitNotes: (id: KnownTargetId, events: ReadonlyArray<TargetHookEvent>) => ReadonlyArray<BuildNote>;
|
|
1149
|
-
//#endregion
|
|
1150
|
-
//#region src/logs.d.ts
|
|
1151
1124
|
/**
|
|
1152
1125
|
* The two files a plugin's components log to.
|
|
1153
1126
|
*
|
|
@@ -1258,8 +1231,6 @@ export declare const readLogFrom: (path: string, offset: number) => Effect.Effec
|
|
|
1258
1231
|
readonly lines: ReadonlyArray<string>;
|
|
1259
1232
|
readonly offset: number;
|
|
1260
1233
|
}, PlatformError.PlatformError, FileSystem.FileSystem>;
|
|
1261
|
-
//#endregion
|
|
1262
|
-
//#region src/manifest.d.ts
|
|
1263
1234
|
/**
|
|
1264
1235
|
* A manifest as written: a JSON object in the target's key order.
|
|
1265
1236
|
*
|
|
@@ -1281,8 +1252,6 @@ export declare const renderManifest: (target: Target, id: KnownTargetId, config:
|
|
|
1281
1252
|
* @public
|
|
1282
1253
|
*/
|
|
1283
1254
|
export declare const serializeManifest: (manifest: Manifest) => string;
|
|
1284
|
-
//#endregion
|
|
1285
|
-
//#region src/monitors.d.ts
|
|
1286
1255
|
/**
|
|
1287
1256
|
* Monitors by name.
|
|
1288
1257
|
*
|
|
@@ -1340,8 +1309,6 @@ interface MonitorContext {
|
|
|
1340
1309
|
* @public
|
|
1341
1310
|
*/
|
|
1342
1311
|
export declare const renderMonitors: (target: Target, id: KnownTargetId, monitors: MonitorMap, invoke: "bash" | "exec", context: MonitorContext) => RenderedMonitors;
|
|
1343
|
-
//#endregion
|
|
1344
|
-
//#region src/operations.d.ts
|
|
1345
1312
|
/**
|
|
1346
1313
|
* The input to `build`.
|
|
1347
1314
|
*
|
|
@@ -1415,8 +1382,6 @@ export declare const build: (input: BuildInput) => Effect.Effect<ReadonlyArray<T
|
|
|
1415
1382
|
* @public
|
|
1416
1383
|
*/
|
|
1417
1384
|
export declare const validate: (input: ValidateInput) => Effect.Effect<ReadonlyArray<TargetValidation>, ConfigError | PlanError | BuildStale | HostRejected, FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>;
|
|
1418
|
-
//#endregion
|
|
1419
|
-
//#region src/servers.d.ts
|
|
1420
1385
|
/**
|
|
1421
1386
|
* A target's server config files, the server maps it writes inline in its
|
|
1422
1387
|
* manifest, the problems that stop it building them, whether any server is a
|
|
@@ -1470,8 +1435,6 @@ interface ServerFiles {
|
|
|
1470
1435
|
* @public
|
|
1471
1436
|
*/
|
|
1472
1437
|
export declare const serverFiles: (target: Target, id: KnownTargetId, config: PluginfinityConfig) => ServerFiles;
|
|
1473
|
-
//#endregion
|
|
1474
|
-
//#region src/skills.d.ts
|
|
1475
1438
|
/**
|
|
1476
1439
|
* The most characters a built skill's `description` may hold: the Agent
|
|
1477
1440
|
* Skills spec's limit, which Copilot enforces.
|
|
@@ -1536,8 +1499,6 @@ interface RenderedSkill {
|
|
|
1536
1499
|
* @public
|
|
1537
1500
|
*/
|
|
1538
1501
|
export declare const renderSkill: (target: Target, id: KnownTargetId, skill: SourceSkill, known: ReadonlyArray<string>, tokens: TokenContext) => Effect.Effect<RenderedSkill | undefined, ComponentInvalid | ComponentsInvalid | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
1539
|
-
//#endregion
|
|
1540
|
-
//#region src/tools.d.ts
|
|
1541
1502
|
/**
|
|
1542
1503
|
* The `ToolDiscovery` doctor uses in production: global lookups only, over the
|
|
1543
1504
|
* platform's `ChildProcessSpawner`. Bound once so every provide shares it.
|
|
@@ -1545,8 +1506,6 @@ export declare const renderSkill: (target: Target, id: KnownTargetId, skill: Sou
|
|
|
1545
1506
|
* @public
|
|
1546
1507
|
*/
|
|
1547
1508
|
export declare const ToolDiscoveryLive: Layer.Layer<ToolDiscovery, never, ChildProcessSpawner.ChildProcessSpawner>;
|
|
1548
|
-
//#endregion
|
|
1549
|
-
//#region src/version.d.ts
|
|
1550
1509
|
/**
|
|
1551
1510
|
* The version of `@pluginfinity/engine` this build was made from: the comparable
|
|
1552
1511
|
* version of a pluginfinity run.
|
|
@@ -1561,6 +1520,5 @@ export declare const ToolDiscoveryLive: Layer.Layer<ToolDiscovery, never, ChildP
|
|
|
1561
1520
|
* @public
|
|
1562
1521
|
*/
|
|
1563
1522
|
export declare const ENGINE_VERSION: string;
|
|
1564
|
-
//#endregion
|
|
1565
1523
|
export type { BuildError, BuildInput, BuildNote, BuildNoteKind, ConfigError, ConfigSelection, DoctorInput, EmittedFile, FieldDrop, HostBlockProblem, LoadedConfig, LogEntry, LogFileName, LogTail, Manifest, MappedFrontmatter, MonitorContext, MonitorMap, OwnMcp, PlanError, PreparedPlugin, RawLogLine, RenderedAgent, RenderedMonitors, RenderedSkill, ServerFiles, ServerRender, SourceAgent, SourceSkill, SplitMarkdown, TargetBuild, TargetHookEvent, TargetValidation, TokenContext, TokenProblem, UnresolvedField, UnsupportedHookEvent, ValidateInput };
|
|
1566
1524
|
//# sourceMappingURL=index.d.ts.map
|
package/lib-files.js
CHANGED
|
@@ -3,7 +3,7 @@ import { renderHostFile } from "./hook-lib.js";
|
|
|
3
3
|
import { LOG_LIB_FILES } from "./log-lib.generated.js";
|
|
4
4
|
import { MONITOR_LIB_FILES } from "./monitor-lib.generated.js";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/lib-files.ts
|
|
7
7
|
/**
|
|
8
8
|
* Where every build gets the shared libraries (`log.sh`, `host.sh`, the server library when
|
|
9
9
|
* there is a local server, `monitor.sh` when a target has monitors, and `env.sh` with its
|
|
@@ -35,5 +35,4 @@ const libFiles = (host, plugin, version, options) => [
|
|
|
35
35
|
...options.env === void 0 ? [] : envLibFiles(options.env, LIB_DIR)
|
|
36
36
|
];
|
|
37
37
|
|
|
38
|
-
//#endregion
|
|
39
38
|
export { LIB_DIR, libFiles };
|
package/loader.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Effect, Path, Schema, SchemaIssue } from "effect";
|
|
|
4
4
|
import { CONFIG_KEYS, KNOWN_TARGET_IDS, PluginfinityConfig, enabledTargets } from "@pluginfinity/targets";
|
|
5
5
|
import { createJiti } from "jiti";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/loader.ts
|
|
8
8
|
const firstLine = (cause) => {
|
|
9
9
|
const text = cause instanceof Error ? cause.message : String(cause);
|
|
10
10
|
return text.split("\n")[0]?.trim() ?? text;
|
|
@@ -77,5 +77,4 @@ var ConfigLoader = class {
|
|
|
77
77
|
});
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
//#endregion
|
|
81
80
|
export { ConfigLoader };
|
package/log-lib.generated.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// src/log-lib.generated.ts
|
|
2
2
|
/** The logging library's files, embedded so a build needs no asset on disk. */
|
|
3
3
|
const LOG_LIB_FILES = [{
|
|
4
4
|
name: "log.sh",
|
|
5
5
|
content: "# shellcheck shell=sh\n# pluginfinity logging. `pluginfinity build` writes this file into every\n# target at lib/pluginfinity/log.sh; do not edit a copy under builds/, the next\n# build overwrites it.\n#\n# POSIX sh. Writes nothing to stdout. Set _pf_log_dir to this file's directory,\n# source it, then call pf_log / pf_debug. From a skill script:\n# _pf_log_dir=\"$(dirname \"$0\")/../../../lib/pluginfinity\"; . \"$_pf_log_dir/log.sh\"\n#\n# Lines go to ${XDG_STATE_HOME:-$HOME/.local/state}/pluginfinity/<plugin>/error.log\n# and, when PLUGINFINITY_DEBUG=1, debug.log, as\n# <ISO-8601 UTC> [<host>] <component>/<script>: <message>\n\n# POSIX sh cannot find a sourced file's own path, so the sourcer sets\n# _pf_log_dir first. host.sh there names the host and plugin.\nif [ -z \"${PLUGINFINITY_PLUGIN:-}\" ] && [ -n \"${_pf_log_dir:-}\" ] && [ -f \"$_pf_log_dir/host.sh\" ]; then\n # shellcheck source=/dev/null\n . \"$_pf_log_dir/host.sh\" 2>/dev/null || :\nfi\n\n_pf_log_write() { # file component message\n _pf_d=\"${XDG_STATE_HOME:-${HOME:-/nonexistent}/.local/state}/pluginfinity/${PLUGINFINITY_PLUGIN:-unknown}\"\n mkdir -p \"$_pf_d\" 2>/dev/null || return 0\n printf '%s [%s] %s/%s: %s\\n' \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\" \"${PLUGINFINITY_HOST:-unknown}\" \\\n \"$2\" \"$(basename \"$0\")\" \"$3\" >>\"$_pf_d/$1\" 2>/dev/null || return 0\n}\n\n# True when PLUGINFINITY_DEBUG=1.\npf_debug_on() { [ \"${PLUGINFINITY_DEBUG:-0}\" = 1 ]; }\n\n# pf_log <component> <message...>: append to error.log. Never fails.\npf_log() {\n _pf_c=${1:-}\n if [ $# -gt 0 ]; then shift; fi\n _pf_log_write error.log \"$_pf_c\" \"$*\"\n return 0\n}\n\n# pf_debug <component> <message...>: append to debug.log when PLUGINFINITY_DEBUG=1.\npf_debug() {\n pf_debug_on || return 0\n _pf_c=${1:-}\n if [ $# -gt 0 ]; then shift; fi\n _pf_log_write debug.log \"$_pf_c\" \"$*\"\n return 0\n}\n\nscript_log() { pf_log script \"$@\"; }\nscript_debug() { pf_debug script \"$@\"; }\n"
|
|
6
6
|
}];
|
|
7
7
|
|
|
8
|
-
//#endregion
|
|
9
8
|
export { LOG_LIB_FILES };
|
package/logs.js
CHANGED
|
@@ -2,7 +2,7 @@ import { preparePlugins } from "./selection.js";
|
|
|
2
2
|
import { pluginName } from "./manifest.js";
|
|
3
3
|
import { Effect, FileSystem, Path } from "effect";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/logs.ts
|
|
6
6
|
const LINE = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z) \[([^\]]*)\] (hook|server|monitor|script)\/([^:]*): (.*)$/;
|
|
7
7
|
/**
|
|
8
8
|
* Parse one log line, or carry it through as raw when it does not follow the
|
|
@@ -143,5 +143,4 @@ const readLogFrom = (path, offset) => Effect.gen(function* () {
|
|
|
143
143
|
offset: 0
|
|
144
144
|
}) : Effect.fail(error)));
|
|
145
145
|
|
|
146
|
-
//#endregion
|
|
147
146
|
export { configPluginNames, listLogPlugins, logDirectory, logRoot, parseLogLine, readLog, readLogFrom };
|
package/manifest.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/manifest.ts
|
|
2
2
|
/** The name a target publishes under: its override, else the config's. */
|
|
3
3
|
const pluginName = (config, id) => {
|
|
4
4
|
const setting = config[id];
|
|
@@ -43,5 +43,4 @@ const renderManifest = (target, id, config, version, servers = {}) => {
|
|
|
43
43
|
*/
|
|
44
44
|
const serializeManifest = (manifest) => `${JSON.stringify(manifest, null, " ")}\n`;
|
|
45
45
|
|
|
46
|
-
//#endregion
|
|
47
46
|
export { pluginName, renderManifest, serializeManifest };
|
package/monitor-lib.generated.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// src/monitor-lib.generated.ts
|
|
2
2
|
/** The monitor library's files, embedded so a build needs no asset on disk. */
|
|
3
3
|
const MONITOR_LIB_FILES = [{
|
|
4
4
|
name: "monitor.sh",
|
|
5
5
|
content: "# shellcheck shell=sh\n# pluginfinity monitor library. `pluginfinity build` writes this file into every\n# target that has monitors, at lib/pluginfinity/monitor.sh; do not edit a copy\n# under builds/, the next build overwrites it.\n#\n# POSIX sh. Writes to stdout only through monitor_notify: one line on stdout is\n# one notification. Set _pf_lib_dir to this file's directory, source it, then\n# call the functions. From a script at monitors/x.sh:\n# _pf_lib_dir=\"$(dirname \"$0\")/../lib/pluginfinity\"; . \"$_pf_lib_dir/monitor.sh\"\n#\n# A monitor never exits non-zero because of an error inside one poll: the\n# library logs it and the loop keeps going.\n#\n# monitor_notify cannot tell monitor_every that stdout closed when it runs inside\n# $(...) or a pipeline subshell; call it directly from the polled function.\n#\n# PLUGINFINITY_MONITOR_MAX_TICKS=<n> is a contract every monitor honours: stop\n# after n checks, however triggered (a poll, a startup sweep, or one handled\n# event). n is a positive integer; monitor_every logs any other value once and\n# ignores it (unbounded). monitor_every does it for you; a monitor that does not use it,\n# such as a node `command` monitor, must honour it itself, because the bats\n# helper's run_monitor sets it to bound a test. Do not set it in a plugin.\n\n# POSIX sh cannot find a sourced file's own path, so the sourcer sets _pf_lib_dir\n# (or _pf_log_dir, the log.sh convention) to this file's directory first. log.sh\n# and host.sh live beside this file. Without a readable log.sh the logging\n# functions are no-ops and the monitor still runs.\n_pf_mon_dir=\"${_pf_lib_dir:-${_pf_log_dir:-.}}\"\n_pf_log_dir=\"$_pf_mon_dir\"\nif [ -r \"$_pf_mon_dir/log.sh\" ]; then\n # shellcheck source=/dev/null\n . \"$_pf_mon_dir/log.sh\"\nelse\n pf_log() { return 0; }\n pf_debug() { return 0; }\n pf_debug_on() { return 1; }\nfi\n\n# A closed stdout must surface as a failed write, not as SIGPIPE killing the monitor.\ntrap '' PIPE\n_pf_mon_closed=0\n\nmonitor_name() { printf '%s\\n' \"${PLUGINFINITY_MONITOR:-$(basename \"$0\" .sh)}\"; }\nmonitor_host() { printf '%s\\n' \"${PLUGINFINITY_HOST:-unknown}\"; }\nmonitor_plugin_root() { (cd \"$_pf_mon_dir/../..\" 2>/dev/null && pwd -P) || printf '%s\\n' \"$_pf_mon_dir/../..\"; }\n\nmonitor_project_dir() {\n if [ -n \"${CLAUDE_PROJECT_DIR:-}\" ]; then\n printf '%s\\n' \"$CLAUDE_PROJECT_DIR\"\n return 0\n fi\n _pf_g=$(git rev-parse --show-toplevel 2>/dev/null) || _pf_g=\n printf '%s\\n' \"${_pf_g:-$PWD}\"\n}\n\nmonitor_log() { pf_log monitor \"$@\"; }\nmonitor_debug() { pf_debug monitor \"$@\"; }\n\n# monitor_notify <text...>: one line on stdout, flushed. Newlines become spaces.\n# Returns 1 when stdout is closed (and monitor_every then stops).\nmonitor_notify() {\n _pf_t=$(printf '%s' \"$*\" | tr '\\r\\n' ' ')\n if [ -z \"$_pf_t\" ]; then\n monitor_debug \"monitor_notify: empty text ignored\"\n return 0\n fi\n if ! printf '%s\\n' \"$_pf_t\" 2>/dev/null; then\n _pf_mon_closed=1\n return 1\n fi\n return 0\n}\n\n# monitor_state_dir: $XDG_STATE_HOME/pluginfinity/<plugin>/monitor/<name>/, created.\nmonitor_state_dir() {\n _pf_s=\"${XDG_STATE_HOME:-${HOME:-/nonexistent}/.local/state}/pluginfinity/${PLUGINFINITY_PLUGIN:-unknown}/monitor/$(monitor_name)/\"\n mkdir -p \"$_pf_s\" 2>/dev/null || :\n printf '%s\\n' \"$_pf_s\"\n}\n\n# monitor_once <key> <text...>: monitor_notify only the first time <key> is seen this session.\nmonitor_once() {\n _pf_k=${1:-}\n if [ $# -gt 0 ]; then shift; fi\n _pf_sd=$(monitor_state_dir)\n _pf_sess=\"${CLAUDE_CODE_SESSION_ID:-${CLAUDE_SESSION_ID:-$PPID}}\"\n # Keys are made filename-safe; the session scopes the marker.\n _pf_m=\"$_pf_sd$(printf '%s' \"$_pf_sess.$_pf_k\" | tr -c 'A-Za-z0-9._-' '_')\"\n if [ -e \"$_pf_m\" ]; then\n return 0\n fi\n monitor_notify \"$@\" || return 1\n : >\"$_pf_m\" 2>/dev/null || :\n}\n\n# monitor_every <seconds> <function>: call <function> now and every <seconds>, forever.\n# A failing call is logged and the loop continues; a closed stdout ends it with exit 0.\nmonitor_every() {\n _pf_iv=${1:-}\n case \"$_pf_iv\" in\n '' | *[!0-9]*)\n monitor_log \"monitor_every: interval '$_pf_iv' is not a number of seconds; using 60\"\n _pf_iv=60\n ;;\n esac\n _pf_fn=${2:-:}\n # PLUGINFINITY_MONITOR_MAX_TICKS is a positive integer; anything else is\n # logged once and treated as unset, so a test mistake never loops on an error.\n _pf_max=${PLUGINFINITY_MONITOR_MAX_TICKS:-}\n case \"$_pf_max\" in\n '') ;;\n *[!0-9]*)\n monitor_log \"monitor_every: PLUGINFINITY_MONITOR_MAX_TICKS '$_pf_max' is not a positive integer; ignoring it\"\n _pf_max=\n ;;\n *)\n if [ \"$_pf_max\" -le 0 ] 2>/dev/null; then\n monitor_log \"monitor_every: PLUGINFINITY_MONITOR_MAX_TICKS '$_pf_max' is not a positive integer; ignoring it\"\n _pf_max=\n fi\n ;;\n esac\n _pf_n=0\n while :; do\n if \"$_pf_fn\"; then _pf_rc=0; else _pf_rc=$?; fi\n if [ \"$_pf_mon_closed\" = 1 ]; then\n monitor_debug \"stdout closed; stopping\"\n exit 0\n fi\n if [ \"$_pf_rc\" -ne 0 ]; then\n monitor_log \"$_pf_fn failed (exit $_pf_rc)\"\n fi\n _pf_n=$((_pf_n + 1))\n if [ -n \"$_pf_max\" ] && [ \"$_pf_n\" -ge \"$_pf_max\" ]; then\n return 0\n fi\n sleep \"$_pf_iv\"\n done\n}\n"
|
|
6
6
|
}];
|
|
7
7
|
|
|
8
|
-
//#endregion
|
|
9
8
|
export { MONITOR_LIB_FILES };
|
package/monitors.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ConfigIssue } from "./errors.js";
|
|
|
2
2
|
import { CONFIG_NOTE_PATH } from "./notes.js";
|
|
3
3
|
import { commandFiles, hookCommand, shellEnvPrefix } from "./hooks.js";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/monitors.ts
|
|
6
6
|
/**
|
|
7
7
|
* The monitors a target builds: the base `monitors` with the target's own
|
|
8
8
|
* replacing the base monitor of the same name.
|
|
@@ -84,5 +84,4 @@ const renderMonitors = (target, id, monitors, invoke, context) => {
|
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
//#endregion
|
|
88
87
|
export { renderMonitors, targetMonitors };
|
package/notes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/notes.ts
|
|
2
2
|
/**
|
|
3
3
|
* Every note kind, in the order they are sorted and printed.
|
|
4
4
|
*
|
|
@@ -32,5 +32,4 @@ const sortNotes = (notes) => {
|
|
|
32
32
|
}).sort(order);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
//#endregion
|
|
36
35
|
export { BUILD_NOTE_KINDS, CONFIG_NOTE_PATH, sortNotes };
|
package/operations.js
CHANGED
|
@@ -21,7 +21,7 @@ import { KNOWN_TARGET_IDS, TARGETS } from "@pluginfinity/targets";
|
|
|
21
21
|
import { Run } from "@effected/commands";
|
|
22
22
|
import { ChildProcess } from "effect/process";
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
// src/operations.ts
|
|
25
25
|
const PackageVersion = Schema.fromJsonString(Schema.Struct({ version: Schema.String }));
|
|
26
26
|
/** The version every manifest copies: `version` in the `package.json` beside the config. */
|
|
27
27
|
const readVersion = (root) => Effect.gen(function* () {
|
|
@@ -547,5 +547,4 @@ const validate = (input) => Effect.gen(function* () {
|
|
|
547
547
|
return validations;
|
|
548
548
|
});
|
|
549
549
|
|
|
550
|
-
//#endregion
|
|
551
550
|
export { build, validate };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluginfinity/engine",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
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": [
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"./package.json": "./package.json"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@effected/commands": "^0.
|
|
38
|
-
"@effected/engine": "^0.
|
|
39
|
-
"@effected/glob": "^0.
|
|
40
|
-
"@effected/semver": "^0.
|
|
41
|
-
"@effected/walker": "^0.
|
|
42
|
-
"@effected/yaml": "^0.
|
|
37
|
+
"@effected/commands": "^0.15.1",
|
|
38
|
+
"@effected/engine": "^0.8.0",
|
|
39
|
+
"@effected/glob": "^0.14.0",
|
|
40
|
+
"@effected/semver": "^0.17.0",
|
|
41
|
+
"@effected/walker": "^0.19.0",
|
|
42
|
+
"@effected/yaml": "^0.25.0",
|
|
43
43
|
"@pluginfinity/core": "0.3.0",
|
|
44
44
|
"@pluginfinity/targets": "0.3.0",
|
|
45
45
|
"jiti": "^2.6.1"
|
package/selection.js
CHANGED
|
@@ -3,7 +3,7 @@ import { ConfigDiscovery } from "./discovery.js";
|
|
|
3
3
|
import { ConfigLoader } from "./loader.js";
|
|
4
4
|
import { Effect, FileSystem } from "effect";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/selection.ts
|
|
7
7
|
/**
|
|
8
8
|
* The config paths a selection names, before loading. `All` with no match is
|
|
9
9
|
* `ConfigNotFound`.
|
|
@@ -50,5 +50,4 @@ const preparePlugins = (input) => Effect.gen(function* () {
|
|
|
50
50
|
return prepared;
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
//#endregion
|
|
54
53
|
export { preparePlugins, selectConfigPaths };
|
package/server-lib.generated.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// src/server-lib.generated.ts
|
|
2
2
|
/** The server library's files, embedded so a build needs no asset on disk. */
|
|
3
3
|
const SERVER_LIB_FILES = [{
|
|
4
4
|
name: "server.sh",
|
|
5
5
|
content: "# shellcheck shell=sh\n# pluginfinity server library. `pluginfinity build` writes this file into every\n# target that has a local MCP or LSP server; do not edit a copy under builds/,\n# the next build overwrites it.\n#\n# Source it first in a launcher, and keep `set -u` (or write\n# ${PLUGINFINITY_LIB:?run by the host}) so a launcher run outside the host fails loudly:\n# . \"$PLUGINFINITY_LIB/server.sh\"\n#\n# POSIX sh. Writes nothing to stdout, which carries the server's protocol.\n\n_pf_server_lib_dir=$(cd \"$(dirname \"$PLUGINFINITY_LIB/server.sh\")\" && pwd -P)\n\n# log.sh sits beside this file.\n_pf_log_dir=$_pf_server_lib_dir\n# shellcheck source=/dev/null\n. \"$_pf_log_dir/log.sh\"\n\n# claude or copilot.\nserver_host() { printf '%s\\n' \"${PLUGINFINITY_HOST:-unknown}\"; }\n\n# The build root the launcher runs from.\nserver_plugin_root() { (cd \"$_pf_server_lib_dir/../..\" && pwd -P); }\n\n# Append a line to the plugin's error log.\nserver_log() { pf_log server \"$*\"; }\n# Append a line to the plugin's debug log when PLUGINFINITY_DEBUG=1.\nserver_debug() { pf_debug server \"$*\"; }\n\n# The project the session works in. Prints it and returns 0, or prints nothing\n# and returns 1 when there is none to report:\n# - Claude with CLAUDE_PROJECT_DIR set: that directory.\n# - Otherwise, when the working directory is the plugin root or inside it:\n# nothing, status 1. Copilot starts an MCP server with its cwd at the plugin\n# root and gives it no project directory, so that cwd says nothing about the\n# project. A Copilot MCP server cannot learn the project: its client offers\n# no roots and no variable names it (measured 2026-10-07).\n# - Otherwise: the closest directory above $PWD holding .git, else $PWD\n# (Copilot starts LSP servers at the git root).\nserver_project_dir() {\n if [ \"${PLUGINFINITY_HOST:-}\" = claude ] && [ -n \"${CLAUDE_PROJECT_DIR:-}\" ]; then\n printf '%s\\n' \"$CLAUDE_PROJECT_DIR\"\n return 0\n fi\n _pf_root=$(server_plugin_root)\n _pf_cwd=$(pwd -P)\n case \"$_pf_cwd\" in\n \"$_pf_root\" | \"$_pf_root\"/*) return 1 ;;\n esac\n _pf_probe=$PWD\n while [ -n \"$_pf_probe\" ] && [ \"$_pf_probe\" != / ]; do\n if [ -e \"$_pf_probe/.git\" ]; then\n printf '%s\\n' \"$_pf_probe\"\n return 0\n fi\n _pf_probe=$(dirname \"$_pf_probe\")\n done\n printf '%s\\n' \"$PWD\"\n}\n\n# npm, pnpm, yarn or bun. With jq on PATH: package.json's devEngines.packageManager\n# (an object, or an array whose first entry is used) name, then packageManager.\n# Without jq only the top-level packageManager field is read (devEngines is\n# ignored). Then lockfiles, else npm. A name other than the four is npm.\n_pf_detect_pm() { # project\n _pf_pm=\"\"\n if [ -f \"$1/package.json\" ]; then\n if command -v jq >/dev/null 2>&1; then\n _pf_pm=$(jq -r '((try (.devEngines.packageManager | if type == \"array\" then .[0] else . end | .name) catch null) | strings) // (.packageManager | strings) // empty' \\\n \"$1/package.json\" 2>/dev/null | cut -d@ -f1)\n else\n _pf_pm=$(grep -o '\"packageManager\"[[:space:]]*:[[:space:]]*\"[^\"]*\"' \"$1/package.json\" 2>/dev/null |\n sed -E 's/.*:[[:space:]]*\"([^@\"]*).*/\\1/')\n fi\n fi\n case \"$_pf_pm\" in\n npm | pnpm | yarn | bun)\n printf '%s\\n' \"$_pf_pm\"\n return 0\n ;;\n *) ;;\n esac\n if [ -f \"$1/pnpm-lock.yaml\" ]; then\n printf 'pnpm\\n'\n elif [ -f \"$1/bun.lock\" ] || [ -f \"$1/bun.lockb\" ]; then\n printf 'bun\\n'\n elif [ -f \"$1/yarn.lock\" ]; then\n printf 'yarn\\n'\n else\n printf 'npm\\n'\n fi\n}\n\n_pf_install_line() { # pm package\n case \"$1\" in\n pnpm) printf ' pnpm add -D %s\\n' \"$2\" ;;\n yarn) printf ' yarn add -D %s\\n' \"$2\" ;;\n bun) printf ' bun add -d %s\\n' \"$2\" ;;\n *) printf ' npm install --save-dev %s\\n' \"$2\" ;;\n esac\n}\n\n# Exec the project's node_modules/.bin/<bin>, else run <package> with the\n# project's package manager (pnpm dlx, yarn dlx, bunx, or npx --yes; see\n# _pf_detect_pm). npm 11 refuses to run in a project whose devEngines names\n# another manager, so npx is only the runner for npm projects, for a manager\n# that is not on PATH (said on stderr), and when there is no project directory\n# (see server_project_dir), which skips the lookup and the install hint. An\n# optional `--install <package>` straight after the two positionals names a\n# different package in the install hint only; the runner still runs <package>.\n# Later args pass through untouched.\nserver_exec_bin() { # bin package [--install install-package] [args...]\n _pf_bin=$1\n _pf_pkg=$2\n _pf_install=$2\n shift 2\n if [ \"${1:-}\" = --install ] && [ $# -ge 2 ]; then\n _pf_install=$2\n shift 2\n fi\n _pf_runner=npx\n if _pf_project=$(server_project_dir); then\n if [ -x \"$_pf_project/node_modules/.bin/$_pf_bin\" ]; then\n exec \"$_pf_project/node_modules/.bin/$_pf_bin\" \"$@\"\n fi\n _pf_pm=$(_pf_detect_pm \"$_pf_project\")\n {\n printf '%s: %s is not installed in %s.\\n' \"${PLUGINFINITY_PLUGIN:-plugin}\" \"$_pf_bin\" \"$_pf_project\"\n printf 'Install it with:\\n'\n _pf_install_line \"$_pf_pm\" \"$_pf_install\"\n } >&2\n case \"$_pf_pm\" in\n pnpm | yarn) _pf_runner=$_pf_pm ;;\n bun) _pf_runner=bunx ;;\n esac\n if [ \"$_pf_runner\" != npx ] && ! command -v \"$_pf_runner\" >/dev/null 2>&1; then\n printf '%s was not found on PATH.\\n' \"$_pf_runner\" >&2\n _pf_runner=npx\n fi\n else\n printf '%s: no project directory is known, so %s cannot be looked up in node_modules.\\n' \\\n \"${PLUGINFINITY_PLUGIN:-plugin}\" \"$_pf_bin\" >&2\n fi\n case \"$_pf_runner\" in\n pnpm | yarn)\n printf 'Falling back to \"%s dlx %s\".\\n' \"$_pf_runner\" \"$_pf_pkg\" >&2\n server_debug \"server_exec_bin: running $_pf_pkg with $_pf_runner dlx\"\n exec \"$_pf_runner\" dlx \"$_pf_pkg\" \"$@\"\n ;;\n bunx)\n printf 'Falling back to \"bunx %s\".\\n' \"$_pf_pkg\" >&2\n server_debug \"server_exec_bin: running $_pf_pkg with bunx\"\n exec bunx \"$_pf_pkg\" \"$@\"\n ;;\n esac\n printf 'Falling back to \"npx --yes %s\".\\n' \"$_pf_pkg\" >&2\n server_debug \"server_exec_bin: running $_pf_pkg with npx --yes\"\n exec npx --yes \"$_pf_pkg\" \"$@\"\n}\n"
|
|
6
6
|
}];
|
|
7
7
|
|
|
8
|
-
//#endregion
|
|
9
8
|
export { SERVER_LIB_FILES };
|
package/server-lib.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LIB_DIR } from "./lib-files.js";
|
|
2
2
|
import { SERVER_LIB_FILES } from "./server-lib.generated.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/server-lib.ts
|
|
5
5
|
/**
|
|
6
6
|
* Where every build that has a local server gets the server library, relative to the build root.
|
|
7
7
|
*
|
|
@@ -18,5 +18,4 @@ const serverLibFiles = () => SERVER_LIB_FILES.map((file) => ({
|
|
|
18
18
|
content: file.content
|
|
19
19
|
}));
|
|
20
20
|
|
|
21
|
-
//#endregion
|
|
22
21
|
export { SERVER_LIB_DIR, serverLibFiles };
|
package/servers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConfigIssue } from "./errors.js";
|
|
2
2
|
import { CONFIG_NOTE_PATH } from "./notes.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/servers.ts
|
|
5
5
|
const PLACEHOLDER = `\${PLUGIN_ROOT}`;
|
|
6
6
|
const ROOT_FILE = /\$\{PLUGIN_ROOT\}\/([^\s"'`;|&<>()$:,]+)/g;
|
|
7
7
|
const HOST_ROOT = /\$\{(?:CLAUDE|COPILOT)_PLUGIN_ROOT\}|\$(?:CLAUDE_|COPILOT_)?PLUGIN_ROOT(?![A-Za-z0-9_])/;
|
|
@@ -252,5 +252,4 @@ const serverFiles = (target, id, config) => {
|
|
|
252
252
|
};
|
|
253
253
|
};
|
|
254
254
|
|
|
255
|
-
//#endregion
|
|
256
255
|
export { mcpServerNames, renderServers, serverFiles };
|
package/skills.js
CHANGED
|
@@ -6,7 +6,7 @@ import { renderTokens } from "./tokens.js";
|
|
|
6
6
|
import { ComponentName, SKILL_FIELDS, SkillFrontmatter } from "@pluginfinity/core";
|
|
7
7
|
import { Effect, FileSystem, Path, Schema } from "effect";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// src/skills.ts
|
|
10
10
|
/**
|
|
11
11
|
* The most characters a built skill's `description` may hold: the Agent
|
|
12
12
|
* Skills spec's limit, which Copilot enforces.
|
|
@@ -163,5 +163,4 @@ const renderSkill = (target, id, skill, known, tokens) => Effect.gen(function* (
|
|
|
163
163
|
};
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
-
//#endregion
|
|
167
166
|
export { SKILL_DESCRIPTION_MAX, readSkills, renderSkill };
|
package/tokens.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fencedLines, inlineCodeSpans } from "./body.js";
|
|
2
2
|
import { splitOwnMcp } from "./frontmatter.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/tokens.ts
|
|
5
5
|
const KINDS = /* @__PURE__ */ new Set([
|
|
6
6
|
"tool",
|
|
7
7
|
"agent",
|
|
@@ -300,5 +300,4 @@ const renderTokens = (text, ctx) => {
|
|
|
300
300
|
return problems.length > 0 ? { problems } : { text: rendered.join("\n") };
|
|
301
301
|
};
|
|
302
302
|
|
|
303
|
-
//#endregion
|
|
304
303
|
export { renderTokens };
|
package/tool-map.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/tool-map.ts
|
|
2
2
|
const singleQuote = (value) => `'${value.replaceAll("'", `'\\''`)}'`;
|
|
3
3
|
/**
|
|
4
4
|
* The generated `tools.sh` the hook library sources to spell a Claude tool
|
|
@@ -31,5 +31,4 @@ const renderToolMap = (target, plugin, servers, has) => {
|
|
|
31
31
|
].join("\n");
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
//#endregion
|
|
35
34
|
export { renderToolMap };
|
package/tools.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
2
|
import { LocalExec, ToolDiscovery } from "@effected/commands";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/tools.ts
|
|
5
5
|
/**
|
|
6
6
|
* The `ToolDiscovery` doctor uses in production: global lookups only, over the
|
|
7
7
|
* platform's `ChildProcessSpawner`. Bound once so every provide shares it.
|
|
@@ -10,5 +10,4 @@ import { LocalExec, ToolDiscovery } from "@effected/commands";
|
|
|
10
10
|
*/
|
|
11
11
|
const ToolDiscoveryLive = ToolDiscovery.layer.pipe(Layer.provide(LocalExec.layerNone));
|
|
12
12
|
|
|
13
|
-
//#endregion
|
|
14
13
|
export { ToolDiscoveryLive };
|
package/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/version.ts
|
|
2
2
|
/**
|
|
3
3
|
* The version of `@pluginfinity/engine` this build was made from: the comparable
|
|
4
4
|
* version of a pluginfinity run.
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
|
-
const ENGINE_VERSION = "0.3.
|
|
15
|
+
const ENGINE_VERSION = "0.3.5";
|
|
16
16
|
|
|
17
|
-
//#endregion
|
|
18
17
|
export { ENGINE_VERSION };
|