bizboost 6.6.21 → 6.6.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";const crypto=require("node:crypto"),fs=require("node:fs"),os=require("node:os"),path=require("node:path"),VERSION=1,EVENT_TO_EV={SessionStart:"session_start",UserPromptSubmit:"prompt",PostToolUse:"tool",PostToolUseFailure:"tool_fail",Stop:"stop",StopFailure:"api_error",SubagentStop:"subagent_stop",SessionEnd:"session_end"},HOOK_EVENTS=Object.keys(EVENT_TO_EV),ERR_KIND=/^[a-z][a-z0-9_]{0,63}$/,SID_SHAPE=/^[A-Za-z0-9-]{1,128}$/,TOOL_SHAPE=/^[A-Za-z0-9_.:-]{1,200}$/,ROLE_SHAPE=/^[^\r\n]{1,200}$/,ANSI_SEQUENCE=/\x1b(?:\[[0-?]*[ -/]*[@-~]|[@-Z\\-_])?/g;function sha16(t){return crypto.createHash("sha256").update(t,"utf8").digest("hex").slice(0,16)}function normalizePrompt(t){return t.replace(ANSI_SEQUENCE,"").replace(/\s+/gu,"")}function footprintDirName(t){return t.replace(/[^A-Za-z0-9]/g,"-")}function footprintFile(t,o,n){return path.join(t,".bluelamp","footprints",footprintDirName(o),`${n}.jsonl`)}function nonEmptyString(t){return"string"==typeof t&&t.length>0?t:null}function toFootprint(t,o,n){if(!t||"object"!=typeof t||Array.isArray(t))return null;const e=EVENT_TO_EV[t.hook_event_name];if(!e)return null;const r=nonEmptyString(t.session_id),i=nonEmptyString(t.cwd);if(!r||!SID_SHAPE.test(r)||!i)return null;const s={v:1,ts:n.toISOString(),sid:r,cwd:i,ev:e};if("session_start"===e){const t=nonEmptyString(o.BLUELAMP_FOOTPRINT_ROLE);t&&ROLE_SHAPE.test(t)&&(s.role=t)}else if("prompt"===e)"string"==typeof t.prompt&&(s.psha=sha16(t.prompt),s.pnsha=sha16(normalizePrompt(t.prompt)));else if("tool"===e||"tool_fail"===e){const o=nonEmptyString(t.tool_name);o&&TOOL_SHAPE.test(o)&&(s.tool=o),s.ok="tool"===e,"CronCreate"===o&&t.tool_input&&"boolean"==typeof t.tool_input.recurring&&(s.recurring=t.tool_input.recurring)}else if("api_error"===e){const o=nonEmptyString(t.error);o&&ERR_KIND.test(o)&&(s.err=o)}const p=nonEmptyString(o.MONSTER_ID);return p&&SID_SHAPE.test(p)&&(s.mid=p),s}function dirCwdOf(t,o){const n=o&&o.BLUELAMP_FOOTPRINT_DIR_CWD;return"string"==typeof n&&n.length>0?n:t.cwd}function quoteForShell(t){return`"${t.replace(/(["\\$`])/g,"\\$1")}"`}function buildSettingsJson(t,o){const n=`${quoteForShell(t)} ${quoteForShell(o)}`,e={};for(const t of HOOK_EVENTS)e[t]=[{hooks:[{type:"command",command:n}]}];return JSON.stringify({hooks:e})}function appendFootprint(t,o,n={}){const e=footprintFile(t,dirCwdOf(o,n),o.sid);return fs.mkdirSync(path.dirname(e),{recursive:!0,mode:448}),fs.appendFileSync(e,`${JSON.stringify(o)}\n`,{encoding:"utf8",mode:384}),e}function main(){"--settings-json"===process.argv[2]&&(process.stdout.write(buildSettingsJson(process.execPath,__filename)),process.exit(0));try{const t=fs.readFileSync(0,"utf8"),o=toFootprint(JSON.parse(t),process.env,new Date);o&&appendFootprint(os.homedir(),o,process.env)}catch{}process.exit(0)}module.exports={HOOK_EVENTS:HOOK_EVENTS,buildSettingsJson:buildSettingsJson,toFootprint:toFootprint,normalizePrompt:normalizePrompt,footprintDirName:footprintDirName,footprintFile:footprintFile,dirCwdOf:dirCwdOf,appendFootprint:appendFootprint},require.main===module&&main();
2
+ "use strict";const crypto=require("node:crypto"),fs=require("node:fs"),os=require("node:os"),path=require("node:path"),VERSION=1,EVENT_TO_EV={SessionStart:"session_start",UserPromptSubmit:"prompt",PostToolUse:"tool",PostToolUseFailure:"tool_fail",Stop:"stop",StopFailure:"api_error",SubagentStop:"subagent_stop",SessionEnd:"session_end"},HOOK_EVENTS=Object.keys(EVENT_TO_EV),ERR_KIND=/^[a-z][a-z0-9_]{0,63}$/,SID_SHAPE=/^[A-Za-z0-9-]{1,128}$/,TOOL_SHAPE=/^[A-Za-z0-9_.:-]{1,200}$/,ROLE_SHAPE=/^[^\r\n]{1,200}$/,ANSI_SEQUENCE=/\x1b(?:\[[0-?]*[ -/]*[@-~]|[@-Z\\-_])?/g;function sha16(t){return crypto.createHash("sha256").update(t,"utf8").digest("hex").slice(0,16)}function normalizePrompt(t){return t.replace(ANSI_SEQUENCE,"").replace(/\s+/gu,"")}function footprintDirName(t){return t.replace(/[^A-Za-z0-9]/g,"-")}function footprintFile(t,o,n){return path.join(t,".bluelamp","footprints",footprintDirName(o),`${n}.jsonl`)}function nonEmptyString(t){return"string"==typeof t&&t.length>0?t:null}function toFootprint(t,o,n){if(!t||"object"!=typeof t||Array.isArray(t))return null;const e=EVENT_TO_EV[t.hook_event_name];if(!e)return null;const r=nonEmptyString(t.session_id),s=nonEmptyString(t.cwd);if(!r||!SID_SHAPE.test(r)||!s)return null;const i={v:1,ts:n.toISOString(),sid:r,cwd:s,ev:e};if("session_start"===e){const t=nonEmptyString(o.BLUELAMP_FOOTPRINT_ROLE);t&&ROLE_SHAPE.test(t)&&(i.role=t)}else if("prompt"===e)"string"==typeof t.prompt&&(i.psha=sha16(t.prompt),i.pnsha=sha16(normalizePrompt(t.prompt)));else if("tool"===e||"tool_fail"===e){const o=nonEmptyString(t.tool_name);o&&TOOL_SHAPE.test(o)&&(i.tool=o),i.ok="tool"===e,"CronCreate"===o&&t.tool_input&&"boolean"==typeof t.tool_input.recurring&&(i.recurring=t.tool_input.recurring)}else if("api_error"===e){const o=nonEmptyString(t.error);o&&ERR_KIND.test(o)&&(i.err=o)}const a=nonEmptyString(o.MONSTER_ID);return a&&SID_SHAPE.test(a)&&(i.mid=a),i}function dirCwdOf(t,o){const n=o&&o.BLUELAMP_FOOTPRINT_DIR_CWD;return"string"==typeof n&&n.length>0?n:t.cwd}const SESSION_UUID=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,PROJECT_DIR_NAME=/^[A-Za-z0-9-]{1,4096}$/;function claudeConfigDirOf(t,o){const n=o&&o.CLAUDE_CONFIG_DIR;return"string"==typeof n&&n.length>0&&path.isAbsolute(n)?path.normalize(n):path.join(t,".claude")}function projectsRootOf(t){return path.join(t,"projects")}function toolResultsDirToClean(t,o){if(!t||"object"!=typeof t||Array.isArray(t))return null;if("SessionEnd"!==t.hook_event_name)return null;const n=t.session_id,e=t.transcript_path;if("string"!=typeof n||!SESSION_UUID.test(n))return null;if("string"!=typeof e||!path.isAbsolute(e)||path.normalize(e)!==e)return null;if(path.basename(e)!==`${n}.jsonl`)return null;const r=path.dirname(e);return path.dirname(r)!==projectsRootOf(o)?null:PROJECT_DIR_NAME.test(path.basename(r))?path.join(r,n,"tool-results"):null}function cleanToolResults(t,o){const n=path.dirname(o),e=path.dirname(n),r=fs.realpathSync(projectsRootOf(t));for(const t of[e,n,o]){const o=fs.lstatSync(t,{throwIfNoEntry:!1});if(!o||o.isSymbolicLink()||!o.isDirectory())return!1}const s=path.join(r,path.basename(e),path.basename(n),"tool-results");if(fs.realpathSync(o)!==s)return!1;fs.rmSync(o,{recursive:!0,force:!0});try{fs.rmdirSync(n)}catch{}return!0}function quoteForShell(t){return`"${t.replace(/(["\\$`])/g,"\\$1")}"`}function buildSettingsJson(t,o){const n=`${quoteForShell(t)} ${quoteForShell(o)}`,e={};for(const t of HOOK_EVENTS)e[t]=[{hooks:[{type:"command",command:n}]}];return JSON.stringify({hooks:e})}function appendFootprint(t,o,n={}){const e=footprintFile(t,dirCwdOf(o,n),o.sid);return fs.mkdirSync(path.dirname(e),{recursive:!0,mode:448}),fs.appendFileSync(e,`${JSON.stringify(o)}\n`,{encoding:"utf8",mode:384}),e}function main(){"--settings-json"===process.argv[2]&&(process.stdout.write(buildSettingsJson(process.execPath,__filename)),process.exit(0));try{const t=fs.readFileSync(0,"utf8"),o=JSON.parse(t);try{const t=toFootprint(o,process.env,new Date);t&&appendFootprint(os.homedir(),t,process.env)}catch{}const n=claudeConfigDirOf(os.homedir(),process.env),e=toolResultsDirToClean(o,n);e&&cleanToolResults(n,e)}catch{}process.exit(0)}module.exports={HOOK_EVENTS:HOOK_EVENTS,buildSettingsJson:buildSettingsJson,toFootprint:toFootprint,claudeConfigDirOf:claudeConfigDirOf,toolResultsDirToClean:toolResultsDirToClean,cleanToolResults:cleanToolResults,normalizePrompt:normalizePrompt,footprintDirName:footprintDirName,footprintFile:footprintFile,dirCwdOf:dirCwdOf,appendFootprint:appendFootprint},require.main===module&&main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bizboost",
3
- "version": "6.6.21",
3
+ "version": "6.6.22",
4
4
  "description": "BizBoost CLI: 旧 bluelampportal/mcp の auth / 200+ bizboost1-N binary / postinstall scripts を TypeScript 化して monorepo に統合したパッケージ。",
5
5
  "keywords": [
6
6
  "bizboost",