@arnavpisces/sutra 1.0.0
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 +203 -0
- package/NOTICE +6 -0
- package/README.md +181 -0
- package/dist/api/client.d.ts +24 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +168 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/confluence-client.d.ts +133 -0
- package/dist/api/confluence-client.d.ts.map +1 -0
- package/dist/api/confluence-client.js +224 -0
- package/dist/api/confluence-client.js.map +1 -0
- package/dist/api/jira-client.d.ts +94 -0
- package/dist/api/jira-client.d.ts.map +1 -0
- package/dist/api/jira-client.js +151 -0
- package/dist/api/jira-client.js.map +1 -0
- package/dist/app.d.ts +2 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +135 -0
- package/dist/app.js.map +1 -0
- package/dist/components/common/Badge.d.ts +7 -0
- package/dist/components/common/Badge.d.ts.map +1 -0
- package/dist/components/common/Badge.js +15 -0
- package/dist/components/common/Badge.js.map +1 -0
- package/dist/components/common/Breadcrumbs.d.ts +5 -0
- package/dist/components/common/Breadcrumbs.d.ts.map +1 -0
- package/dist/components/common/Breadcrumbs.js +9 -0
- package/dist/components/common/Breadcrumbs.js.map +1 -0
- package/dist/components/common/Divider.d.ts +7 -0
- package/dist/components/common/Divider.d.ts.map +1 -0
- package/dist/components/common/Divider.js +13 -0
- package/dist/components/common/Divider.js.map +1 -0
- package/dist/components/common/EditableTextBox.d.ts +30 -0
- package/dist/components/common/EditableTextBox.d.ts.map +1 -0
- package/dist/components/common/EditableTextBox.js +512 -0
- package/dist/components/common/EditableTextBox.js.map +1 -0
- package/dist/components/common/Footer.d.ts +9 -0
- package/dist/components/common/Footer.d.ts.map +1 -0
- package/dist/components/common/Footer.js +7 -0
- package/dist/components/common/Footer.js.map +1 -0
- package/dist/components/common/FuzzySelect.d.ts +17 -0
- package/dist/components/common/FuzzySelect.d.ts.map +1 -0
- package/dist/components/common/FuzzySelect.js +72 -0
- package/dist/components/common/FuzzySelect.js.map +1 -0
- package/dist/components/common/Header.d.ts +7 -0
- package/dist/components/common/Header.d.ts.map +1 -0
- package/dist/components/common/Header.js +18 -0
- package/dist/components/common/Header.js.map +1 -0
- package/dist/components/common/HelpModal.d.ts +13 -0
- package/dist/components/common/HelpModal.d.ts.map +1 -0
- package/dist/components/common/HelpModal.js +9 -0
- package/dist/components/common/HelpModal.js.map +1 -0
- package/dist/components/common/KeyHint.d.ts +15 -0
- package/dist/components/common/KeyHint.d.ts.map +1 -0
- package/dist/components/common/KeyHint.js +10 -0
- package/dist/components/common/KeyHint.js.map +1 -0
- package/dist/components/common/MenuList.d.ts +15 -0
- package/dist/components/common/MenuList.d.ts.map +1 -0
- package/dist/components/common/MenuList.js +31 -0
- package/dist/components/common/MenuList.js.map +1 -0
- package/dist/components/common/Panel.d.ts +12 -0
- package/dist/components/common/Panel.d.ts.map +1 -0
- package/dist/components/common/Panel.js +6 -0
- package/dist/components/common/Panel.js.map +1 -0
- package/dist/components/common/ProgressBar.d.ts +11 -0
- package/dist/components/common/ProgressBar.d.ts.map +1 -0
- package/dist/components/common/ProgressBar.js +11 -0
- package/dist/components/common/ProgressBar.js.map +1 -0
- package/dist/components/common/SavedList.d.ts +16 -0
- package/dist/components/common/SavedList.d.ts.map +1 -0
- package/dist/components/common/SavedList.js +37 -0
- package/dist/components/common/SavedList.js.map +1 -0
- package/dist/components/common/ScrollBox.d.ts +9 -0
- package/dist/components/common/ScrollBox.d.ts.map +1 -0
- package/dist/components/common/ScrollBox.js +105 -0
- package/dist/components/common/ScrollBox.js.map +1 -0
- package/dist/components/common/SearchBar.d.ts +10 -0
- package/dist/components/common/SearchBar.d.ts.map +1 -0
- package/dist/components/common/SearchBar.js +7 -0
- package/dist/components/common/SearchBar.js.map +1 -0
- package/dist/components/common/SelectableItem.d.ts +14 -0
- package/dist/components/common/SelectableItem.d.ts.map +1 -0
- package/dist/components/common/SelectableItem.js +14 -0
- package/dist/components/common/SelectableItem.js.map +1 -0
- package/dist/components/common/Spinner.d.ts +7 -0
- package/dist/components/common/Spinner.d.ts.map +1 -0
- package/dist/components/common/Spinner.js +23 -0
- package/dist/components/common/Spinner.js.map +1 -0
- package/dist/components/common/SplitPane.d.ts +8 -0
- package/dist/components/common/SplitPane.d.ts.map +1 -0
- package/dist/components/common/SplitPane.js +10 -0
- package/dist/components/common/SplitPane.js.map +1 -0
- package/dist/components/common/StatusBar.d.ts +9 -0
- package/dist/components/common/StatusBar.d.ts.map +1 -0
- package/dist/components/common/StatusBar.js +6 -0
- package/dist/components/common/StatusBar.js.map +1 -0
- package/dist/components/common/TabBar.d.ts +9 -0
- package/dist/components/common/TabBar.d.ts.map +1 -0
- package/dist/components/common/TabBar.js +12 -0
- package/dist/components/common/TabBar.js.map +1 -0
- package/dist/components/common/Table.d.ts +19 -0
- package/dist/components/common/Table.d.ts.map +1 -0
- package/dist/components/common/Table.js +24 -0
- package/dist/components/common/Table.js.map +1 -0
- package/dist/components/common/TextEditor.d.ts +10 -0
- package/dist/components/common/TextEditor.d.ts.map +1 -0
- package/dist/components/common/TextEditor.js +17 -0
- package/dist/components/common/TextEditor.js.map +1 -0
- package/dist/components/common/Toast.d.ts +8 -0
- package/dist/components/common/Toast.d.ts.map +1 -0
- package/dist/components/common/Toast.js +32 -0
- package/dist/components/common/Toast.js.map +1 -0
- package/dist/components/common/index.d.ts +38 -0
- package/dist/components/common/index.d.ts.map +1 -0
- package/dist/components/common/index.js +22 -0
- package/dist/components/common/index.js.map +1 -0
- package/dist/components/confluence/ConfluenceView.d.ts +6 -0
- package/dist/components/confluence/ConfluenceView.d.ts.map +1 -0
- package/dist/components/confluence/ConfluenceView.js +184 -0
- package/dist/components/confluence/ConfluenceView.js.map +1 -0
- package/dist/components/confluence/DocTree.d.ts +10 -0
- package/dist/components/confluence/DocTree.d.ts.map +1 -0
- package/dist/components/confluence/DocTree.js +125 -0
- package/dist/components/confluence/DocTree.js.map +1 -0
- package/dist/components/confluence/PageAttachments.d.ts +8 -0
- package/dist/components/confluence/PageAttachments.d.ts.map +1 -0
- package/dist/components/confluence/PageAttachments.js +108 -0
- package/dist/components/confluence/PageAttachments.js.map +1 -0
- package/dist/components/confluence/PageBrowser.d.ts +8 -0
- package/dist/components/confluence/PageBrowser.d.ts.map +1 -0
- package/dist/components/confluence/PageBrowser.js +93 -0
- package/dist/components/confluence/PageBrowser.js.map +1 -0
- package/dist/components/confluence/PageComments.d.ts +8 -0
- package/dist/components/confluence/PageComments.d.ts.map +1 -0
- package/dist/components/confluence/PageComments.js +75 -0
- package/dist/components/confluence/PageComments.js.map +1 -0
- package/dist/components/confluence/PageEditor.d.ts +13 -0
- package/dist/components/confluence/PageEditor.d.ts.map +1 -0
- package/dist/components/confluence/PageEditor.js +37 -0
- package/dist/components/confluence/PageEditor.js.map +1 -0
- package/dist/components/confluence/PageLabels.d.ts +8 -0
- package/dist/components/confluence/PageLabels.d.ts.map +1 -0
- package/dist/components/confluence/PageLabels.js +92 -0
- package/dist/components/confluence/PageLabels.js.map +1 -0
- package/dist/components/confluence/PageList.d.ts +8 -0
- package/dist/components/confluence/PageList.d.ts.map +1 -0
- package/dist/components/confluence/PageList.js +95 -0
- package/dist/components/confluence/PageList.js.map +1 -0
- package/dist/components/confluence/PageViewer.d.ts +14 -0
- package/dist/components/confluence/PageViewer.d.ts.map +1 -0
- package/dist/components/confluence/PageViewer.js +160 -0
- package/dist/components/confluence/PageViewer.js.map +1 -0
- package/dist/components/confluence/SpaceTree.d.ts +10 -0
- package/dist/components/confluence/SpaceTree.d.ts.map +1 -0
- package/dist/components/confluence/SpaceTree.js +220 -0
- package/dist/components/confluence/SpaceTree.js.map +1 -0
- package/dist/components/jira/CommentForm.d.ts +7 -0
- package/dist/components/jira/CommentForm.d.ts.map +1 -0
- package/dist/components/jira/CommentForm.js +24 -0
- package/dist/components/jira/CommentForm.js.map +1 -0
- package/dist/components/jira/CreateTicket.d.ts +9 -0
- package/dist/components/jira/CreateTicket.d.ts.map +1 -0
- package/dist/components/jira/CreateTicket.js +106 -0
- package/dist/components/jira/CreateTicket.js.map +1 -0
- package/dist/components/jira/IssueList.d.ts +9 -0
- package/dist/components/jira/IssueList.d.ts.map +1 -0
- package/dist/components/jira/IssueList.js +43 -0
- package/dist/components/jira/IssueList.js.map +1 -0
- package/dist/components/jira/JiraIssueRow.d.ts +7 -0
- package/dist/components/jira/JiraIssueRow.d.ts.map +1 -0
- package/dist/components/jira/JiraIssueRow.js +49 -0
- package/dist/components/jira/JiraIssueRow.js.map +1 -0
- package/dist/components/jira/JiraView.d.ts +7 -0
- package/dist/components/jira/JiraView.d.ts.map +1 -0
- package/dist/components/jira/JiraView.js +283 -0
- package/dist/components/jira/JiraView.js.map +1 -0
- package/dist/components/jira/JqlSearch.d.ts +8 -0
- package/dist/components/jira/JqlSearch.d.ts.map +1 -0
- package/dist/components/jira/JqlSearch.js +51 -0
- package/dist/components/jira/JqlSearch.js.map +1 -0
- package/dist/components/jira/QuickFilters.d.ts +8 -0
- package/dist/components/jira/QuickFilters.d.ts.map +1 -0
- package/dist/components/jira/QuickFilters.js +61 -0
- package/dist/components/jira/QuickFilters.js.map +1 -0
- package/dist/components/jira/StatusSelector.d.ts +9 -0
- package/dist/components/jira/StatusSelector.d.ts.map +1 -0
- package/dist/components/jira/StatusSelector.js +11 -0
- package/dist/components/jira/StatusSelector.js.map +1 -0
- package/dist/components/jira/TicketDetail.d.ts +23 -0
- package/dist/components/jira/TicketDetail.d.ts.map +1 -0
- package/dist/components/jira/TicketDetail.js +409 -0
- package/dist/components/jira/TicketDetail.js.map +1 -0
- package/dist/components/jira/TicketEditor.d.ts +9 -0
- package/dist/components/jira/TicketEditor.d.ts.map +1 -0
- package/dist/components/jira/TicketEditor.js +21 -0
- package/dist/components/jira/TicketEditor.js.map +1 -0
- package/dist/components/jira/TicketList.d.ts +8 -0
- package/dist/components/jira/TicketList.d.ts.map +1 -0
- package/dist/components/jira/TicketList.js +89 -0
- package/dist/components/jira/TicketList.js.map +1 -0
- package/dist/config/config-manager.d.ts +11 -0
- package/dist/config/config-manager.d.ts.map +1 -0
- package/dist/config/config-manager.js +65 -0
- package/dist/config/config-manager.js.map +1 -0
- package/dist/config/types.d.ts +81 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +16 -0
- package/dist/config/types.js.map +1 -0
- package/dist/formatters/adf-converter.d.ts +21 -0
- package/dist/formatters/adf-converter.d.ts.map +1 -0
- package/dist/formatters/adf-converter.js +73 -0
- package/dist/formatters/adf-converter.js.map +1 -0
- package/dist/formatters/confluence-converter.d.ts +25 -0
- package/dist/formatters/confluence-converter.d.ts.map +1 -0
- package/dist/formatters/confluence-converter.js +77 -0
- package/dist/formatters/confluence-converter.js.map +1 -0
- package/dist/formatters/glow-renderer.d.ts +39 -0
- package/dist/formatters/glow-renderer.d.ts.map +1 -0
- package/dist/formatters/glow-renderer.js +136 -0
- package/dist/formatters/glow-renderer.js.map +1 -0
- package/dist/formatters/markdown-ansi-renderer.d.ts +24 -0
- package/dist/formatters/markdown-ansi-renderer.d.ts.map +1 -0
- package/dist/formatters/markdown-ansi-renderer.js +240 -0
- package/dist/formatters/markdown-ansi-renderer.js.map +1 -0
- package/dist/formatters/mdcat-renderer.d.ts +29 -0
- package/dist/formatters/mdcat-renderer.d.ts.map +1 -0
- package/dist/formatters/mdcat-renderer.js +106 -0
- package/dist/formatters/mdcat-renderer.js.map +1 -0
- package/dist/hooks/useConfluencePage.d.ts +9 -0
- package/dist/hooks/useConfluencePage.d.ts.map +1 -0
- package/dist/hooks/useConfluencePage.js +53 -0
- package/dist/hooks/useConfluencePage.js.map +1 -0
- package/dist/hooks/useJiraIssue.d.ts +9 -0
- package/dist/hooks/useJiraIssue.d.ts.map +1 -0
- package/dist/hooks/useJiraIssue.js +52 -0
- package/dist/hooks/useJiraIssue.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +214 -0
- package/dist/index.js.map +1 -0
- package/dist/storage/bookmarks.d.ts +16 -0
- package/dist/storage/bookmarks.d.ts.map +1 -0
- package/dist/storage/bookmarks.js +49 -0
- package/dist/storage/bookmarks.js.map +1 -0
- package/dist/storage/cache.d.ts +12 -0
- package/dist/storage/cache.d.ts.map +1 -0
- package/dist/storage/cache.js +57 -0
- package/dist/storage/cache.js.map +1 -0
- package/dist/storage/db.d.ts +4 -0
- package/dist/storage/db.d.ts.map +1 -0
- package/dist/storage/db.js +63 -0
- package/dist/storage/db.js.map +1 -0
- package/dist/storage/recents.d.ts +13 -0
- package/dist/storage/recents.d.ts.map +1 -0
- package/dist/storage/recents.js +40 -0
- package/dist/storage/recents.js.map +1 -0
- package/dist/theme/te.d.ts +12 -0
- package/dist/theme/te.d.ts.map +1 -0
- package/dist/theme/te.js +13 -0
- package/dist/theme/te.js.map +1 -0
- package/dist/utils/cache.d.ts +15 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +34 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/errors.d.ts +16 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +32 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/external-editor.d.ts +32 -0
- package/dist/utils/external-editor.d.ts.map +1 -0
- package/dist/utils/external-editor.js +173 -0
- package/dist/utils/external-editor.js.map +1 -0
- package/dist/utils/jira-colors.d.ts +4 -0
- package/dist/utils/jira-colors.d.ts.map +1 -0
- package/dist/utils/jira-colors.js +47 -0
- package/dist/utils/jira-colors.js.map +1 -0
- package/dist/utils/links.d.ts +5 -0
- package/dist/utils/links.d.ts.map +1 -0
- package/dist/utils/links.js +43 -0
- package/dist/utils/links.js.map +1 -0
- package/dist/utils/markdown-highlighter.d.ts +49 -0
- package/dist/utils/markdown-highlighter.d.ts.map +1 -0
- package/dist/utils/markdown-highlighter.js +282 -0
- package/dist/utils/markdown-highlighter.js.map +1 -0
- package/dist/utils/paths.d.ts +3 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +15 -0
- package/dist/utils/paths.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import Conf from 'conf';
|
|
2
|
+
import { ConfigSchema } from './types.js';
|
|
3
|
+
const confSchema = {
|
|
4
|
+
jira: {
|
|
5
|
+
type: 'object',
|
|
6
|
+
properties: {
|
|
7
|
+
baseUrl: { type: 'string' },
|
|
8
|
+
email: { type: 'string' },
|
|
9
|
+
apiToken: { type: 'string' },
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
confluence: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
baseUrl: { type: 'string' },
|
|
16
|
+
email: { type: 'string' },
|
|
17
|
+
apiToken: { type: 'string' },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
const config = new Conf({
|
|
22
|
+
projectName: 'sutra',
|
|
23
|
+
schema: confSchema,
|
|
24
|
+
});
|
|
25
|
+
// Legacy config used before renaming from ticket-tui.
|
|
26
|
+
const legacyConfig = new Conf({
|
|
27
|
+
projectName: 'ticket-tui',
|
|
28
|
+
schema: confSchema,
|
|
29
|
+
});
|
|
30
|
+
export class ConfigManager {
|
|
31
|
+
static getConfig() {
|
|
32
|
+
const current = ConfigSchema.parse(config.store);
|
|
33
|
+
// One-time migration: carry forward existing user setup from legacy project name.
|
|
34
|
+
if (!current.jira && !current.confluence) {
|
|
35
|
+
const legacy = ConfigSchema.parse(legacyConfig.store);
|
|
36
|
+
if (legacy.jira || legacy.confluence) {
|
|
37
|
+
config.store = legacy;
|
|
38
|
+
return ConfigSchema.parse(config.store);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return current;
|
|
42
|
+
}
|
|
43
|
+
static setJiraConfig(jiraConfig) {
|
|
44
|
+
config.set('jira', jiraConfig);
|
|
45
|
+
}
|
|
46
|
+
static setConfluenceConfig(confluenceConfig) {
|
|
47
|
+
config.set('confluence', confluenceConfig);
|
|
48
|
+
}
|
|
49
|
+
static getJiraConfig() {
|
|
50
|
+
const cfg = this.getConfig();
|
|
51
|
+
return cfg.jira;
|
|
52
|
+
}
|
|
53
|
+
static getConfluenceConfig() {
|
|
54
|
+
const cfg = this.getConfig();
|
|
55
|
+
return cfg.confluence;
|
|
56
|
+
}
|
|
57
|
+
static isConfigured() {
|
|
58
|
+
const cfg = this.getConfig();
|
|
59
|
+
return !!(cfg.jira && cfg.confluence);
|
|
60
|
+
}
|
|
61
|
+
static clear() {
|
|
62
|
+
config.clear();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=config-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-manager.js","sourceRoot":"","sources":["../../src/config/config-manager.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAU,YAAY,EAAgC,MAAM,YAAY,CAAC;AAEhF,MAAM,UAAU,GAAG;IACjB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC7B;KACF;IACD,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC7B;KACF;CACO,CAAC;AAEX,MAAM,MAAM,GAAG,IAAI,IAAI,CAAS;IAC9B,WAAW,EAAE,OAAO;IACpB,MAAM,EAAE,UAAU;CACnB,CAAC,CAAC;AAEH,sDAAsD;AACtD,MA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C,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,KAAK;QACV,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const JiraConfigSchema: z.ZodObject<{
|
|
3
|
+
baseUrl: z.ZodString;
|
|
4
|
+
email: z.ZodString;
|
|
5
|
+
apiToken: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
email: string;
|
|
9
|
+
apiToken: string;
|
|
10
|
+
}, {
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
email: string;
|
|
13
|
+
apiToken: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const ConfluenceConfigSchema: z.ZodObject<{
|
|
16
|
+
baseUrl: z.ZodString;
|
|
17
|
+
email: z.ZodString;
|
|
18
|
+
apiToken: z.ZodString;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
baseUrl: string;
|
|
21
|
+
email: string;
|
|
22
|
+
apiToken: string;
|
|
23
|
+
}, {
|
|
24
|
+
baseUrl: string;
|
|
25
|
+
email: string;
|
|
26
|
+
apiToken: string;
|
|
27
|
+
}>;
|
|
28
|
+
export declare const ConfigSchema: z.ZodObject<{
|
|
29
|
+
jira: z.ZodOptional<z.ZodObject<{
|
|
30
|
+
baseUrl: z.ZodString;
|
|
31
|
+
email: z.ZodString;
|
|
32
|
+
apiToken: z.ZodString;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
baseUrl: string;
|
|
35
|
+
email: string;
|
|
36
|
+
apiToken: string;
|
|
37
|
+
}, {
|
|
38
|
+
baseUrl: string;
|
|
39
|
+
email: string;
|
|
40
|
+
apiToken: string;
|
|
41
|
+
}>>;
|
|
42
|
+
confluence: z.ZodOptional<z.ZodObject<{
|
|
43
|
+
baseUrl: z.ZodString;
|
|
44
|
+
email: z.ZodString;
|
|
45
|
+
apiToken: z.ZodString;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
baseUrl: string;
|
|
48
|
+
email: string;
|
|
49
|
+
apiToken: string;
|
|
50
|
+
}, {
|
|
51
|
+
baseUrl: string;
|
|
52
|
+
email: string;
|
|
53
|
+
apiToken: string;
|
|
54
|
+
}>>;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
jira?: {
|
|
57
|
+
baseUrl: string;
|
|
58
|
+
email: string;
|
|
59
|
+
apiToken: string;
|
|
60
|
+
} | undefined;
|
|
61
|
+
confluence?: {
|
|
62
|
+
baseUrl: string;
|
|
63
|
+
email: string;
|
|
64
|
+
apiToken: string;
|
|
65
|
+
} | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
jira?: {
|
|
68
|
+
baseUrl: string;
|
|
69
|
+
email: string;
|
|
70
|
+
apiToken: string;
|
|
71
|
+
} | undefined;
|
|
72
|
+
confluence?: {
|
|
73
|
+
baseUrl: string;
|
|
74
|
+
email: string;
|
|
75
|
+
apiToken: string;
|
|
76
|
+
} | undefined;
|
|
77
|
+
}>;
|
|
78
|
+
export type JiraConfig = z.infer<typeof JiraConfigSchema>;
|
|
79
|
+
export type ConfluenceConfig = z.infer<typeof ConfluenceConfigSchema>;
|
|
80
|
+
export type Config = z.infer<typeof ConfigSchema>;
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EAI3B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;EAIjC,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGvB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const JiraConfigSchema = z.object({
|
|
3
|
+
baseUrl: z.string().url('Invalid Jira URL'),
|
|
4
|
+
email: z.string().email('Invalid email'),
|
|
5
|
+
apiToken: z.string().min(1, 'API token is required'),
|
|
6
|
+
});
|
|
7
|
+
export const ConfluenceConfigSchema = z.object({
|
|
8
|
+
baseUrl: z.string().url('Invalid Confluence URL'),
|
|
9
|
+
email: z.string().email('Invalid email'),
|
|
10
|
+
apiToken: z.string().min(1, 'API token is required'),
|
|
11
|
+
});
|
|
12
|
+
export const ConfigSchema = z.object({
|
|
13
|
+
jira: JiraConfigSchema.optional(),
|
|
14
|
+
confluence: ConfluenceConfigSchema.optional(),
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAC3C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC;IACxC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;CACrD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,wBAAwB,CAAC;IACjD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC;IACxC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;CACrD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,gBAAgB,CAAC,QAAQ,EAAE;IACjC,UAAU,EAAE,sBAAsB,CAAC,QAAQ,EAAE;CAC9C,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare class AdfConverter {
|
|
2
|
+
/**
|
|
3
|
+
* Convert Markdown to ADF (Atlassian Document Format)
|
|
4
|
+
* Used for sending content to Jira (descriptions, comments)
|
|
5
|
+
*/
|
|
6
|
+
static markdownToAdf(markdown: string): any;
|
|
7
|
+
/**
|
|
8
|
+
* Convert ADF to Markdown
|
|
9
|
+
* Used for displaying Jira content in the terminal
|
|
10
|
+
*/
|
|
11
|
+
static adfToMarkdown(adf: any): string;
|
|
12
|
+
/**
|
|
13
|
+
* Convert plain text to ADF format
|
|
14
|
+
*/
|
|
15
|
+
private static plainTextToAdf;
|
|
16
|
+
/**
|
|
17
|
+
* Extract plain text from ADF
|
|
18
|
+
*/
|
|
19
|
+
private static extractPlainText;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=adf-converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adf-converter.d.ts","sourceRoot":"","sources":["../../src/formatters/adf-converter.ts"],"names":[],"mappings":"AAGA,qBAAa,YAAY;IACvB;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG;IAS3C;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;IAUtC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAkB7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;CAoBhC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { markdownToAdf } from 'marklassian';
|
|
2
|
+
import { convertADFToMarkdown } from 'adf-to-markdown';
|
|
3
|
+
export class AdfConverter {
|
|
4
|
+
/**
|
|
5
|
+
* Convert Markdown to ADF (Atlassian Document Format)
|
|
6
|
+
* Used for sending content to Jira (descriptions, comments)
|
|
7
|
+
*/
|
|
8
|
+
static markdownToAdf(markdown) {
|
|
9
|
+
try {
|
|
10
|
+
return markdownToAdf(markdown);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
// Fallback to plain text if markdown conversion fails
|
|
14
|
+
return this.plainTextToAdf(markdown);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Convert ADF to Markdown
|
|
19
|
+
* Used for displaying Jira content in the terminal
|
|
20
|
+
*/
|
|
21
|
+
static adfToMarkdown(adf) {
|
|
22
|
+
try {
|
|
23
|
+
if (!adf)
|
|
24
|
+
return '';
|
|
25
|
+
return convertADFToMarkdown(adf);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
// Fallback to plain text extraction
|
|
29
|
+
return this.extractPlainText(adf);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Convert plain text to ADF format
|
|
34
|
+
*/
|
|
35
|
+
static plainTextToAdf(text) {
|
|
36
|
+
return {
|
|
37
|
+
version: 1,
|
|
38
|
+
type: 'doc',
|
|
39
|
+
content: [
|
|
40
|
+
{
|
|
41
|
+
type: 'paragraph',
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: 'text',
|
|
45
|
+
text: text,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Extract plain text from ADF
|
|
54
|
+
*/
|
|
55
|
+
static extractPlainText(adf) {
|
|
56
|
+
if (!adf)
|
|
57
|
+
return '';
|
|
58
|
+
const textParts = [];
|
|
59
|
+
const traverse = (node) => {
|
|
60
|
+
if (!node)
|
|
61
|
+
return;
|
|
62
|
+
if (node.type === 'text' && node.text) {
|
|
63
|
+
textParts.push(node.text);
|
|
64
|
+
}
|
|
65
|
+
if (node.content && Array.isArray(node.content)) {
|
|
66
|
+
node.content.forEach(traverse);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
traverse(adf);
|
|
70
|
+
return textParts.join('');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=adf-converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adf-converter.js","sourceRoot":"","sources":["../../src/formatters/adf-converter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,OAAO,YAAY;IACvB;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,QAAgB;QACnC,IAAI,CAAC;YACH,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,sDAAsD;YACtD,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,GAAQ;QAC3B,IAAI,CAAC;YACH,IAAI,CAAC,GAAG;gBAAE,OAAO,EAAE,CAAC;YACpB,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,oCAAoC;YACpC,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,cAAc,CAAC,IAAY;QACxC,OAAO;YACL,OAAO,EAAE,CAAC;YACV,IAAI,EAAE,KAAK;YACX,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,IAAI;yBACX;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,gBAAgB,CAAC,GAAQ;QACtC,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,CAAC;QAEpB,MAAM,SAAS,GAAa,EAAE,CAAC;QAE/B,MAAM,QAAQ,GAAG,CAAC,IAAS,EAAE,EAAE;YAC7B,IAAI,CAAC,IAAI;gBAAE,OAAO;YAElB,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACtC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YAED,IAAI,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAChD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACjC,CAAC;QACH,CAAC,CAAC;QAEF,QAAQ,CAAC,GAAG,CAAC,CAAC;QACd,OAAO,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare class ConfluenceConverter {
|
|
2
|
+
/**
|
|
3
|
+
* Convert Confluence storage format (XHTML) to Markdown
|
|
4
|
+
* Storage format is XHTML-based, we need to convert it to markdown
|
|
5
|
+
*/
|
|
6
|
+
static storageToMarkdown(storage: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Convert Markdown to Confluence storage format
|
|
9
|
+
* Storage format is XHTML-based
|
|
10
|
+
*/
|
|
11
|
+
static markdownToStorage(markdown: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Extract plain text from HTML storage format
|
|
14
|
+
*/
|
|
15
|
+
private static extractPlainText;
|
|
16
|
+
/**
|
|
17
|
+
* Wrap HTML in Confluence storage format
|
|
18
|
+
*/
|
|
19
|
+
private static wrapInStorageFormat;
|
|
20
|
+
/**
|
|
21
|
+
* Convert plain text to Confluence storage format
|
|
22
|
+
*/
|
|
23
|
+
private static plainTextToStorage;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=confluence-converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confluence-converter.d.ts","sourceRoot":"","sources":["../../src/formatters/confluence-converter.ts"],"names":[],"mappings":"AAMA,qBAAa,mBAAmB;IAC9B;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAajD;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAelD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAY/B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAMlC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAWlC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import TurndownService from 'turndown';
|
|
2
|
+
import MarkdownIt from 'markdown-it';
|
|
3
|
+
const turndownService = new TurndownService();
|
|
4
|
+
const markdownIt = new MarkdownIt();
|
|
5
|
+
export class ConfluenceConverter {
|
|
6
|
+
/**
|
|
7
|
+
* Convert Confluence storage format (XHTML) to Markdown
|
|
8
|
+
* Storage format is XHTML-based, we need to convert it to markdown
|
|
9
|
+
*/
|
|
10
|
+
static storageToMarkdown(storage) {
|
|
11
|
+
try {
|
|
12
|
+
if (!storage)
|
|
13
|
+
return '';
|
|
14
|
+
// Convert XHTML storage to markdown using turndown
|
|
15
|
+
const markdown = turndownService.turndown(storage);
|
|
16
|
+
return markdown.trim();
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
// Fallback: try to extract plain text
|
|
20
|
+
return this.extractPlainText(storage);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Convert Markdown to Confluence storage format
|
|
25
|
+
* Storage format is XHTML-based
|
|
26
|
+
*/
|
|
27
|
+
static markdownToStorage(markdown) {
|
|
28
|
+
try {
|
|
29
|
+
if (!markdown)
|
|
30
|
+
return '';
|
|
31
|
+
// Convert markdown to HTML using markdown-it
|
|
32
|
+
const html = markdownIt.render(markdown);
|
|
33
|
+
// Wrap in storage format (required by Confluence API)
|
|
34
|
+
return this.wrapInStorageFormat(html);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
// Fallback to plain text wrapped in storage format
|
|
38
|
+
return this.plainTextToStorage(markdown);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Extract plain text from HTML storage format
|
|
43
|
+
*/
|
|
44
|
+
static extractPlainText(html) {
|
|
45
|
+
// Remove HTML tags and decode entities
|
|
46
|
+
return html
|
|
47
|
+
.replace(/<[^>]*>/g, '')
|
|
48
|
+
.replace(/</g, '<')
|
|
49
|
+
.replace(/>/g, '>')
|
|
50
|
+
.replace(/&/g, '&')
|
|
51
|
+
.replace(/"/g, '"')
|
|
52
|
+
.replace(/'/g, "'")
|
|
53
|
+
.trim();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Wrap HTML in Confluence storage format
|
|
57
|
+
*/
|
|
58
|
+
static wrapInStorageFormat(html) {
|
|
59
|
+
// Confluence storage format is valid XHTML/XML
|
|
60
|
+
// Just ensure it's properly formatted
|
|
61
|
+
return html.trim();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Convert plain text to Confluence storage format
|
|
65
|
+
*/
|
|
66
|
+
static plainTextToStorage(text) {
|
|
67
|
+
// Escape special characters and wrap in paragraph tags
|
|
68
|
+
const escaped = text
|
|
69
|
+
.replace(/&/g, '&')
|
|
70
|
+
.replace(/</g, '<')
|
|
71
|
+
.replace(/>/g, '>')
|
|
72
|
+
.replace(/"/g, '"')
|
|
73
|
+
.replace(/'/g, ''');
|
|
74
|
+
return `<p>${escaped}</p>`;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=confluence-converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confluence-converter.js","sourceRoot":"","sources":["../../src/formatters/confluence-converter.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,UAAU,CAAC;AACvC,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;AAC9C,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;AAEpC,MAAM,OAAO,mBAAmB;IAC9B;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CAAC,OAAe;QACtC,IAAI,CAAC;YACH,IAAI,CAAC,OAAO;gBAAE,OAAO,EAAE,CAAC;YAExB,mDAAmD;YACnD,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACnD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,sCAAsC;YACtC,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CAAC,QAAgB;QACvC,IAAI,CAAC;YACH,IAAI,CAAC,QAAQ;gBAAE,OAAO,EAAE,C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Renders Markdown using Glow CLI for beautiful terminal output.
|
|
3
|
+
* Glow provides better rendering than in-process solutions, including:
|
|
4
|
+
* - Proper table formatting
|
|
5
|
+
* - Syntax highlighting for code blocks
|
|
6
|
+
* - Better list handling
|
|
7
|
+
* - Consistent styling
|
|
8
|
+
*/
|
|
9
|
+
export declare class GlowRenderer {
|
|
10
|
+
private glowPath;
|
|
11
|
+
private available;
|
|
12
|
+
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Check if glow is available on the system
|
|
15
|
+
*/
|
|
16
|
+
private detectGlow;
|
|
17
|
+
/**
|
|
18
|
+
* Check if glow is available
|
|
19
|
+
*/
|
|
20
|
+
isAvailable(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Get installation instructions
|
|
23
|
+
*/
|
|
24
|
+
getInstallInstructions(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Render markdown to styled terminal output using glow
|
|
27
|
+
*/
|
|
28
|
+
render(markdown: string, width?: number): string;
|
|
29
|
+
/**
|
|
30
|
+
* Render with a specific style theme
|
|
31
|
+
*/
|
|
32
|
+
renderWithStyle(markdown: string, style?: 'dark' | 'light' | 'notty' | 'auto', width?: number): string;
|
|
33
|
+
}
|
|
34
|
+
export declare const glowRenderer: GlowRenderer;
|
|
35
|
+
/**
|
|
36
|
+
* Simple helper function for quick rendering
|
|
37
|
+
*/
|
|
38
|
+
export declare function renderMarkdownWithGlow(markdown: string): string;
|
|
39
|
+
//# sourceMappingURL=glow-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glow-renderer.d.ts","sourceRoot":"","sources":["../../src/formatters/glow-renderer.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,SAAS,CAAwB;;IAMzC;;OAEG;IACH,OAAO,CAAC,UAAU;IAiBlB;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,sBAAsB,IAAI,MAAM;IAIhC;;OAEG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM;IAgDhD;;OAEG;IACH,eAAe,CACX,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAe,EACnD,KAAK,CAAC,EAAE,MAAM,GACf,MAAM;CAgCZ;AAGD,eAAO,MAAM,YAAY,cAAqB,CAAC;AAE/C;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/D"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { execSync, spawnSync } from 'child_process';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as os from 'os';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
/**
|
|
6
|
+
* Renders Markdown using Glow CLI for beautiful terminal output.
|
|
7
|
+
* Glow provides better rendering than in-process solutions, including:
|
|
8
|
+
* - Proper table formatting
|
|
9
|
+
* - Syntax highlighting for code blocks
|
|
10
|
+
* - Better list handling
|
|
11
|
+
* - Consistent styling
|
|
12
|
+
*/
|
|
13
|
+
export class GlowRenderer {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.glowPath = null;
|
|
16
|
+
this.available = null;
|
|
17
|
+
this.detectGlow();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Check if glow is available on the system
|
|
21
|
+
*/
|
|
22
|
+
detectGlow() {
|
|
23
|
+
try {
|
|
24
|
+
const result = spawnSync('which', ['glow'], {
|
|
25
|
+
encoding: 'utf-8',
|
|
26
|
+
timeout: 2000,
|
|
27
|
+
});
|
|
28
|
+
if (result.status === 0 && result.stdout.trim()) {
|
|
29
|
+
this.glowPath = result.stdout.trim();
|
|
30
|
+
this.available = true;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
this.available = false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
this.available = false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Check if glow is available
|
|
42
|
+
*/
|
|
43
|
+
isAvailable() {
|
|
44
|
+
return this.available === true;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get installation instructions
|
|
48
|
+
*/
|
|
49
|
+
getInstallInstructions() {
|
|
50
|
+
return 'Install glow: brew install glow (macOS) or go install github.com/charmbracelet/glow@latest';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Render markdown to styled terminal output using glow
|
|
54
|
+
*/
|
|
55
|
+
render(markdown, width) {
|
|
56
|
+
if (!this.available || !this.glowPath) {
|
|
57
|
+
// Fallback to plain text if glow is not available
|
|
58
|
+
return markdown;
|
|
59
|
+
}
|
|
60
|
+
// Create temp file for markdown content
|
|
61
|
+
const tmpDir = os.tmpdir();
|
|
62
|
+
const tmpFile = path.join(tmpDir, `sutra-${Date.now()}.md`);
|
|
63
|
+
try {
|
|
64
|
+
// Write markdown to temp file
|
|
65
|
+
fs.writeFileSync(tmpFile, markdown, 'utf-8');
|
|
66
|
+
// Get terminal width or use provided width
|
|
67
|
+
const termWidth = width || process.stdout.columns || 80;
|
|
68
|
+
// Call glow to render
|
|
69
|
+
const result = execSync(`"${this.glowPath}" --style auto --width ${termWidth - 4} "${tmpFile}"`, {
|
|
70
|
+
encoding: 'utf-8',
|
|
71
|
+
timeout: 5000,
|
|
72
|
+
maxBuffer: 10 * 1024 * 1024, // 10MB buffer for large docs
|
|
73
|
+
});
|
|
74
|
+
// If glow returns almost nothing, fallback to plain markdown
|
|
75
|
+
// This can happen when glow has issues with certain content
|
|
76
|
+
if (result.trim().length < 10 && markdown.length > 10) {
|
|
77
|
+
return markdown;
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
// On error, return plain markdown
|
|
83
|
+
console.error('Glow render error:', error);
|
|
84
|
+
return markdown;
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
// Clean up temp file
|
|
88
|
+
try {
|
|
89
|
+
fs.unlinkSync(tmpFile);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// Ignore cleanup errors
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Render with a specific style theme
|
|
98
|
+
*/
|
|
99
|
+
renderWithStyle(markdown, style = 'auto', width) {
|
|
100
|
+
if (!this.available || !this.glowPath) {
|
|
101
|
+
return markdown;
|
|
102
|
+
}
|
|
103
|
+
const tmpDir = os.tmpdir();
|
|
104
|
+
const tmpFile = path.join(tmpDir, `sutra-${Date.now()}.md`);
|
|
105
|
+
try {
|
|
106
|
+
fs.writeFileSync(tmpFile, markdown, 'utf-8');
|
|
107
|
+
const termWidth = width || process.stdout.columns || 80;
|
|
108
|
+
const result = execSync(`"${this.glowPath}" --style ${style} --width ${termWidth - 4} "${tmpFile}"`, {
|
|
109
|
+
encoding: 'utf-8',
|
|
110
|
+
timeout: 5000,
|
|
111
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
112
|
+
});
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return markdown;
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
try {
|
|
120
|
+
fs.unlinkSync(tmpFile);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
// Ignore cleanup errors
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Singleton instance
|
|
129
|
+
export const glowRenderer = new GlowRenderer();
|
|
130
|
+
/**
|
|
131
|
+
* Simple helper function for quick rendering
|
|
132
|
+
*/
|
|
133
|
+
export function renderMarkdownWithGlow(markdown) {
|
|
134
|
+
return glowRenderer.render(markdown);
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=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IACnD,OAAO,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders Markdown to ANSI-styled text for terminal display.
|
|
3
|
+
* Uses markdown-it for parsing and chalk for styling.
|
|
4
|
+
*/
|
|
5
|
+
export declare class MarkdownAnsiRenderer {
|
|
6
|
+
private md;
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Render markdown string to ANSI-styled terminal text
|
|
10
|
+
*/
|
|
11
|
+
render(markdown: string): string;
|
|
12
|
+
private renderTokens;
|
|
13
|
+
private renderHeading;
|
|
14
|
+
private renderInline;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a clickable hyperlink using OSC 8 escape sequence.
|
|
17
|
+
* Supported by: iTerm2, Kitty, Alacritty, Hyper, VS Code terminal, and more.
|
|
18
|
+
*/
|
|
19
|
+
private makeClickableLink;
|
|
20
|
+
private renderCodeBlock;
|
|
21
|
+
private handleHtml;
|
|
22
|
+
}
|
|
23
|
+
export declare const markdownRenderer: MarkdownAnsiRenderer;
|
|
24
|
+
//# sourceMappingURL=markdown-ansi-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-ansi-renderer.d.ts","sourceRoot":"","sources":["../../src/formatters/markdown-ansi-renderer.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,qBAAa,oBAAoB;IAC7B,OAAO,CAAC,EAAE,CAAa;;IAUvB;;OAEG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAKhC,OAAO,CAAC,YAAY;IAqHpB,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,YAAY;IAkEpB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,UAAU;CAgBrB;AAGD,eAAO,MAAM,gBAAgB,sBAA6B,CAAC"}
|