@sylphx/flow 0.0.3 → 0.0.4
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 +14 -10
- package/dist/{chunk-rtrp1qa5.js → chunk-0fz6p8ka.js} +2 -2
- package/dist/{chunk-rtrp1qa5.js.map → chunk-0fz6p8ka.js.map} +1 -1
- package/dist/{chunk-j7rqqb2w.js → chunk-5eyfa6f8.js} +2 -2
- package/dist/{chunk-j7rqqb2w.js.map → chunk-5eyfa6f8.js.map} +1 -1
- package/dist/chunk-6hhhwb03.js +3 -0
- package/dist/chunk-6hhhwb03.js.map +10 -0
- package/dist/{chunk-z9h5spfk.js → chunk-8saardnr.js} +3 -3
- package/dist/{chunk-z9h5spfk.js.map → chunk-8saardnr.js.map} +1 -1
- package/dist/chunk-e07nqvwm.js +3 -0
- package/dist/chunk-e07nqvwm.js.map +10 -0
- package/dist/{chunk-8bvc13yx.js → chunk-e80fq5bq.js} +2 -2
- package/dist/{chunk-8bvc13yx.js.map → chunk-e80fq5bq.js.map} +1 -1
- package/dist/{chunk-5grx6px4.js → chunk-hpef24m4.js} +2 -2
- package/dist/{chunk-5grx6px4.js.map → chunk-hpef24m4.js.map} +1 -1
- package/dist/chunk-n5gbcebk.js +5 -0
- package/dist/chunk-n5gbcebk.js.map +10 -0
- package/dist/{chunk-wv5zpnbp.js → chunk-n9kqfqp9.js} +2 -2
- package/dist/{chunk-wv5zpnbp.js.map → chunk-n9kqfqp9.js.map} +1 -1
- package/dist/chunk-sdjvmsk2.js +3 -0
- package/dist/{chunk-npw0sq1m.js.map → chunk-sdjvmsk2.js.map} +1 -1
- package/dist/{chunk-p56r2pqw.js → chunk-t6aqpg7b.js} +1 -1
- package/dist/{chunk-e0cdpket.js → chunk-wj8k6qd1.js} +2 -2
- package/dist/{chunk-e0cdpket.js.map → chunk-wj8k6qd1.js.map} +1 -1
- package/dist/index.js +153 -154
- package/dist/index.js.map +6 -7
- package/package.json +1 -1
- package/dist/chunk-npw0sq1m.js +0 -3
- package/dist/chunk-w8epyz4j.js +0 -3
- package/dist/chunk-w8epyz4j.js.map +0 -10
- /package/dist/{chunk-p56r2pqw.js.map → chunk-t6aqpg7b.js.map} +0 -0
package/package.json
CHANGED
package/dist/chunk-npw0sq1m.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{f as q}from"./chunk-j7rqqb2w.js";import{j as v}from"./chunk-e0cdpket.js";import"./chunk-8bvc13yx.js";import w from"node:fs/promises";import B from"node:path";var I=(...b)=>B.join(...b),J=(...b)=>B.resolve(...b),K=(b)=>B.dirname(b),L=(b,k)=>B.basename(b,k),M=(b)=>B.extname(b),N=async(b)=>{return v(async()=>{return await w.readFile(b,"utf-8")},(k)=>q(`Failed to read file: ${b}`,b,"read",{cause:k instanceof Error?k:void 0}))},O=async(b,k)=>{return v(async()=>{await w.writeFile(b,k,"utf-8")},(z)=>q(`Failed to write file: ${b}`,b,"write",{cause:z instanceof Error?z:void 0}))},Q=async(b)=>{return v(async()=>{await w.unlink(b)},(k)=>q(`Failed to delete file: ${b}`,b,"delete",{cause:k instanceof Error?k:void 0}))},R=async(b,k)=>{return v(async()=>{await w.mkdir(b,{recursive:k?.recursive??!0})},(z)=>q(`Failed to create directory: ${b}`,b,"create",{cause:z instanceof Error?z:void 0}))},T=async(b)=>{return v(async()=>{try{return await w.access(b),!0}catch{return!1}},(k)=>q(`Failed to check if path exists: ${b}`,b,"stat",{cause:k instanceof Error?k:void 0}))},U=async(b)=>{return v(async()=>{return await w.readdir(b)},(k)=>q(`Failed to read directory: ${b}`,b,"read",{cause:k instanceof Error?k:void 0}))},V=async(b)=>{return v(async()=>{let k=await w.stat(b);return{isFile:k.isFile(),isDirectory:k.isDirectory(),size:k.size}},(k)=>q(`Failed to get stats for: ${b}`,b,"stat",{cause:k instanceof Error?k:void 0}))};export{O as writeFile,J as resolvePath,N as readFile,U as readDirectory,T as pathExists,I as joinPath,V as getStats,M as extname,K as dirname,Q as deleteFile,R as createDirectory,L as basename};
|
|
2
|
-
|
|
3
|
-
//# debugId=05B3E02BA3B1178D64756E2164756E21
|
package/dist/chunk-w8epyz4j.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{e as J}from"./chunk-j7rqqb2w.js";import{g as I,h as Q,i as W}from"./chunk-e0cdpket.js";import"./chunk-8bvc13yx.js";var B={sessionCommand:"npx -y github:sylphxltd/flow hook --type session --target claude-code",messageCommand:"npx -y github:sylphxltd/flow hook --type message --target claude-code",notificationCommand:"npx -y github:sylphxltd/flow hook --type notification --target claude-code"},Y=(q)=>{return W(()=>JSON.parse(q),(v)=>J("Failed to parse Claude Code settings",{cause:v instanceof Error?v:void 0}))},X=(q=B)=>{let v=q.sessionCommand||B.sessionCommand,G=q.messageCommand||B.messageCommand,M=q.notificationCommand||B.notificationCommand;return{SessionStart:[{hooks:[{type:"command",command:v}]}],UserPromptSubmit:[{hooks:[{type:"command",command:G}]}],Notification:[{matcher:"",hooks:[{type:"command",command:M}]}]}},Z=(q,v=B)=>{let G=X(v);return{...q,hooks:{...q.hooks||{},...G}}},V=(q=B)=>{return{hooks:X(q)}},P=(q)=>{return JSON.stringify(q,null,2)},b=()=>{return"Claude Code hooks configured: SessionStart (static info) + UserPromptSubmit (dynamic info)"},j=(q,v=B)=>{if(q===null||q.trim()===""){let N=V(v);return I(P(N))}let G=Y(q);if(G._tag==="Failure"){let N=V(v);return I(P(N))}let M=Z(G.value,v);return I(P(M))},y=(q)=>{if(q.sessionCommand!==void 0&&q.sessionCommand.trim()==="")return Q(J("Session command cannot be empty"));if(q.messageCommand!==void 0&&q.messageCommand.trim()==="")return Q(J("Message command cannot be empty"));return I(q)};export{y as validateHookConfig,P as serializeSettings,j as processSettings,Y as parseSettings,Z as mergeSettings,b as getSuccessMessage,V as createSettings,X as buildHookConfiguration,B as DEFAULT_HOOKS};
|
|
2
|
-
|
|
3
|
-
//# debugId=A31520A620DA7C9964756E2164756E21
|
|
@@ -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 * Default hook commands\n * Now using unified hook command for all content (rules, output styles, system info)\n */\nexport const DEFAULT_HOOKS: HookConfig = {\n sessionCommand: 'npx -y github:sylphxltd/flow hook --type session --target claude-code',\n messageCommand: 'npx -y github:sylphxltd/flow hook --type message --target claude-code',\n notificationCommand: 'npx -y github:sylphxltd/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": "sIA0CO,FAAM,JAA4B,CACvC,eAAgB,wEAChB,eAAgB,wEAChB,oBAAqB,4EACvB,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,KAAM,CAAC,GAM5B,EAAoB,IAAc,CAC7C,MAAO,8FAMI,EAAkB,CAC7B,EACA,EAAyB,IACO,CAChC,GAAI,IAAoB,MAAQ,EAAgB,KAAK,IAAM,GAAI,CAE7D,IAAM,EAAW,EAAe,CAAU,EAC1C,OAAO,EAAQ,EAAkB,CAAQ,CAAC,EAI5C,IAAM,EAAc,EAAc,CAAe,EACjD,GAAI,EAAY,OAAS,UAAW,CAElC,IAAM,EAAW,EAAe,CAAU,EAC1C,OAAO,EAAQ,EAAkB,CAAQ,CAAC,EAI5C,IAAM,EAAS,EAAc,EAAY,MAAO,CAAU,EAC1D,OAAO,EAAQ,EAAkB,CAAM,CAAC,GAM7B,EAAqB,CAAC,IAAwD,CACzF,GAAI,EAAO,iBAAmB,QAAa,EAAO,eAAe,KAAK,IAAM,GAC1E,OAAO,EAAQ,EAAY,iCAAiC,CAAC,EAG/D,GAAI,EAAO,iBAAmB,QAAa,EAAO,eAAe,KAAK,IAAM,GAC1E,OAAO,EAAQ,EAAY,iCAAiC,CAAC,EAG/D,OAAO,EAAQ,CAAM",
|
|
8
|
-
"debugId": "A31520A620DA7C9964756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
|
File without changes
|