skrypt-ai 0.1.9 → 0.2.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 +92 -0
- package/dist/auth/index.d.ts +21 -0
- package/dist/auth/index.js +94 -0
- package/dist/cli.js +5 -1
- package/dist/commands/autofix.js +5 -0
- package/dist/commands/gh-action.js +5 -0
- package/dist/commands/login.d.ts +4 -0
- package/dist/commands/login.js +65 -0
- package/dist/commands/mcp.js +5 -0
- package/dist/commands/monitor.js +5 -0
- package/dist/commands/sdk.js +5 -0
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Elastic License 2.0
|
|
2
|
+
|
|
3
|
+
## Acceptance
|
|
4
|
+
|
|
5
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
6
|
+
|
|
7
|
+
## Copyright License
|
|
8
|
+
|
|
9
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
10
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
11
|
+
available, and prepare derivative works of the software, in each case subject
|
|
12
|
+
to the limitations and conditions below.
|
|
13
|
+
|
|
14
|
+
## Limitations
|
|
15
|
+
|
|
16
|
+
You may not provide the software to third parties as a hosted or managed
|
|
17
|
+
service, where the service provides users with access to any substantial set
|
|
18
|
+
of the features or functionality of the software.
|
|
19
|
+
|
|
20
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
21
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
22
|
+
software that is protected by the license key.
|
|
23
|
+
|
|
24
|
+
You may not alter, remove, or obscure any licensing, copyright, or other
|
|
25
|
+
notices of the licensor in the software. Any use of the licensor's trademarks
|
|
26
|
+
is subject to applicable law.
|
|
27
|
+
|
|
28
|
+
## Patents
|
|
29
|
+
|
|
30
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
31
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
32
|
+
sale, import and have imported the software, in each case subject to the
|
|
33
|
+
limitations and conditions in this license. This license does not cover any
|
|
34
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
35
|
+
the software. If you or your company make any written claim that the software
|
|
36
|
+
infringes or contributes to infringement of any patent, your patent license
|
|
37
|
+
for the software granted under these terms ends immediately. If your company
|
|
38
|
+
makes such a claim, your patent license ends immediately for work on behalf
|
|
39
|
+
of your company.
|
|
40
|
+
|
|
41
|
+
## Notices
|
|
42
|
+
|
|
43
|
+
You must ensure that anyone who gets a copy of any part of the software from
|
|
44
|
+
you also gets a copy of these terms.
|
|
45
|
+
|
|
46
|
+
If you modify the software, you must include in any modified copies of the
|
|
47
|
+
software prominent notices stating that you have modified the software.
|
|
48
|
+
|
|
49
|
+
## No Other Rights
|
|
50
|
+
|
|
51
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
52
|
+
these terms.
|
|
53
|
+
|
|
54
|
+
## Termination
|
|
55
|
+
|
|
56
|
+
If you use the software in violation of these terms, such use is not
|
|
57
|
+
licensed, and your licenses will automatically terminate. If the licensor
|
|
58
|
+
provides you with a notice of your violation, and you cease all violation of
|
|
59
|
+
this license no later than 30 days after you receive that notice, your
|
|
60
|
+
licenses will be reinstated retroactively. However, if you violate these
|
|
61
|
+
terms after such reinstatement, any additional violation of these terms will
|
|
62
|
+
cause your licenses to terminate automatically and permanently.
|
|
63
|
+
|
|
64
|
+
## No Liability
|
|
65
|
+
|
|
66
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
67
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
68
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
69
|
+
legal claim.*
|
|
70
|
+
|
|
71
|
+
## Definitions
|
|
72
|
+
|
|
73
|
+
The **licensor** is Skrypt Inc.
|
|
74
|
+
|
|
75
|
+
The **software** is the software the licensor makes available under these
|
|
76
|
+
terms, including any portion of it.
|
|
77
|
+
|
|
78
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
79
|
+
|
|
80
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of
|
|
81
|
+
organization that you work for, plus all organizations that have control over,
|
|
82
|
+
are under the control of, or are under common control with that organization.
|
|
83
|
+
**Control** means ownership of substantially all the assets of an entity, or
|
|
84
|
+
the power to direct its management and policies by vote, contract, or
|
|
85
|
+
otherwise. Control can be direct or indirect.
|
|
86
|
+
|
|
87
|
+
**Your licenses** are all the licenses granted to you for the software under
|
|
88
|
+
these terms.
|
|
89
|
+
|
|
90
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
|
91
|
+
|
|
92
|
+
**Trademark** means trademarks, service marks, and similar rights.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface AuthConfig {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
email?: string;
|
|
4
|
+
plan?: 'free' | 'pro';
|
|
5
|
+
expiresAt?: string;
|
|
6
|
+
}
|
|
7
|
+
interface PlanCheckResponse {
|
|
8
|
+
valid: boolean;
|
|
9
|
+
plan: 'free' | 'pro';
|
|
10
|
+
email: string;
|
|
11
|
+
expiresAt?: string;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function getAuthConfig(): AuthConfig;
|
|
15
|
+
export declare function saveAuthConfig(config: AuthConfig): void;
|
|
16
|
+
export declare function clearAuth(): void;
|
|
17
|
+
export declare function checkPlan(apiKey: string): Promise<PlanCheckResponse>;
|
|
18
|
+
export declare function requirePro(commandName: string): Promise<boolean>;
|
|
19
|
+
export declare const PRO_COMMANDS: string[];
|
|
20
|
+
export declare function isProCommand(command: string): boolean;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
const CONFIG_DIR = join(homedir(), '.skrypt');
|
|
5
|
+
const AUTH_FILE = join(CONFIG_DIR, 'auth.json');
|
|
6
|
+
const API_BASE = process.env.SKRYPT_API_URL || 'https://api.skrypt.sh';
|
|
7
|
+
export function getAuthConfig() {
|
|
8
|
+
if (!existsSync(AUTH_FILE)) {
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
return JSON.parse(readFileSync(AUTH_FILE, 'utf-8'));
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function saveAuthConfig(config) {
|
|
19
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
20
|
+
writeFileSync(AUTH_FILE, JSON.stringify(config, null, 2));
|
|
21
|
+
}
|
|
22
|
+
export function clearAuth() {
|
|
23
|
+
if (existsSync(AUTH_FILE)) {
|
|
24
|
+
writeFileSync(AUTH_FILE, '{}');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function checkPlan(apiKey) {
|
|
28
|
+
try {
|
|
29
|
+
const response = await fetch(`${API_BASE}/v1/plan`, {
|
|
30
|
+
headers: {
|
|
31
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
32
|
+
'Content-Type': 'application/json'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
return { valid: false, plan: 'free', email: '', error: 'Invalid API key' };
|
|
37
|
+
}
|
|
38
|
+
return await response.json();
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return { valid: false, plan: 'free', email: '', error: 'Failed to connect to API' };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export async function requirePro(commandName) {
|
|
45
|
+
const config = getAuthConfig();
|
|
46
|
+
if (!config.apiKey) {
|
|
47
|
+
console.error(`\n ⚡ ${commandName} requires Skrypt Pro\n`);
|
|
48
|
+
console.error(' Get started:');
|
|
49
|
+
console.error(' 1. Sign up at https://skrypt.sh/pro');
|
|
50
|
+
console.error(' 2. Run: skrypt login\n');
|
|
51
|
+
console.error(' Or use SKRYPT_API_KEY environment variable\n');
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
// Check if we have a cached valid plan
|
|
55
|
+
if (config.plan === 'pro' && config.expiresAt) {
|
|
56
|
+
const expires = new Date(config.expiresAt);
|
|
57
|
+
if (expires > new Date()) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Verify with API
|
|
62
|
+
console.log(' Verifying Pro subscription...');
|
|
63
|
+
const result = await checkPlan(config.apiKey);
|
|
64
|
+
if (!result.valid || result.plan !== 'pro') {
|
|
65
|
+
console.error(`\n ⚡ ${commandName} requires Skrypt Pro\n`);
|
|
66
|
+
if (result.error) {
|
|
67
|
+
console.error(` Error: ${result.error}`);
|
|
68
|
+
}
|
|
69
|
+
console.error(' Upgrade at https://skrypt.sh/pro\n');
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
// Cache the result for 1 hour
|
|
73
|
+
saveAuthConfig({
|
|
74
|
+
...config,
|
|
75
|
+
plan: result.plan,
|
|
76
|
+
email: result.email,
|
|
77
|
+
expiresAt: new Date(Date.now() + 60 * 60 * 1000).toISOString()
|
|
78
|
+
});
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
// Pro commands list
|
|
82
|
+
export const PRO_COMMANDS = [
|
|
83
|
+
'monitor',
|
|
84
|
+
'autofix',
|
|
85
|
+
'heal',
|
|
86
|
+
'test',
|
|
87
|
+
'sdk',
|
|
88
|
+
'gh-action',
|
|
89
|
+
'ci',
|
|
90
|
+
'mcp'
|
|
91
|
+
];
|
|
92
|
+
export function isProCommand(command) {
|
|
93
|
+
return PRO_COMMANDS.includes(command);
|
|
94
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -14,7 +14,8 @@ import { monitorCommand } from './commands/monitor.js';
|
|
|
14
14
|
import { sdkCommand } from './commands/sdk.js';
|
|
15
15
|
import { ghActionCommand } from './commands/gh-action.js';
|
|
16
16
|
import { llmsTxtCommand } from './commands/llms-txt.js';
|
|
17
|
-
|
|
17
|
+
import { loginCommand, logoutCommand, whoamiCommand } from './commands/login.js';
|
|
18
|
+
const VERSION = '0.2.0';
|
|
18
19
|
async function checkForUpdates() {
|
|
19
20
|
try {
|
|
20
21
|
const res = await fetch('https://registry.npmjs.org/skrypt-ai/latest', {
|
|
@@ -55,4 +56,7 @@ program.addCommand(monitorCommand);
|
|
|
55
56
|
program.addCommand(sdkCommand);
|
|
56
57
|
program.addCommand(ghActionCommand);
|
|
57
58
|
program.addCommand(llmsTxtCommand);
|
|
59
|
+
program.addCommand(loginCommand);
|
|
60
|
+
program.addCommand(logoutCommand);
|
|
61
|
+
program.addCommand(whoamiCommand);
|
|
58
62
|
program.parse();
|
package/dist/commands/autofix.js
CHANGED
|
@@ -4,6 +4,7 @@ import { resolve } from 'path';
|
|
|
4
4
|
import { loadConfig, checkApiKey } from '../config/index.js';
|
|
5
5
|
import { createLLMClient } from '../llm/index.js';
|
|
6
6
|
import { autoFixExample, createTypeScriptValidator, createPythonValidator } from '../autofix/index.js';
|
|
7
|
+
import { requirePro } from '../auth/index.js';
|
|
7
8
|
export const autofixCommand = new Command('autofix')
|
|
8
9
|
.description('Auto-fix broken code examples in documentation')
|
|
9
10
|
.argument('<file>', 'Documentation file to fix (markdown/mdx)')
|
|
@@ -14,6 +15,10 @@ export const autofixCommand = new Command('autofix')
|
|
|
14
15
|
.option('--dry-run', 'Show fixes without writing')
|
|
15
16
|
.option('--language <lang>', 'Force language for validation')
|
|
16
17
|
.action(async (file, options) => {
|
|
18
|
+
// Pro feature - requires subscription
|
|
19
|
+
if (!await requirePro('autofix')) {
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
17
22
|
const config = loadConfig(options.config);
|
|
18
23
|
if (options.provider)
|
|
19
24
|
config.llm.provider = options.provider;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { existsSync, writeFileSync, mkdirSync } from 'fs';
|
|
3
3
|
import { resolve, join } from 'path';
|
|
4
|
+
import { requirePro } from '../auth/index.js';
|
|
4
5
|
const GITHUB_ACTION_WORKFLOW = `name: Skrypt Documentation Check
|
|
5
6
|
|
|
6
7
|
on:
|
|
@@ -162,6 +163,10 @@ export const ghActionCommand = new Command('gh-action')
|
|
|
162
163
|
.argument('[repo-path]', 'Repository path', '.')
|
|
163
164
|
.option('-f, --force', 'Overwrite existing workflow')
|
|
164
165
|
.action(async (repoPath, options) => {
|
|
166
|
+
// Pro feature - requires subscription
|
|
167
|
+
if (!await requirePro('gh-action')) {
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
165
170
|
const resolvedPath = resolve(repoPath);
|
|
166
171
|
const workflowDir = join(resolvedPath, '.github', 'workflows');
|
|
167
172
|
const workflowPath = join(workflowDir, 'skrypt-docs.yml');
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { saveAuthConfig, getAuthConfig, clearAuth, checkPlan } from '../auth/index.js';
|
|
3
|
+
import * as readline from 'readline';
|
|
4
|
+
function prompt(question) {
|
|
5
|
+
const rl = readline.createInterface({
|
|
6
|
+
input: process.stdin,
|
|
7
|
+
output: process.stdout
|
|
8
|
+
});
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
rl.question(question, (answer) => {
|
|
11
|
+
rl.close();
|
|
12
|
+
resolve(answer.trim());
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export const loginCommand = new Command('login')
|
|
17
|
+
.description('Login to Skrypt Pro')
|
|
18
|
+
.option('--key <api-key>', 'API key (or set SKRYPT_API_KEY env var)')
|
|
19
|
+
.action(async (options) => {
|
|
20
|
+
console.log('skrypt login\n');
|
|
21
|
+
let apiKey = options.key || process.env.SKRYPT_API_KEY;
|
|
22
|
+
if (!apiKey) {
|
|
23
|
+
console.log(' Get your API key at: https://skrypt.sh/dashboard/settings\n');
|
|
24
|
+
apiKey = await prompt(' Enter API key: ');
|
|
25
|
+
}
|
|
26
|
+
if (!apiKey) {
|
|
27
|
+
console.error(' Error: No API key provided');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
console.log('\n Verifying...');
|
|
31
|
+
const result = await checkPlan(apiKey);
|
|
32
|
+
if (!result.valid) {
|
|
33
|
+
console.error(`\n Error: ${result.error || 'Invalid API key'}`);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
saveAuthConfig({
|
|
37
|
+
apiKey,
|
|
38
|
+
email: result.email,
|
|
39
|
+
plan: result.plan,
|
|
40
|
+
expiresAt: new Date(Date.now() + 60 * 60 * 1000).toISOString()
|
|
41
|
+
});
|
|
42
|
+
console.log(`\n ✓ Logged in as ${result.email}`);
|
|
43
|
+
console.log(` Plan: ${result.plan.toUpperCase()}\n`);
|
|
44
|
+
if (result.plan === 'free') {
|
|
45
|
+
console.log(' Upgrade to Pro: https://skrypt.sh/pro\n');
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
export const logoutCommand = new Command('logout')
|
|
49
|
+
.description('Logout from Skrypt')
|
|
50
|
+
.action(async () => {
|
|
51
|
+
clearAuth();
|
|
52
|
+
console.log(' Logged out successfully\n');
|
|
53
|
+
});
|
|
54
|
+
export const whoamiCommand = new Command('whoami')
|
|
55
|
+
.description('Show current login status')
|
|
56
|
+
.action(async () => {
|
|
57
|
+
const config = getAuthConfig();
|
|
58
|
+
if (!config.apiKey) {
|
|
59
|
+
console.log(' Not logged in');
|
|
60
|
+
console.log(' Run: skrypt login\n');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
console.log(` Email: ${config.email || 'Unknown'}`);
|
|
64
|
+
console.log(` Plan: ${(config.plan || 'free').toUpperCase()}\n`);
|
|
65
|
+
});
|
package/dist/commands/mcp.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from 'fs';
|
|
3
3
|
import { resolve, join, extname, relative } from 'path';
|
|
4
4
|
import { createServer } from 'http';
|
|
5
|
+
import { requirePro } from '../auth/index.js';
|
|
5
6
|
function findMdxFiles(dir) {
|
|
6
7
|
const files = [];
|
|
7
8
|
function walk(currentDir) {
|
|
@@ -166,6 +167,10 @@ export const mcpCommand = new Command('mcp')
|
|
|
166
167
|
.option('-h, --host <host>', 'Server host', 'localhost')
|
|
167
168
|
.option('-o, --output <file>', 'Output manifest to file instead of starting server')
|
|
168
169
|
.action(async (path, options) => {
|
|
170
|
+
// Pro feature - requires subscription
|
|
171
|
+
if (!await requirePro('mcp')) {
|
|
172
|
+
process.exit(1);
|
|
173
|
+
}
|
|
169
174
|
const targetPath = resolve(path);
|
|
170
175
|
if (!existsSync(targetPath)) {
|
|
171
176
|
console.error(`Error: Path not found: ${targetPath}`);
|
package/dist/commands/monitor.js
CHANGED
|
@@ -4,6 +4,7 @@ import { existsSync, writeFileSync, readdirSync, statSync, mkdirSync } from 'fs'
|
|
|
4
4
|
import { resolve, join, dirname } from 'path';
|
|
5
5
|
import { createLLMClient } from '../llm/index.js';
|
|
6
6
|
import { loadConfig, checkApiKey } from '../config/index.js';
|
|
7
|
+
import { requirePro } from '../auth/index.js';
|
|
7
8
|
function getGitChanges(since, repoPath) {
|
|
8
9
|
const changes = [];
|
|
9
10
|
try {
|
|
@@ -177,6 +178,10 @@ export const monitorCommand = new Command('monitor')
|
|
|
177
178
|
.option('--create-pr', 'Create a GitHub PR with changes')
|
|
178
179
|
.option('--dry-run', 'Show what would be done without making changes')
|
|
179
180
|
.action(async (repoPath, options) => {
|
|
181
|
+
// Pro feature - requires subscription
|
|
182
|
+
if (!await requirePro('monitor')) {
|
|
183
|
+
process.exit(1);
|
|
184
|
+
}
|
|
180
185
|
const resolvedPath = resolve(repoPath);
|
|
181
186
|
console.log('skrypt monitor');
|
|
182
187
|
console.log(` repo: ${resolvedPath}`);
|
package/dist/commands/sdk.js
CHANGED
|
@@ -3,6 +3,7 @@ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
|
3
3
|
import { resolve, join, basename } from 'path';
|
|
4
4
|
import { createLLMClient } from '../llm/index.js';
|
|
5
5
|
import { loadConfig, checkApiKey } from '../config/index.js';
|
|
6
|
+
import { requirePro } from '../auth/index.js';
|
|
6
7
|
const SUPPORTED_LANGUAGES = ['typescript', 'python', 'go', 'ruby', 'php', 'java', 'curl', 'csharp'];
|
|
7
8
|
const LANGUAGE_TEMPLATES = {
|
|
8
9
|
typescript: `// TypeScript with fetch
|
|
@@ -222,6 +223,10 @@ export const sdkCommand = new Command('sdk')
|
|
|
222
223
|
.option('--model <name>', 'LLM model')
|
|
223
224
|
.option('--format <type>', 'Output format (markdown or json)', 'markdown')
|
|
224
225
|
.action(async (specPath, options) => {
|
|
226
|
+
// Pro feature - requires subscription
|
|
227
|
+
if (!await requirePro('sdk')) {
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
225
230
|
const resolvedSpec = resolve(specPath);
|
|
226
231
|
if (!existsSync(resolvedSpec)) {
|
|
227
232
|
console.error(`Error: Spec file not found: ${resolvedSpec}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skrypt-ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "AI-powered documentation generator with code examples",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cli.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"api"
|
|
46
46
|
],
|
|
47
47
|
"author": "",
|
|
48
|
-
"license": "
|
|
48
|
+
"license": "Elastic-2.0",
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
51
51
|
"chalk": "^5.6.2",
|