Skip to content

Commit 8418450

Browse files
committed
Merge branch 'dev' of https://github.com/SmythOS/sre into feat/core/ecma-sandbox-connector-implementation
2 parents f071e40 + 5c76029 commit 8418450

File tree

19 files changed

+581
-166
lines changed

19 files changed

+581
-166
lines changed

examples/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.profiling/
2+
.clinic/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sre",
3-
"version": "0.1.1",
3+
"version": "0.1.3",
44
"description": "",
55
"author": "Alaa-eddine KADDOURI",
66
"license": "MIT",

packages/cli/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.vscode
22
.internals
33
launch.json
4-
oclif.manifest.json
4+
oclif.manifest.json
5+
profiling/

packages/cli/.npmignore

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Source code
2+
src/
3+
tests/
4+
*.ts
5+
*.tsx
6+
tsconfig*.json
7+
rollup.config.js
8+
9+
# Build tools and dependencies
10+
node_modules/
11+
.pnpm-lock.yaml
12+
package-lock.json
13+
yarn.lock
14+
15+
# Development files
16+
.env*
17+
.vscode/
18+
.idea/
19+
*.log
20+
npm-debug.log*
21+
yarn-debug.log*
22+
yarn-error.log*
23+
24+
# OS generated files
25+
.DS_Store
26+
.DS_Store?
27+
._*
28+
.Spotlight-V100
29+
.Trashes
30+
ehthumbs.db
31+
Thumbs.db
32+
33+
# Development configs
34+
knip.json
35+
typedoc.json
36+
.eslintrc*
37+
.prettierrc*
38+
39+
# Distribution files (we only want the built ones)
40+
dist/types/
41+
dist/**/*.map
42+
43+
# Source maps (optional - remove if you want to include them)
44+
*.map
45+
46+
# Build artifacts we don't need
47+
profiling/
48+
49+
# Only include what's necessary:
50+
# - dist/*.cjs files (bundled CLI)
51+
# - dist/commands/*.cjs (bundled commands)
52+
# - dist/hooks/*.cjs (bundled hooks)
53+
# - oclif.manifest.json
54+
# - theme.json
55+
# - README.md
56+
# - CHANGELOG.md

