@lon-ask/dockit 0.1.1 → 0.1.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.
Files changed (140) hide show
  1. package/LICENSE +21 -674
  2. package/README.md +618 -328
  3. package/SKILL.md +61 -110
  4. package/apps/client/dist/assets/{index-CqOXxsEZ.js → index-DzadxeQH.js} +2 -2
  5. package/apps/client/dist/index.html +1 -1
  6. package/apps/client/index.html +12 -0
  7. package/apps/client/package.json +26 -0
  8. package/apps/client/src/App.tsx +18 -0
  9. package/apps/client/src/api/client.ts +54 -0
  10. package/apps/client/src/components/BuildPanel.tsx +77 -0
  11. package/apps/client/src/components/DocViewer.tsx +76 -0
  12. package/apps/client/src/components/EntryDetail.tsx +322 -0
  13. package/apps/client/src/components/EntryForm.tsx +117 -0
  14. package/apps/client/src/components/EntryList.tsx +165 -0
  15. package/apps/client/src/components/GlobalSearchBar.tsx +166 -0
  16. package/apps/client/src/components/Layout.tsx +57 -0
  17. package/apps/client/src/components/SearchBar.tsx +103 -0
  18. package/apps/client/src/components/SourceForm.tsx +497 -0
  19. package/apps/client/src/hooks/useTheme.ts +19 -0
  20. package/apps/client/src/index.css +77 -0
  21. package/apps/client/src/main.tsx +13 -0
  22. package/apps/client/src/types.ts +105 -0
  23. package/apps/client/vite.config.ts +13 -0
  24. package/apps/server/dist/core/domain/entry.js +20 -0
  25. package/apps/server/dist/core/domain/entry.js.map +1 -0
  26. package/apps/server/dist/core/domain/errors.js +33 -0
  27. package/apps/server/dist/core/domain/errors.js.map +1 -0
  28. package/apps/server/dist/core/domain/knowledge-graph.js +2 -0
  29. package/apps/server/dist/core/domain/knowledge-graph.js.map +1 -0
  30. package/apps/server/dist/core/domain/types.js +2 -0
  31. package/apps/server/dist/core/domain/types.js.map +1 -0
  32. package/apps/server/dist/core/ports/IBuildRepository.js +2 -0
  33. package/apps/server/dist/core/ports/IBuildRepository.js.map +1 -0
  34. package/apps/server/dist/core/ports/IDocumentNormalizer.js +2 -0
  35. package/apps/server/dist/core/ports/IDocumentNormalizer.js.map +1 -0
  36. package/apps/server/dist/core/ports/IDocumentStore.js +2 -0
  37. package/apps/server/dist/core/ports/IDocumentStore.js.map +1 -0
  38. package/apps/server/dist/core/ports/IEntryReadModel.js +2 -0
  39. package/apps/server/dist/core/ports/IEntryReadModel.js.map +1 -0
  40. package/apps/server/dist/core/ports/IEntryRepository.js +2 -0
  41. package/apps/server/dist/core/ports/IEntryRepository.js.map +1 -0
  42. package/apps/server/dist/core/ports/IKnowledgeGraph.js +2 -0
  43. package/apps/server/dist/core/ports/IKnowledgeGraph.js.map +1 -0
  44. package/apps/server/dist/core/ports/IPathResolver.js +2 -0
  45. package/apps/server/dist/core/ports/IPathResolver.js.map +1 -0
  46. package/apps/server/dist/core/ports/ISearchEngine.js +2 -0
  47. package/apps/server/dist/core/ports/ISearchEngine.js.map +1 -0
  48. package/apps/server/dist/core/ports/ISourceProcessor.js +2 -0
  49. package/apps/server/dist/core/ports/ISourceProcessor.js.map +1 -0
  50. package/apps/server/dist/core/ports/ISourceRepository.js +2 -0
  51. package/apps/server/dist/core/ports/ISourceRepository.js.map +1 -0
  52. package/apps/server/dist/core/usecases/BuildUseCase.js +76 -0
  53. package/apps/server/dist/core/usecases/BuildUseCase.js.map +1 -0
  54. package/apps/server/dist/core/usecases/ConfigUseCase.js +62 -0
  55. package/apps/server/dist/core/usecases/ConfigUseCase.js.map +1 -0
  56. package/apps/server/dist/core/usecases/SearchUseCase.js +17 -0
  57. package/apps/server/dist/core/usecases/SearchUseCase.js.map +1 -0
  58. package/apps/server/dist/index.js +86 -0
  59. package/apps/server/dist/index.js.map +1 -0
  60. package/apps/server/dist/infrastructure/filesystem/FileSystemDocumentStore.js +25 -0
  61. package/apps/server/dist/infrastructure/filesystem/FileSystemDocumentStore.js.map +1 -0
  62. package/apps/server/dist/infrastructure/graph/GraphSearchDecorator.js +42 -0
  63. package/apps/server/dist/infrastructure/graph/GraphSearchDecorator.js.map +1 -0
  64. package/apps/server/dist/infrastructure/graph/GraphifyKnowledgeGraph.js +145 -0
  65. package/apps/server/dist/infrastructure/graph/GraphifyKnowledgeGraph.js.map +1 -0
  66. package/apps/server/dist/infrastructure/graph/index.js +3 -0
  67. package/apps/server/dist/infrastructure/graph/index.js.map +1 -0
  68. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteBuildRepository.js +21 -0
  69. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteBuildRepository.js.map +1 -0
  70. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteEntryReadModel.js +11 -0
  71. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteEntryReadModel.js.map +1 -0
  72. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteEntryRepository.js +59 -0
  73. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteEntryRepository.js.map +1 -0
  74. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteSourceRepository.js +47 -0
  75. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteSourceRepository.js.map +1 -0
  76. package/apps/server/dist/infrastructure/persistence/sqlite/connection.js +50 -0
  77. package/apps/server/dist/infrastructure/persistence/sqlite/connection.js.map +1 -0
  78. package/apps/server/dist/infrastructure/search/SearchEngineFactory.js +32 -0
  79. package/apps/server/dist/infrastructure/search/SearchEngineFactory.js.map +1 -0
  80. package/apps/server/dist/infrastructure/search/json/JsonSearchEngine.js +147 -0
  81. package/apps/server/dist/infrastructure/search/json/JsonSearchEngine.js.map +1 -0
  82. package/apps/server/dist/infrastructure/search/vector/EmbeddingService.js +23 -0
  83. package/apps/server/dist/infrastructure/search/vector/EmbeddingService.js.map +1 -0
  84. package/apps/server/dist/infrastructure/search/vector/VectorSearchEngine.js +378 -0
  85. package/apps/server/dist/infrastructure/search/vector/VectorSearchEngine.js.map +1 -0
  86. package/apps/server/dist/infrastructure/source-processors/AntoraSourceProcessor.js +11 -0
  87. package/apps/server/dist/infrastructure/source-processors/AntoraSourceProcessor.js.map +1 -0
  88. package/apps/server/dist/infrastructure/source-processors/AsciidocSourceProcessor.js +9 -0
  89. package/apps/server/dist/infrastructure/source-processors/AsciidocSourceProcessor.js.map +1 -0
  90. package/apps/server/dist/infrastructure/source-processors/DocumentNormalizer.js +11 -0
  91. package/apps/server/dist/infrastructure/source-processors/DocumentNormalizer.js.map +1 -0
  92. package/apps/server/dist/infrastructure/source-processors/GithubMarkdownSourceProcessor.js +9 -0
  93. package/apps/server/dist/infrastructure/source-processors/GithubMarkdownSourceProcessor.js.map +1 -0
  94. package/apps/server/dist/infrastructure/source-processors/MavenSourceProcessor.js +9 -0
  95. package/apps/server/dist/infrastructure/source-processors/MavenSourceProcessor.js.map +1 -0
  96. package/apps/server/dist/infrastructure/source-processors/PathResolver.js +5 -0
  97. package/apps/server/dist/infrastructure/source-processors/PathResolver.js.map +1 -0
  98. package/apps/server/dist/infrastructure/source-processors/SourceCodeSourceProcessor.js +269 -0
  99. package/apps/server/dist/infrastructure/source-processors/SourceCodeSourceProcessor.js.map +1 -0
  100. package/apps/server/dist/infrastructure/source-processors/ZipSourceProcessor.js +9 -0
  101. package/apps/server/dist/infrastructure/source-processors/ZipSourceProcessor.js.map +1 -0
  102. package/apps/server/dist/mcp-http.js +93 -0
  103. package/apps/server/dist/mcp-http.js.map +1 -0
  104. package/apps/server/dist/mcp.js +339 -0
  105. package/apps/server/dist/mcp.js.map +1 -0
  106. package/apps/server/dist/routes/build.js +89 -0
  107. package/apps/server/dist/routes/build.js.map +1 -0
  108. package/apps/server/dist/routes/entries.js +52 -0
  109. package/apps/server/dist/routes/entries.js.map +1 -0
  110. package/apps/server/dist/routes/graph.js +58 -0
  111. package/apps/server/dist/routes/graph.js.map +1 -0
  112. package/apps/server/dist/routes/search.js +24 -0
  113. package/apps/server/dist/routes/search.js.map +1 -0
  114. package/apps/server/dist/routes/sources.js +100 -0
  115. package/apps/server/dist/routes/sources.js.map +1 -0
  116. package/apps/server/dist/routes/viewer.js +22 -0
  117. package/apps/server/dist/routes/viewer.js.map +1 -0
  118. package/apps/server/dist/services/antora.js +222 -0
  119. package/apps/server/dist/services/antora.js.map +1 -0
  120. package/apps/server/dist/services/asciidoc.js +206 -0
  121. package/apps/server/dist/services/asciidoc.js.map +1 -0
  122. package/apps/server/dist/services/configLoader.js +150 -0
  123. package/apps/server/dist/services/configLoader.js.map +1 -0
  124. package/apps/server/dist/services/githubMarkdown.js +221 -0
  125. package/apps/server/dist/services/githubMarkdown.js.map +1 -0
  126. package/apps/server/dist/services/maven.js +148 -0
  127. package/apps/server/dist/services/maven.js.map +1 -0
  128. package/apps/server/dist/services/normalizer.js +42 -0
  129. package/apps/server/dist/services/normalizer.js.map +1 -0
  130. package/apps/server/dist/services/paths.js +5 -0
  131. package/apps/server/dist/services/paths.js.map +1 -0
  132. package/apps/server/dist/services/textExtractor.js +46 -0
  133. package/apps/server/dist/services/textExtractor.js.map +1 -0
  134. package/apps/server/dist/services/zip.js +63 -0
  135. package/apps/server/dist/services/zip.js.map +1 -0
  136. package/apps/server/package.json +38 -0
  137. package/apps/server/src/infrastructure/source-processors/SourceCodeSourceProcessor.ts +9 -2
  138. package/bin/commands/dev.ts +2 -2
  139. package/bin/commands/serve.ts +2 -2
  140. package/package.json +22 -4
