Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/cli/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode
.internals
launch.json
oclif.manifest.json
oclif.manifest.json
profiling/
56 changes: 56 additions & 0 deletions packages/cli/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Source code
src/
tests/
*.ts
*.tsx
tsconfig*.json
rollup.config.js

# Build tools and dependencies
node_modules/
.pnpm-lock.yaml
package-lock.json
yarn.lock

# Development files
.env*
.vscode/
.idea/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Development configs
knip.json
typedoc.json
.eslintrc*
.prettierrc*

# Distribution files (we only want the built ones)
dist/types/
dist/**/*.map

# Source maps (optional - remove if you want to include them)
*.map

# Build artifacts we don't need
profiling/

# Only include what's necessary:
# - dist/*.cjs files (bundled CLI)
# - dist/commands/*.cjs (bundled commands)
# - dist/hooks/*.cjs (bundled hooks)
# - oclif.manifest.json
# - theme.json
# - README.md
# - CHANGELOG.md
22 changes: 11 additions & 11 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smythos/cli",
"version": "0.2.20",
"version": "0.2.21",
"description": "SmythOS SRE Command Line Interface",
"keywords": [
"smythos",
Expand All @@ -13,14 +13,14 @@
],
"author": "Alaa-eddine KADDOURI",
"license": "MIT",
"main": "dist/index.js",
"main": "dist/index.cjs",
"types": "dist/types/index.d.ts",
"bin": {
"sre": "dist/index.js"
"sre": "dist/index.cjs"
},
"exports": {
".": {
"import": "./dist/index.js",
"import": "./dist/index.cjs",
"types": "./dist/types/index.d.ts"
}
},
Expand All @@ -47,7 +47,7 @@
"scripts": {
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist/types -p tsconfig.dts.json",
"build:bundle": "cross-env BUILD=dev rollup -c",
"build": "pnpm run build:bundle && pnpm run oclif:manifest && pnpm run build:types",
"build": "pnpm run build:bundle && pnpm run oclif:manifest",
"dev": "rollup -c -w",
"lint": "echo 'Lint script not implemented'",
"test": "echo 'Test script not implemented'",
Expand All @@ -62,9 +62,8 @@
"commands": "./dist/commands",
"topicSeparator": " ",
"theme": "theme.json",
"helpClass": "./dist/help",
"hooks": {
"preparse": "./dist/hooks/preparse.js"
"preparse": "./dist/hooks/preparse.cjs"
},
"topics": {
"agent": {
Expand All @@ -79,7 +78,10 @@
}
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.12.1",

},
"devDependencies": {
"@modelcontextprotocol/sdk": "^1.14.0",
"@oclif/core": "^4.3.3",
"@smythos/sdk": "workspace:*",
"@smythos/sre": "workspace:*",
Expand All @@ -91,9 +93,7 @@
"inquirer": "^9.2.15",
"log-update": "^6.1.0",
"ora": "^8.2.0",
"update-notifier": "^7.0.0"
},
"devDependencies": {
"update-notifier": "^7.0.0",
"@oclif/plugin-help": "^6.2.21",
"@oclif/test": "^3.1.9",
"@rollup/plugin-commonjs": "^28.0.3",
Expand Down
122 changes: 78 additions & 44 deletions packages/cli/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { typescriptPaths } from 'rollup-plugin-typescript-paths';

import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import fs from 'fs';

const isProduction = process.env.BUILD === 'prod';

Expand Down Expand Up @@ -52,54 +53,38 @@ const config = {
],
};

const devConfig = {
input: './src/index.ts',
const isCJS = true;
// Zero-dependency standalone bundle configuration (No optimizations)
const zeroDepConfig = {
input: {
index: 'src/index.ts',
'commands/agent': 'src/commands/agent/agent.index.ts',
'commands/create': 'src/commands/create/create.index.ts',
'commands/update': 'src/commands/update.ts',
'hooks/preparse': 'src/hooks/preparse.ts',
},
output: {
file: './dist/cli.cjs', // CommonJS output
format: 'cjs', // Specify the CommonJS format
sourcemap: true,
inlineDynamicImports: true, // Inline all dynamic imports into one file
dir: 'dist',
format: isCJS ? 'cjs' : 'es',
sourcemap: false, // Enable sourcemaps for debugging
banner: '#!/usr/bin/env node',
entryFileNames: isCJS ? '[name].cjs' : '[name].js',
chunkFileNames: isCJS ? 'chunks/[name].cjs' : 'chunks/[name].js', // Use predictable chunk names
inlineDynamicImports: false, // Keep separate files
exports: 'auto', // Handle mixed exports
// manualChunks: (id) => {
// if (id.includes('node_modules')) {
// return 'vendor';
// }
// },
},
plugins: [
resolve({
browser: false, // Explicitly disable browser field resolution
preferBuiltins: true, // Prefer Node.js built-in modules
mainFields: ['main', 'module'], // Prioritize 'main' field for Node.js packages
extensions: ['.js', '.ts', '.json'], // Resolve these extensions
exportConditions: ['node'], // Use Node.js export conditions
}),
commonjs({
// Handle mixed ES modules and CommonJS
transformMixedEsModules: true,
// Ignore browser-specific globals
ignore: ['electron'],
}),
json(),

typescriptPaths({
tsconfig: './tsconfig.json',
preserveExtensions: true,
nonRelative: false,
}),
esbuild({
sourceMap: true,
minify: false,
treeShaking: false,
target: 'node18',
platform: 'node', // Explicitly set platform to node
define: {
// Define Node.js environment
'process.env.NODE_ENV': '"development"',
global: 'globalThis',
},
}),
sourcemaps(),
],
// Only keep essential Node.js built-ins external
external: [
// Keep Node.js built-ins external
'fs',
'fs/promises',
'path',
'path/posix',
'path/win32',
'os',
'util',
'crypto',
Expand Down Expand Up @@ -128,10 +113,53 @@ const devConfig = {
'worker_threads',
'perf_hooks',
'async_hooks',
'inspector',
'v8',
'constants',
'assert',
'process',
],
plugins: [
deleteFolder('dist'),
colorfulLogs('CLI Zero-Dep Builder'),
resolve({
browser: false,
preferBuiltins: true,
mainFields: ['module', 'main'],
extensions: ['.js', '.ts', '.json'],
exportConditions: isCJS ? ['node'] : ['node', 'import'],
}),
commonjs({
transformMixedEsModules: true,
ignore: ['electron'],
requireReturnsDefault: 'auto',
ignoreDynamicRequires: isCJS, // Handle dynamic requires properly
dynamicRequireTargets: ['node_modules/**/*.js'],
}),
json(),
typescriptPaths({
tsconfig: './tsconfig.json',
preserveExtensions: true,
nonRelative: false,
}),
esbuild({
sourceMap: false,
minify: true, // No minification
treeShaking: true, // No tree-shaking
target: 'node18',
platform: 'node',
format: isCJS ? undefined : 'esm',
define: {
'process.env.NODE_ENV': '"development"',
global: 'globalThis',
},
keepNames: true, // Keep all names
}),
// No terser plugin - no compression at all
],
};

export default config;
export default zeroDepConfig;

//#region [Custom Plugins] =====================================================

Expand All @@ -151,6 +179,12 @@ const colors = {
bgBlue: '\x1b[44m',
};

function deleteFolder(folderPath) {
if (fs.existsSync(folderPath)) {
fs.rmSync(folderPath, { recursive: true });
}
}

// Custom colorful logging plugin
function colorfulLogs(title = 'CLI Builder') {
function formatBytes(bytes, decimals = 2) {
Expand Down Expand Up @@ -214,8 +248,8 @@ function colorfulLogs(title = 'CLI Builder') {
return null;
},
transform(code, id) {
processedFiles++;
if (!id.includes('node_modules')) {
processedFiles++;
const relativePath = path.relative(process.cwd(), id);
currentFile = relativePath;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
* SRE CLI Entry Point
* Oclif CLI runner with better error handling
*/
import { suppressWarnings } from './warnings-override';

suppressWarnings();

import { run } from '@oclif/core';
import chalk from 'chalk';
Expand Down
53 changes: 53 additions & 0 deletions packages/cli/src/warnings-override.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Suppress runtime warnings
process.env.NODE_NO_WARNINGS = '1';
process.env.OCLIF_SKIP_TYPESCRIPT = '1';
process.env.OCLIF_COMPILATION = 'false';

// Override console methods to suppress warnings
const originalConsoleWarn = console.warn;
const originalConsoleError = console.error;
const originalConsoleLog = console.log;

export function suppressWarnings() {
console.warn = (...args: any[]) => {
const message = args.join(' ');
if (message.includes('Could not find typescript') || message.includes('punycode') || message.includes('DEP0040')) {
return;
}
originalConsoleWarn.apply(console, args);
};

console.error = (...args: any[]) => {
const message = args.join(' ');
if (message.includes('Could not find typescript') || message.includes('punycode') || message.includes('DEP0040')) {
return;
}
originalConsoleError.apply(console, args);
};

console.log = (...args: any[]) => {
const message = args.join(' ');
if (message.includes('Could not find typescript') || message.includes('punycode') || message.includes('DEP0040')) {
return;
}
originalConsoleLog.apply(console, args);
};

// Override stdout.write to suppress TypeScript warnings
const originalStdoutWrite = process.stdout.write;
process.stdout.write = function (chunk: any, encoding?: any, callback?: any): boolean {
if (typeof chunk === 'string' && chunk.includes('Could not find typescript')) {
return true;
}
return originalStdoutWrite.call(this, chunk, encoding, callback);
};

// Override stderr.write to suppress punycode warnings
const originalStderrWrite = process.stderr.write;
process.stderr.write = function (chunk: any, encoding?: any, callback?: any): boolean {
if (typeof chunk === 'string' && (chunk.includes('punycode') || chunk.includes('DEP0040'))) {
return true;
}
return originalStderrWrite.call(this, chunk, encoding, callback);
};
}
4 changes: 3 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smythos/sre",
"version": "1.5.24",
"version": "1.5.25",
"description": "Smyth Runtime Environment",
"author": "Alaa-eddine KADDOURI",
"license": "MIT",
Expand Down Expand Up @@ -30,7 +30,9 @@
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@rollup/plugin-commonjs": "^28.0.3",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.3.1",
"@rollup/pluginutils": "^5.1.0",
"@types/express": "^4.17.23",
"@types/lodash": "^4.17.10",
Expand Down
Loading