packages/cli/package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@smythos/cli",
3-
"version": "0.2.20",
3+
"version": "0.2.21",
44
"description": "SmythOS SRE Command Line Interface",
55
"keywords": [
66
"smythos",
@@ -13,14 +13,14 @@
1313
],
1414
"author": "Alaa-eddine KADDOURI",
1515
"license": "MIT",
16-
"main": "dist/index.js",
16+
"main": "dist/index.cjs",
1717
"types": "dist/types/index.d.ts",
1818
"bin": {
19-
"sre": "dist/index.js"
19+
"sre": "dist/index.cjs"
2020
},
2121
"exports": {
2222
".": {
23-
"import": "./dist/index.js",
23+
"import": "./dist/index.cjs",
2424
"types": "./dist/types/index.d.ts"
2525
}
2626
},
@@ -47,7 +47,7 @@
4747
"scripts": {
4848
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist/types -p tsconfig.dts.json",
4949
"build:bundle": "cross-env BUILD=dev rollup -c",
50-
"build": "pnpm run build:bundle && pnpm run oclif:manifest && pnpm run build:types",
50+
"build": "pnpm run build:bundle && pnpm run oclif:manifest",
5151
"dev": "rollup -c -w",
5252
"lint": "echo 'Lint script not implemented'",
5353
"test": "echo 'Test script not implemented'",
@@ -62,9 +62,8 @@
6262
"commands": "./dist/commands",
6363
"topicSeparator": " ",
6464
"theme": "theme.json",
65-
"helpClass": "./dist/help",
6665
"hooks": {
67-
"preparse": "./dist/hooks/preparse.js"
66+
"preparse": "./dist/hooks/preparse.cjs"
6867
},
6968
"topics": {
7069
"agent": {
@@ -79,7 +78,10 @@
7978
}
8079
},
8180
"dependencies": {
82-
"@modelcontextprotocol/sdk": "^1.12.1",
81+
82+
},
83+
"devDependencies": {
84+
"@modelcontextprotocol/sdk": "^1.14.0",
8385
"@oclif/core": "^4.3.3",
8486
"@smythos/sdk": "workspace:*",
8587
"@smythos/sre": "workspace:*",
@@ -91,9 +93,7 @@
9193
"inquirer": "^9.2.15",
9294
"log-update": "^6.1.0",
9395
"ora": "^8.2.0",
94-
"update-notifier": "^7.0.0"
95-
},
96-
"devDependencies": {
96+
"update-notifier": "^7.0.0",
9797
"@oclif/plugin-help": "^6.2.21",
9898
"@oclif/test": "^3.1.9",
9999
"@rollup/plugin-commonjs": "^28.0.3",

packages/cli/rollup.config.js

Lines changed: 78 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { typescriptPaths } from 'rollup-plugin-typescript-paths';
77

88
import commonjs from '@rollup/plugin-commonjs';
99
import resolve from '@rollup/plugin-node-resolve';
10+
import fs from 'fs';
1011

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

@@ -52,54 +53,38 @@ const config = {
5253
],
5354
};
5455

55-
const devConfig = {
56-
input: './src/index.ts',
56+
const isCJS = true;
57+
// Zero-dependency standalone bundle configuration (No optimizations)
58+
const zeroDepConfig = {
59+
input: {
60+
index: 'src/index.ts',
61+
'commands/agent': 'src/commands/agent/agent.index.ts',
62+
'commands/create': 'src/commands/create/create.index.ts',
63+
'commands/update': 'src/commands/update.ts',
64+
'hooks/preparse': 'src/hooks/preparse.ts',
65+
},
5766
output: {
58-
file: './dist/cli.cjs', // CommonJS output
59-
format: 'cjs', // Specify the CommonJS format
60-
sourcemap: true,
61-
inlineDynamicImports: true, // Inline all dynamic imports into one file
67+
dir: 'dist',
68+
format: isCJS ? 'cjs' : 'es',
69+
sourcemap: false, // Enable sourcemaps for debugging
6270
banner: '#!/usr/bin/env node',
71+
entryFileNames: isCJS ? '[name].cjs' : '[name].js',
72+
chunkFileNames: isCJS ? 'chunks/[name].cjs' : 'chunks/[name].js', // Use predictable chunk names
73+
inlineDynamicImports: false, // Keep separate files
74+
exports: 'auto', // Handle mixed exports
75+
// manualChunks: (id) => {
76+
// if (id.includes('node_modules')) {
77+
// return 'vendor';
78+
// }
79+
// },
6380
},
64-
plugins: [
65-
resolve({
66-
browser: false, // Explicitly disable browser field resolution
67-
preferBuiltins: true, // Prefer Node.js built-in modules
68-
mainFields: ['main', 'module'], // Prioritize 'main' field for Node.js packages
69-
extensions: ['.js', '.ts', '.json'], // Resolve these extensions
70-
exportConditions: ['node'], // Use Node.js export conditions
71-
}),
72-
commonjs({
73-
// Handle mixed ES modules and CommonJS
74-
transformMixedEsModules: true,
75-
// Ignore browser-specific globals
76-
ignore: ['electron'],
77-
}),
78-
json(),
79-
80-
typescriptPaths({
81-
tsconfig: './tsconfig.json',
82-
preserveExtensions: true,
83-
nonRelative: false,
84-
}),
85-
esbuild({
86-
sourceMap: true,
87-
minify: false,
88-
treeShaking: false,
89-
target: 'node18',
90-
platform: 'node', // Explicitly set platform to node
91-
define: {
92-
// Define Node.js environment
93-
'process.env.NODE_ENV': '"development"',
94-
global: 'globalThis',
95-
},
96-
}),
97-
sourcemaps(),
98-
],
81+
// Only keep essential Node.js built-ins external
9982
external: [
100-
// Keep Node.js built-ins external
10183
'fs',
84+
'fs/promises',
10285
'path',
86+
'path/posix',
87+
'path/win32',
10388
'os',
10489
'util',
10590
'crypto',
@@ -128,10 +113,53 @@ const devConfig = {
128113
'worker_threads',
129114
'perf_hooks',
130115
'async_hooks',
116+
'inspector',
117+
'v8',
118+
'constants',
119+
'assert',
120+
'process',
121+
],
122+
plugins: [
123+
deleteFolder('dist'),
124+
colorfulLogs('CLI Zero-Dep Builder'),
125+
resolve({
126+
browser: false,
127+
preferBuiltins: true,
128+
mainFields: ['module', 'main'],
129+
extensions: ['.js', '.ts', '.json'],
130+
exportConditions: isCJS ? ['node'] : ['node', 'import'],
131+
}),
132+
commonjs({
133+
transformMixedEsModules: true,
134+
ignore: ['electron'],
135+
requireReturnsDefault: 'auto',
136+
ignoreDynamicRequires: isCJS, // Handle dynamic requires properly
137+
dynamicRequireTargets: ['node_modules/**/*.js'],
138+
}),
139+
json(),
140+
typescriptPaths({
141+
tsconfig: './tsconfig.json',
142+
preserveExtensions: true,
143+
nonRelative: false,
144+
}),
145+
esbuild({
146+
sourceMap: false,
147+
minify: true, // No minification
148+
treeShaking: true, // No tree-shaking
149+
target: 'node18',
150+
platform: 'node',
151+
format: isCJS ? undefined : 'esm',
152+
define: {
153+
'process.env.NODE_ENV': '"development"',
154+
global: 'globalThis',
155+
},
156+
keepNames: true, // Keep all names
157+
}),
158+
// No terser plugin - no compression at all
131159
],
132160
};
133161

134-
export default config;
162+
export default zeroDepConfig;
135163

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

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

182+
function deleteFolder(folderPath) {
183+
if (fs.existsSync(folderPath)) {
184+
fs.rmSync(folderPath, { recursive: true });
185+
}
186+
}
187+
154188
// Custom colorful logging plugin
155189
function colorfulLogs(title = 'CLI Builder') {
156190
function formatBytes(bytes, decimals = 2) {
@@ -214,8 +248,8 @@ function colorfulLogs(title = 'CLI Builder') {
214248
return null;
215249
},
216250
transform(code, id) {
251+
processedFiles++;
217252
if (!id.includes('node_modules')) {
218-
processedFiles++;
219253
const relativePath = path.relative(process.cwd(), id);
220254
currentFile = relativePath;
221255
}

packages/cli/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
* SRE CLI Entry Point
33
* Oclif CLI runner with better error handling
44
*/
5+
import { suppressWarnings } from './warnings-override';
6+
7+
suppressWarnings();
58

69
import { run } from '@oclif/core';
710
import chalk from 'chalk';
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Suppress runtime warnings
2+
process.env.NODE_NO_WARNINGS = '1';
3+
process.env.OCLIF_SKIP_TYPESCRIPT = '1';
4+
process.env.OCLIF_COMPILATION = 'false';
5+
6+
// Override console methods to suppress warnings
7+
const originalConsoleWarn = console.warn;
8+
const originalConsoleError = console.error;
9+
const originalConsoleLog = console.log;
10+
11+
export function suppressWarnings() {
12+
console.warn = (...args: any[]) => {
13+
const message = args.join(' ');
14+
if (message.includes('Could not find typescript') || message.includes('punycode') || message.includes('DEP0040')) {
15+
return;
16+
}
17+
originalConsoleWarn.apply(console, args);
18+
};
19+
20+
console.error = (...args: any[]) => {
21+
const message = args.join(' ');
22+
if (message.includes('Could not find typescript') || message.includes('punycode') || message.includes('DEP0040')) {
23+
return;
24+
}
25+
originalConsoleError.apply(console, args);
26+
};
27+
28+
console.log = (...args: any[]) => {
29+
const message = args.join(' ');
30+
if (message.includes('Could not find typescript') || message.includes('punycode') || message.includes('DEP0040')) {
31+
return;
32+
}
33+
originalConsoleLog.apply(console, args);
34+
};
35+
36+
// Override stdout.write to suppress TypeScript warnings
37+
const originalStdoutWrite = process.stdout.write;
38+
process.stdout.write = function (chunk: any, encoding?: any, callback?: any): boolean {
39+
if (typeof chunk === 'string' && chunk.includes('Could not find typescript')) {
40+
return true;
41+
}
42+
return originalStdoutWrite.call(this, chunk, encoding, callback);
43+
};
44+
45+
// Override stderr.write to suppress punycode warnings
46+
const originalStderrWrite = process.stderr.write;
47+
process.stderr.write = function (chunk: any, encoding?: any, callback?: any): boolean {
48+
if (typeof chunk === 'string' && (chunk.includes('punycode') || chunk.includes('DEP0040'))) {
49+
return true;
50+
}
51+
return originalStderrWrite.call(this, chunk, encoding, callback);
52+
};
53+
}

packages/core/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@smythos/sre",
3-
"version": "1.5.24",
3+
"version": "1.5.26",
44
"description": "Smyth Runtime Environment",
55
"author": "Alaa-eddine KADDOURI",
66
"license": "MIT",
@@ -30,7 +30,9 @@
3030
},
3131
"devDependencies": {
3232
"@istanbuljs/nyc-config-typescript": "^1.0.2",
33+
"@rollup/plugin-commonjs": "^28.0.3",
3334
"@rollup/plugin-json": "^6.1.0",
35+
"@rollup/plugin-node-resolve": "^15.3.1",
3436
"@rollup/pluginutils": "^5.1.0",
3537
"@types/express": "^4.17.23",
3638
"@types/lodash": "^4.17.10",

0 commit comments

Comments
 (0)