@sylphx/flow 0.0.7 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -23
- package/dist/{chunk-zn6bhyhc.js → chunk-7d3pwe6x.js} +2 -2
- package/dist/{chunk-zn6bhyhc.js.map → chunk-7d3pwe6x.js.map} +1 -1
- package/dist/{chunk-j08f9mnk.js → chunk-84x5fbqe.js} +2 -2
- package/dist/{chunk-j08f9mnk.js.map → chunk-84x5fbqe.js.map} +1 -1
- package/dist/{chunk-y21bxgfy.js → chunk-90tmk3w7.js} +3 -3
- package/dist/{chunk-y21bxgfy.js.map → chunk-90tmk3w7.js.map} +1 -1
- package/dist/{chunk-3nkp0s1j.js → chunk-bmfd3jzw.js} +2 -2
- package/dist/{chunk-3nkp0s1j.js.map → chunk-bmfd3jzw.js.map} +1 -1
- package/dist/{chunk-y6n0153m.js → chunk-cshxyqvc.js} +2 -2
- package/dist/{chunk-y6n0153m.js.map → chunk-cshxyqvc.js.map} +1 -1
- package/dist/{chunk-7wpv8zs7.js → chunk-d6cgnb03.js} +3 -3
- package/dist/{chunk-7wpv8zs7.js.map → chunk-d6cgnb03.js.map} +1 -1
- package/dist/{chunk-qb07mbyd.js → chunk-fphp2agv.js} +3 -3
- package/dist/{chunk-qb07mbyd.js.map → chunk-fphp2agv.js.map} +1 -1
- package/dist/{chunk-h9kssnyy.js → chunk-mbhd0326.js} +2 -2
- package/dist/{chunk-h9kssnyy.js.map → chunk-mbhd0326.js.map} +1 -1
- package/dist/{chunk-2cevqakq.js → chunk-nmg7vhjj.js} +2 -2
- package/dist/{chunk-2cevqakq.js.map → chunk-nmg7vhjj.js.map} +1 -1
- package/dist/{chunk-x46tzzn9.js → chunk-pxh2vz4k.js} +2 -2
- package/dist/{chunk-x46tzzn9.js.map → chunk-pxh2vz4k.js.map} +1 -1
- package/dist/{chunk-1ph5m7yh.js → chunk-vttjr3cg.js} +3 -3
- package/dist/{chunk-1ph5m7yh.js.map → chunk-vttjr3cg.js.map} +1 -1
- package/dist/chunk-zwsaqnr2.js +3 -0
- package/dist/chunk-zwsaqnr2.js.map +10 -0
- package/dist/{chunk-jgkkyjtr.js → chunk-zx3gqx7b.js} +3 -3
- package/dist/{chunk-jgkkyjtr.js.map → chunk-zx3gqx7b.js.map} +1 -1
- package/dist/index.js +205 -204
- package/dist/index.js.map +6 -5
- package/package.json +1 -1
- package/dist/chunk-02jj9ahn.js +0 -5
- package/dist/chunk-02jj9ahn.js.map +0 -10
- package/dist/chunk-b2zeg2wa.js +0 -3
- package/dist/chunk-b2zeg2wa.js.map +0 -10
- package/dist/chunk-qctnd9ga.js +0 -3
- package/dist/chunk-qctnd9ga.js.map +0 -10
package/package.json
CHANGED
package/dist/chunk-02jj9ahn.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{B as X,E as M}from"./chunk-j08f9mnk.js";import"./chunk-x46tzzn9.js";import J from"node:fs/promises";import Y from"node:path";var F=".sylphx-flow/settings.json",G="1.0.0",K=(q=process.cwd())=>Y.join(q,F),L=async(q=process.cwd())=>{try{return await J.access(K(q)),!0}catch{return!1}},Q=async(q=process.cwd())=>{let z=K(q);return M(async()=>{let B=await J.readFile(z,"utf8");return JSON.parse(B)},(B)=>{if(B.code==="ENOENT")return Error("EMPTY_SETTINGS");return Error(`Failed to load settings: ${B.message}`)}).then((B)=>{if(B._tag==="Failure"&&B.error.message==="EMPTY_SETTINGS")return X({});return B})},Z=async(q,z=process.cwd())=>{let B=K(z);return M(async()=>{await J.mkdir(Y.dirname(B),{recursive:!0});let H={...q,version:q.version||G};await J.writeFile(B,`${JSON.stringify(H,null,2)}
|
|
2
|
-
`,"utf8")},(H)=>Error(`Failed to save settings: ${H.message}`))},$=async(q,z=process.cwd())=>{let B=await Q(z);if(B._tag==="Failure")return B;let H={...B.value,...q};return Z(H,z)},O=async(q=process.cwd())=>{let z=await Q(q);return z._tag==="Success"?z.value.defaultTarget:void 0},W=async(q,z=process.cwd())=>$({defaultTarget:q},z);class k{cwd;constructor(q=process.cwd()){this.cwd=q;this.settingsPath=K(q)}async load(){let q=await Q(this.cwd);if(q._tag==="Failure")throw q.error;return q.value}async save(q){let z=await Z(q,this.cwd);if(z._tag==="Failure")throw z.error}async update(q){let z=await $(q,this.cwd);if(z._tag==="Failure")throw z.error}async getDefaultTarget(){return O(this.cwd)}async setDefaultTarget(q){let z=await W(q,this.cwd);if(z._tag==="Failure")throw z.error}async exists(){return L(this.cwd)}}var D=new k;export{$ as updateSettings,L as settingsExists,W as setDefaultTarget,Z as saveSettings,D as projectSettings,Q as loadSettings,K as getSettingsPath,O as getDefaultTarget,k as ProjectSettings};
|
|
3
|
-
export{D as y};
|
|
4
|
-
|
|
5
|
-
//# debugId=ADDFE133D120885A64756E2164756E21
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/utils/settings.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"/**\n * Project settings manager - functional implementation\n * Pure functions for managing uncommitted project-specific settings\n */\n\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { type Result, success, tryCatchAsync } from '../core/functional/result.js';\n\nexport interface ProjectSettings {\n /** Default target for the project */\n defaultTarget?: string;\n /** Settings version for migration purposes */\n version?: string;\n /** How the CLI was invoked (for generating consistent commands) */\n invocationMethod?: {\n type: 'npm' | 'github' | 'bunx' | 'local-dev' | 'global' | 'unknown';\n package?: string;\n repo?: string;\n script?: string;\n command?: string;\n };\n}\n\nconst SETTINGS_FILE = '.sylphx-flow/settings.json';\nconst CURRENT_VERSION = '1.0.0';\n\n/**\n * Get settings file path for a given working directory\n */\nexport const getSettingsPath = (cwd: string = process.cwd()): string =>\n path.join(cwd, SETTINGS_FILE);\n\n/**\n * Check if settings file exists\n */\nexport const settingsExists = async (cwd: string = process.cwd()): Promise<boolean> => {\n try {\n await fs.access(getSettingsPath(cwd));\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Load project settings from file\n * Returns Result type for explicit error handling\n */\nexport const loadSettings = async (\n cwd: string = process.cwd()\n): Promise<Result<ProjectSettings, Error>> => {\n const settingsPath = getSettingsPath(cwd);\n\n return tryCatchAsync(\n async () => {\n const content = await fs.readFile(settingsPath, 'utf8');\n return JSON.parse(content) as ProjectSettings;\n },\n (error: any) => {\n // File not found is not an error - return empty settings\n if (error.code === 'ENOENT') {\n return new Error('EMPTY_SETTINGS');\n }\n return new Error(`Failed to load settings: ${error.message}`);\n }\n ).then((result) => {\n // Convert EMPTY_SETTINGS error to success with empty object\n if (result._tag === 'Failure' && result.error.message === 'EMPTY_SETTINGS') {\n return success({});\n }\n return result;\n });\n};\n\n/**\n * Save project settings to file\n * Returns Result type for explicit error handling\n */\nexport const saveSettings = async (\n settings: ProjectSettings,\n cwd: string = process.cwd()\n): Promise<Result<void, Error>> => {\n const settingsPath = getSettingsPath(cwd);\n\n return tryCatchAsync(\n async () => {\n // Ensure the directory exists\n await fs.mkdir(path.dirname(settingsPath), { recursive: true });\n\n // Add current version if not present\n const settingsWithVersion = {\n ...settings,\n version: settings.version || CURRENT_VERSION,\n };\n\n // Write settings with proper formatting\n await fs.writeFile(settingsPath, `${JSON.stringify(settingsWithVersion, null, 2)}\\n`, 'utf8');\n },\n (error: any) => new Error(`Failed to save settings: ${error.message}`)\n );\n};\n\n/**\n * Update specific settings properties\n */\nexport const updateSettings = async (\n updates: Partial<ProjectSettings>,\n cwd: string = process.cwd()\n): Promise<Result<void, Error>> => {\n const currentResult = await loadSettings(cwd);\n\n if (currentResult._tag === 'Failure') {\n return currentResult;\n }\n\n const newSettings = { ...currentResult.value, ...updates };\n return saveSettings(newSettings, cwd);\n};\n\n/**\n * Get the default target from settings\n */\nexport const getDefaultTarget = async (\n cwd: string = process.cwd()\n): Promise<string | undefined> => {\n const result = await loadSettings(cwd);\n return result._tag === 'Success' ? result.value.defaultTarget : undefined;\n};\n\n/**\n * Set the default target in settings\n */\nexport const setDefaultTarget = async (\n target: string,\n cwd: string = process.cwd()\n): Promise<Result<void, Error>> => updateSettings({ defaultTarget: target }, cwd);\n\n/**\n * Legacy class-based interface for backward compatibility\n * @deprecated Use functional exports instead (loadSettings, saveSettings, etc.)\n */\nexport class ProjectSettings {\n constructor(private cwd: string = process.cwd()) {\n this.settingsPath = getSettingsPath(cwd);\n }\n\n async load(): Promise<ProjectSettings> {\n const result = await loadSettings(this.cwd);\n if (result._tag === 'Failure') {\n throw result.error;\n }\n return result.value;\n }\n\n async save(settings: ProjectSettings): Promise<void> {\n const result = await saveSettings(settings, this.cwd);\n if (result._tag === 'Failure') {\n throw result.error;\n }\n }\n\n async update(updates: Partial<ProjectSettings>): Promise<void> {\n const result = await updateSettings(updates, this.cwd);\n if (result._tag === 'Failure') {\n throw result.error;\n }\n }\n\n async getDefaultTarget(): Promise<string | undefined> {\n return getDefaultTarget(this.cwd);\n }\n\n async setDefaultTarget(target: string): Promise<void> {\n const result = await setDefaultTarget(target, this.cwd);\n if (result._tag === 'Failure') {\n throw result.error;\n }\n }\n\n async exists(): Promise<boolean> {\n return settingsExists(this.cwd);\n }\n}\n\n/**\n * Singleton instance for backward compatibility\n * @deprecated Use functional exports with explicit cwd parameter\n */\nexport const projectSettings = new ProjectSettings();\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": "iFAKA,0BACA,yBAkBA,IAAM,EAAgB,6BAChB,EAAkB,QAKX,EAAkB,CAAC,EAAc,QAAQ,IAAI,IACxD,EAAK,KAAK,EAAK,CAAa,EAKjB,EAAiB,MAAO,EAAc,QAAQ,IAAI,IAAwB,CACrF,GAAI,CAEF,OADA,MAAM,EAAG,OAAO,EAAgB,CAAG,CAAC,EAC7B,GACP,KAAM,CACN,MAAO,KAQE,EAAe,MAC1B,EAAc,QAAQ,IAAI,IACkB,CAC5C,IAAM,EAAe,EAAgB,CAAG,EAExC,OAAO,EACL,SAAY,CACV,IAAM,EAAU,MAAM,EAAG,SAAS,EAAc,MAA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1C,GAAI,EAAO,OAAS,UAClB,MAAM,EAAO,MAEf,OAAO,EAAO,WAGV,KAAI,CAAC,EAA0C,CACnD,IAAM,EAAS,MAAM,EAAa,EAAU,KAAK,GAAG,EACpD,GAAI,EAAO,OAAS,UAClB,MAAM,EAAO,WAIX,OAAM,CAAC,EAAkD,CAC7D,IAAM,EAAS,MAAM,EAAe,EAAS,KAAK,GAAG,EACrD,GAAI,EAAO,OAAS,UAClB,MAAM,EAAO,WAIX,iBAAgB,EAAgC,CACpD,OAAO,EAAiB,KAAK,GAAG,OAG5B,iBAAgB,CAAC,EAA+B,CACpD,IAAM,EAAS,MAAM,EAAiB,EAAQ,KAAK,GAAG,EACtD,GAAI,EAAO,OAAS,UAClB,MAAM,EAAO,WAIX,OAAM,EAAqB,CAC/B,OAAO,EAAe,KAAK,GAAG,EAElC,CAMO,IAAM,EAAkB,IAAI",
|
|
8
|
-
"debugId": "ADDFE133D120885A64756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
package/dist/chunk-b2zeg2wa.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{F as B,I as D}from"./chunk-x46tzzn9.js";var A=()=>{let q=process.argv,b=q[0],w=q[1];if(w.includes("/_npx/")&&w.includes("github"))return{type:"github",repo:"github:sylphxltd/flow"};if(w.includes("/_npx/")){let z=w.match(/@sylphx\/flow|@sylphxltd\/flow/);return{type:"npm",package:z?z[0]:"@sylphx/flow"}}if(w.includes("/.bun/install/cache/")||w.includes("/bun/install/cache/"))return{type:"bunx",package:"@sylphx/flow"};if(b.includes("bun")&&!w.includes(process.cwd()))return{type:"bunx",package:"@sylphx/flow"};if(w.includes(process.cwd())){if(b.includes("bun"))return{type:"local-dev",script:"bun run dev"};return{type:"local-dev",script:"npm run dev"}}if(w.includes("node_modules/.bin")||w.includes("/bin/sylphx-flow"))return{type:"global",command:"sylphx-flow"};return{type:"unknown"}},E=(q)=>{let b=q||A();switch(b.type){case"npm":return`npx -y ${b.package}`;case"github":return`npx -y ${b.repo}`;case"bunx":return`bunx ${b.package}`;case"local-dev":return b.script;case"global":return b.command;case"unknown":return"npx -y @sylphx/flow"}},F=(q)=>{let b=q||A();switch(b.type){case"npm":return["-y",b.package,"mcp","start"];case"github":return["-y",b.repo,"mcp","start"];case"bunx":return[b.package,"mcp","start"];case"local-dev":return["./dist/index.js","mcp","start"];case"global":return[b.command,"mcp","start"];case"unknown":return["-y","@sylphx/flow","mcp","start"]}},G=(q)=>{switch((q||A()).type){case"npm":case"github":return"npx";case"bunx":return"bunx";case"local-dev":return process.execPath.includes("bun")?"bun":"node";case"global":case"unknown":return"npx"}},H=(q,b,w)=>{return`${E(w)} hook --type ${q} --target ${b}`},J=async(q)=>{let{updateSettings:b}=await import("./chunk-02jj9ahn.js");await b({invocationMethod:q})},K=async()=>{let{loadSettings:q}=await import("./chunk-02jj9ahn.js"),b=await q();if(b._tag==="Success")return b.value.invocationMethod;return};export{J as saveInvocationMethod,K as loadInvocationMethod,G as getMCPServerCommand,F as getMCPServerArgs,E as getCommandPrefix,H as generateHookCommand,A as detectInvocation};
|
|
2
|
-
|
|
3
|
-
//# debugId=AE5BA2434A51019C64756E2164756E21
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/utils/cli-invocation.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"/**\n * CLI Invocation Detection\n * Detects how the CLI was invoked and generates appropriate commands\n *\n * Supports common invocation methods:\n * - npm/npx (most common)\n * - GitHub direct (for bleeding edge)\n * - Bun/bunx (emerging)\n * - Local development (bun/npm run dev)\n * - Global installation\n * - Unknown methods fallback to npm (safe default)\n */\n\n/**\n * Invocation method types\n */\nexport type InvocationMethod =\n | { type: 'npm'; package: string }\n | { type: 'github'; repo: string }\n | { type: 'bunx'; package: string }\n | { type: 'local-dev'; script: string }\n | { type: 'global'; command: string }\n | { type: 'unknown' };\n\n/**\n * Detect how the CLI was invoked\n * Examines process.argv to determine invocation method\n */\nexport const detectInvocation = (): InvocationMethod => {\n const argv = process.argv;\n const execPath = argv[0]; // node/bun executable path\n const scriptPath = argv[1]; // script being executed\n\n // Check if running via npx with github\n if (scriptPath.includes('/_npx/') && scriptPath.includes('github')) {\n return { type: 'github', repo: 'github:sylphxltd/flow' };\n }\n\n // Check if running via npx with npm package\n if (scriptPath.includes('/_npx/')) {\n // Extract package name from path\n const match = scriptPath.match(/@sylphx\\/flow|@sylphxltd\\/flow/);\n return { type: 'npm', package: match ? match[0] : '@sylphx/flow' };\n }\n\n // Check if running via bunx (bun's cache directory)\n // Note: bunx uses #!/usr/bin/env node shebang, so execPath won't be bun\n // Instead, check for bun's install cache directory structure\n if (\n scriptPath.includes('/.bun/install/cache/') ||\n scriptPath.includes('/bun/install/cache/')\n ) {\n return { type: 'bunx', package: '@sylphx/flow' };\n }\n\n // Check if running via bunx (old detection using execPath)\n if (execPath.includes('bun') && !scriptPath.includes(process.cwd())) {\n return { type: 'bunx', package: '@sylphx/flow' };\n }\n\n // Check if running locally in development\n if (scriptPath.includes(process.cwd())) {\n // Check if using bun run dev or npm run dev\n if (execPath.includes('bun')) {\n return { type: 'local-dev', script: 'bun run dev' };\n }\n return { type: 'local-dev', script: 'npm run dev' };\n }\n\n // Check if globally installed\n if (scriptPath.includes('node_modules/.bin') || scriptPath.includes('/bin/sylphx-flow')) {\n return { type: 'global', command: 'sylphx-flow' };\n }\n\n return { type: 'unknown' };\n};\n\n/**\n * Generate command prefix based on invocation method\n * Used for generating hook commands, MCP configs, etc.\n */\nexport const getCommandPrefix = (method?: InvocationMethod): string => {\n const invocation = method || detectInvocation();\n\n switch (invocation.type) {\n case 'npm':\n return `npx -y ${invocation.package}`;\n\n case 'github':\n return `npx -y ${invocation.repo}`;\n\n case 'bunx':\n return `bunx ${invocation.package}`;\n\n case 'local-dev':\n return invocation.script;\n\n case 'global':\n return invocation.command;\n\n case 'unknown':\n // Fallback to npm package (safe default)\n return 'npx -y @sylphx/flow';\n }\n};\n\n/**\n * Generate MCP server args array based on invocation\n */\nexport const getMCPServerArgs = (method?: InvocationMethod): string[] => {\n const invocation = method || detectInvocation();\n\n switch (invocation.type) {\n case 'npm':\n return ['-y', invocation.package, 'mcp', 'start'];\n\n case 'github':\n return ['-y', invocation.repo, 'mcp', 'start'];\n\n case 'bunx':\n return [invocation.package, 'mcp', 'start'];\n\n case 'local-dev':\n // For local dev, use the built dist\n return ['./dist/index.js', 'mcp', 'start'];\n\n case 'global':\n return [invocation.command, 'mcp', 'start'];\n\n case 'unknown':\n // Fallback to npm\n return ['-y', '@sylphx/flow', 'mcp', 'start'];\n }\n};\n\n/**\n * Get MCP server command based on invocation\n */\nexport const getMCPServerCommand = (method?: InvocationMethod): string => {\n const invocation = method || detectInvocation();\n\n switch (invocation.type) {\n case 'npm':\n case 'github':\n return 'npx';\n\n case 'bunx':\n return 'bunx';\n\n case 'local-dev':\n // Use node or bun depending on what's running\n return process.execPath.includes('bun') ? 'bun' : 'node';\n\n case 'global':\n case 'unknown':\n return 'npx';\n }\n};\n\n/**\n * Generate hook command for specific hook type\n */\nexport const generateHookCommand = (\n hookType: 'session' | 'message' | 'notification',\n targetId: string,\n method?: InvocationMethod\n): string => {\n const prefix = getCommandPrefix(method);\n return `${prefix} hook --type ${hookType} --target ${targetId}`;\n};\n\n/**\n * Save invocation method to settings for future use\n */\nexport const saveInvocationMethod = async (method: InvocationMethod): Promise<void> => {\n const { updateSettings } = await import('./settings.js');\n await updateSettings({\n invocationMethod: method as any,\n });\n};\n\n/**\n * Load saved invocation method from settings\n */\nexport const loadInvocationMethod = async (): Promise<InvocationMethod | undefined> => {\n const { loadSettings } = await import('./settings.js');\n const result = await loadSettings();\n if (result._tag === 'Success') {\n return (result.value as any).invocationMethod;\n }\n return undefined;\n};\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": "+CA4BO,IAAM,EAAmB,IAAwB,CACtD,IAAM,EAAO,QAAQ,KACf,EAAW,EAAK,GAChB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W,QAAS,MAAO,OAAO,MAEvC,YAEH,MAAO,CAAC,kBAAmB,MAAO,OAAO,MAEtC,SACH,MAAO,CAAC,EAAW,QAAS,MAAO,OAAO,MAEvC,UAEH,MAAO,CAAC,KAAM,eAAgB,MAAO,OAAO,IAOrC,EAAsB,CAAC,IAAsC,CAGxE,QAFmB,GAAU,EAAiB,GAE3B,UACZ,UACA,SACH,MAAO,UAEJ,OACH,MAAO,WAEJ,YAEH,OAAO,QAAQ,SAAS,SAAS,KAAK,EAAI,MAAQ,WAE/C,aACA,UACH,MAAO,QAOA,EAAsB,CACjC,EACA,EACA,IACW,CAEX,MAAO,GADQ,EAAiB,CAAM,iBACN,cAAqB,KAM1C,EAAuB,MAAO,IAA4C,CACrF,IAAQ,kBAAmB,KAAa,+BACxC,MAAM,EAAe,CACnB,iBAAkB,CACpB,CAAC,GAMU,EAAuB,SAAmD,CACrF,IAAQ,gBAAiB,KAAa,+BAChC,EAAS,MAAM,EAAa,EAClC,GAAI,EAAO,OAAS,UAClB,OAAQ,EAAO,MAAc,iBAE/B",
|
|
8
|
-
"debugId": "AE5BA2434A51019C64756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
package/dist/chunk-qctnd9ga.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{z as V}from"./chunk-h9kssnyy.js";import{B as P,C as Y,D as $}from"./chunk-j08f9mnk.js";import{F as M,I as b}from"./chunk-x46tzzn9.js";var z=async(q)=>{let{detectInvocation:B,generateHookCommand:G,loadInvocationMethod:N}=await import("./chunk-b2zeg2wa.js"),W=await N()||B();return{sessionCommand:G("session",q,W),messageCommand:G("message",q,W),notificationCommand:G("notification",q,W)}},J={sessionCommand:"npx -y @sylphx/flow hook --type session --target claude-code",messageCommand:"npx -y @sylphx/flow hook --type message --target claude-code",notificationCommand:"npx -y @sylphx/flow hook --type notification --target claude-code"},y=(q)=>{return $(()=>JSON.parse(q),(B)=>V("Failed to parse Claude Code settings",{cause:B instanceof Error?B:void 0}))},w=(q=J)=>{let B=q.sessionCommand||J.sessionCommand,G=q.messageCommand||J.messageCommand,N=q.notificationCommand||J.notificationCommand;return{SessionStart:[{hooks:[{type:"command",command:B}]}],UserPromptSubmit:[{hooks:[{type:"command",command:G}]}],Notification:[{matcher:"",hooks:[{type:"command",command:N}]}]}},R=(q,B=J)=>{let G=w(B);return{...q,hooks:{...q.hooks||{},...G}}},Z=(q=J)=>{return{hooks:w(q)}},X=(q)=>{return JSON.stringify(q,null,2)},p=()=>{return"Claude Code hooks configured: SessionStart (static info) + UserPromptSubmit (dynamic info)"},A=(q,B=J)=>{if(q===null||q.trim()===""){let Q=Z(B);return P(X(Q))}let G=y(q);if(G._tag==="Failure"){let Q=Z(B);return P(X(Q))}let N=R(G.value,B);return P(X(N))},D=(q)=>{if(q.sessionCommand!==void 0&&q.sessionCommand.trim()==="")return Y(V("Session command cannot be empty"));if(q.messageCommand!==void 0&&q.messageCommand.trim()==="")return Y(V("Message command cannot be empty"));return P(q)};export{D as validateHookConfig,X as serializeSettings,A as processSettings,y as parseSettings,R as mergeSettings,p as getSuccessMessage,z as generateHookCommands,Z as createSettings,w as buildHookConfiguration,J as DEFAULT_HOOKS};
|
|
2
|
-
|
|
3
|
-
//# debugId=FAAB79DEE5BF095C64756E2164756E21
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/targets/functional/claude-code-logic.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"/**\n * Business logic for Claude Code target setup\n * Pure functions separated from I/O\n *\n * DESIGN RATIONALE:\n * - Business logic testable without file system\n * - Pure functions for settings transformation\n * - Side effects isolated\n * - Clear separation of concerns\n */\n\nimport type { ConfigError } from '../../core/functional/error-types.js';\nimport { configError } from '../../core/functional/error-types.js';\nimport type { Result } from '../../core/functional/result.js';\nimport { failure, success, tryCatch } from '../../core/functional/result.js';\n\n/**\n * Claude Code settings structure\n */\nexport interface ClaudeCodeSettings {\n hooks?: Record<\n string,\n Array<{\n hooks: Array<{\n type: string;\n command: string;\n }>;\n }>\n >;\n [key: string]: unknown;\n}\n\nexport interface HookConfig {\n sessionCommand?: string;\n messageCommand?: string;\n notificationCommand?: string;\n}\n\n/**\n * Generate hook commands based on how CLI was invoked\n * Detects invocation method and generates matching commands\n */\nexport const generateHookCommands = async (targetId: string): Promise<HookConfig> => {\n const { detectInvocation, generateHookCommand, loadInvocationMethod } = await import(\n '../../utils/cli-invocation.js'\n );\n\n // Try to load saved invocation method, fall back to detection\n const savedMethod = await loadInvocationMethod();\n const method = savedMethod || detectInvocation();\n\n return {\n sessionCommand: generateHookCommand('session', targetId, method),\n messageCommand: generateHookCommand('message', targetId, method),\n notificationCommand: generateHookCommand('notification', targetId, method),\n };\n};\n\n/**\n * Default hook commands (fallback)\n * Now using unified hook command for all content (rules, output styles, system info)\n */\nexport const DEFAULT_HOOKS: HookConfig = {\n sessionCommand: 'npx -y @sylphx/flow hook --type session --target claude-code',\n messageCommand: 'npx -y @sylphx/flow hook --type message --target claude-code',\n notificationCommand: 'npx -y @sylphx/flow hook --type notification --target claude-code',\n};\n\n/**\n * Parse JSON settings (pure)\n */\nexport const parseSettings = (content: string): Result<ClaudeCodeSettings, ConfigError> => {\n return tryCatch(\n () => JSON.parse(content) as ClaudeCodeSettings,\n (error) =>\n configError('Failed to parse Claude Code settings', {\n cause: error instanceof Error ? error : undefined,\n })\n );\n};\n\n/**\n * Build hook configuration (pure)\n */\nexport const buildHookConfiguration = (\n config: HookConfig = DEFAULT_HOOKS\n): ClaudeCodeSettings['hooks'] => {\n const sessionCommand = config.sessionCommand || DEFAULT_HOOKS.sessionCommand!;\n const messageCommand = config.messageCommand || DEFAULT_HOOKS.messageCommand!;\n const notificationCommand = config.notificationCommand || DEFAULT_HOOKS.notificationCommand!;\n\n return {\n SessionStart: [\n {\n hooks: [\n {\n type: 'command',\n command: sessionCommand,\n },\n ],\n },\n ],\n UserPromptSubmit: [\n {\n hooks: [\n {\n type: 'command',\n command: messageCommand,\n },\n ],\n },\n ],\n Notification: [\n {\n matcher: '',\n hooks: [\n {\n type: 'command',\n command: notificationCommand,\n },\n ],\n },\n ],\n };\n};\n\n/**\n * Merge settings with new hooks (pure)\n */\nexport const mergeSettings = (\n existingSettings: ClaudeCodeSettings,\n hookConfig: HookConfig = DEFAULT_HOOKS\n): ClaudeCodeSettings => {\n const newHooks = buildHookConfiguration(hookConfig);\n\n return {\n ...existingSettings,\n hooks: {\n ...(existingSettings.hooks || {}),\n ...newHooks,\n },\n };\n};\n\n/**\n * Create settings with hooks (pure)\n */\nexport const createSettings = (hookConfig: HookConfig = DEFAULT_HOOKS): ClaudeCodeSettings => {\n return {\n hooks: buildHookConfiguration(hookConfig),\n };\n};\n\n/**\n * Serialize settings to JSON (pure)\n */\nexport const serializeSettings = (settings: ClaudeCodeSettings): string => {\n return JSON.stringify(settings, null, 2);\n};\n\n/**\n * Get success message (pure)\n */\nexport const getSuccessMessage = (): string => {\n return 'Claude Code hooks configured: SessionStart (static info) + UserPromptSubmit (dynamic info)';\n};\n\n/**\n * Process settings: parse existing or create new, merge hooks, serialize (pure)\n */\nexport const processSettings = (\n existingContent: string | null,\n hookConfig: HookConfig = DEFAULT_HOOKS\n): Result<string, ConfigError> => {\n if (existingContent === null || existingContent.trim() === '') {\n // No existing settings, create new\n const settings = createSettings(hookConfig);\n return success(serializeSettings(settings));\n }\n\n // Parse existing settings\n const parseResult = parseSettings(existingContent);\n if (parseResult._tag === 'Failure') {\n // If parsing fails, create new settings\n const settings = createSettings(hookConfig);\n return success(serializeSettings(settings));\n }\n\n // Merge with existing\n const merged = mergeSettings(parseResult.value, hookConfig);\n return success(serializeSettings(merged));\n};\n\n/**\n * Validate hook configuration (pure)\n */\nexport const validateHookConfig = (config: HookConfig): Result<HookConfig, ConfigError> => {\n if (config.sessionCommand !== undefined && config.sessionCommand.trim() === '') {\n return failure(configError('Session command cannot be empty'));\n }\n\n if (config.messageCommand !== undefined && config.messageCommand.trim() === '') {\n return failure(configError('Message command cannot be empty'));\n }\n\n return success(config);\n};\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": "yJA0CO,FAAM,JAAuB,MAAO,IAA0C,CACnF,IAAQ,mBAAkB,sBAAqB,wBAAyB,KACtE,+BAKI,EADc,MAAM,EAAqB,GACjB,EAAiB,EAE/C,MAAO,CACL,eAAgB,EAAoB,UAAW,EAAU,CAAM,EAC/D,eAAgB,EAAoB,UAAW,EAAU,CAAM,EAC/D,oBAAqB,EAAoB,eAAgB,EAAU,CAAM,CAC3E,GAOW,EAA4B,CACvC,eAAgB,+DAChB,eAAgB,+DAChB,oBAAqB,mEACvB,EAKa,EAAgB,CAAC,IAA6D,CACzF,OAAO,EACL,IAAM,KAAK,MAAM,CAAO,EACxB,CAAC,IACC,EAAY,uCAAwC,CAClD,MAAO,aAAiB,MAAQ,EAAQ,MAC1C,CAAC,CACL,GAMW,EAAyB,CACpC,EAAqB,IACW,CAChC,IAAM,EAAiB,EAAO,gBAAkB,EAAc,eACxD,EAAiB,EAAO,gBAAkB,EAAc,eACxD,EAAsB,EAAO,qBAAuB,EAAc,oBAExE,MAAO,CACL,aAAc,CACZ,CACE,MAAO,CACL,CACE,KAAM,UACN,QAAS,CACX,CACF,CACF,CACF,EACA,iBAAkB,CAChB,CACE,MAAO,CACL,CACE,KAAM,UACN,QAAS,CACX,CACF,CACF,CACF,EACA,aAAc,CACZ,CACE,QAAS,GACT,MAAO,CACL,CACE,KAAM,UACN,QAAS,CACX,CACF,CACF,CACF,CACF,GAMW,EAAgB,CAC3B,EACA,EAAyB,IACF,CACvB,IAAM,EAAW,EAAuB,CAAU,EAElD,MAAO,IACF,EACH,MAAO,IACD,EAAiB,OAAS,CAAC,KAC5B,CACL,CACF,GAMW,EAAiB,CAAC,EAAyB,IAAsC,CAC5F,MAAO,CACL,MAAO,EAAuB,CAAU,CAC1C,GAMW,EAAoB,CAAC,IAAyC,CACzE,OAAO,KAAK,UAAU,EAAU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