skrypt-ai 0.1.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 +21 -0
- package/README.md +200 -0
- package/dist/autofix/index.d.ts +46 -0
- package/dist/autofix/index.js +240 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +40 -0
- package/dist/commands/autofix.d.ts +2 -0
- package/dist/commands/autofix.js +143 -0
- package/dist/commands/generate.d.ts +2 -0
- package/dist/commands/generate.js +320 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +56 -0
- package/dist/commands/review-pr.d.ts +2 -0
- package/dist/commands/review-pr.js +117 -0
- package/dist/commands/watch.d.ts +2 -0
- package/dist/commands/watch.js +142 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +2 -0
- package/dist/config/loader.d.ts +9 -0
- package/dist/config/loader.js +82 -0
- package/dist/config/types.d.ts +24 -0
- package/dist/config/types.js +34 -0
- package/dist/generator/generator.d.ts +15 -0
- package/dist/generator/generator.js +144 -0
- package/dist/generator/index.d.ts +4 -0
- package/dist/generator/index.js +4 -0
- package/dist/generator/organizer.d.ts +29 -0
- package/dist/generator/organizer.js +222 -0
- package/dist/generator/types.d.ts +83 -0
- package/dist/generator/types.js +1 -0
- package/dist/generator/writer.d.ts +28 -0
- package/dist/generator/writer.js +320 -0
- package/dist/github/pr-comments.d.ts +40 -0
- package/dist/github/pr-comments.js +308 -0
- package/dist/llm/anthropic-client.d.ts +16 -0
- package/dist/llm/anthropic-client.js +92 -0
- package/dist/llm/index.d.ts +53 -0
- package/dist/llm/index.js +400 -0
- package/dist/llm/llm.manual-test.d.ts +1 -0
- package/dist/llm/llm.manual-test.js +112 -0
- package/dist/llm/llm.mock-test.d.ts +4 -0
- package/dist/llm/llm.mock-test.js +79 -0
- package/dist/llm/openai-client.d.ts +17 -0
- package/dist/llm/openai-client.js +90 -0
- package/dist/llm/types.d.ts +60 -0
- package/dist/llm/types.js +20 -0
- package/dist/scanner/content-type.d.ts +39 -0
- package/dist/scanner/content-type.js +194 -0
- package/dist/scanner/content-type.test.d.ts +1 -0
- package/dist/scanner/content-type.test.js +231 -0
- package/dist/scanner/go.d.ts +20 -0
- package/dist/scanner/go.js +269 -0
- package/dist/scanner/index.d.ts +21 -0
- package/dist/scanner/index.js +137 -0
- package/dist/scanner/python.d.ts +6 -0
- package/dist/scanner/python.js +57 -0
- package/dist/scanner/python_parser.py +230 -0
- package/dist/scanner/rust.d.ts +23 -0
- package/dist/scanner/rust.js +304 -0
- package/dist/scanner/scanner.test.d.ts +1 -0
- package/dist/scanner/scanner.test.js +210 -0
- package/dist/scanner/types.d.ts +50 -0
- package/dist/scanner/types.js +1 -0
- package/dist/scanner/typescript.d.ts +34 -0
- package/dist/scanner/typescript.js +327 -0
- package/dist/scanner/typescript.manual-test.d.ts +1 -0
- package/dist/scanner/typescript.manual-test.js +112 -0
- package/dist/template/docs.json +32 -0
- package/dist/template/mdx-components.tsx +62 -0
- package/dist/template/next-env.d.ts +6 -0
- package/dist/template/next.config.mjs +17 -0
- package/dist/template/package.json +39 -0
- package/dist/template/postcss.config.mjs +5 -0
- package/dist/template/public/search-index.json +1 -0
- package/dist/template/scripts/build-search-index.mjs +120 -0
- package/dist/template/src/app/api/mock/[...path]/route.ts +224 -0
- package/dist/template/src/app/api/openapi/route.ts +48 -0
- package/dist/template/src/app/api/rate-limit/route.ts +84 -0
- package/dist/template/src/app/docs/[...slug]/page.tsx +81 -0
- package/dist/template/src/app/docs/layout.tsx +9 -0
- package/dist/template/src/app/docs/page.mdx +67 -0
- package/dist/template/src/app/error.tsx +63 -0
- package/dist/template/src/app/layout.tsx +71 -0
- package/dist/template/src/app/page.tsx +18 -0
- package/dist/template/src/app/reference/route.ts +36 -0
- package/dist/template/src/app/robots.ts +14 -0
- package/dist/template/src/app/sitemap.ts +64 -0
- package/dist/template/src/components/breadcrumbs.tsx +41 -0
- package/dist/template/src/components/copy-button.tsx +29 -0
- package/dist/template/src/components/docs-layout.tsx +35 -0
- package/dist/template/src/components/edit-link.tsx +39 -0
- package/dist/template/src/components/feedback.tsx +52 -0
- package/dist/template/src/components/header.tsx +66 -0
- package/dist/template/src/components/mdx/accordion.tsx +48 -0
- package/dist/template/src/components/mdx/api-badge.tsx +57 -0
- package/dist/template/src/components/mdx/callout.tsx +111 -0
- package/dist/template/src/components/mdx/card.tsx +62 -0
- package/dist/template/src/components/mdx/changelog.tsx +57 -0
- package/dist/template/src/components/mdx/code-block.tsx +42 -0
- package/dist/template/src/components/mdx/code-group.tsx +125 -0
- package/dist/template/src/components/mdx/code-playground.tsx +322 -0
- package/dist/template/src/components/mdx/go-playground.tsx +235 -0
- package/dist/template/src/components/mdx/heading.tsx +37 -0
- package/dist/template/src/components/mdx/highlighted-code.tsx +89 -0
- package/dist/template/src/components/mdx/index.tsx +15 -0
- package/dist/template/src/components/mdx/param-table.tsx +71 -0
- package/dist/template/src/components/mdx/python-playground.tsx +293 -0
- package/dist/template/src/components/mdx/steps.tsx +43 -0
- package/dist/template/src/components/mdx/tabs.tsx +81 -0
- package/dist/template/src/components/rate-limit-display.tsx +183 -0
- package/dist/template/src/components/search-dialog.tsx +178 -0
- package/dist/template/src/components/sidebar.tsx +129 -0
- package/dist/template/src/components/syntax-theme-selector.tsx +50 -0
- package/dist/template/src/components/table-of-contents.tsx +84 -0
- package/dist/template/src/components/theme-toggle.tsx +46 -0
- package/dist/template/src/components/version-selector.tsx +61 -0
- package/dist/template/src/contexts/syntax-theme.tsx +52 -0
- package/dist/template/src/lib/highlight.ts +83 -0
- package/dist/template/src/lib/search-types.ts +37 -0
- package/dist/template/src/lib/search.ts +125 -0
- package/dist/template/src/lib/utils.ts +6 -0
- package/dist/template/src/styles/globals.css +152 -0
- package/dist/template/tsconfig.json +25 -0
- package/dist/template/tsconfig.tsbuildinfo +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for Orama search database
|
|
3
|
+
* Fixes P0: Removes `any` types from search functionality
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Orama, Results, SearchParams } from '@orama/orama'
|
|
7
|
+
|
|
8
|
+
// Schema definition for search index documents
|
|
9
|
+
export interface SearchDocument {
|
|
10
|
+
id: string
|
|
11
|
+
title: string
|
|
12
|
+
content: string
|
|
13
|
+
href: string
|
|
14
|
+
section: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Orama database type with our schema
|
|
18
|
+
export type SearchDatabase = Orama<{
|
|
19
|
+
id: 'string'
|
|
20
|
+
title: 'string'
|
|
21
|
+
content: 'string'
|
|
22
|
+
href: 'string'
|
|
23
|
+
section: 'string'
|
|
24
|
+
}>
|
|
25
|
+
|
|
26
|
+
// Search hit from Orama results
|
|
27
|
+
export interface SearchHit {
|
|
28
|
+
id: string
|
|
29
|
+
score: number
|
|
30
|
+
document: SearchDocument
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Orama search results type
|
|
34
|
+
export type SearchResults = Results<SearchDocument>
|
|
35
|
+
|
|
36
|
+
// Search parameters for our use case
|
|
37
|
+
export type SearchOptions = SearchParams<SearchDatabase, SearchDocument>
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { create, load, search as oramaSearch } from '@orama/orama'
|
|
2
|
+
import type { SearchDatabase, SearchHit } from './search-types'
|
|
3
|
+
|
|
4
|
+
let db: SearchDatabase | null = null
|
|
5
|
+
let loadPromise: Promise<void> | null = null
|
|
6
|
+
|
|
7
|
+
const schema = {
|
|
8
|
+
id: 'string' as const,
|
|
9
|
+
title: 'string' as const,
|
|
10
|
+
content: 'string' as const,
|
|
11
|
+
href: 'string' as const,
|
|
12
|
+
section: 'string' as const,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface SearchResult {
|
|
16
|
+
title: string
|
|
17
|
+
href: string
|
|
18
|
+
content: string
|
|
19
|
+
section?: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function loadSearchIndex(): Promise<void> {
|
|
23
|
+
if (db) return
|
|
24
|
+
if (loadPromise) return loadPromise
|
|
25
|
+
|
|
26
|
+
loadPromise = (async () => {
|
|
27
|
+
try {
|
|
28
|
+
const response = await fetch('/search-index.json')
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
throw new Error('Search index not found')
|
|
31
|
+
}
|
|
32
|
+
const data = await response.json()
|
|
33
|
+
|
|
34
|
+
const newDb = await create({ schema }) as SearchDatabase
|
|
35
|
+
await load(newDb, data)
|
|
36
|
+
db = newDb
|
|
37
|
+
} catch (err) {
|
|
38
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
39
|
+
console.error('Failed to load search index:', message)
|
|
40
|
+
db = null
|
|
41
|
+
}
|
|
42
|
+
})()
|
|
43
|
+
|
|
44
|
+
return loadPromise
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Generate a snippet with highlighted search terms
|
|
49
|
+
*/
|
|
50
|
+
function generateSnippet(content: string, query: string, maxLength: number = 150): string {
|
|
51
|
+
const terms = query.toLowerCase().split(/\s+/).filter(Boolean)
|
|
52
|
+
const contentLower = content.toLowerCase()
|
|
53
|
+
|
|
54
|
+
// Find the best position to start the snippet (where most terms match)
|
|
55
|
+
let bestPos = 0
|
|
56
|
+
let bestScore = 0
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < content.length - 50; i += 20) {
|
|
59
|
+
const window = contentLower.slice(i, i + maxLength)
|
|
60
|
+
const score = terms.filter(term => window.includes(term)).length
|
|
61
|
+
if (score > bestScore) {
|
|
62
|
+
bestScore = score
|
|
63
|
+
bestPos = i
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Extract snippet around best position
|
|
68
|
+
let start = Math.max(0, bestPos - 20)
|
|
69
|
+
let end = Math.min(content.length, start + maxLength)
|
|
70
|
+
|
|
71
|
+
// Adjust to word boundaries
|
|
72
|
+
if (start > 0) {
|
|
73
|
+
const spaceIndex = content.indexOf(' ', start)
|
|
74
|
+
if (spaceIndex !== -1 && spaceIndex < start + 20) start = spaceIndex + 1
|
|
75
|
+
}
|
|
76
|
+
if (end < content.length) {
|
|
77
|
+
const spaceIndex = content.lastIndexOf(' ', end)
|
|
78
|
+
if (spaceIndex > end - 20) end = spaceIndex
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let snippet = content.slice(start, end)
|
|
82
|
+
if (start > 0) snippet = '...' + snippet
|
|
83
|
+
if (end < content.length) snippet = snippet + '...'
|
|
84
|
+
|
|
85
|
+
return snippet
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface SearchResultWithHighlight extends SearchResult {
|
|
89
|
+
snippet: string
|
|
90
|
+
score: number
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function search(query: string): Promise<SearchResultWithHighlight[]> {
|
|
94
|
+
if (!query.trim()) return []
|
|
95
|
+
|
|
96
|
+
await loadSearchIndex()
|
|
97
|
+
|
|
98
|
+
if (!db) return []
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
const results = await oramaSearch(db, {
|
|
102
|
+
term: query,
|
|
103
|
+
properties: ['title', 'content'],
|
|
104
|
+
limit: 10,
|
|
105
|
+
tolerance: 1,
|
|
106
|
+
boost: {
|
|
107
|
+
title: 2,
|
|
108
|
+
content: 1,
|
|
109
|
+
},
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
return results.hits.map((hit: SearchHit) => ({
|
|
113
|
+
title: hit.document.title,
|
|
114
|
+
href: hit.document.href,
|
|
115
|
+
content: hit.document.content,
|
|
116
|
+
section: hit.document.section || undefined,
|
|
117
|
+
snippet: generateSnippet(hit.document.content, query),
|
|
118
|
+
score: hit.score,
|
|
119
|
+
}))
|
|
120
|
+
} catch (err) {
|
|
121
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
122
|
+
console.error('Search error:', message)
|
|
123
|
+
return []
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
|
|
3
|
+
@theme {
|
|
4
|
+
/* Colors */
|
|
5
|
+
--color-primary: #3b82f6;
|
|
6
|
+
--color-primary-dark: #2563eb;
|
|
7
|
+
--color-accent: #8b5cf6;
|
|
8
|
+
|
|
9
|
+
/* Background */
|
|
10
|
+
--color-bg: #ffffff;
|
|
11
|
+
--color-bg-secondary: #f8fafc;
|
|
12
|
+
--color-bg-tertiary: #f1f5f9;
|
|
13
|
+
|
|
14
|
+
/* Text */
|
|
15
|
+
--color-text: #0f172a;
|
|
16
|
+
--color-text-secondary: #475569;
|
|
17
|
+
--color-text-tertiary: #94a3b8;
|
|
18
|
+
|
|
19
|
+
/* Border */
|
|
20
|
+
--color-border: #e2e8f0;
|
|
21
|
+
--color-border-strong: #cbd5e1;
|
|
22
|
+
|
|
23
|
+
/* Code */
|
|
24
|
+
--color-code-bg: #1e293b;
|
|
25
|
+
--color-code-text: #e2e8f0;
|
|
26
|
+
|
|
27
|
+
/* Sidebar */
|
|
28
|
+
--sidebar-width: 280px;
|
|
29
|
+
--toc-width: 240px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Dark mode - supports both system preference and manual toggle */
|
|
33
|
+
@media (prefers-color-scheme: dark) {
|
|
34
|
+
:root:not(.light) {
|
|
35
|
+
--color-bg: #0f172a;
|
|
36
|
+
--color-bg-secondary: #1e293b;
|
|
37
|
+
--color-bg-tertiary: #334155;
|
|
38
|
+
--color-text: #f8fafc;
|
|
39
|
+
--color-text-secondary: #cbd5e1;
|
|
40
|
+
--color-text-tertiary: #64748b;
|
|
41
|
+
--color-border: #334155;
|
|
42
|
+
--color-border-strong: #475569;
|
|
43
|
+
--color-code-bg: #0f172a;
|
|
44
|
+
--color-code-text: #e2e8f0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Manual dark mode override */
|
|
49
|
+
:root.dark {
|
|
50
|
+
--color-bg: #0f172a;
|
|
51
|
+
--color-bg-secondary: #1e293b;
|
|
52
|
+
--color-bg-tertiary: #334155;
|
|
53
|
+
--color-text: #f8fafc;
|
|
54
|
+
--color-text-secondary: #cbd5e1;
|
|
55
|
+
--color-text-tertiary: #64748b;
|
|
56
|
+
--color-border: #334155;
|
|
57
|
+
--color-border-strong: #475569;
|
|
58
|
+
--color-code-bg: #0f172a;
|
|
59
|
+
--color-code-text: #e2e8f0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Base styles */
|
|
63
|
+
html {
|
|
64
|
+
scroll-behavior: smooth;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
body {
|
|
68
|
+
background-color: var(--color-bg);
|
|
69
|
+
color: var(--color-text);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* Code blocks */
|
|
73
|
+
pre {
|
|
74
|
+
background-color: var(--color-code-bg) !important;
|
|
75
|
+
border-radius: 0.5rem;
|
|
76
|
+
padding: 1rem;
|
|
77
|
+
overflow-x: auto;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
code {
|
|
81
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
82
|
+
font-size: 0.875rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Inline code */
|
|
86
|
+
:not(pre) > code {
|
|
87
|
+
background-color: var(--color-bg-tertiary);
|
|
88
|
+
padding: 0.125rem 0.375rem;
|
|
89
|
+
border-radius: 0.25rem;
|
|
90
|
+
font-size: 0.875em;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Links */
|
|
94
|
+
a {
|
|
95
|
+
color: var(--color-primary);
|
|
96
|
+
text-decoration: none;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
a:hover {
|
|
100
|
+
text-decoration: underline;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Headings */
|
|
104
|
+
h1, h2, h3, h4, h5, h6 {
|
|
105
|
+
color: var(--color-text);
|
|
106
|
+
font-weight: 600;
|
|
107
|
+
line-height: 1.25;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
h1 { font-size: 2.25rem; }
|
|
111
|
+
h2 { font-size: 1.75rem; margin-top: 2rem; }
|
|
112
|
+
h3 { font-size: 1.375rem; margin-top: 1.5rem; }
|
|
113
|
+
h4 { font-size: 1.125rem; margin-top: 1.25rem; }
|
|
114
|
+
|
|
115
|
+
/* Prose content */
|
|
116
|
+
.prose {
|
|
117
|
+
max-width: 65ch;
|
|
118
|
+
line-height: 1.75;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.prose p {
|
|
122
|
+
margin-top: 1.25rem;
|
|
123
|
+
margin-bottom: 1.25rem;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.prose ul, .prose ol {
|
|
127
|
+
margin-top: 1rem;
|
|
128
|
+
margin-bottom: 1rem;
|
|
129
|
+
padding-left: 1.5rem;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.prose li {
|
|
133
|
+
margin-top: 0.5rem;
|
|
134
|
+
margin-bottom: 0.5rem;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.prose table {
|
|
138
|
+
width: 100%;
|
|
139
|
+
border-collapse: collapse;
|
|
140
|
+
margin: 1.5rem 0;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.prose th, .prose td {
|
|
144
|
+
border: 1px solid var(--color-border);
|
|
145
|
+
padding: 0.75rem;
|
|
146
|
+
text-align: left;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.prose th {
|
|
150
|
+
background-color: var(--color-bg-secondary);
|
|
151
|
+
font-weight: 600;
|
|
152
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"jsx": "preserve",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"plugins": [{ "name": "next" }],
|
|
17
|
+
"paths": {
|
|
18
|
+
"@/*": ["./src/*"],
|
|
19
|
+
"@/components/*": ["./src/components/*"],
|
|
20
|
+
"@/lib/*": ["./src/lib/*"]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
24
|
+
"exclude": ["node_modules"]
|
|
25
|
+
}
|