cngkit 1.1.21 → 1.1.23
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/LICENSE +198 -4
- package/README.md +22 -12
- package/dist/{chunk-NGEWD4BW.js → chunk-25Q463MH.js} +1 -2
- package/dist/{chunk-SMTQ3W3F.js → chunk-3BATDTKU.js} +131 -112
- package/dist/chunk-3BATDTKU.js.map +1 -0
- package/dist/{chunk-DIJEVOVN.js → chunk-67FUBMNB.js} +71 -240
- package/dist/chunk-67FUBMNB.js.map +1 -0
- package/dist/chunk-AS7FIJWP.js +88 -0
- package/dist/chunk-AS7FIJWP.js.map +1 -0
- package/dist/chunk-BRFWVQI4.js +18 -0
- package/dist/chunk-BRFWVQI4.js.map +1 -0
- package/dist/{chunk-CVF2ODLP.js → chunk-BXS4IKUA.js} +300 -143
- package/dist/chunk-BXS4IKUA.js.map +1 -0
- package/dist/{chunk-YJXAH7D5.js → chunk-GYRLVNJX.js} +2 -2
- package/dist/chunk-GYRLVNJX.js.map +1 -0
- package/dist/{chunk-SKK2XLRZ.js → chunk-JNHW72SU.js} +21 -15
- package/dist/chunk-JNHW72SU.js.map +1 -0
- package/dist/chunk-U725ZHCI.js +67 -0
- package/dist/chunk-U725ZHCI.js.map +1 -0
- package/dist/chunk-VMTXY4KQ.js +111 -0
- package/dist/chunk-VMTXY4KQ.js.map +1 -0
- package/dist/chunk-WIEYHKQA.js +268 -0
- package/dist/chunk-WIEYHKQA.js.map +1 -0
- package/dist/chunk-YALWTRIP.js +102 -0
- package/dist/chunk-YALWTRIP.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/coderoom/index.js +4 -4
- package/dist/commands/coderoom/join.js +5 -5
- package/dist/commands/coderoom/share.js +8 -11
- package/dist/commands/coderoom/share.js.map +1 -1
- package/dist/commands/hookify/index.js +4 -4
- package/dist/commands/hookify/ingest.js +4 -4
- package/dist/commands/hooks/index.js +4 -4
- package/dist/commands/hooks/install.js +4 -4
- package/dist/commands/hooks/uninstall.js +4 -4
- package/dist/commands/index.js +3 -3
- package/dist/commands/knowledges/audiences.js +26 -8
- package/dist/commands/knowledges/audiences.js.map +1 -1
- package/dist/commands/knowledges/cat.js +26 -7
- package/dist/commands/knowledges/cat.js.map +1 -1
- package/dist/commands/knowledges/files.js +39 -8
- package/dist/commands/knowledges/files.js.map +1 -1
- package/dist/commands/knowledges/find.js +48 -8
- package/dist/commands/knowledges/find.js.map +1 -1
- package/dist/commands/knowledges/glob.js +41 -8
- package/dist/commands/knowledges/glob.js.map +1 -1
- package/dist/commands/knowledges/grep.js +73 -8
- package/dist/commands/knowledges/grep.js.map +1 -1
- package/dist/commands/knowledges/head.js +31 -8
- package/dist/commands/knowledges/head.js.map +1 -1
- package/dist/commands/knowledges/index.js +4 -4
- package/dist/commands/knowledges/list.js +39 -8
- package/dist/commands/knowledges/list.js.map +1 -1
- package/dist/commands/knowledges/ls.js +47 -8
- package/dist/commands/knowledges/ls.js.map +1 -1
- package/dist/commands/knowledges/read.js +46 -8
- package/dist/commands/knowledges/read.js.map +1 -1
- package/dist/commands/knowledges/realpath.js +23 -8
- package/dist/commands/knowledges/realpath.js.map +1 -1
- package/dist/commands/knowledges/search.js +34 -8
- package/dist/commands/knowledges/search.js.map +1 -1
- package/dist/commands/knowledges/stat.js +32 -8
- package/dist/commands/knowledges/stat.js.map +1 -1
- package/dist/commands/knowledges/status.js +26 -8
- package/dist/commands/knowledges/status.js.map +1 -1
- package/dist/commands/knowledges/tail.js +30 -8
- package/dist/commands/knowledges/tail.js.map +1 -1
- package/dist/commands/knowledges/tree.js +38 -8
- package/dist/commands/knowledges/tree.js.map +1 -1
- package/dist/commands/login.js +3 -3
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/scrub.js +3 -3
- package/dist/commands/scrub.js.map +1 -1
- package/dist/commands/transcripts.js +137 -119
- package/dist/commands/transcripts.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-52PGDSFU.js +0 -42
- package/dist/chunk-52PGDSFU.js.map +0 -1
- package/dist/chunk-5WTRGYAO.js +0 -658
- package/dist/chunk-5WTRGYAO.js.map +0 -1
- package/dist/chunk-CVF2ODLP.js.map +0 -1
- package/dist/chunk-DIJEVOVN.js.map +0 -1
- package/dist/chunk-SKK2XLRZ.js.map +0 -1
- package/dist/chunk-SMTQ3W3F.js.map +0 -1
- package/dist/chunk-YJXAH7D5.js.map +0 -1
- /package/dist/{chunk-NGEWD4BW.js.map → chunk-25Q463MH.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/features/knowledges/run-knowledges-command.ts","../src/features/knowledges/knowledges-api.ts","../src/features/knowledges/knowledges-input.ts","../src/features/knowledges/knowledges-output.tsx"],"sourcesContent":["import { createElement } from \"react\";\n\nimport { renderKnowledgesHelp } from \"../../cli/help-specs.js\";\nimport type { CngApi } from \"@cng/client\";\nimport {\n coerceLimit,\n coerceOptionalNumber,\n formatJson,\n optionalJoinedArgument,\n shouldPrintJson,\n type JsonOutputOptions,\n type NumberOption,\n} from \"../../shared/command-utils.js\";\nimport { resolveOutputFormat } from \"../../shared/config.js\";\nimport type { GlobalCommandOptions } from \"../../shared/config.js\";\nimport type { CommandOutput } from \"../../shared/output.js\";\nimport { createKnowledgesApi, type KnowCommandDependencies } from \"./knowledges-api.js\";\nimport {\n formatCatalogPathForDisplay,\n normalizeAudienceId,\n normalizeCatalogPath,\n normalizeFilesystemCatalogPath,\n normalizeGrepMode,\n} from \"./knowledges-input.js\";\nimport {\n KnowAudienceList,\n KnowCatalogSummary,\n KnowSearchResults,\n KnowTopicFileList,\n KnowTopicList,\n} from \"./knowledges-output.js\";\n\nexport type KnowStatusCommandOptions = GlobalCommandOptions & JsonOutputOptions;\n\nexport type KnowAudiencesCommandOptions = GlobalCommandOptions & JsonOutputOptions;\n\nexport type KnowSearchCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n limit?: NumberOption;\n };\n\nexport type KnowListCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n limit?: NumberOption;\n };\n\nexport type KnowFilesCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n audience?: string;\n limit?: NumberOption;\n };\n\nexport type KnowReadCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n offset?: NumberOption;\n limit?: NumberOption;\n };\n\nexport type KnowCatCommandOptions = GlobalCommandOptions & JsonOutputOptions;\n\nexport type KnowHeadCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n lines?: NumberOption;\n };\n\nexport type KnowTailCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n lines?: NumberOption;\n };\n\nexport type KnowGrepCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n path?: string;\n include?: string;\n outputMode?: string;\n context?: NumberOption;\n caseInsensitive?: boolean;\n limit?: NumberOption;\n };\n\nexport type KnowGlobCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n path?: string;\n limit?: NumberOption;\n };\n\nexport type KnowLsCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n limit?: NumberOption;\n long?: boolean;\n };\n\nexport type KnowTreeCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n depth?: NumberOption;\n limit?: NumberOption;\n };\n\nexport type KnowFindCommandOptions = GlobalCommandOptions &\n JsonOutputOptions & {\n name?: string;\n type?: \"file\" | \"directory\";\n maxDepth?: NumberOption;\n limit?: NumberOption;\n };\n\nexport type KnowStatCommandOptions = GlobalCommandOptions & JsonOutputOptions;\n\nexport type KnowRealpathCommandOptions = GlobalCommandOptions & JsonOutputOptions;\n\nexport type KnowledgesCliOptions = KnowFilesCommandOptions &\n KnowGlobCommandOptions &\n KnowGrepCommandOptions &\n KnowCatCommandOptions &\n KnowHeadCommandOptions &\n KnowTailCommandOptions &\n KnowReadCommandOptions &\n KnowSearchCommandOptions &\n KnowLsCommandOptions &\n KnowTreeCommandOptions &\n KnowFindCommandOptions;\n\nexport async function runKnowledgesCommand(\n args: string[] | undefined,\n options: KnowledgesCliOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const [subcommand, ...subcommandArgs] = args ?? [];\n\n if (subcommand === undefined || subcommand === \"help\") {\n output.component(renderKnowledgesHelp(subcommandArgs[0]));\n return;\n }\n\n switch (subcommand) {\n case \"status\":\n return runKnowStatusCommand(options, output, dependencies);\n case \"audiences\":\n return runKnowAudiencesCommand(options, output, dependencies);\n case \"search\":\n return runKnowSearchCommand(\n optionalJoinedArgument(subcommandArgs),\n options,\n output,\n dependencies\n );\n case \"list\":\n return runKnowListCommand(\n optionalJoinedArgument(subcommandArgs),\n options,\n output,\n dependencies\n );\n case \"files\":\n return runKnowFilesCommand(\n optionalJoinedArgument(subcommandArgs),\n options,\n output,\n dependencies\n );\n case \"read\":\n return runKnowReadCommand(subcommandArgs[0], options, output, dependencies);\n case \"cat\":\n return runKnowCatCommand(subcommandArgs[0], options, output, dependencies);\n case \"head\":\n return runKnowHeadCommand(subcommandArgs[0], options, output, dependencies);\n case \"tail\":\n return runKnowTailCommand(subcommandArgs[0], options, output, dependencies);\n case \"grep\":\n return runKnowGrepCommand(\n optionalJoinedArgument(subcommandArgs),\n options,\n output,\n dependencies\n );\n case \"glob\":\n return runKnowGlobCommand(\n optionalJoinedArgument(subcommandArgs),\n options,\n output,\n dependencies\n );\n case \"ls\":\n return runKnowLsCommand(subcommandArgs[0], options, output, dependencies);\n case \"tree\":\n return runKnowTreeCommand(subcommandArgs[0], options, output, dependencies);\n case \"find\":\n return runKnowFindCommand(subcommandArgs[0], options, output, dependencies);\n case \"stat\":\n return runKnowStatCommand(subcommandArgs[0], options, output, dependencies);\n case \"realpath\":\n return runKnowRealpathCommand(subcommandArgs[0], options, output);\n default:\n throw new Error(\n \"Missing knowledges command. Usage: cngkit knowledges <status|audiences|search|list|files|read|cat|head|tail|grep|glob|ls|tree|find|stat|realpath>\"\n );\n }\n}\n\nexport async function runKnowStatusCommand(\n options: KnowStatusCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.getCatalog();\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n output.component(createElement(KnowCatalogSummary, { catalog: response.data }));\n}\n\nexport async function runKnowAudiencesCommand(\n options: KnowAudiencesCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.listAudiences();\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n output.component(createElement(KnowAudienceList, { audiences: response.data.audiences }));\n}\n\nexport async function runKnowSearchCommand(\n query: string | undefined,\n options: KnowSearchCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!query) {\n throw new Error(\"Missing search query. Usage: cngkit knowledges search <query>\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.search(query, coerceLimit(options.limit, 5));\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n if (response.data.results.length > 0) {\n output.component(createElement(KnowSearchResults, { results: response.data.results }));\n return;\n }\n\n output.warning(`No results for \"${query}\".`);\n}\n\nexport async function runKnowListCommand(\n query: string | undefined,\n options: KnowListCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.listTopics();\n const limit = coerceLimit(options.limit, 25);\n const normalizedQuery = query?.toLowerCase();\n const topics = response.data.topics\n .filter((topic) => {\n if (!normalizedQuery) {\n return true;\n }\n return [topic.name, topic.title, topic.description, topic.type]\n .join(\" \")\n .toLowerCase()\n .includes(normalizedQuery);\n })\n .slice(0, limit);\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson({ topics, total: topics.length }));\n return;\n }\n\n if (topics.length > 0) {\n output.component(createElement(KnowTopicList, { topics }));\n return;\n }\n\n output.warning(\"No matching topics.\");\n}\n\nexport async function runKnowFilesCommand(\n query: string | undefined,\n options: KnowFilesCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.listFiles({\n query,\n audience: normalizeAudienceId(options.audience),\n limit: coerceLimit(options.limit, 25),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n if (response.data.files.length > 0) {\n output.component(createElement(KnowTopicFileList, { files: response.data.files }));\n return;\n }\n\n output.warning(\"No matching files.\");\n}\n\nexport async function runKnowReadCommand(\n filePath: string | undefined,\n options: KnowReadCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!filePath) {\n throw new Error(\"Missing file_path. Usage: cngkit knowledges read <file_path>\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.read({\n filePath: normalizeCatalogPath(filePath),\n offset: coerceOptionalNumber(options.offset),\n limit: coerceLimit(options.limit, 200, 2000),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n if (resolveOutputFormat() === \"markdown\" || !response.data.file_path.endsWith(\".md\")) {\n output.raw(response.data.content);\n } else {\n output.markdown(response.data.content);\n }\n\n if (response.data.truncated) {\n output.warning(\n `[truncated: showing ${response.data.limit} lines from offset ${response.data.offset} of ${response.data.total_lines}]`\n );\n }\n}\n\nexport async function runKnowCatCommand(\n filePath: string | undefined,\n options: KnowCatCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!filePath) {\n throw new Error(\"Missing file_path. Usage: cngkit knowledges cat <file_path>\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.read({\n filePath: normalizeCatalogPath(filePath),\n offset: 0,\n limit: 2000,\n });\n\n outputRawContent(response.data, options, output);\n}\n\nexport async function runKnowHeadCommand(\n filePath: string | undefined,\n options: KnowHeadCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!filePath) {\n throw new Error(\"Missing file_path. Usage: cngkit knowledges head <file_path> -n 10\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.read({\n filePath: normalizeCatalogPath(filePath),\n offset: 0,\n limit: coerceLimit(options.lines, 10, 2000),\n });\n\n outputRawContent(response.data, options, output);\n}\n\nexport async function runKnowTailCommand(\n filePath: string | undefined,\n options: KnowTailCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!filePath) {\n throw new Error(\"Missing file_path. Usage: cngkit knowledges tail <file_path> -n 10\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.tail({\n filePath: normalizeCatalogPath(filePath),\n lines: coerceLimit(options.lines, 10, 2000),\n });\n\n outputRawContent(response.data, options, output);\n}\n\nexport async function runKnowGrepCommand(\n pattern: string | undefined,\n options: KnowGrepCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!pattern) {\n throw new Error(\"Missing pattern. Usage: cngkit knowledges grep <pattern>\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const limit = options.limit !== undefined ? coerceOptionalNumber(options.limit) : undefined;\n const response = await api.grep({\n pattern,\n path: normalizeCatalogPath(options.path ?? \"/\"),\n include: options.include ?? \"*\",\n mode: normalizeGrepMode(options.outputMode),\n context: coerceLimit(options.context, 0, 20),\n ignoreCase: options.caseInsensitive === true,\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n if (response.data.mode === \"files_with_matches\") {\n const files = limit ? response.data.files.slice(0, limit) : response.data.files;\n if (files.length > 0) {\n output.raw(files.map(formatCatalogPathForDisplay).join(\"\\n\"));\n return;\n }\n\n output.warning(`No files matched \"${pattern}\".`);\n return;\n }\n\n if (response.data.mode === \"count\") {\n const counts = limit ? response.data.counts.slice(0, limit) : response.data.counts;\n const lines = counts.map(\n (count) => `${formatCatalogPathForDisplay(count.file_path)}: ${count.match_count}`\n );\n if (lines.length > 0) {\n output.raw(lines.join(\"\\n\"));\n return;\n }\n\n output.warning(`No matches for \"${pattern}\".`);\n return;\n }\n\n const matches = limit ? response.data.matches.slice(0, limit) : response.data.matches;\n const lines = matches.flatMap((match) => [\n `${formatCatalogPathForDisplay(match.file_path)}:${match.line_number}`,\n ...match.context_before.map((line) => ` ${line}`),\n `> ${match.line}`,\n ...match.context_after.map((line) => ` ${line}`),\n ]);\n\n if (lines.length > 0) {\n output.raw(lines.join(\"\\n\"));\n return;\n }\n\n output.warning(`No matches for \"${pattern}\".`);\n}\n\nexport async function runKnowGlobCommand(\n pattern: string | undefined,\n options: KnowGlobCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const limit = options.limit !== undefined ? coerceOptionalNumber(options.limit) : undefined;\n const response = await api.glob({\n pattern: pattern ?? \"**/*.md\",\n path: normalizeCatalogPath(options.path ?? \"/\"),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n const files = limit ? response.data.files.slice(0, limit) : response.data.files;\n const wasClientTruncated = limit ? response.data.files.length > limit : false;\n\n if (files.length > 0) {\n output.raw(files.map(formatCatalogPathForDisplay).join(\"\\n\"));\n } else {\n output.warning(\"No matching files.\");\n }\n if (response.data.truncated || wasClientTruncated) {\n output.warning(`[truncated: ${response.data.total_files} total files]`);\n }\n}\n\nexport async function runKnowLsCommand(\n path: string | undefined,\n options: KnowLsCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.listDirectory({\n path: normalizeFilesystemCatalogPath(path ?? \"/\"),\n limit: coerceLimit(options.limit, 100, 1000),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n const entries = [...response.data.entries].sort(compareFilesystemEntries);\n const lines = entries.map((entry) =>\n options.long === true\n ? formatLongFilesystemEntryLine(entry)\n : formatShellFilesystemEntryName(entry)\n );\n\n if (lines.length > 0) {\n output.raw(lines.join(\"\\n\"));\n } else {\n output.warning(`No entries under ${formatCatalogPathForDisplay(response.data.path)}.`);\n }\n\n if (response.data.truncated) {\n output.warning(`[truncated: ${response.data.total_entries} total entries]`);\n }\n}\n\nexport async function runKnowTreeCommand(\n path: string | undefined,\n options: KnowTreeCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.tree({\n path: normalizeFilesystemCatalogPath(path ?? \"/\"),\n depth: coerceLimit(options.depth, 3, 8),\n limit: coerceLimit(options.limit, 500, 2000),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n const lines = formatFilesystemTree(response.data.path, response.data.entries);\n output.raw(lines.join(\"\\n\"));\n\n if (response.data.truncated) {\n output.warning(`[truncated: ${response.data.total_entries} total entries]`);\n }\n}\n\nexport async function runKnowFindCommand(\n path: string | undefined,\n options: KnowFindCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.find({\n path: normalizeFilesystemCatalogPath(path ?? \"/\"),\n name: options.name,\n type: options.type,\n maxDepth: coerceOptionalFiniteNumber(options.maxDepth),\n limit: coerceLimit(options.limit, 500, 2000),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n const entries = [...response.data.entries].sort(compareFilesystemEntries);\n const lines = entries.map(formatFilesystemEntryPath);\n\n if (lines.length > 0) {\n output.raw(lines.join(\"\\n\"));\n } else {\n output.warning(`No entries found under ${formatCatalogPathForDisplay(response.data.path)}.`);\n }\n\n if (response.data.truncated) {\n output.warning(`[truncated: ${response.data.total_entries} total entries]`);\n }\n}\n\nexport async function runKnowStatCommand(\n path: string | undefined,\n options: KnowStatCommandOptions,\n output: CommandOutput,\n dependencies?: KnowCommandDependencies\n): Promise<void> {\n if (!path) {\n throw new Error(\"Missing path. Usage: cngkit knowledges stat <path>\");\n }\n\n const api = dependencies?.api ?? createKnowledgesApi(options);\n const response = await api.statPath({\n path: normalizeFilesystemCatalogPath(path),\n });\n\n if (shouldPrintJson(options)) {\n output.raw(formatJson(response.data));\n return;\n }\n\n output.raw(formatFilesystemStat(response.data));\n}\n\nexport async function runKnowRealpathCommand(\n path: string | undefined,\n options: KnowRealpathCommandOptions,\n output: CommandOutput\n): Promise<void> {\n if (!path) {\n throw new Error(\"Missing path. Usage: cngkit knowledges realpath <path>\");\n }\n\n const resolvedPath = formatCatalogPathForDisplay(normalizeFilesystemCatalogPath(path));\n if (shouldPrintJson(options)) {\n output.raw(formatJson({ path: resolvedPath }));\n return;\n }\n\n output.raw(resolvedPath);\n}\n\nfunction compareFilesystemEntries(\n left: CngApi.HarnessFilesystemEntry,\n right: CngApi.HarnessFilesystemEntry\n): number {\n if (left.type !== right.type) {\n return left.type === \"directory\" ? -1 : 1;\n }\n\n return left.path.localeCompare(right.path);\n}\n\nfunction outputRawContent(\n data: CngApi.HarnessReadResponse,\n options: JsonOutputOptions,\n output: CommandOutput\n): void {\n if (shouldPrintJson(options)) {\n output.raw(formatJson(data));\n return;\n }\n\n output.raw(data.content);\n}\n\nfunction formatFilesystemTree(\n rootPath: string,\n entries: CngApi.HarnessFilesystemEntry[]\n): string[] {\n const normalizedRootPath = rootPath.replace(/\\/+$/, \"\");\n const rootLine = formatTreeDirectoryName(rootPath);\n const entryLines = [...entries].sort(compareFilesystemEntries).map((entry) => {\n const relativePath = stripRootPath(entry.path, normalizedRootPath);\n const segmentCount = relativePath.split(\"/\").filter(Boolean).length;\n const indent = \" \".repeat(Math.max(segmentCount - 1, 0));\n return `${indent}${formatShellFilesystemEntryName(entry)}`;\n });\n\n return [rootLine, ...entryLines];\n}\n\nfunction stripRootPath(path: string, rootPath: string): string {\n if (path === rootPath) {\n return \"\";\n }\n\n if (rootPath && path.startsWith(`${rootPath}/`)) {\n return path.slice(rootPath.length + 1);\n }\n\n return path;\n}\n\nfunction formatTreeDirectoryName(path: string): string {\n const normalizedPath = formatCatalogPathForDisplay(path).replace(/\\/+$/, \"\");\n return normalizedPath ? `${normalizedPath}/` : \"/\";\n}\n\nfunction formatShellFilesystemEntryName(entry: CngApi.HarnessFilesystemEntry): string {\n return entry.type === \"directory\" ? `${entry.name}/` : entry.name;\n}\n\nfunction formatFilesystemEntryPath(entry: CngApi.HarnessFilesystemEntry): string {\n const displayPath = formatCatalogPathForDisplay(entry.path);\n return entry.type === \"directory\" ? `${displayPath}/` : displayPath;\n}\n\nfunction formatLongFilesystemEntryLine(entry: CngApi.HarnessFilesystemEntry): string {\n const fields = [\n entry.type,\n formatCatalogPathForDisplay(entry.path),\n ...formatOptionalEntryFields([\n [\"size\", entry.size],\n [\"files\", entry.file_count],\n [\"children\", entry.child_count],\n [\"total_size\", entry.total_size],\n [\"sha256\", entry.sha256],\n [\"asset_kind\", entry.asset_kind],\n [\"topic\", entry.topic_name],\n ]),\n ];\n\n return fields.join(\"\\t\");\n}\n\nfunction coerceOptionalFiniteNumber(value: NumberOption | undefined): number | undefined {\n const normalizedValue = coerceOptionalNumber(value);\n return normalizedValue === undefined || Number.isNaN(normalizedValue)\n ? undefined\n : Math.max(1, Math.trunc(normalizedValue));\n}\n\nfunction formatFilesystemStat(entry: CngApi.HarnessFilesystemStatResponse): string {\n const fields: Array<[string, string | number | null]> = [\n [\"path\", formatCatalogPathForDisplay(entry.path)],\n [\"type\", entry.type],\n [\"name\", entry.name],\n [\"depth\", entry.depth],\n [\"size\", entry.size],\n [\"files\", entry.file_count],\n [\"children\", entry.child_count],\n [\"total_size\", entry.total_size],\n [\"sha256\", entry.sha256],\n [\"asset_kind\", entry.asset_kind],\n [\"title\", entry.title],\n [\"topic\", entry.topic_name],\n [\"updated_at\", entry.updated_at],\n ];\n\n return formatOptionalEntryFields(fields).join(\"\\n\");\n}\n\nfunction formatOptionalEntryFields(fields: Array<[string, string | number | null]>): string[] {\n return fields.flatMap(([key, value]) => {\n if (value === null || value === \"\") {\n return [];\n }\n\n return [`${key}=${value}`];\n });\n}\n","import type { CngApi } from \"@cng/client\";\n\nimport { createCngApiClient } from \"../../shared/api-client.js\";\nimport type { GlobalCommandOptions } from \"../../shared/config.js\";\n\nexport type KnowCommandDependencies = {\n api?: KnowledgesApi;\n};\n\nexport type KnowledgesApi = {\n getCatalog(): Promise<CngApi.HarnessCatalogSummaryApiResponse>;\n listAudiences(): Promise<CngApi.HarnessAudiencesApiResponse>;\n search(query: string, limit: number): Promise<CngApi.HarnessSemanticSearchApiResponse>;\n listTopics(): Promise<CngApi.HarnessTopicsApiResponse>;\n listFiles(options: {\n query?: string;\n audience?: CngApi.HarnessAudienceId;\n limit: number;\n }): Promise<CngApi.HarnessTopicAssetsApiResponse>;\n read(options: {\n filePath: string;\n offset?: number;\n limit: number;\n }): Promise<CngApi.HarnessReadApiResponse>;\n grep(options: {\n pattern: string;\n path: string;\n include: string;\n mode: CngApi.HarnessGrepOutputMode;\n context: number;\n ignoreCase: boolean;\n }): Promise<CngApi.HarnessGrepApiResponse>;\n glob(options: { pattern: string; path: string }): Promise<CngApi.HarnessGlobApiResponse>;\n listDirectory(options: {\n path: string;\n limit: number;\n }): Promise<CngApi.HarnessFilesystemLsApiResponse>;\n tree(options: {\n path: string;\n depth: number;\n limit: number;\n }): Promise<CngApi.HarnessFilesystemTreeApiResponse>;\n find(options: {\n path: string;\n name?: string;\n type?: CngApi.HarnessFilesystemFindType;\n maxDepth?: number;\n limit: number;\n }): Promise<CngApi.HarnessFilesystemFindApiResponse>;\n tail(options: {\n filePath: string;\n lines: number;\n }): Promise<CngApi.HarnessFilesystemTailApiResponse>;\n statPath(options: { path: string }): Promise<CngApi.HarnessFilesystemStatApiResponse>;\n};\n\nexport function createKnowledgesApi(options: GlobalCommandOptions): KnowledgesApi {\n const client = createCngApiClient(options);\n\n return {\n getCatalog: () => client.harnessKnowledges.getHarnessKnowledgesCatalog(),\n listAudiences: () => client.harnessKnowledges.listHarnessKnowledgesAudiences(),\n search: (query, limit) =>\n client.harnessKnowledges.searchHarnessKnowledges({\n q: query,\n limit,\n }),\n listTopics: () => client.harnessKnowledges.listHarnessKnowledgesTopics(),\n listFiles: ({ query, audience, limit }) =>\n client.harnessKnowledges.listHarnessTopicAssets({\n ...(query ? { q: query } : {}),\n ...(audience ? { audience } : {}),\n limit,\n }),\n read: ({ filePath, offset, limit }) =>\n client.harnessFilesystem.getHarnessFilesystemRead({\n file_path: filePath,\n offset,\n limit,\n }),\n grep: ({ pattern, path, include, mode, context, ignoreCase }) =>\n client.harnessFilesystem.getHarnessFilesystemGrep({\n pattern,\n path,\n include,\n output_mode: mode,\n context,\n case_insensitive: ignoreCase ? \"true\" : undefined,\n }),\n glob: ({ pattern, path }) =>\n client.harnessFilesystem.getHarnessFilesystemGlob({\n pattern,\n path,\n }),\n listDirectory: ({ path, limit }) =>\n client.harnessFilesystem.getHarnessFilesystemLs({\n path,\n limit,\n }),\n tree: ({ path, depth, limit }) =>\n client.harnessFilesystem.getHarnessFilesystemTree({\n path,\n depth,\n limit,\n }),\n find: ({ path, name, type, maxDepth, limit }) =>\n client.harnessFilesystem.getHarnessFilesystemFind({\n path,\n ...(name ? { name } : {}),\n ...(type ? { type } : {}),\n ...(maxDepth !== undefined ? { max_depth: maxDepth } : {}),\n limit,\n }),\n tail: ({ filePath, lines }) =>\n client.harnessFilesystem.getHarnessFilesystemTail({\n file_path: filePath,\n lines,\n }),\n statPath: ({ path }) =>\n client.harnessFilesystem.getHarnessFilesystemStat({\n path,\n }),\n };\n}\n","import type { CngApi } from \"@cng/client\";\n\nconst storedTopicsRoot = \"skills/knowledges/topics\";\n\nexport function normalizeAudienceId(value: string | undefined): CngApi.HarnessAudienceId | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n switch (value) {\n case \"all\":\n case \"operators\":\n case \"builders\":\n case \"researchers\":\n case \"agent-makers\":\n return value;\n default:\n throw new Error(\n `Unknown audience \"${value}\". Run cngkit knowledges audiences to see supported values.`\n );\n }\n}\n\nexport function normalizeCatalogPath(value: string): string {\n const trimmed = value.trim();\n if (trimmed === \"/\" || trimmed === \"\") {\n return storedTopicsRoot;\n }\n\n const relativePath = trimmed.replace(/^\\/+/, \"\");\n if (relativePath === storedTopicsRoot || relativePath.startsWith(`${storedTopicsRoot}/`)) {\n return relativePath;\n }\n\n const topicRelativePath = relativePath.startsWith(\"topics/\")\n ? relativePath.slice(\"topics/\".length)\n : relativePath;\n\n const [firstSegment, ...restSegments] = relativePath.split(\"/\");\n if (!firstSegment) {\n return relativePath;\n }\n\n switch (firstSegment) {\n case \"concepts\":\n case \"domains\":\n case \"formats\":\n case \"languages\":\n case \"libraries\":\n case \"patterns\":\n case \"platforms\":\n case \"procedures\":\n case \"protocols\":\n case \"tools\":\n return `${storedTopicsRoot}/${firstSegment}${restSegments.length > 0 ? `/${restSegments.join(\"/\")}` : \"\"}`;\n default:\n return `${storedTopicsRoot}/${topicRelativePath}`;\n }\n}\n\nexport function normalizeFilesystemCatalogPath(value: string): string {\n const trimmed = value.trim();\n if (trimmed === \"/\" || trimmed === \"\") {\n return storedTopicsRoot;\n }\n\n return normalizeCatalogPath(trimmed);\n}\n\nexport function formatCatalogPathForDisplay(value: string): string {\n const normalized = value.replace(/\\/+$/, \"\");\n if (normalized === storedTopicsRoot) {\n return \"/\";\n }\n\n if (normalized.startsWith(`${storedTopicsRoot}/`)) {\n return `/${normalized.slice(storedTopicsRoot.length + 1)}`;\n }\n\n return value;\n}\n\nexport function normalizeGrepMode(value: string | undefined): CngApi.HarnessGrepOutputMode {\n if (value === undefined) {\n return \"content\";\n }\n\n switch (value) {\n case \"content\":\n case \"files_with_matches\":\n case \"count\":\n return value;\n default:\n throw new Error(\"Unknown grep mode. Use one of: content, files_with_matches, count.\");\n }\n}\n","import type { CngApi } from \"@cng/client\";\nimport { Box, Text } from \"ink\";\n\nimport { singleLine } from \"../../shared/command-utils.js\";\nimport { formatCatalogPathForDisplay } from \"./knowledges-input.js\";\n\nexport function KnowCatalogSummary({ catalog }: { readonly catalog: CngApi.HarnessCatalogSummary }) {\n return (\n <Box flexDirection=\"column\">\n <Text>\n <Text bold>Catalog: </Text>\n {catalog.name}\n </Text>\n <Text>\n <Text bold>Files: </Text>\n {catalog.files}\n </Text>\n <Text>\n <Text bold>Blobs: </Text>\n {catalog.blobs}\n </Text>\n <Text>\n <Text bold>Database: </Text>\n {catalog.database.engine} ({catalog.database.binding})\n </Text>\n </Box>\n );\n}\n\nexport function KnowAudienceList({ audiences }: { readonly audiences: readonly CngApi.HarnessAudience[] }) {\n if (audiences.length === 0) {\n return <Text color=\"yellow\">No audiences available.</Text>;\n }\n\n return (\n <Box flexDirection=\"column\">\n {audiences.map((audience) => (\n <Box flexDirection=\"column\" key={audience.id} marginBottom={1}>\n <Text>\n <Text color=\"cyan\">{audience.id}</Text>\n <Text> - {audience.label}</Text>\n </Text>\n <Text dimColor>{singleLine(audience.help)}</Text>\n </Box>\n ))}\n </Box>\n );\n}\n\nexport function KnowSearchResults({\n results,\n}: {\n readonly results: readonly CngApi.HarnessSemanticSearchResult[];\n}) {\n return (\n <Box flexDirection=\"column\">\n {results.map((result, index) => (\n <Box flexDirection=\"column\" key={result.id} marginBottom={1}>\n <Text>\n <Text color=\"cyan\">{index + 1}. </Text>\n <Text bold>{result.title}</Text>\n <Text dimColor> ({result.topicName})</Text>\n </Text>\n <Text dimColor>\n score {result.score.toFixed(3)} | {formatCatalogPathForDisplay(result.path)}\n </Text>\n <Text>{singleLine(result.description || result.contentPreview)}</Text>\n </Box>\n ))}\n </Box>\n );\n}\n\nexport function KnowTopicList({ topics }: { readonly topics: readonly CngApi.HarnessTopicSummary[] }) {\n return (\n <Box flexDirection=\"column\">\n {topics.map((topic) => (\n <Box flexDirection=\"column\" key={topic.id} marginBottom={1}>\n <Text>\n <Text color=\"cyan\">{topic.name}</Text>\n <Text dimColor> [{topic.type}]</Text>\n </Text>\n <Text>\n {topic.title} | files {topic.fileCount} | rating {topic.rating}\n </Text>\n <Text dimColor>{singleLine(topic.description)}</Text>\n </Box>\n ))}\n </Box>\n );\n}\n\nexport function KnowTopicFileList({ files }: { readonly files: readonly CngApi.HarnessTopicAsset[] }) {\n return (\n <Box flexDirection=\"column\">\n {files.map((file) => {\n const title = file.display_title ?? file.title ?? file.topic_name ?? \"Untitled\";\n\n return (\n <Box flexDirection=\"column\" key={`${file.path}-${file.sha256}`} marginBottom={1}>\n <Text color=\"cyan\">{formatCatalogPathForDisplay(file.path)}</Text>\n <Text dimColor>{title}</Text>\n </Box>\n );\n })}\n </Box>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;;;ACwDvB,SAAS,oBAAoB,SAA8C;AAChF,QAAM,SAAS,mBAAmB,OAAO;AAEzC,SAAO;AAAA,IACL,YAAY,MAAM,OAAO,kBAAkB,4BAA4B;AAAA,IACvE,eAAe,MAAM,OAAO,kBAAkB,+BAA+B;AAAA,IAC7E,QAAQ,CAAC,OAAO,UACd,OAAO,kBAAkB,wBAAwB;AAAA,MAC/C,GAAG;AAAA,MACH;AAAA,IACF,CAAC;AAAA,IACH,YAAY,MAAM,OAAO,kBAAkB,4BAA4B;AAAA,IACvE,WAAW,CAAC,EAAE,OAAO,UAAU,MAAM,MACnC,OAAO,kBAAkB,uBAAuB;AAAA,MAC9C,GAAI,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC;AAAA,MAC5B,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;AAAA,MAC/B;AAAA,IACF,CAAC;AAAA,IACH,MAAM,CAAC,EAAE,UAAU,QAAQ,MAAM,MAC/B,OAAO,kBAAkB,yBAAyB;AAAA,MAChD,WAAW;AAAA,MACX;AAA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,CAAC,cAAc,MAAM,UAAU;AAAA,EACjC;AAEA,SAAO,0BAA0B,MAAM,EAAE,KAAK,IAAI;AACpD;AAEA,SAAS,0BAA0B,QAA2D;AAC5F,SAAO,OAAO,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACtC,QAAI,UAAU,QAAQ,UAAU,IAAI;AAClC,aAAO,CAAC;AAAA,IACV;AAEA,WAAO,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE;AAAA,EAC3B,CAAC;AACH;","names":["lines"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/features/coderoom/run-coderoom-command.ts","../src/features/coderoom/sync/client.ts","../src/features/coderoom/sync/files.ts","../src/features/coderoom/sync/paths.ts","../src/features/coderoom/sync/protocol.ts"],"sourcesContent":["import process from \"node:process\";\n\nimport { readBackendHealth } from \"../../shared/api-client.js\";\nimport { createRoomCode, resolveApiBaseUrl, type GlobalCommandOptions } from \"../../shared/config.js\";\nimport type { CommandOutput } from \"../../shared/output.js\";\nimport { startSyncSession, type SyncSessionRole } from \"./sync/client.js\";\n\nexport type CoderoomCommandOptions = GlobalCommandOptions;\n\nexport type ShareCommandOptions = GlobalCommandOptions;\n\nexport async function runCoderoomCommand(\n args: string[] | undefined,\n options: CoderoomCommandOptions,\n output: CommandOutput\n): Promise<void> {\n const [subcommand, ...subcommandArgs] = args ?? [];\n\n switch (subcommand) {\n case \"share\":\n return runShareCommand(subcommandArgs[0], options, output);\n case \"join\":\n return runJoinCommand(subcommandArgs[0], options, output);\n default:\n throw new Error(\"Missing coderoom command. Usage: cngkit coderoom <share|join>\");\n }\n}\n\nexport async function runShareCommand(\n roomCode: string | undefined,\n options: ShareCommandOptions,\n output: CommandOutput\n): Promise<void> {\n const syncRoomCode = roomCode ?? createRoomCode();\n\n output.success(`Share code: ${syncRoomCode}`);\n await printBackendStatus(options, output);\n await runSyncSession(\"share\", syncRoomCode, options, output);\n}\n\nexport async function runJoinCommand(\n roomCode: string | undefined,\n options: GlobalCommandOptions,\n output: CommandOutput\n): Promise<void> {\n if (!roomCode) {\n throw new Error(\"Missing room code. Usage: cngkit coderoom join <room-code>\");\n }\n\n await printBackendStatus(options, output);\n await runSyncSession(\"join\", roomCode, options, output);\n}\n\nasync function printBackendStatus(\n options: GlobalCommandOptions,\n output: CommandOutput\n): Promise<void> {\n const health = await readBackendHealth(options);\n if (health.ok) {\n output.success(`API: ${health.service} ready`);\n return;\n }\n\n output.warning(`API: unavailable (${health.message})`);\n}\n\nasync function runSyncSession(\n role: SyncSessionRole,\n roomCode: string,\n options: GlobalCommandOptions,\n output: CommandOutput\n): Promise<void> {\n await startSyncSession({\n apiBaseUrl: resolveApiBaseUrl(options),\n roomCode,\n role,\n cwd: process.cwd(),\n output,\n });\n}\n","import process from \"node:process\";\nimport fs from \"node:fs\";\n\nimport chokidar, { type FSWatcher } from \"chokidar\";\nimport WebSocket, { type RawData } from \"ws\";\n\nimport { createPeerId } from \"../../../shared/config.js\";\nimport type { CommandOutput } from \"../../../shared/output.js\";\nimport {\n applyRemoteMessage,\n buildFileMessage,\n collectSnapshotMessages,\n createSuppressionTracker,\n type SuppressionTracker,\n} from \"./files.js\";\nimport {\n resolveRepoContext,\n shouldSyncRelativePath,\n toRepoRelativePath,\n type RepoContext,\n} from \"./paths.js\";\nimport { decodeSyncMessage, encodeSyncMessage, type SyncMessage } from \"./protocol.js\";\n\nexport type SyncSessionRole = \"share\" | \"join\";\n\nexport type StartSyncSessionOptions = {\n apiBaseUrl: string;\n roomCode: string;\n role: SyncSessionRole;\n cwd: string;\n output: CommandOutput;\n};\n\ntype WatcherContext = {\n repoContext: RepoContext;\n socket: WebSocket;\n peerId: string;\n suppressionTracker: SuppressionTracker;\n output: CommandOutput;\n};\n\nfunction createSyncWebSocketUrl(apiBaseUrl: string, roomCode: string): string {\n const url = new URL(apiBaseUrl);\n url.protocol = url.protocol === \"http:\" ? \"ws:\" : \"wss:\";\n url.pathname = `/api/cng/sync/${encodeURIComponent(roomCode)}`;\n url.search = \"\";\n url.hash = \"\";\n return url.toString();\n}\n\nfunction sendMessage(socket: WebSocket, message: SyncMessage): void {\n if (socket.readyState === WebSocket.OPEN) {\n socket.send(encodeSyncMessage(message));\n }\n}\n\nexport async function startSyncSession(options: StartSyncSessionOptions): Promise<void> {\n const repoContext = await resolveRepoContext(options.cwd);\n const peerId = createPeerId();\n const suppressionTracker = createSuppressionTracker();\n const webSocketUrl = createSyncWebSocketUrl(options.apiBaseUrl, options.roomCode);\n const socket = new WebSocket(webSocketUrl);\n\n options.output.success(`Room: ${options.roomCode}`);\n options.output.info(`Repo: ${repoContext.rootDir}`);\n options.output.muted(`Peer: ${peerId}`);\n\n const watcherContext: WatcherContext = {\n repoContext,\n socket,\n peerId,\n suppressionTracker,\n output: options.output,\n };\n const watcher = createRepoWatcher(watcherContext);\n\n socket.on(\"open\", () => {\n sendMessage(socket, {\n type: \"hello\",\n peerId,\n role: options.role,\n sentAt: Date.now(),\n });\n void sendInitialSnapshot(socket, repoContext, peerId, options.output);\n });\n\n socket.on(\"message\", (data) => {\n void handleRemoteMessage({\n data,\n repoContext,\n peerId,\n suppressionTracker,\n output: options.output,\n });\n });\n\n await waitForSessionClose(socket, watcher);\n}\n\nfunction createRepoWatcher(context: WatcherContext): FSWatcher {\n const watcher = chokidar.watch(context.repoContext.rootDir, {\n ignoreInitial: true,\n ignored: (candidatePath) => {\n const relativePath = toRepoRelativePath(context.repoContext.rootDir, candidatePath);\n if (relativePath?.split(\"/\").includes(\".git\") ?? false) {\n return true;\n }\n try {\n const stat = fs.statSync(candidatePath);\n return !stat.isFile() && !stat.isDirectory();\n } catch {\n return false;\n }\n },\n });\n\n watcher.on(\"add\", (absolutePath) => {\n void sendLocalFileChange(context, absolutePath);\n });\n watcher.on(\"change\", (absolutePath) => {\n void sendLocalFileChange(context, absolutePath);\n });\n watcher.on(\"unlink\", (absolutePath) => {\n void sendLocalDelete(context, absolutePath);\n });\n watcher.on(\"error\", (watcherError) => {\n context.output.warning(`watcher error: ${watcherError instanceof Error ? watcherError.message : String(watcherError)}`);\n });\n\n return watcher;\n}\n\nasync function sendInitialSnapshot(\n socket: WebSocket,\n repoContext: RepoContext,\n peerId: string,\n output: CommandOutput\n): Promise<void> {\n let fileCount = 0;\n\n for await (const message of collectSnapshotMessages(repoContext, peerId)) {\n sendMessage(socket, message);\n fileCount += 1;\n }\n\n sendMessage(socket, {\n type: \"snapshot-complete\",\n peerId,\n sentAt: Date.now(),\n fileCount,\n });\n output.success(`sent snapshot ${fileCount} files`);\n}\n\nasync function sendLocalFileChange(context: WatcherContext, absolutePath: string): Promise<void> {\n const relativePath = toRepoRelativePath(context.repoContext.rootDir, absolutePath);\n if (!relativePath || context.suppressionTracker.isSuppressed(relativePath)) {\n return;\n }\n\n const message = await buildFileMessage(context.repoContext, context.peerId, relativePath);\n if (!message) {\n return;\n }\n\n sendMessage(context.socket, message);\n context.output.muted(`sent file ${relativePath}`);\n}\n\nasync function sendLocalDelete(context: WatcherContext, absolutePath: string): Promise<void> {\n const relativePath = toRepoRelativePath(context.repoContext.rootDir, absolutePath);\n if (!relativePath || context.suppressionTracker.isSuppressed(relativePath)) {\n return;\n }\n\n if (!(await shouldSyncRelativePath(context.repoContext, relativePath))) {\n return;\n }\n\n sendMessage(context.socket, {\n type: \"delete\",\n peerId: context.peerId,\n path: relativePath,\n mtimeMs: Date.now(),\n sentAt: Date.now(),\n });\n context.output.warning(`sent delete ${relativePath}`);\n}\n\nasync function handleRemoteMessage(options: {\n data: RawData;\n repoContext: RepoContext;\n peerId: string;\n suppressionTracker: SuppressionTracker;\n output: CommandOutput;\n}): Promise<void> {\n const decodedMessage = decodeSyncMessage(options.data.toString());\n if (!decodedMessage || decodedMessage.peerId === options.peerId) {\n return;\n }\n\n if (decodedMessage.type === \"hello\") {\n options.output.info(`peer joined ${decodedMessage.peerId}`);\n return;\n }\n\n if (decodedMessage.type === \"snapshot-complete\") {\n options.output.success(`peer snapshot complete ${decodedMessage.fileCount} files`);\n return;\n }\n\n await applyRemoteMessage(options.repoContext, decodedMessage, options.suppressionTracker);\n options.output.success(`applied ${decodedMessage.type} ${decodedMessage.path}`);\n}\n\nasync function waitForSessionClose(socket: WebSocket, watcher: FSWatcher): Promise<void> {\n await new Promise<void>((resolve, reject) => {\n let settled = false;\n\n const closeSession = async (): Promise<void> => {\n await watcher.close();\n if (socket.readyState === WebSocket.OPEN || socket.readyState === WebSocket.CONNECTING) {\n socket.close();\n }\n };\n\n const finish = async (): Promise<void> => {\n if (settled) {\n return;\n }\n settled = true;\n process.off(\"SIGINT\", onSignal);\n process.off(\"SIGTERM\", onSignal);\n await closeSession();\n resolve();\n };\n\n const onSignal = (): void => {\n void finish();\n };\n\n socket.on(\"error\", async (error) => {\n if (settled) {\n return;\n }\n settled = true;\n process.off(\"SIGINT\", onSignal);\n process.off(\"SIGTERM\", onSignal);\n await closeSession();\n reject(error);\n });\n\n socket.on(\"close\", () => {\n void finish();\n });\n\n process.on(\"SIGINT\", onSignal);\n process.on(\"SIGTERM\", onSignal);\n });\n}\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { SyncFileMutationMessage, SyncMessage } from \"./protocol.js\";\nimport {\n resolveRepoPath,\n shouldSyncRelativePath,\n toRepoRelativePath,\n type RepoContext,\n} from \"./paths.js\";\n\nexport type SuppressionTracker = {\n suppress(relativePath: string): void;\n isSuppressed(relativePath: string): boolean;\n};\n\nexport function createSuppressionTracker(windowMs = 1500): SuppressionTracker {\n const suppressedUntilByPath = new Map<string, number>();\n\n return {\n suppress(relativePath: string) {\n suppressedUntilByPath.set(relativePath, Date.now() + windowMs);\n },\n isSuppressed(relativePath: string) {\n const suppressedUntil = suppressedUntilByPath.get(relativePath);\n if (!suppressedUntil) {\n return false;\n }\n if (suppressedUntil < Date.now()) {\n suppressedUntilByPath.delete(relativePath);\n return false;\n }\n return true;\n },\n };\n}\n\nexport async function* collectSnapshotMessages(\n context: RepoContext,\n peerId: string\n): AsyncGenerator<SyncMessage> {\n yield* collectDirectorySnapshot(context, context.rootDir, peerId);\n}\n\nasync function* collectDirectorySnapshot(\n context: RepoContext,\n directoryPath: string,\n peerId: string\n): AsyncGenerator<SyncMessage> {\n const entries = await fs.opendir(directoryPath);\n\n for await (const entry of entries) {\n const absolutePath = path.join(directoryPath, entry.name);\n const relativePath = toRepoRelativePath(context.rootDir, absolutePath);\n\n if (!relativePath || !(await shouldSyncRelativePath(context, relativePath))) {\n continue;\n }\n\n if (entry.isDirectory()) {\n yield* collectDirectorySnapshot(context, absolutePath, peerId);\n continue;\n }\n\n if (!entry.isFile()) {\n continue;\n }\n\n const [content, stat] = await Promise.all([fs.readFile(absolutePath), fs.stat(absolutePath)]);\n yield {\n type: \"file\",\n peerId,\n path: relativePath,\n contentBase64: content.toString(\"base64\"),\n mtimeMs: stat.mtimeMs,\n sentAt: Date.now(),\n };\n }\n}\n\nexport async function buildFileMessage(\n context: RepoContext,\n peerId: string,\n relativePath: string\n): Promise<SyncMessage | undefined> {\n if (!(await shouldSyncRelativePath(context, relativePath))) {\n return undefined;\n }\n\n const absolutePath = resolveRepoPath(context.rootDir, relativePath);\n if (!absolutePath) {\n return undefined;\n }\n\n const stat = await fs.stat(absolutePath);\n if (!stat.isFile()) {\n return undefined;\n }\n\n const content = await fs.readFile(absolutePath);\n return {\n type: \"file\",\n peerId,\n path: relativePath,\n contentBase64: content.toString(\"base64\"),\n mtimeMs: stat.mtimeMs,\n sentAt: Date.now(),\n };\n}\n\nexport async function applyRemoteMessage(\n context: RepoContext,\n message: SyncFileMutationMessage,\n suppressionTracker: SuppressionTracker\n): Promise<void> {\n const absolutePath = resolveRepoPath(context.rootDir, message.path);\n if (!absolutePath || !(await shouldSyncRelativePath(context, message.path))) {\n return;\n }\n\n suppressionTracker.suppress(message.path);\n\n if (message.type === \"delete\") {\n await fs.rm(absolutePath, { force: true });\n return;\n }\n\n await fs.mkdir(path.dirname(absolutePath), { recursive: true });\n await fs.writeFile(absolutePath, Buffer.from(message.contentBase64, \"base64\"));\n}\n","import { execFile } from \"node:child_process\";\nimport path from \"node:path\";\nimport { promisify } from \"node:util\";\n\nconst execFileAsync = promisify(execFile);\n\nexport type RepoContext = {\n rootDir: string;\n};\n\nexport async function resolveRepoContext(cwd: string): Promise<RepoContext> {\n try {\n const { stdout } = await execFileAsync(\"git\", [\"rev-parse\", \"--show-toplevel\"], {\n cwd,\n });\n return { rootDir: path.resolve(stdout.trim()) };\n } catch {\n return { rootDir: path.resolve(cwd) };\n }\n}\n\nexport function toRepoRelativePath(rootDir: string, absolutePath: string): string | undefined {\n const relativePath = path.relative(rootDir, absolutePath);\n\n if (!relativePath || relativePath.startsWith(\"..\") || path.isAbsolute(relativePath)) {\n return undefined;\n }\n\n return relativePath.split(path.sep).join(\"/\");\n}\n\nexport function resolveRepoPath(rootDir: string, relativePath: string): string | undefined {\n if (!isSafeRelativePath(relativePath)) {\n return undefined;\n }\n\n const absolutePath = path.resolve(rootDir, relativePath);\n const normalizedRoot = `${path.resolve(rootDir)}${path.sep}`;\n\n if (absolutePath !== path.resolve(rootDir) && !absolutePath.startsWith(normalizedRoot)) {\n return undefined;\n }\n\n return absolutePath;\n}\n\nexport function isSafeRelativePath(relativePath: string): boolean {\n if (!relativePath || relativePath.startsWith(\"/\") || relativePath.includes(\"\\0\")) {\n return false;\n }\n\n const normalizedParts = relativePath.split(/[\\\\/]+/).filter(Boolean);\n if (normalizedParts.includes(\"..\")) {\n return false;\n }\n\n return normalizedParts[0] !== \".git\";\n}\n\nexport async function shouldSyncRelativePath(\n context: RepoContext,\n relativePath: string\n): Promise<boolean> {\n if (!isSafeRelativePath(relativePath)) {\n return false;\n }\n\n try {\n await execFileAsync(\"git\", [\"check-ignore\", \"--quiet\", \"--\", relativePath], {\n cwd: context.rootDir,\n });\n return false;\n } catch (error) {\n const exitCode =\n typeof error === \"object\" && error !== null && \"code\" in error ? error.code : undefined;\n return exitCode === 1;\n }\n}\n","import { z } from \"zod\";\n\nconst SyncBaseMessageSchema = z.object({\n peerId: z.string().min(1),\n sentAt: z.number().finite(),\n});\n\nexport const SyncHelloMessageSchema = SyncBaseMessageSchema.extend({\n type: z.literal(\"hello\"),\n role: z.union([z.literal(\"share\"), z.literal(\"join\")]),\n});\n\nexport const SyncFileMessageSchema = SyncBaseMessageSchema.extend({\n type: z.literal(\"file\"),\n path: z.string().min(1),\n contentBase64: z.string(),\n mtimeMs: z.number().finite(),\n});\n\nexport const SyncDeleteMessageSchema = SyncBaseMessageSchema.extend({\n type: z.literal(\"delete\"),\n path: z.string().min(1),\n mtimeMs: z.number().finite(),\n});\n\nexport const SyncSnapshotCompleteMessageSchema = SyncBaseMessageSchema.extend({\n type: z.literal(\"snapshot-complete\"),\n fileCount: z.number().int().nonnegative(),\n});\n\nexport const SyncMessageSchema = z.discriminatedUnion(\"type\", [\n SyncHelloMessageSchema,\n SyncFileMessageSchema,\n SyncDeleteMessageSchema,\n SyncSnapshotCompleteMessageSchema,\n]);\n\nexport type SyncMessage = z.infer<typeof SyncMessageSchema>;\nexport type SyncFileMutationMessage = Extract<SyncMessage, { type: \"file\" | \"delete\" }>;\n\nexport function encodeSyncMessage(message: SyncMessage): string {\n return JSON.stringify(SyncMessageSchema.parse(message));\n}\n\nexport function decodeSyncMessage(value: unknown): SyncMessage | undefined {\n if (typeof value !== \"string\") {\n return undefined;\n }\n\n try {\n return SyncMessageSchema.parse(JSON.parse(value));\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,cAAa;;;ACApB,OAAO,aAAa;AACpB,OAAOC,SAAQ;AAEf,OAAO,cAAkC;AACzC,OAAO,eAAiC;;;ACJxC,OAAO,QAAQ;AACf,OAAOC,WAAU;;;ACDjB,SAAS,gBAAgB;AACzB,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAE1B,IAAM,gBAAgB,UAAU,QAAQ;AAMxC,eAAsB,mBAAmB,KAAmC;AAC1E,MAAI;AACF,UAAM,EAAE,OAAO,IAAI,MAAM,cAAc,OA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