@neural-tools/core 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.
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './license';
3
+ export { logger, Logger } from './logger';
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Logger = exports.logger = void 0;
18
+ // Types
19
+ __exportStar(require("./types"), exports);
20
+ // License management
21
+ __exportStar(require("./license"), exports);
22
+ // Logger
23
+ var logger_1 = require("./logger");
24
+ Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_1.logger; } });
25
+ Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
@@ -0,0 +1,16 @@
1
+ import { License, LicenseTier } from './types';
2
+ export declare class LicenseManager {
3
+ private static instance;
4
+ private license;
5
+ private constructor();
6
+ static getInstance(): LicenseManager;
7
+ loadLicense(): Promise<License>;
8
+ saveLicense(license: License): Promise<void>;
9
+ checkFeature(feature: string): Promise<boolean>;
10
+ requireFeature(feature: string, featureName?: string): Promise<void>;
11
+ getTier(): Promise<LicenseTier>;
12
+ }
13
+ export declare const licenseManager: LicenseManager;
14
+ export declare function checkLicense(): Promise<License>;
15
+ export declare function checkFeature(feature: string): Promise<boolean>;
16
+ export declare function requireFeature(feature: string, featureName?: string): Promise<void>;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.licenseManager = exports.LicenseManager = void 0;
7
+ exports.checkLicense = checkLicense;
8
+ exports.checkFeature = checkFeature;
9
+ exports.requireFeature = requireFeature;
10
+ const promises_1 = __importDefault(require("fs/promises"));
11
+ const path_1 = __importDefault(require("path"));
12
+ const os_1 = __importDefault(require("os"));
13
+ const types_1 = require("./types");
14
+ const LICENSE_FILE = path_1.default.join(os_1.default.homedir(), '.ai-toolkit', 'license.json');
15
+ class LicenseManager {
16
+ static instance;
17
+ license = null;
18
+ constructor() { }
19
+ static getInstance() {
20
+ if (!LicenseManager.instance) {
21
+ LicenseManager.instance = new LicenseManager();
22
+ }
23
+ return LicenseManager.instance;
24
+ }
25
+ async loadLicense() {
26
+ if (this.license) {
27
+ return this.license;
28
+ }
29
+ try {
30
+ const licenseData = await promises_1.default.readFile(LICENSE_FILE, 'utf-8');
31
+ const parsed = JSON.parse(licenseData);
32
+ this.license = types_1.LicenseSchema.parse(parsed);
33
+ // Check if license is expired
34
+ if (this.license.expiresAt) {
35
+ const expiresAt = new Date(this.license.expiresAt);
36
+ if (expiresAt < new Date()) {
37
+ throw new Error('License has expired');
38
+ }
39
+ }
40
+ return this.license;
41
+ }
42
+ catch (error) {
43
+ // Default to free tier if no license found
44
+ this.license = {
45
+ tier: types_1.LicenseTier.FREE,
46
+ features: ['mcp-generation', 'claude-commands', 'basic-templates']
47
+ };
48
+ return this.license;
49
+ }
50
+ }
51
+ async saveLicense(license) {
52
+ const validated = types_1.LicenseSchema.parse(license);
53
+ const licenseDir = path_1.default.dirname(LICENSE_FILE);
54
+ await promises_1.default.mkdir(licenseDir, { recursive: true });
55
+ await promises_1.default.writeFile(LICENSE_FILE, JSON.stringify(validated, null, 2), 'utf-8');
56
+ this.license = validated;
57
+ }
58
+ async checkFeature(feature) {
59
+ const license = await this.loadLicense();
60
+ // Free tier features
61
+ const freeTierFeatures = [
62
+ 'mcp-generation',
63
+ 'claude-commands',
64
+ 'basic-templates',
65
+ 'local-development'
66
+ ];
67
+ // Pro tier features
68
+ const proTierFeatures = [
69
+ ...freeTierFeatures,
70
+ 'vector-db',
71
+ 'semantic-cache',
72
+ 'fine-tuning',
73
+ 'cloud-deployment',
74
+ 'premium-templates',
75
+ 'github-automation'
76
+ ];
77
+ // Enterprise tier features
78
+ const enterpriseTierFeatures = [
79
+ ...proTierFeatures,
80
+ 'white-label',
81
+ 'custom-integrations',
82
+ 'priority-support',
83
+ 'sla-guarantee'
84
+ ];
85
+ switch (license.tier) {
86
+ case types_1.LicenseTier.FREE:
87
+ return freeTierFeatures.includes(feature) || license.features.includes(feature);
88
+ case types_1.LicenseTier.PRO:
89
+ return proTierFeatures.includes(feature) || license.features.includes(feature);
90
+ case types_1.LicenseTier.ENTERPRISE:
91
+ return enterpriseTierFeatures.includes(feature) || license.features.includes(feature);
92
+ default:
93
+ return freeTierFeatures.includes(feature);
94
+ }
95
+ }
96
+ async requireFeature(feature, featureName) {
97
+ const hasFeature = await this.checkFeature(feature);
98
+ if (!hasFeature) {
99
+ const displayName = featureName || feature;
100
+ throw new Error(`Feature "${displayName}" requires a Pro or Enterprise license.\n` +
101
+ `Visit https://ai-toolkit.dev/pricing to upgrade.`);
102
+ }
103
+ }
104
+ async getTier() {
105
+ const license = await this.loadLicense();
106
+ return license.tier;
107
+ }
108
+ }
109
+ exports.LicenseManager = LicenseManager;
110
+ exports.licenseManager = LicenseManager.getInstance();
111
+ // Convenience functions
112
+ async function checkLicense() {
113
+ return exports.licenseManager.loadLicense();
114
+ }
115
+ async function checkFeature(feature) {
116
+ return exports.licenseManager.checkFeature(feature);
117
+ }
118
+ async function requireFeature(feature, featureName) {
119
+ return exports.licenseManager.requireFeature(feature, featureName);
120
+ }
@@ -0,0 +1,17 @@
1
+ export declare class Logger {
2
+ private spinner;
3
+ info(message: string): void;
4
+ success(message: string): void;
5
+ warn(message: string): void;
6
+ error(message: string): void;
7
+ debug(message: string): void;
8
+ startSpinner(message: string): void;
9
+ succeedSpinner(message?: string): void;
10
+ failSpinner(message?: string): void;
11
+ updateSpinner(message: string): void;
12
+ log(message: string): void;
13
+ newline(): void;
14
+ header(message: string): void;
15
+ section(title: string, content: string[]): void;
16
+ }
17
+ export declare const logger: Logger;
package/dist/logger.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.logger = exports.Logger = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const ora_1 = __importDefault(require("ora"));
9
+ class Logger {
10
+ spinner = null;
11
+ info(message) {
12
+ console.log(chalk_1.default.blue('ℹ'), message);
13
+ }
14
+ success(message) {
15
+ console.log(chalk_1.default.green('✓'), message);
16
+ }
17
+ warn(message) {
18
+ console.log(chalk_1.default.yellow('⚠'), message);
19
+ }
20
+ error(message) {
21
+ console.log(chalk_1.default.red('✗'), message);
22
+ }
23
+ debug(message) {
24
+ if (process.env.DEBUG) {
25
+ console.log(chalk_1.default.gray('→'), message);
26
+ }
27
+ }
28
+ startSpinner(message) {
29
+ this.spinner = (0, ora_1.default)(message).start();
30
+ }
31
+ succeedSpinner(message) {
32
+ if (this.spinner) {
33
+ this.spinner.succeed(message);
34
+ this.spinner = null;
35
+ }
36
+ }
37
+ failSpinner(message) {
38
+ if (this.spinner) {
39
+ this.spinner.fail(message);
40
+ this.spinner = null;
41
+ }
42
+ }
43
+ updateSpinner(message) {
44
+ if (this.spinner) {
45
+ this.spinner.text = message;
46
+ }
47
+ }
48
+ log(message) {
49
+ console.log(message);
50
+ }
51
+ newline() {
52
+ console.log();
53
+ }
54
+ header(message) {
55
+ console.log();
56
+ console.log(chalk_1.default.bold.cyan(message));
57
+ console.log(chalk_1.default.cyan('─'.repeat(message.length)));
58
+ }
59
+ section(title, content) {
60
+ this.header(title);
61
+ content.forEach(line => this.log(` ${line}`));
62
+ this.newline();
63
+ }
64
+ }
65
+ exports.Logger = Logger;
66
+ exports.logger = new Logger();
@@ -0,0 +1,133 @@
1
+ import { z } from 'zod';
2
+ export declare enum LicenseTier {
3
+ FREE = "free",
4
+ PRO = "pro",
5
+ ENTERPRISE = "enterprise"
6
+ }
7
+ export declare const LicenseSchema: z.ZodObject<{
8
+ tier: z.ZodNativeEnum<typeof LicenseTier>;
9
+ email: z.ZodOptional<z.ZodString>;
10
+ key: z.ZodOptional<z.ZodString>;
11
+ expiresAt: z.ZodOptional<z.ZodString>;
12
+ features: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
13
+ }, "strip", z.ZodTypeAny, {
14
+ tier: LicenseTier;
15
+ features: string[];
16
+ email?: string | undefined;
17
+ key?: string | undefined;
18
+ expiresAt?: string | undefined;
19
+ }, {
20
+ tier: LicenseTier;
21
+ email?: string | undefined;
22
+ key?: string | undefined;
23
+ expiresAt?: string | undefined;
24
+ features?: string[] | undefined;
25
+ }>;
26
+ export type License = z.infer<typeof LicenseSchema>;
27
+ export declare const MCPConfigSchema: z.ZodObject<{
28
+ name: z.ZodString;
29
+ description: z.ZodString;
30
+ version: z.ZodString;
31
+ author: z.ZodOptional<z.ZodString>;
32
+ homepage: z.ZodOptional<z.ZodString>;
33
+ repository: z.ZodOptional<z.ZodString>;
34
+ license: z.ZodDefault<z.ZodString>;
35
+ fastmcp: z.ZodOptional<z.ZodObject<{
36
+ tools: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
37
+ prompts: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
38
+ resources: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ tools: string[];
41
+ prompts: string[];
42
+ resources: string[];
43
+ }, {
44
+ tools?: string[] | undefined;
45
+ prompts?: string[] | undefined;
46
+ resources?: string[] | undefined;
47
+ }>>;
48
+ }, "strip", z.ZodTypeAny, {
49
+ name: string;
50
+ description: string;
51
+ version: string;
52
+ license: string;
53
+ author?: string | undefined;
54
+ homepage?: string | undefined;
55
+ repository?: string | undefined;
56
+ fastmcp?: {
57
+ tools: string[];
58
+ prompts: string[];
59
+ resources: string[];
60
+ } | undefined;
61
+ }, {
62
+ name: string;
63
+ description: string;
64
+ version: string;
65
+ author?: string | undefined;
66
+ homepage?: string | undefined;
67
+ repository?: string | undefined;
68
+ license?: string | undefined;
69
+ fastmcp?: {
70
+ tools?: string[] | undefined;
71
+ prompts?: string[] | undefined;
72
+ resources?: string[] | undefined;
73
+ } | undefined;
74
+ }>;
75
+ export type MCPConfig = z.infer<typeof MCPConfigSchema>;
76
+ export declare const ClaudeCommandConfigSchema: z.ZodObject<{
77
+ name: z.ZodString;
78
+ description: z.ZodString;
79
+ argumentHint: z.ZodOptional<z.ZodString>;
80
+ allowedTools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
81
+ content: z.ZodString;
82
+ }, "strip", z.ZodTypeAny, {
83
+ name: string;
84
+ description: string;
85
+ content: string;
86
+ argumentHint?: string | undefined;
87
+ allowedTools?: string[] | undefined;
88
+ }, {
89
+ name: string;
90
+ description: string;
91
+ content: string;
92
+ argumentHint?: string | undefined;
93
+ allowedTools?: string[] | undefined;
94
+ }>;
95
+ export type ClaudeCommandConfig = z.infer<typeof ClaudeCommandConfigSchema>;
96
+ export interface GeneratorOptions {
97
+ name: string;
98
+ description?: string;
99
+ outputDir?: string;
100
+ template?: string;
101
+ dryRun?: boolean;
102
+ }
103
+ export interface MCPGeneratorOptions extends GeneratorOptions {
104
+ fastmcp?: boolean;
105
+ cicd?: 'github' | 'harness' | 'none';
106
+ deployment?: 'aws' | 'gcp' | 'none';
107
+ }
108
+ export interface ClaudeCommandGeneratorOptions extends GeneratorOptions {
109
+ arguments?: string[];
110
+ allowedTools?: string[];
111
+ installGlobally?: boolean;
112
+ }
113
+ export interface VectorDBConfig {
114
+ provider: 'pinecone' | 'qdrant' | 'chromadb' | 'local';
115
+ apiKey?: string;
116
+ endpoint?: string;
117
+ dimension?: number;
118
+ metric?: 'cosine' | 'euclidean' | 'dotproduct';
119
+ }
120
+ export interface SemanticCacheConfig {
121
+ enabled: boolean;
122
+ ttl?: number;
123
+ similarityThreshold?: number;
124
+ vectorDB?: VectorDBConfig;
125
+ }
126
+ export interface FineTuneConfig {
127
+ provider: 'openai' | 'anthropic' | 'custom';
128
+ model: string;
129
+ datasetPath: string;
130
+ validationSplit?: number;
131
+ epochs?: number;
132
+ learningRate?: number;
133
+ }
package/dist/types.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClaudeCommandConfigSchema = exports.MCPConfigSchema = exports.LicenseSchema = exports.LicenseTier = void 0;
4
+ const zod_1 = require("zod");
5
+ // License tiers
6
+ var LicenseTier;
7
+ (function (LicenseTier) {
8
+ LicenseTier["FREE"] = "free";
9
+ LicenseTier["PRO"] = "pro";
10
+ LicenseTier["ENTERPRISE"] = "enterprise";
11
+ })(LicenseTier || (exports.LicenseTier = LicenseTier = {}));
12
+ // License schema
13
+ exports.LicenseSchema = zod_1.z.object({
14
+ tier: zod_1.z.nativeEnum(LicenseTier),
15
+ email: zod_1.z.string().email().optional(),
16
+ key: zod_1.z.string().optional(),
17
+ expiresAt: zod_1.z.string().datetime().optional(),
18
+ features: zod_1.z.array(zod_1.z.string()).default([])
19
+ });
20
+ // MCP Configuration
21
+ exports.MCPConfigSchema = zod_1.z.object({
22
+ name: zod_1.z.string(),
23
+ description: zod_1.z.string(),
24
+ version: zod_1.z.string(),
25
+ author: zod_1.z.string().optional(),
26
+ homepage: zod_1.z.string().url().optional(),
27
+ repository: zod_1.z.string().url().optional(),
28
+ license: zod_1.z.string().default('MIT'),
29
+ fastmcp: zod_1.z.object({
30
+ tools: zod_1.z.array(zod_1.z.string()).default([]),
31
+ prompts: zod_1.z.array(zod_1.z.string()).default([]),
32
+ resources: zod_1.z.array(zod_1.z.string()).default([])
33
+ }).optional()
34
+ });
35
+ // Claude Command Configuration
36
+ exports.ClaudeCommandConfigSchema = zod_1.z.object({
37
+ name: zod_1.z.string(),
38
+ description: zod_1.z.string(),
39
+ argumentHint: zod_1.z.string().optional(),
40
+ allowedTools: zod_1.z.array(zod_1.z.string()).optional(),
41
+ content: zod_1.z.string()
42
+ });
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@neural-tools/core",
3
+ "version": "0.1.0",
4
+ "description": "Core utilities and types for Neural Tools",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "license": "SEE LICENSE IN ../../LICENSE.md",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/yourusername/ai-toolkit.git",
14
+ "directory": "packages/core"
15
+ },
16
+ "dependencies": {
17
+ "zod": "^3.22.4",
18
+ "chalk": "^5.3.0",
19
+ "ora": "^8.0.1"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^20.11.5",
23
+ "typescript": "^5.3.3"
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "dev": "tsc --watch",
31
+ "clean": "rm -rf dist",
32
+ "test": "echo 'Tests coming soon'"
33
+ }
34
+ }