this.me 2.4.5 β 2.4.7
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/README.md +18 -6
- package/main.js +25 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
# .me Suite - Your AI Playground
|
|
4
4
|
For every recursive action, there's a repercussion.
|
|
5
|
-
**Docs:** [this.me](https://www.neurons.me/this-me)
|
|
6
5
|
|
|
7
6
|
```
|
|
8
7
|
npm install this.me
|
|
9
8
|
```
|
|
10
9
|
|
|
10
|
+
**Docs:** [this.me](https://www.neurons.me/this-me)
|
|
11
|
+
|
|
11
12
|
### Conceptual Flow:
|
|
12
13
|
|
|
13
14
|
- [ ] Set up your context with [this.me.](https://www.npmjs.com/package/this.me)
|
|
@@ -24,9 +25,19 @@ npm install this.me
|
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
# Setting up your Context. ππ»ππΌππ½ππΎππΏ
|
|
28
29
|
Defining the environment and context in which your code runs, especially when you're interacting with intelligent agents or services likeΒ me.
|
|
29
|
-
Having a clear declaration of the environment and the context can have a series of implications for security, interoperability, and clarity.
|
|
30
|
+
Having a clear declaration of the environment and the context can have a series of implications for security, interoperability, and clarity.
|
|
31
|
+
|
|
32
|
+
The codebase is often vast, dynamic, and continually evolving.
|
|
33
|
+
|
|
34
|
+
Given the dynamic nature of such environments, ensuring the integrity of the code and data becomes paramount. You wouldn't want an agent to execute or rely on code that has been tampered with or is different from the expected version. This is where hashing comes into play.
|
|
35
|
+
|
|
36
|
+
The **SHA256 cryptographic hash function** is used to produce a unique, fixed-length sequence of characters (a hash) for the data. This setup does a thorough job of hashing the content of files or entire directories.
|
|
37
|
+
Even a tiny change in the content will result in a completely different hash.
|
|
38
|
+
[Read More.](https://www.neurons.me/this-me#h.sg59uu9ka8i8)
|
|
39
|
+
|
|
40
|
+
Let's delve into the importance of such declarations:
|
|
30
41
|
|
|
31
42
|
### Security Context:
|
|
32
43
|
Defining the environment ensures that both the user and the IA have a clear understanding of the boundary within which interactions take place.
|
|
@@ -41,6 +52,10 @@ Declaring the environment or context helps ensure that all systems are on the "s
|
|
|
41
52
|
For industries or applications where audit trails and compliance are important, having a clear declaration of the environment ensures that every interaction and operation can be traced back to a defined context.
|
|
42
53
|
Such clear demarcations can aid in forensic analysis if something goes wrong or if there's a need to understand the context of an interaction.
|
|
43
54
|
|
|
55
|
+
### Conclusion:
|
|
56
|
+
|
|
57
|
+
In the broader context of a dynamic and interactive environment like the one you're building, hashing becomes a powerful tool. It's not just about verifying code; it's about ensuring the entire ecosystem's security, integrity, and seamless operation. By employing a hashing mechanism, you're taking a proactive step towards establishing trust in the code and data that powers your system.
|
|
58
|
+
|
|
44
59
|
### Dependencies:
|
|
45
60
|
```json
|
|
46
61
|
"dependencies": {
|
|
@@ -61,7 +76,6 @@ Such clear demarcations can aid in forensic analysis if something goes wrong or
|
|
|
61
76
|
```
|
|
62
77
|
|
|
63
78
|
|
|
64
|
-
|
|
65
79
|
# Context of Abstraction for Machine Learning Standardization
|
|
66
80
|
|
|
67
81
|
Traditional web development elements, from images to audio, are designed mainly for display and interaction. But what if they could be seamlessly converted into standardized formats primed for machine learning? That's the vision behind the **this.** modules.
|
|
@@ -82,8 +96,6 @@ Rooted in JavaScript, the this. library builds upon public web development stand
|
|
|
82
96
|
|
|
83
97
|
The this. library champions open standards. By leveraging public web standards, it invites collaboration, hoping to create a community that continually refines and enhances the bridge between web development and machine learning.
|
|
84
98
|
|
|
85
|
-
|
|
86
|
-
|
|
87
99
|
[neurons.me](https://www.neurons.me)
|
|
88
100
|
|
|
89
101
|
[neurons.me/this](https://www.neurons.me/this)
|
package/main.js
CHANGED
|
@@ -64,34 +64,44 @@ function handleAtomCommand() {
|
|
|
64
64
|
//.. THIS SECTION IS FOR HASHING PURPOSES ...//
|
|
65
65
|
/* Create a function that computes the hash of the @src directory.
|
|
66
66
|
'hash-src') to handle hashing when the relevant command is passed to the script.*/
|
|
67
|
-
function
|
|
67
|
+
function getAllFiles(directory) {
|
|
68
68
|
const entries = fs.readdirSync(directory, { withFileTypes: true });
|
|
69
69
|
const files = entries.filter(fileDirent => fileDirent.isFile()).map(fileDirent => path.join(directory, fileDirent.name));
|
|
70
70
|
const folders = entries.filter(folderDirent => folderDirent.isDirectory());
|
|
71
71
|
for (const folder of folders) {
|
|
72
|
-
files.push(...
|
|
72
|
+
files.push(...getAllFiles(path.join(directory, folder.name)));
|
|
73
73
|
}
|
|
74
74
|
return files;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function hashThis(directoryOrFilePath) {
|
|
77
77
|
// Ensure path is absolute
|
|
78
|
-
if (!path.isAbsolute(
|
|
79
|
-
throw new Error('
|
|
78
|
+
if (!path.isAbsolute(directoryOrFilePath)) {
|
|
79
|
+
throw new Error('Path must be absolute.');
|
|
80
|
+
}
|
|
81
|
+
let allContent = "";
|
|
82
|
+
// Check if it's a directory or a file
|
|
83
|
+
const stat = fs.statSync(directoryOrFilePath);
|
|
84
|
+
if (stat.isDirectory()) {
|
|
85
|
+
// Get all files from the directory recursively
|
|
86
|
+
const allFiles = getAllFiles(directoryOrFilePath);
|
|
87
|
+
// Read all file content and concatenate it
|
|
88
|
+
allContent = allFiles.map(file => fs.readFileSync(file)).join('');
|
|
89
|
+
} else if (stat.isFile()) {
|
|
90
|
+
// Read file content
|
|
91
|
+
allContent = fs.readFileSync(directoryOrFilePath);
|
|
92
|
+
} else {
|
|
93
|
+
throw new Error('Provided path is neither a directory nor a file.');
|
|
80
94
|
}
|
|
81
|
-
// Get all files from the directory recursively
|
|
82
|
-
const allFiles = getAllFilesFromSourceCode(directoryPath);
|
|
83
|
-
// Read all file content and concatenate it
|
|
84
|
-
const allContent = allFiles.map(file => fs.readFileSync(file)).join('');
|
|
85
95
|
// Hash the content using SHA256 (or another hashing algorithm)
|
|
86
96
|
const hash = crypto.createHash('sha256').update(allContent).digest('hex');
|
|
87
97
|
return hash;
|
|
88
98
|
}
|
|
89
99
|
|
|
90
|
-
function
|
|
100
|
+
function hashSrc() {
|
|
91
101
|
try {
|
|
92
102
|
// Adjust this to the exact location of your @src directory
|
|
93
103
|
const srcDirPath = path.resolve(__dirname, '@src');
|
|
94
|
-
const hash =
|
|
104
|
+
const hash = hashThis(srcDirPath);
|
|
95
105
|
console.log(`Hash of @src directory: ${hash}`);
|
|
96
106
|
} catch (error) {
|
|
97
107
|
console.error('Error hashing @src directory:', error.message);
|
|
@@ -104,7 +114,7 @@ displayWelcomeMessage();
|
|
|
104
114
|
// COMMAND HANDLERS
|
|
105
115
|
switch(args[0]) {
|
|
106
116
|
case 'hash-src':
|
|
107
|
-
|
|
117
|
+
hashSrc();
|
|
108
118
|
break;
|
|
109
119
|
case 'viewer':
|
|
110
120
|
handleViewerCommand();
|
|
@@ -120,7 +130,7 @@ module.exports = {
|
|
|
120
130
|
cleaker,
|
|
121
131
|
neurons,
|
|
122
132
|
Atom,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
133
|
+
getAllFiles,
|
|
134
|
+
hashThis,
|
|
135
|
+
hashSrc
|
|
126
136
|
};
|