@netlify/agent-runner-cli 1.116.0-migration-guard-hook.0 → 1.116.0-migration-guard-hook.2

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.
@@ -0,0 +1,15 @@
1
+ import N from"fs";import A from"fs/promises";import x from"path";var f="HOOKS_CONTEXT";var u;function a(){return u===void 0&&(u=v()??R()),u}function v(){let e=process.argv[2];if(!e)return null;try{return JSON.parse(Buffer.from(e,"base64").toString("utf-8"))}catch{return null}}function R(){let e=process.env[f];if(!e)return null;try{return JSON.parse(e)}catch(n){return process.stderr.write(`[hook] failed to parse ${f}: ${n.message}
2
+ `),null}}import g from"path";import S from"fs";import i from"path";var H=["drizzle.config.ts","drizzle.config.js","drizzle.config.mjs"],P="netlify/database/migrations";function d(e,n){if(!n)return i.join(e,P);let t=i.isAbsolute(n)?n:i.resolve(e,n),r=i.relative(e,t);if(!(r!==""&&(r.startsWith("..")||i.isAbsolute(r))))return t}function D(e){return H.find(n=>S.existsSync(i.join(e,n)))}function p(e){return!!D(e)}var E="Direct writes to migration files are not allowed in this Drizzle project (drizzle.config.ts is present in cwd). Files under the migrations directory are owned by drizzle-kit and are not user-editable artifacts; writing one directly breaks the migration ordering and metadata that drizzle-kit relies on.\n\nTo produce a migration:\n\n- For schema changes (CREATE/ALTER/DROP TABLE etc.): edit `db/schema.ts`, then run `npx drizzle-kit generate`. Drizzle produces the migration file with the correct ordering.\n- For data-only migrations (INSERT/UPDATE/DELETE): run `npx drizzle-kit generate --custom` to scaffold a placeholder migration file you can then edit.\n\nThe generated filename is mechanical: drizzle-kit assigns it for ordering and diffing purposes. Use the filename it produces as-is \u2014 do not rename, move, or copy the generated SQL file, and do not delete drizzle metadata (`_journal.json`, `meta/*.json`, `snapshot.json`); these are required for future migrations. A migration filename or path mentioned in the user prompt describes where the migration should land in general terms; drizzle-kit's actual output replaces that placeholder.\n\nThis run is non-interactive \u2014 there is no user available to answer follow-up questions, so the steps above are the next action, not a proposal.";function L(e){return`Direct writes to migration files are not allowed. Files under the migrations directory are owned by the Netlify CLI scaffolder and are not user-editable artifacts until the scaffolder produces them; writing one directly breaks the project's migration ordering.
3
+
4
+ To produce a migration, run:
5
+
6
+ ${e} database migrations new --description "<description>"
7
+
8
+ \`<description>\` should be a short imperative description of what the migration does (e.g. "add todos table"); the CLI uses it to generate the filename suffix after the numeric prefix. Then edit the generated file in place.
9
+
10
+ The generated filename is mechanical: the CLI assigns the numeric prefix for ordering. Use the filename it produces as-is \u2014 do not rename, move, or copy the generated SQL file. A migration filename mentioned in the user prompt describes where the migration should land in general terms; the CLI's actual output replaces that placeholder.
11
+
12
+ This run is non-interactive \u2014 there is no user available to answer follow-up questions, so the command above is the next action, not a proposal.`}function T(e,n){let t=g.relative(n,e);return t!==""&&!t.startsWith("..")&&!g.isAbsolute(t)}var m={name:"block_direct_migration_writes",evaluate:async({absolutePath:e,cwd:n,context:t,isCreate:r})=>{if(!await r()||!e.endsWith(".sql"))return null;let o=d(n,t.migrationsPath);return!o||!T(e,o)?null:p(n)?{reason:E}:{reason:L(t.netlifyCliPath)}}};import I from"fs";import V from"os";import K from"path";import{randomUUID as ee}from"crypto";import{format as _}from"util";var h="[AR]";function y(e){let n=(t,r)=>{if(process.env.LOG==="0")return;let o=a()?.logFilePath;if(!o)return;let s=t==="log"||t==="info"?`${h}-[hook:${e}]`:`${h}-[${t.toUpperCase()}]-[hook:${e}]`;try{I.appendFileSync(o,`${s} ${_(...r)}
13
+ `)}catch{}};return{log:(...t)=>n("log",t),info:(...t)=>n("info",t),error:(...t)=>n("error",t),warn:(...t)=>n("warn",t),debug:(...t)=>n("debug",t)}}var F=y("pre-file-write-guard-core"),k=[m],ce=k.map(e=>e.name);async function j(e){try{return await A.access(e),!0}catch{return!1}}async function w(e,n){let t=a();if(!t)return null;for(let r of e){let o=x.isAbsolute(r.filePath)?r.filePath:x.resolve(n,r.filePath);for(let s of k){if(!t.enabledHooks.includes(s.name))continue;let c=await s.evaluate({filePath:r.filePath,absolutePath:o,content:r.content,cwd:n,context:t,isCreate:async()=>!await j(o)});if(c)return F.info("pre-file-write-guard rules want to block a file write",{...r,...c}),c}}return null}var b=JSON.parse(N.readFileSync(0,"utf-8")),l=b.tool_input??{},O=b.cwd??process.cwd(),z=l.file_path;z==null&&process.exit(0);var $=l.content??l.new_string??(l.edits??[]).map(e=>e.new_string??"").join(`
14
+ `),C=await w([{filePath:z,content:$}],O);C||process.exit(0);process.stdout.write(JSON.stringify({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:C.reason}}));process.exit(0);
15
+ //# sourceMappingURL=claude-adapter.js.map
@@ -0,0 +1,16 @@
1
+ import N from"fs";import I from"fs/promises";import x from"path";var f="HOOKS_CONTEXT";var c;function a(){return c===void 0&&(c=v()??P()),c}function v(){let e=process.argv[2];if(!e)return null;try{return JSON.parse(Buffer.from(e,"base64").toString("utf-8"))}catch{return null}}function P(){let e=process.env[f];if(!e)return null;try{return JSON.parse(e)}catch(t){return process.stderr.write(`[hook] failed to parse ${f}: ${t.message}
2
+ `),null}}import g from"path";import S from"fs";import s from"path";var R=["drizzle.config.ts","drizzle.config.js","drizzle.config.mjs"],H="netlify/database/migrations";function d(e,t){if(!t)return s.join(e,H);let n=s.isAbsolute(t)?t:s.resolve(e,t),r=s.relative(e,n);if(!(r!==""&&(r.startsWith("..")||s.isAbsolute(r))))return n}function D(e){return R.find(t=>S.existsSync(s.join(e,t)))}function p(e){return!!D(e)}var E="Direct writes to migration files are not allowed in this Drizzle project (drizzle.config.ts is present in cwd). Files under the migrations directory are owned by drizzle-kit and are not user-editable artifacts; writing one directly breaks the migration ordering and metadata that drizzle-kit relies on.\n\nTo produce a migration:\n\n- For schema changes (CREATE/ALTER/DROP TABLE etc.): edit `db/schema.ts`, then run `npx drizzle-kit generate`. Drizzle produces the migration file with the correct ordering.\n- For data-only migrations (INSERT/UPDATE/DELETE): run `npx drizzle-kit generate --custom` to scaffold a placeholder migration file you can then edit.\n\nThe generated filename is mechanical: drizzle-kit assigns it for ordering and diffing purposes. Use the filename it produces as-is \u2014 do not rename, move, or copy the generated SQL file, and do not delete drizzle metadata (`_journal.json`, `meta/*.json`, `snapshot.json`); these are required for future migrations. A migration filename or path mentioned in the user prompt describes where the migration should land in general terms; drizzle-kit's actual output replaces that placeholder.\n\nThis run is non-interactive \u2014 there is no user available to answer follow-up questions, so the steps above are the next action, not a proposal.";function T(e){return`Direct writes to migration files are not allowed. Files under the migrations directory are owned by the Netlify CLI scaffolder and are not user-editable artifacts until the scaffolder produces them; writing one directly breaks the project's migration ordering.
3
+
4
+ To produce a migration, run:
5
+
6
+ ${e} database migrations new --description "<description>"
7
+
8
+ \`<description>\` should be a short imperative description of what the migration does (e.g. "add todos table"); the CLI uses it to generate the filename suffix after the numeric prefix. Then edit the generated file in place.
9
+
10
+ The generated filename is mechanical: the CLI assigns the numeric prefix for ordering. Use the filename it produces as-is \u2014 do not rename, move, or copy the generated SQL file. A migration filename mentioned in the user prompt describes where the migration should land in general terms; the CLI's actual output replaces that placeholder.
11
+
12
+ This run is non-interactive \u2014 there is no user available to answer follow-up questions, so the command above is the next action, not a proposal.`}function A(e,t){let n=g.relative(t,e);return n!==""&&!n.startsWith("..")&&!g.isAbsolute(n)}var m={name:"block_direct_migration_writes",evaluate:async({absolutePath:e,cwd:t,context:n,isCreate:r})=>{if(!await r()||!e.endsWith(".sql"))return null;let o=d(t,n.migrationsPath);return!o||!A(e,o)?null:p(t)?{reason:E}:{reason:T(n.netlifyCliPath)}}};import L from"fs";import X from"os";import Y from"path";import{randomUUID as te}from"crypto";import{format as F}from"util";var h="[AR]";function y(e){let t=(n,r)=>{if(process.env.LOG==="0")return;let o=a()?.logFilePath;if(!o)return;let i=n==="log"||n==="info"?`${h}-[hook:${e}]`:`${h}-[${n.toUpperCase()}]-[hook:${e}]`;try{L.appendFileSync(o,`${i} ${F(...r)}
13
+ `)}catch{}};return{log:(...n)=>t("log",n),info:(...n)=>t("info",n),error:(...n)=>t("error",n),warn:(...n)=>t("warn",n),debug:(...n)=>t("debug",n)}}var j=y("pre-file-write-guard-core"),k=[m],ue=k.map(e=>e.name);async function _(e){try{return await I.access(e),!0}catch{return!1}}async function w(e,t){let n=a();if(!n)return null;for(let r of e){let o=x.isAbsolute(r.filePath)?r.filePath:x.resolve(t,r.filePath);for(let i of k){if(!n.enabledHooks.includes(i.name))continue;let l=await i.evaluate({filePath:r.filePath,absolutePath:o,content:r.content,cwd:t,context:n,isCreate:async()=>!await _(o)});if(l)return j.info("pre-file-write-guard rules want to block a file write",{...r,...l}),l}}return null}function $(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){let t=e;if(typeof t.command=="string")return t.command;if(Array.isArray(t.command)&&typeof t.command[1]=="string")return t.command[1];if(typeof t.input=="string")return t.input;if(typeof t.patch=="string")return t.patch}}function O(e){let t=[],n=null,r=()=>{n&&(t.push({filePath:n.filePath,content:n.added.join(`
14
+ `)}),n=null)};for(let o of e.split(`
15
+ `)){let i=o.match(/^\*\*\* (?:Add|Update) File: (.+)$/);if(i){r(),n={filePath:i[1].trim(),added:[]};continue}if(o.startsWith("*** Delete File:")||o.startsWith("*** End Patch")||o.startsWith("*** Begin Patch")){r();continue}n&&o.startsWith("+")&&n.added.push(o.slice(1))}return r(),t}var u=JSON.parse(N.readFileSync(0,"utf-8")),U=u.cwd??process.cwd();u.tool_name!=="apply_patch"&&process.exit(0);var b=$(u.tool_input);b==null&&process.exit(0);var z=O(b);z.length===0&&process.exit(0);var C=await w(z,U);C||process.exit(0);process.stdout.write(JSON.stringify({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:C.reason}}));process.exit(0);
16
+ //# sourceMappingURL=codex-adapter.js.map
@@ -0,0 +1,14 @@
1
+ import N from"fs";import F from"fs/promises";import x from"path";var f="HOOKS_CONTEXT";var c;function a(){return c===void 0&&(c=C()??R()),c}function C(){let e=process.argv[2];if(!e)return null;try{return JSON.parse(Buffer.from(e,"base64").toString("utf-8"))}catch{return null}}function R(){let e=process.env[f];if(!e)return null;try{return JSON.parse(e)}catch(n){return process.stderr.write(`[hook] failed to parse ${f}: ${n.message}
2
+ `),null}}import g from"path";import S from"fs";import i from"path";var H=["drizzle.config.ts","drizzle.config.js","drizzle.config.mjs"],P="netlify/database/migrations";function d(e,n){if(!n)return i.join(e,P);let t=i.isAbsolute(n)?n:i.resolve(e,n),r=i.relative(e,t);if(!(r!==""&&(r.startsWith("..")||i.isAbsolute(r))))return t}function D(e){return H.find(n=>S.existsSync(i.join(e,n)))}function p(e){return!!D(e)}var E="Direct writes to migration files are not allowed in this Drizzle project (drizzle.config.ts is present in cwd). Files under the migrations directory are owned by drizzle-kit and are not user-editable artifacts; writing one directly breaks the migration ordering and metadata that drizzle-kit relies on.\n\nTo produce a migration:\n\n- For schema changes (CREATE/ALTER/DROP TABLE etc.): edit `db/schema.ts`, then run `npx drizzle-kit generate`. Drizzle produces the migration file with the correct ordering.\n- For data-only migrations (INSERT/UPDATE/DELETE): run `npx drizzle-kit generate --custom` to scaffold a placeholder migration file you can then edit.\n\nThe generated filename is mechanical: drizzle-kit assigns it for ordering and diffing purposes. Use the filename it produces as-is \u2014 do not rename, move, or copy the generated SQL file, and do not delete drizzle metadata (`_journal.json`, `meta/*.json`, `snapshot.json`); these are required for future migrations. A migration filename or path mentioned in the user prompt describes where the migration should land in general terms; drizzle-kit's actual output replaces that placeholder.\n\nThis run is non-interactive \u2014 there is no user available to answer follow-up questions, so the steps above are the next action, not a proposal.";function L(e){return`Direct writes to migration files are not allowed. Files under the migrations directory are owned by the Netlify CLI scaffolder and are not user-editable artifacts until the scaffolder produces them; writing one directly breaks the project's migration ordering.
3
+
4
+ To produce a migration, run:
5
+
6
+ ${e} database migrations new --description "<description>"
7
+
8
+ \`<description>\` should be a short imperative description of what the migration does (e.g. "add todos table"); the CLI uses it to generate the filename suffix after the numeric prefix. Then edit the generated file in place.
9
+
10
+ The generated filename is mechanical: the CLI assigns the numeric prefix for ordering. Use the filename it produces as-is \u2014 do not rename, move, or copy the generated SQL file. A migration filename mentioned in the user prompt describes where the migration should land in general terms; the CLI's actual output replaces that placeholder.
11
+
12
+ This run is non-interactive \u2014 there is no user available to answer follow-up questions, so the command above is the next action, not a proposal.`}function I(e,n){let t=g.relative(n,e);return t!==""&&!t.startsWith("..")&&!g.isAbsolute(t)}var m={name:"block_direct_migration_writes",evaluate:async({absolutePath:e,cwd:n,context:t,isCreate:r})=>{if(!await r()||!e.endsWith(".sql"))return null;let o=d(n,t.migrationsPath);return!o||!I(e,o)?null:p(n)?{reason:E}:{reason:L(t.netlifyCliPath)}}};import T from"fs";import V from"os";import K from"path";import{randomUUID as ee}from"crypto";import{format as A}from"util";var h="[AR]";function y(e){let n=(t,r)=>{if(process.env.LOG==="0")return;let o=a()?.logFilePath;if(!o)return;let s=t==="log"||t==="info"?`${h}-[hook:${e}]`:`${h}-[${t.toUpperCase()}]-[hook:${e}]`;try{T.appendFileSync(o,`${s} ${A(...r)}
13
+ `)}catch{}};return{log:(...t)=>n("log",t),info:(...t)=>n("info",t),error:(...t)=>n("error",t),warn:(...t)=>n("warn",t),debug:(...t)=>n("debug",t)}}var _=y("pre-file-write-guard-core"),k=[m],ce=k.map(e=>e.name);async function j(e){try{return await F.access(e),!0}catch{return!1}}async function w(e,n){let t=a();if(!t)return null;for(let r of e){let o=x.isAbsolute(r.filePath)?r.filePath:x.resolve(n,r.filePath);for(let s of k){if(!t.enabledHooks.includes(s.name))continue;let l=await s.evaluate({filePath:r.filePath,absolutePath:o,content:r.content,cwd:n,context:t,isCreate:async()=>!await j(o)});if(l)return _.info("pre-file-write-guard rules want to block a file write",{...r,...l}),l}}return null}var b=JSON.parse(N.readFileSync(0,"utf-8")),u=b.tool_input??{},$=b.cwd??process.cwd(),z=u.file_path;z==null&&process.exit(0);var O=u.content??u.new_string??"",v=await w([{filePath:z,content:O}],$);v||process.exit(0);process.stdout.write(JSON.stringify({decision:"deny",reason:v.reason}));process.exit(0);
14
+ //# sourceMappingURL=gemini-adapter.js.map