@@ -0,0 +1,150 @@
1
+ import fs from 'node:fs';
2
+ import { load as loadYaml } from 'js-yaml';
3
+ export function loadConfig(configPath) {
4
+ if (!fs.existsSync(configPath)) {
5
+ throw new Error(`Config file not found: ${configPath}. Create a dockit.yaml file with your entries and sources.`);
6
+ }
7
+ const content = fs.readFileSync(configPath, 'utf-8');
8
+ const config = loadYaml(content);
9
+ if (!config.entries || !Array.isArray(config.entries) || config.entries.length === 0) {
10
+ throw new Error('Config file must contain at least one entry under "entries:"');
11
+ }
12
+ for (const entry of config.entries) {
13
+ if (!entry.id || !entry.name || !entry.version) {
14
+ throw new Error(`Entry missing required fields (id/name/version): ${JSON.stringify(entry)}`);
15
+ }
16
+ if (!entry.sources || entry.sources.length === 0) {
17
+ throw new Error(`Entry "${entry.id}" has no sources`);
18
+ }
19
+ for (const source of entry.sources) {
20
+ if (!source.type || !source.label) {
21
+ throw new Error(`Source in entry "${entry.id}" missing type or label`);
22
+ }
23
+ validateSourceConfig(source);
24
+ }
25
+ }
26
+ return config;
27
+ }
28
+ function validateSourceConfig(source) {
29
+ switch (source.type) {
30
+ case 'zip':
31
+ if (!source.url && !source.localPath) {
32
+ throw new Error(`ZIP source "${source.label}" requires "url" or "localPath"`);
33
+ }
34
+ break;
35
+ case 'maven':
36
+ if (!source.groupId || !source.artifactId || !source.version) {
37
+ throw new Error(`Maven source "${source.label}" requires groupId, artifactId, and version`);
38
+ }
39
+ break;
40
+ case 'antora':
41
+ if (!source.repoUrl && !source.zipPath && !source.localPath) {
42
+ throw new Error(`Antora source "${source.label}" requires repoUrl, localPath, or zipPath`);
43
+ }
44
+ break;
45
+ case 'asciidoc':
46
+ if (!source.repoUrl && !source.zipPath && !source.localPath) {
47
+ throw new Error(`AsciiDoc source "${source.label}" requires repoUrl, localPath, or zipPath`);
48
+ }
49
+ break;
50
+ case 'github-markdown':
51
+ if (!source.repoUrl && !source.localPath) {
52
+ throw new Error(`GitHub Markdown source "${source.label}" requires repoUrl or localPath`);
53
+ }
54
+ break;
55
+ case 'source-code':
56
+ if (!source.repoUrl && !source.localPath && !source.zipPath) {
57
+ throw new Error(`Source code source "${source.label}" requires repoUrl, localPath, or zipPath`);
58
+ }
59
+ break;
60
+ default:
61
+ throw new Error(`Unknown source type: "${source.type}" in source "${source.label}"`);
62
+ }
63
+ }
64
+ export async function syncConfigToDb(config, entryRepo, sourceRepo) {
65
+ const entryIds = [];
66
+ for (const entryConfig of config.entries) {
67
+ // Preserve existing status if entry already exists
68
+ const existing = await entryRepo.findById(entryConfig.id);
69
+ const now = new Date().toISOString();
70
+ const created_at = existing?.created_at ?? now;
71
+ await entryRepo.save({
72
+ id: entryConfig.id,
73
+ name: entryConfig.name,
74
+ version: entryConfig.version,
75
+ description: entryConfig.description || '',
76
+ status: existing?.status ?? 'pending',
77
+ created_at,
78
+ updated_at: now,
79
+ });
80
+ entryIds.push(entryConfig.id);
81
+ for (const sourceConfig of entryConfig.sources) {
82
+ const config = buildSourceConfig(sourceConfig);
83
+ const sourceId = `${entryConfig.id}-src-${sourceConfig.label.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '')}`;
84
+ // Preserve existing source status if it already exists
85
+ const existingSource = await sourceRepo.findById(sourceId);
86
+ await sourceRepo.save({
87
+ id: sourceId,
88
+ entry_id: entryConfig.id,
89
+ type: sourceConfig.type,
90
+ label: sourceConfig.label,
91
+ config,
92
+ status: existingSource?.status ?? 'pending',
93
+ created_at: existingSource?.created_at ?? now,
94
+ });
95
+ }
96
+ }
97
+ return entryIds;
98
+ }
99
+ function buildSourceConfig(source) {
100
+ switch (source.type) {
101
+ case 'zip':
102
+ return { url: source.url, localPath: source.localPath };
103
+ case 'maven':
104
+ return {
105
+ groupId: source.groupId,
106
+ artifactId: source.artifactId,
107
+ version: source.version,
108
+ classifier: source.classifier || 'javadoc',
109
+ useMavenCommand: source.useMavenCommand,
110
+ localJar: source.localJar,
111
+ };
112
+ case 'antora':
113
+ return {
114
+ repoUrl: source.repoUrl,
115
+ zipPath: source.zipPath,
116
+ localPath: source.localPath,
117
+ playbookOverrides: source.playbookOverrides,
118
+ graphifyEnabled: source.graphifyEnabled,
119
+ graphifySourcePath: source.graphifySourcePath,
120
+ };
121
+ case 'asciidoc':
122
+ return {
123
+ repoUrl: source.repoUrl,
124
+ zipPath: source.zipPath,
125
+ localPath: source.localPath,
126
+ sourcePath: source.sourcePath,
127
+ graphifyEnabled: source.graphifyEnabled,
128
+ graphifySourcePath: source.graphifySourcePath,
129
+ };
130
+ case 'github-markdown':
131
+ return {
132
+ repoUrl: source.repoUrl,
133
+ localPath: source.localPath,
134
+ sourcePath: source.sourcePath,
135
+ branch: source.branch,
136
+ graphifyEnabled: source.graphifyEnabled,
137
+ graphifySourcePath: source.graphifySourcePath,
138
+ };
139
+ case 'source-code':
140
+ return {
141
+ repoUrl: source.repoUrl,
142
+ localPath: source.localPath,
143
+ zipPath: source.zipPath,
144
+ sourcePath: source.sourcePath,
145
+ branch: source.branch,
146
+ graphifySourcePath: source.graphifySourcePath,
147
+ };
148
+ }
149
+ }
150
+ //# sourceMappingURL=configLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configLoader.js","sourceRoot":"","sources":["../../src/services/configLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,SAAS,CAAC;AA6C3C,MAAM,UAAU,UAAU,CAAC,UAAkB;IAC3C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,0BAA0B,UAAU,4DAA4D,CAAC,CAAC;IACpH,CAAC;IAED,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAiB,CAAC;IAEjD,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrF,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAClF,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,oDAAoD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC/F,CAAC;QACD,IAAI,CAAC,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BAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;aAC9C,CAAC;IACN,CAAC;AACH,CAAC"}
@@ -0,0 +1,221 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs';
3
+ import os from 'node:os';
4
+ import { spawn } from 'node:child_process';
5
+ import { marked } from 'marked';
6
+ const SKIP_DIRS = new Set([
7
+ 'node_modules', 'target', 'build', 'dist', '.git',
8
+ 'test', 'tests', 'tcks', '__tests__', 'fixtures',
9
+ ]);
10
+ async function cloneRepo(repoUrl, targetDir, branch, log) {
11
+ const branchArg = branch ? ['--branch', branch] : [];
12
+ log(`Cloning repository ${repoUrl}${branch ? ` (branch: ${branch})` : ''}`);
13
+ if (fs.existsSync(targetDir))
14
+ fs.rmSync(targetDir, { recursive: true, force: true });
15
+ return new Promise((resolve, reject) => {
16
+ const proc = spawn('git', ['clone', '--depth', '1', ...branchArg, repoUrl, targetDir], {
17
+ stdio: ['ignore', 'pipe', 'pipe'],
18
+ });
19
+ let stderr = '';
20
+ proc.stderr?.on('data', (data) => {
21
+ stderr += data.toString();
22
+ const lines = data.toString().trim().split('\n');
23
+ for (const line of lines) {
24
+ if (line)
25
+ log(` git: ${line}`);
26
+ }
27
+ });
28
+ proc.on('close', (code) => {
29
+ if (code === 0) {
30
+ log('Repository cloned successfully');
31
+ resolve();
32
+ }
33
+ else {
34
+ reject(new Error(`git clone failed with code ${code}: ${stderr}`));
35
+ }
36
+ });
37
+ proc.on('error', reject);
38
+ });
39
+ }
40
+ function findMarkdownFiles(dir, sourcePath) {
41
+ const root = sourcePath ? path.join(dir, sourcePath) : dir;
42
+ if (!fs.existsSync(root)) {
43
+ return [];
44
+ }
45
+ const results = [];
46
+ const stack = [root];
47
+ while (stack.length > 0) {
48
+ const current = stack.pop();
49
+ let entries;
50
+ try {
51
+ entries = fs.readdirSync(current, { withFileTypes: true });
52
+ }
53
+ catch {
54
+ continue;
55
+ }
56
+ for (const entry of entries) {
57
+ if (entry.name.startsWith('.') || SKIP_DIRS.has(entry.name))
58
+ continue;
59
+ const fullPath = path.join(current, entry.name);
60
+ if (entry.isDirectory()) {
61
+ stack.push(fullPath);
62
+ }
63
+ else if (entry.name.endsWith('.md')) {
64
+ results.push(fullPath);
65
+ }
66
+ }
67
+ }
68
+ return results;
69
+ }
70
+ function stripFrontmatter(content) {
71
+ if (content.startsWith('---')) {
72
+ const end = content.indexOf('---', 3);
73
+ if (end !== -1) {
74
+ return content.slice(end + 3).trimStart();
75
+ }
76
+ }
77
+ return content;
78
+ }
79
+ function buildHtmlTemplate(title, bodyHtml, relPath) {
80
+ return `<!DOCTYPE html>
81
+ <html lang="en">
82
+ <head>
83
+ <meta charset="UTF-8">
84
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
85
+ <title>${escapeHtml(title)}</title>
86
+ <style>
87
+ body{font-family:system-ui,-apple-system,sans-serif;line-height:1.6;max-width:900px;margin:40px auto;padding:0 20px;color:#333}
88
+ pre{background:#f5f5f5;padding:12px;border-radius:6px;overflow-x:auto}
89
+ code{font-family:monospace;background:#f5f5f5;padding:2px 6px;border-radius:3px;font-size:.9em}
90
+ pre code{padding:0;background:none}
91
+ table{border-collapse:collapse;width:100%}
92
+ th,td{border:1px solid #ddd;padding:8px;text-align:left}
93
+ th{background:#f5f5f5}
94
+ img{max-width:100%}
95
+ blockquote{border-left:4px solid #ddd;margin:0;padding-left:16px;color:#666}
96
+ h1,h2,h3,h4,h5,h6{margin-top:1.5em;margin-bottom:.5em}
97
+ a{color:#0366d6}
98
+ </style>
99
+ </head>
100
+ <body>
101
+ <main>
102
+ ${bodyHtml}
103
+ </main>
104
+ </body>
105
+ </html>`;
106
+ }
107
+ function escapeHtml(text) {
108
+ return text
109
+ .replace(/&/g, '&amp;')
110
+ .replace(/</g, '&lt;')
111
+ .replace(/>/g, '&gt;')
112
+ .replace(/"/g, '&quot;');
113
+ }
114
+ async function convertMarkdownFiles(mdFiles, sourceRoot, targetDir, log) {
115
+ log(`Converting ${mdFiles.length} .md files to HTML`);
116
+ let filesProcessed = 0;
117
+ let filesSkipped = 0;
118
+ for (const mdFile of mdFiles) {
119
+ try {
120
+ const relPath = path.relative(sourceRoot, mdFile);
121
+ const outPath = path.join(targetDir, relPath.replace(/\.md$/i, '.html'));
122
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
123
+ const raw = fs.readFileSync(mdFile, 'utf-8');
124
+ const withoutFrontmatter = stripFrontmatter(raw);
125
+ const bodyHtml = await marked(withoutFrontmatter);
126
+ const title = path.basename(mdFile, '.md');
127
+ const fullHtml = buildHtmlTemplate(title, bodyHtml, relPath);
128
+ fs.writeFileSync(outPath, fullHtml, 'utf-8');
129
+ filesProcessed++;
130
+ }
131
+ catch (err) {
132
+ const rel = path.relative(sourceRoot, mdFile);
133
+ log(` WARNING: Failed to convert ${rel}: ${err.message || err}`);
134
+ filesSkipped++;
135
+ }
136
+ }
137
+ const htmlCount = countHtmlFiles(targetDir);
138
+ log(`Markdown conversion complete: ${filesProcessed} converted, ${filesSkipped} skipped, ${htmlCount} HTML files generated`);
139
+ if (htmlCount === 0 && filesProcessed === 0) {
140
+ throw new Error('Markdown conversion failed to produce any HTML. Check that the source files are valid.');
141
+ }
142
+ }
143
+ function countHtmlFiles(dir) {
144
+ if (!fs.existsSync(dir))
145
+ return 0;
146
+ let count = 0;
147
+ const stack = [dir];
148
+ while (stack.length > 0) {
149
+ const current = stack.pop();
150
+ let entries;
151
+ try {
152
+ entries = fs.readdirSync(current, { withFileTypes: true });
153
+ }
154
+ catch {
155
+ continue;
156
+ }
157
+ for (const e of entries) {
158
+ const p = path.join(current, e.name);
159
+ if (e.isDirectory() && !e.name.startsWith('.'))
160
+ stack.push(p);
161
+ else if (e.name.endsWith('.html'))
162
+ count++;
163
+ }
164
+ }
165
+ return count;
166
+ }
167
+ function rmDir(dir) {
168
+ try {
169
+ fs.rmSync(dir, { recursive: true, force: true });
170
+ }
171
+ catch {
172
+ // best-effort cleanup
173
+ }
174
+ }
175
+ export async function buildGithubMarkdownSource(config, targetDir, log) {
176
+ let repoDir;
177
+ let shouldCleanup;
178
+ if (config.localPath) {
179
+ if (!fs.existsSync(config.localPath)) {
180
+ throw new Error(`Local path not found: ${config.localPath}`);
181
+ }
182
+ if (!fs.statSync(config.localPath).isDirectory()) {
183
+ throw new Error(`localPath must be a directory: ${config.localPath}`);
184
+ }
185
+ log(`Using local directory: ${config.localPath}`);
186
+ repoDir = config.localPath;
187
+ shouldCleanup = false;
188
+ }
189
+ else if (config.repoUrl) {
190
+ repoDir = path.join(os.tmpdir(), `dockit-github-md-${Date.now()}`);
191
+ await cloneRepo(config.repoUrl, repoDir, config.branch, log);
192
+ shouldCleanup = true;
193
+ }
194
+ else {
195
+ throw new Error('GitHub Markdown source requires repoUrl or localPath');
196
+ }
197
+ try {
198
+ const sourcePath = config.sourcePath || '';
199
+ const sourceRoot = sourcePath ? path.join(repoDir, sourcePath) : repoDir;
200
+ log(`Scanning for .md files in ${sourcePath || 'repository root'}`);
201
+ const mdFiles = findMarkdownFiles(repoDir, sourcePath);
202
+ if (mdFiles.length === 0) {
203
+ if (sourcePath) {
204
+ throw new Error(`No .md files found at path "${sourcePath}" in the repository`);
205
+ }
206
+ throw new Error(`No .md files found in the repository. ` +
207
+ `If the docs live in a subdirectory, set the "sourcePath" field ` +
208
+ `(e.g. "src/content" for React docs).`);
209
+ }
210
+ log(`Found ${mdFiles.length} .md file(s)`);
211
+ fs.mkdirSync(targetDir, { recursive: true });
212
+ await convertMarkdownFiles(mdFiles, sourceRoot, targetDir, log);
213
+ }
214
+ finally {
215
+ if (shouldCleanup && fs.existsSync(repoDir)) {
216
+ log('Cleaning up cloned repository...');
217
+ rmDir(repoDir);
218
+ }
219
+ }
220
+ }
221
+ //# sourceMappingURL=githubMarkdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3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,GAAG,CAAC,CAAC;IAClE,CAAC;YAAS,CAAC;QACT,IAAI,aAAa,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5C,GAAG,CAAC,kCAAkC,CAAC,CAAC;YACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,148 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs';
3
+ import { Readable } from 'node:stream';
4
+ import { pipeline } from 'node:stream/promises';
5
+ import { spawn } from 'node:child_process';
6
+ import unzipper from 'unzipper';
7
+ function buildMavenUrl(config) {
8
+ const groupPath = config.groupId.replace(/\./g, '/');
9
+ const classifier = config.classifier || 'javadoc';
10
+ return `https://repo1.maven.org/maven2/${groupPath}/${config.artifactId}/${config.version}/${config.artifactId}-${config.version}-${classifier}.jar`;
11
+ }
12
+ export async function downloadWithMavenCommand(config, targetDir, log) {
13
+ const classifier = config.classifier || 'javadoc';
14
+ const artifact = `${config.groupId}:${config.artifactId}:${config.version}:jar:${classifier}`;
15
+ log(`Resolved Maven artifact: ${config.groupId}:${config.artifactId}:${config.version}`);
16
+ log(`Downloading via mvn dependency:copy (using ~/.m2/settings.xml)`);
17
+ fs.mkdirSync(targetDir, { recursive: true });
18
+ const escapedArtifact = artifact.replace(/"/g, '\\"');
19
+ return new Promise((resolve, reject) => {
20
+ const proc = spawn('mvn', [
21
+ 'org.apache.maven.plugins:maven-dependency-plugin:3.10.0:copy',
22
+ `-Dartifact=${escapedArtifact}`,
23
+ `-DoutputDirectory=${targetDir}`,
24
+ '-Dtransitive=false',
25
+ ], {
26
+ stdio: ['ignore', 'pipe', 'pipe'],
27
+ });
28
+ let stderr = '';
29
+ proc.stdout?.on('data', (data) => {
30
+ const lines = data.toString().trim().split('\n');
31
+ for (const line of lines) {
32
+ if (line)
33
+ log(` mvn: ${line}`);
34
+ }
35
+ });
36
+ proc.stderr?.on('data', (data) => {
37
+ stderr += data.toString();
38
+ const lines = data.toString().trim().split('\n');
39
+ for (const line of lines) {
40
+ if (line)
41
+ log(` mvn: ${line}`);
42
+ }
43
+ });
44
+ proc.on('close', (code) => {
45
+ if (code === 0) {
46
+ log(`Maven download complete`);
47
+ const downloaded = findJarFiles(targetDir);
48
+ if (downloaded.length > 0) {
49
+ log(`Downloaded: ${downloaded.map((p) => path.basename(p)).join(', ')}`);
50
+ resolve();
51
+ return;
52
+ }
53
+ reject(new Error('Maven download succeeded but no JAR files found in target directory'));
54
+ }
55
+ else {
56
+ const tail = stderr.slice(-500);
57
+ if (stderr.includes('BUILD FAILURE') || tail.includes('Could not resolve dependencies')) {
58
+ reject(new Error(`Maven download failed — artifact may not exist or your settings.xml proxy is misconfigured.\n` +
59
+ `Artifact: ${artifact}\n` +
60
+ `Last output: ${tail}`));
61
+ }
62
+ else {
63
+ reject(new Error(`Maven download failed with code ${code}. Install Maven or use direct download/locallJar mode. Last output: ${tail}`));
64
+ }
65
+ }
66
+ });
67
+ proc.on('error', (err) => {
68
+ if (err.code === 'ENOENT') {
69
+ reject(new Error('mvn command not found. Install Maven (apt install maven) or use direct download/locallJar mode.'));
70
+ }
71
+ else {
72
+ reject(err);
73
+ }
74
+ });
75
+ });
76
+ }
77
+ export async function extractLocalJar(localJarPath, targetDir, log) {
78
+ if (!fs.existsSync(localJarPath)) {
79
+ throw new Error(`Local JAR not found: ${localJarPath}`);
80
+ }
81
+ const stat = fs.statSync(localJarPath);
82
+ if (!stat.isFile()) {
83
+ throw new Error(`localJar must be a .jar file, got directory: ${localJarPath}`);
84
+ }
85
+ if (!localJarPath.endsWith('.jar')) {
86
+ throw new Error(`localJar must be a .jar file: ${localJarPath}`);
87
+ }
88
+ log(`Extracting local JAR from ${localJarPath}`);
89
+ fs.mkdirSync(targetDir, { recursive: true });
90
+ const data = fs.readFileSync(localJarPath);
91
+ const stream = Readable.from(data);
92
+ await pipeline(stream, unzipper.Extract({ path: targetDir }));
93
+ log(`Extracted JAR to ${targetDir}`);
94
+ const files = countFilesRecursive(targetDir);
95
+ log(`Found ${files} files in extracted artifact`);
96
+ }
97
+ export async function downloadAndExtractMavenJar(config, targetDir, log) {
98
+ if (config.localJar) {
99
+ await extractLocalJar(config.localJar, targetDir, log);
100
+ return;
101
+ }
102
+ if (config.useMavenCommand) {
103
+ await downloadWithMavenCommand(config, targetDir, log);
104
+ return;
105
+ }
106
+ const url = buildMavenUrl(config);
107
+ log(`Resolved Maven artifact: ${config.groupId}:${config.artifactId}:${config.version}`);
108
+ log(`Downloading JAR from ${url}`);
109
+ const response = await fetch(url);
110
+ if (!response.ok) {
111
+ throw new Error(`Failed to download Maven JAR: ${response.status} ${response.statusText} — ${url}`);
112
+ }
113
+ fs.mkdirSync(targetDir, { recursive: true });
114
+ if (!response.body) {
115
+ throw new Error('No response body');
116
+ }
117
+ const nodeStream = Readable.fromWeb(response.body);
118
+ await pipeline(nodeStream, unzipper.Extract({ path: targetDir }));
119
+ log(`Extracted Maven JAR to ${targetDir}`);
120
+ const files = countFilesRecursive(targetDir);
121
+ log(`Found ${files} files in extracted artifact`);
122
+ }
123
+ function findJarFiles(dir) {
124
+ const results = [];
125
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
126
+ for (const entry of entries) {
127
+ const fullPath = path.join(dir, entry.name);
128
+ if (entry.isFile() && entry.name.endsWith('.jar')) {
129
+ results.push(fullPath);
130
+ }
131
+ }
132
+ return results;
133
+ }
134
+ function countFilesRecursive(dir) {
135
+ let count = 0;
136
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
137
+ for (const entry of entries) {
138
+ const fullPath = path.join(dir, entry.name);
139
+ if (entry.isDirectory()) {
140
+ count += countFilesRecursive(fullPath);
141
+ }
142
+ else {
143
+ count++;
144
+ }
145
+ }
146
+ return count;
147
+ }
148
+ //# sourceMappingURL=maven.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maven.js","sourceRoot":"","sources":["../../src/services/maven.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MA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aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAW;IACtC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,KAAK,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,KAAK,EAAE,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,42 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs';
3
+ export function normalizeDocs(sources, outputDir, log) {
4
+ fs.mkdirSync(outputDir, { recursive: true });
5
+ const htmlFiles = [];
6
+ for (const source of sources) {
7
+ log(`Normalizing source "${source.label}" from ${source.dir}`);
8
+ const sourceDir = path.join(outputDir, sanitizeDirname(source.label));
9
+ copyDirContents(source.dir, sourceDir, outputDir, htmlFiles, log);
10
+ }
11
+ log(`Normalized ${htmlFiles.length} HTML files into ${outputDir}`);
12
+ return htmlFiles.map((f) => f.relativePath);
13
+ }
14
+ function sanitizeDirname(name) {
15
+ return name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
16
+ }
17
+ function copyDirContents(srcDir, destDir, bundleRoot, htmlFiles, log) {
18
+ if (!fs.existsSync(srcDir)) {
19
+ log(` Warning: source directory does not exist: ${srcDir}`);
20
+ return;
21
+ }
22
+ const entries = fs.readdirSync(srcDir, { withFileTypes: true });
23
+ for (const entry of entries) {
24
+ const srcPath = path.join(srcDir, entry.name);
25
+ const destPath = path.join(destDir, entry.name);
26
+ if (entry.isDirectory()) {
27
+ fs.mkdirSync(destPath, { recursive: true });
28
+ copyDirContents(srcPath, destPath, bundleRoot, htmlFiles, log);
29
+ }
30
+ else if (entry.isFile() && entry.name.endsWith('.html')) {
31
+ fs.mkdirSync(path.dirname(destPath), { recursive: true });
32
+ fs.copyFileSync(srcPath, destPath);
33
+ const relativePath = path.relative(bundleRoot, destPath);
34
+ htmlFiles.push({ relativePath, fullPath: destPath });
35
+ }
36
+ else if (entry.isFile()) {
37
+ fs.mkdirSync(path.dirname(destPath), { recursive: true });
38
+ fs.copyFileSync(srcPath, destPath);
39
+ }
40
+ }
41
+ }
42
+ //# sourceMappingURL=normalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizer.js","sourceRoot":"","sources":["../../src/services/normalizer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAOzB,MAAM,UAAU,aAAa,CAC3B,OAA0B,EAC1B,SAAiB,EACjB,GAA0B;IAE1B,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE7C,MAAM,SAAS,GAAsD,EAAE,CAAC;IAExE,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,GAAG,CAAC,uBAAuB,MAAM,CAA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AAE,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC5C,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;QACjE,CAAC;aAAM,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1D,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1D,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACnC,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YACzD,SAAS,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QACvD,CAAC;aAAM,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1B,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1D,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import path from 'node:path';
2
+ import os from 'node:os';
3
+ const home = os.homedir() || process.cwd();
4
+ export const DATA_ROOT = process.env.DOCKIT_DATA_DIR || path.join(home, '.dockit');
5
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/services/paths.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;AAC3C,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC"}