@vertesia/memory 0.24.0-dev.202601221707
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 +13 -0
- package/README.md +473 -0
- package/lib/cjs/Builder.js +186 -0
- package/lib/cjs/Builder.js.map +1 -0
- package/lib/cjs/ContentObject.js +114 -0
- package/lib/cjs/ContentObject.js.map +1 -0
- package/lib/cjs/ContentSource.js +82 -0
- package/lib/cjs/ContentSource.js.map +1 -0
- package/lib/cjs/MemoryPack.js +228 -0
- package/lib/cjs/MemoryPack.js.map +1 -0
- package/lib/cjs/MemoryPackBuilder.js +47 -0
- package/lib/cjs/MemoryPackBuilder.js.map +1 -0
- package/lib/cjs/commands/copy.js +53 -0
- package/lib/cjs/commands/copy.js.map +1 -0
- package/lib/cjs/commands/exec.js +82 -0
- package/lib/cjs/commands/exec.js.map +1 -0
- package/lib/cjs/index.js +28 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/utils/cmdline.js +90 -0
- package/lib/cjs/utils/cmdline.js.map +1 -0
- package/lib/cjs/utils/rewrite.js +166 -0
- package/lib/cjs/utils/rewrite.js.map +1 -0
- package/lib/cjs/utils/stream.js +27 -0
- package/lib/cjs/utils/stream.js.map +1 -0
- package/lib/cjs/utils/tar.js +185 -0
- package/lib/cjs/utils/tar.js.map +1 -0
- package/lib/esm/Builder.js +178 -0
- package/lib/esm/Builder.js.map +1 -0
- package/lib/esm/ContentObject.js +103 -0
- package/lib/esm/ContentObject.js.map +1 -0
- package/lib/esm/ContentSource.js +75 -0
- package/lib/esm/ContentSource.js.map +1 -0
- package/lib/esm/MemoryPack.js +218 -0
- package/lib/esm/MemoryPack.js.map +1 -0
- package/lib/esm/MemoryPackBuilder.js +43 -0
- package/lib/esm/MemoryPackBuilder.js.map +1 -0
- package/lib/esm/commands/copy.js +50 -0
- package/lib/esm/commands/copy.js.map +1 -0
- package/lib/esm/commands/exec.js +75 -0
- package/lib/esm/commands/exec.js.map +1 -0
- package/lib/esm/index.js +7 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/utils/cmdline.js +86 -0
- package/lib/esm/utils/cmdline.js.map +1 -0
- package/lib/esm/utils/rewrite.js +161 -0
- package/lib/esm/utils/rewrite.js.map +1 -0
- package/lib/esm/utils/stream.js +23 -0
- package/lib/esm/utils/stream.js.map +1 -0
- package/lib/esm/utils/tar.js +175 -0
- package/lib/esm/utils/tar.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/Builder.d.ts +72 -0
- package/lib/types/Builder.d.ts.map +1 -0
- package/lib/types/ContentObject.d.ts +43 -0
- package/lib/types/ContentObject.d.ts.map +1 -0
- package/lib/types/ContentSource.d.ts +32 -0
- package/lib/types/ContentSource.d.ts.map +1 -0
- package/lib/types/MemoryPack.d.ts +46 -0
- package/lib/types/MemoryPack.d.ts.map +1 -0
- package/lib/types/MemoryPackBuilder.d.ts +18 -0
- package/lib/types/MemoryPackBuilder.d.ts.map +1 -0
- package/lib/types/commands/copy.d.ts +8 -0
- package/lib/types/commands/copy.d.ts.map +1 -0
- package/lib/types/commands/exec.d.ts +7 -0
- package/lib/types/commands/exec.d.ts.map +1 -0
- package/lib/types/index.d.ts +14 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/utils/cmdline.d.ts +10 -0
- package/lib/types/utils/cmdline.d.ts.map +1 -0
- package/lib/types/utils/rewrite.d.ts +38 -0
- package/lib/types/utils/rewrite.d.ts.map +1 -0
- package/lib/types/utils/stream.d.ts +9 -0
- package/lib/types/utils/stream.d.ts.map +1 -0
- package/lib/types/utils/tar.d.ts +40 -0
- package/lib/types/utils/tar.d.ts.map +1 -0
- package/package.json +53 -0
- package/src/Builder.ts +239 -0
- package/src/ContentObject.ts +114 -0
- package/src/ContentSource.ts +88 -0
- package/src/MemoryPack.ts +233 -0
- package/src/MemoryPackBuilder.ts +55 -0
- package/src/builder.test.ts +214 -0
- package/src/commands/copy.ts +53 -0
- package/src/commands/exec.test.ts +22 -0
- package/src/commands/exec.ts +83 -0
- package/src/index.ts +14 -0
- package/src/utils/cmdline.test.ts +32 -0
- package/src/utils/cmdline.ts +92 -0
- package/src/utils/rewrite.test.ts +65 -0
- package/src/utils/rewrite.ts +167 -0
- package/src/utils/stream.test.ts +13 -0
- package/src/utils/stream.ts +27 -0
- package/src/utils/tar.test.ts +48 -0
- package/src/utils/tar.ts +203 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2024 Composable
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
# Memory Pack: portable context for LLMs
|
|
2
|
+
|
|
3
|
+
Memory Packs are portable, immutable contexts for Large Language Models. Too often, data need to be queried at the time of prompt expansion, creating issues od data access, security, and immutability. With Memory Packs, we want to solve this problem by easily creating immutable, portable, and reusable contexts for LLMs. You can think of it as Docker images for LLM's contexts.
|
|
4
|
+
|
|
5
|
+
Technically, a memory pack is an `indexed` TAR file that package the context to be used when expanding LLM prompts. The file is a regular tar file but with a special `.index` file added as the last entry in the tar. The index file list the files inside the tar, one file by line with the byte offset indicating the start of the tar entry where the file is located and the size in bytes of te file content.
|
|
6
|
+
|
|
7
|
+
**Example:**
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
changes.diff:0,256
|
|
11
|
+
metadata.json:1024,52
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
A memory pack contains at least one file: `metadata.json`. This file is a JSON object containing random properties and is required even if the memory is not defining any metadata properties. In that case an empty JSON object `{}` should be put in the metadata file.
|
|
15
|
+
|
|
16
|
+
## Memory file implementation
|
|
17
|
+
|
|
18
|
+
The packages in this repository are providing an implementation of the memory file for javascript and some tooling to build and test memory files.
|
|
19
|
+
|
|
20
|
+
## [@vertesia/memory](packages/core)
|
|
21
|
+
|
|
22
|
+
This is the core library implementing the memory pack and providing an API to programmatically create ans use memory packs.
|
|
23
|
+
|
|
24
|
+
### Installation
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
npm install @vertesia/memory
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## [@vertesia/memory-cli](packages/cli)
|
|
31
|
+
|
|
32
|
+
This is a terminal CLI application useful to build and test memory packs.
|
|
33
|
+
|
|
34
|
+
It builds a memory pack by running a recipe file. The recipe file is a typescript script which may add content to the tar and which must export a JSON object which will be stored in the `metadata.json` file.
|
|
35
|
+
|
|
36
|
+
### Installation
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
npm install -g @vertesia/memory-cli
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The package install an application named `memo`.
|
|
43
|
+
|
|
44
|
+
Use `memo help` to see the list of commands.
|
|
45
|
+
|
|
46
|
+
## [@vertesia/memory-commands](packages/commands)
|
|
47
|
+
|
|
48
|
+
This package must only be imported from the recipe file. It provides a list of the commands to use to build the memory pack.
|
|
49
|
+
|
|
50
|
+
## Memory Pack Recipe
|
|
51
|
+
|
|
52
|
+
A recipe is a typescript file that is used to build a memory pack.
|
|
53
|
+
The recipe can contain any javascript code but it must use the builtin commands to create the memory TAR file.
|
|
54
|
+
|
|
55
|
+
A memory pack recipe has the following structure:
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
import { copy, ... other commands ... } from "@vertesia/memory-commands";
|
|
59
|
+
|
|
60
|
+
// You can optionally extend an existing memory pack
|
|
61
|
+
await from("path/to/memory.tar")
|
|
62
|
+
|
|
63
|
+
/** then you can build the memory tar content using builtin commands
|
|
64
|
+
* You can either use the built-in commands or `exec` to run a shell command
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
// ... Your commands here ...
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* At the end of the file you must export the memory pack metadata.
|
|
71
|
+
* This is a JSON object which holds the properties to be used when creating LLM interactions.
|
|
72
|
+
*/
|
|
73
|
+
export default {
|
|
74
|
+
someProperty: "hello",
|
|
75
|
+
...
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Memory Pack Commands
|
|
80
|
+
|
|
81
|
+
The only dependency you need to import in your recipe ts file is the `@vertesia/memory-commands` package. This package contains all the built-in commands which are grouped in two categories: execution commands and content loading commands:
|
|
82
|
+
|
|
83
|
+
### Context commands
|
|
84
|
+
|
|
85
|
+
1. **vars** - Get the build user variables
|
|
86
|
+
2. **tmpdir** - Get or create a temporary directory for use while building
|
|
87
|
+
3. **getBuilder** - Get the builder instance.
|
|
88
|
+
|
|
89
|
+
### Execution commands
|
|
90
|
+
|
|
91
|
+
1. **from** - Extends an existing memory pack (a tar file)
|
|
92
|
+
2. **exec** - Execute a shell command.
|
|
93
|
+
3. **copy** - Copy a file to the tar. The file content can be transformed using the built-in transformers. See the [copy command](#copy) for more details.
|
|
94
|
+
4. **copyText** - Copy an inline text or string variable as a tar entry.
|
|
95
|
+
5. **build** - Build an external recipe.
|
|
96
|
+
|
|
97
|
+
### Content loading commands
|
|
98
|
+
|
|
99
|
+
These commands can be used to fetch content from files. The result is returned as a variable which will only fetch the content when used. All these commands supports globs as argument to fetch content from multiple files. When a glob is used the result will always be an array of variables.
|
|
100
|
+
|
|
101
|
+
1. **content** - fetch the text content from a text file.
|
|
102
|
+
2. **json** - fetch a JSON object from a json file.
|
|
103
|
+
3. **pdf** - extract the text content from a PDF file.
|
|
104
|
+
4. **docx** - extract the text content from a Docx file.
|
|
105
|
+
5. **media** - Load an image with an optional conversion. The image is exported as base64 text, when the variable is referenced in the exported memory metadata.
|
|
106
|
+
|
|
107
|
+
#### vars
|
|
108
|
+
|
|
109
|
+
**Signature:** `vars (): Record<string,any>`
|
|
110
|
+
|
|
111
|
+
A command that returns the user variables which were specified when invoking the memory pack build.
|
|
112
|
+
These variables can be used to parametrize the recipe. When using the `memo` cli application (i.e. `@vertesia/memory-cli`) you can pass vars to the recipe by using command line parameters which starts with a `--var-` prefix.
|
|
113
|
+
|
|
114
|
+
**Example:** `--var-language fr` will produce a property `language` with a value of `'fr'`.
|
|
115
|
+
|
|
116
|
+
**Usage:**
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
import { vars } from '@vertesia/memory-commands';
|
|
120
|
+
|
|
121
|
+
const { language } = vars();
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### tmpdir
|
|
125
|
+
|
|
126
|
+
**Signature:** `tmpdir (): string`
|
|
127
|
+
|
|
128
|
+
Get or create a temporary directory. If the directory was not yet created it will be created and its path returned.
|
|
129
|
+
|
|
130
|
+
If created, the temporary directory will be automatically removed at the end of the build.
|
|
131
|
+
|
|
132
|
+
**Usage:**
|
|
133
|
+
|
|
134
|
+
```js
|
|
135
|
+
import { tmpdir } from '@vertesia/memory-commands';
|
|
136
|
+
|
|
137
|
+
const wd = tmpdir();
|
|
138
|
+
|
|
139
|
+
await exec(`ls -al > ${wd}/text.txt`);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### getBuilder
|
|
143
|
+
|
|
144
|
+
**Signature:** `getBuilder (): Builder`
|
|
145
|
+
|
|
146
|
+
Get the instance of the builder which is used to build the current recipe ts file.
|
|
147
|
+
|
|
148
|
+
### from
|
|
149
|
+
|
|
150
|
+
**Signature:** `from (location: string, options?: FromOptions): void`
|
|
151
|
+
|
|
152
|
+
The from command load an existing memory pack tar as a source of the current pack being built. You can filter which files and metadata properties will be included from the source tar by specifying a `files` filter and a metadata properties `projection`.
|
|
153
|
+
|
|
154
|
+
The `from` command is an asynchronous operation so you need to `await` for its completion.
|
|
155
|
+
|
|
156
|
+
The shape of the `FromOptions` is:
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
{
|
|
160
|
+
files?: string[];
|
|
161
|
+
projection?: Record<string, boolean | 0 | 1>;
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The `files` filter is an array of globs as supported by the [micromatch](https://www.npmjs.com/package/micromatch) library. You can either include files using globs expressions or files by prepending the glob expression with an `!` character.
|
|
166
|
+
|
|
167
|
+
The `projection` is an object which map keys to a truthy or falsy value. You can either use false or true to exclude or include properties not both.
|
|
168
|
+
|
|
169
|
+
_Example:_
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
import { vars, from } from '@vertesia/memory-commands';
|
|
173
|
+
await from('./memory-source.tar', {
|
|
174
|
+
files: ['images/*.png'],
|
|
175
|
+
projection: {
|
|
176
|
+
name: true,
|
|
177
|
+
language: true,
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
// export a new metadata object
|
|
181
|
+
export default {
|
|
182
|
+
theme: vars.theme || 'dark',
|
|
183
|
+
};
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The memory pack built above will contain all the `images/*.png` files from the source tar and the metadata JSON object will contain the `name` and `language` properties from the source memory pack metadata and will add a new metadata property named `theme`.
|
|
187
|
+
|
|
188
|
+
### exec
|
|
189
|
+
|
|
190
|
+
**Signature:** `exec (cmd: string, options?: ExecOptions): Promise<void | string>`
|
|
191
|
+
|
|
192
|
+
Execute a shell command. You can execute a pipe of shell commands or use stdout redirection at the end of the command:
|
|
193
|
+
|
|
194
|
+
The `exec` command is asynchronous so you need to use await when invoking it. If no output redirection is specified then the output will be returned as a string from the `exec()` function
|
|
195
|
+
|
|
196
|
+
**Example:**
|
|
197
|
+
|
|
198
|
+
```javascript
|
|
199
|
+
import { tmpdir, exec } from '@vertesia/memory-commands';
|
|
200
|
+
const wd = tmpdir();
|
|
201
|
+
const output = await exec('cat some/file | wc -l');
|
|
202
|
+
await exec(`cat some/file | wc -l > ${wd}out.txt`);
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### copy
|
|
206
|
+
|
|
207
|
+
**Signature:** `copy (location: SourceSpec, path: string, options?: CopyOptions): void`
|
|
208
|
+
|
|
209
|
+
This command will copy the content of a file to a tar entry specified by the `path` argument.
|
|
210
|
+
The `location` argument specify from source from where the content is copied.
|
|
211
|
+
It may be either a `string` or a `ContentSource` object. ContentSource objects are returned by any of the [Content Loading Commands](#content-loading-commands).
|
|
212
|
+
|
|
213
|
+
If location is a string it will be expected to point to a file path or to a glob expression.
|
|
214
|
+
If a glob expression is used the the `copy` operation will copy the content of all the matching files. You can, in that case, specify a path rewrite expression as the `path` argument.
|
|
215
|
+
|
|
216
|
+
You can transform the file content when copying it to the tar by using the `options` argument. The shape of the options is:
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
export interface CopyOptions {
|
|
220
|
+
media?: {
|
|
221
|
+
max_hw?: number;
|
|
222
|
+
format?: 'jpeg' | 'png';
|
|
223
|
+
};
|
|
224
|
+
extractText?: boolean | string;
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
You can convert images by specifying a max height or width and / or an output image format. For documents like pdf or docx you can specify `extractText: "pdf" | "docx" | boolean`. If true is specified the type of text extraction will be guessed from the file extension.
|
|
229
|
+
|
|
230
|
+
**Example:**
|
|
231
|
+
|
|
232
|
+
```js
|
|
233
|
+
import { exec, copy, tmpdir } from '@vertesia/memory-commands';
|
|
234
|
+
const wd = tmpdir();
|
|
235
|
+
await exec(`cat some/file > ${wd}/out.txt`);
|
|
236
|
+
copy(`${wd}/out.txt`, 'out.txt');
|
|
237
|
+
copy('./my-project/src/**/*.ts', './my-project/src!sources/*');
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The rewrite expression in the example above `./my-project/src!sources/*` means: strip the prefix `./my-project/src` from the copied file and prefix the remaining od the path with the value `sources/`.
|
|
241
|
+
|
|
242
|
+
#### Path rewrite expressions
|
|
243
|
+
|
|
244
|
+
A path rewrite expression is composed of two parts:
|
|
245
|
+
|
|
246
|
+
1. an optional prefix separated by a `!` character from the rest of the path. If present this prefix will be removed from the matched path.
|
|
247
|
+
If no prefix is specified then the entire directory part of the matched path will be removed.
|
|
248
|
+
2. A mandatory suffix which is describing how to rewrite the matched path. The suffix may contain either a wildcard `*` which will be replaced with the matched path (without the removed prefix), either a combination of the following variables:
|
|
249
|
+
- `%n` - the file name without the extension
|
|
250
|
+
- `%e` - the extension
|
|
251
|
+
- `%f` - the file name including the extension
|
|
252
|
+
- `%d` - the directory path (not including the removed prefix)
|
|
253
|
+
- `%i` - the 0 based index of the file in the matched array of files.
|
|
254
|
+
|
|
255
|
+
**Examples:**
|
|
256
|
+
|
|
257
|
+
```js
|
|
258
|
+
// copy all .ts files flattened in the sources directory (the directory structure is not preserved)
|
|
259
|
+
copy('work/docs/project1/src/**/*.ts', 'sources/*');
|
|
260
|
+
// copy all .ts files in the sources directory and recreate the subdirectories structure inside src/
|
|
261
|
+
copy('work/docs/project1/src/**/*.ts', 'work/docs/project1/src!sources/*');
|
|
262
|
+
// Remove the work/ prefix and preserver the same subdirectories structure including images/
|
|
263
|
+
// and replace the file extension with .png
|
|
264
|
+
copy('work/images/**/*.png', 'work!%d/%n.jpeg');
|
|
265
|
+
// Copy all images inside a images/ folder without preserving subdirectories and append the index of the image
|
|
266
|
+
copy('work/images/**/*.png', 'images/%n-%i.%e');
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
In the last example for the matched files: `work/images/header/home.png` and `work/images/footer/logo.png` the result will be: `images/home-0.png`, `images/logo-1.png`
|
|
270
|
+
|
|
271
|
+
### copyText
|
|
272
|
+
|
|
273
|
+
**Signature:** `copyText (text: string, path: string): void`
|
|
274
|
+
|
|
275
|
+
This command will create a new entry in the target memory pack tar using the content you specified through the `text` argument. The tar entry path is specified by the `path` argument.
|
|
276
|
+
|
|
277
|
+
```js
|
|
278
|
+
import { exec, copyText } from '@vertesia/memory-commands';
|
|
279
|
+
const content = await exec(`cat some/file`);
|
|
280
|
+
copyText(content.trim(), 'content.txt');
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### build
|
|
284
|
+
|
|
285
|
+
**Signature:** `build (recipePath: string, options?: BuildOptions): void`
|
|
286
|
+
|
|
287
|
+
Build a memory pack from a recipe file. You can use this command if you need to build multiple memory packs.
|
|
288
|
+
|
|
289
|
+
The `BuildOptions` options have the following shape:
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
export interface BuildOptions {
|
|
293
|
+
indent?: number;
|
|
294
|
+
/**
|
|
295
|
+
* the path to save the output. Defaults to 'memory.tar'.
|
|
296
|
+
* If no .tar extension is present it will be added
|
|
297
|
+
*/
|
|
298
|
+
out?: string;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* If set, suppress logs. Defaults to false.
|
|
302
|
+
*/
|
|
303
|
+
quiet?: boolean;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* If true, compress the output (tar or json) with gzip. Defaults to false.
|
|
307
|
+
*/
|
|
308
|
+
gzip?: boolean;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Vars to be injected into the script context as the vars object
|
|
312
|
+
*/
|
|
313
|
+
vars?: Record<string, any>;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Optional publish action
|
|
317
|
+
* @param file
|
|
318
|
+
* @returns the URI of the published memory
|
|
319
|
+
*/
|
|
320
|
+
publish?: (file: string, name: string) => Promise<string>;
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Usage:**
|
|
325
|
+
|
|
326
|
+
```js
|
|
327
|
+
import { build, tmpdir } from '@vertesia/memory-commands';
|
|
328
|
+
const wd = tmpdir();
|
|
329
|
+
await build('./some/recipe.ts', { out: `${wd}}/child-memory` });
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### content
|
|
333
|
+
|
|
334
|
+
**Signature:** `content (location: string, encoding?: BufferEncoding): ContentObject | ContentObject[]`
|
|
335
|
+
|
|
336
|
+
If the location is a glob expression then an array of `ContentObject` is returned. A `ContentObject` implements `ContentSource` so it can be used as the location argument of the copy operation.
|
|
337
|
+
The actual content of a file is only fetched (and transformed) only when the ContentObject is used: either a method of the object is used, either it is assigned to a value of a metadata property.
|
|
338
|
+
|
|
339
|
+
The `content` command simply load the content of the given file(s) as a text using an optional encoding. The default encoding is "utf-8".
|
|
340
|
+
|
|
341
|
+
### json
|
|
342
|
+
|
|
343
|
+
**Signature:** `json (location: string) => ContentObject | ContentObject[]`
|
|
344
|
+
|
|
345
|
+
Load a JSON object from a json file. When assigned as a metadata property the content will by transformed in a JSON object.
|
|
346
|
+
|
|
347
|
+
### pdf
|
|
348
|
+
|
|
349
|
+
**Signature:** `pdf (location: string) => PdfObject | PdfObject[]`
|
|
350
|
+
|
|
351
|
+
Load a PdfObject form a pdf file. When assigned as a metadata property the PdfObject is transformed to the text representation of the PDF.
|
|
352
|
+
|
|
353
|
+
**Example:**
|
|
354
|
+
|
|
355
|
+
```js
|
|
356
|
+
import { pdf } from '@vertesia/memory-commands';
|
|
357
|
+
|
|
358
|
+
const doc = pdf('./my-doc.pdf');
|
|
359
|
+
|
|
360
|
+
export default {
|
|
361
|
+
textContent: doc,
|
|
362
|
+
};
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
In the example above the PDF text will be extracted from the pdf and injected as the textContent property ion the memory pack metadata.
|
|
366
|
+
|
|
367
|
+
### docx
|
|
368
|
+
|
|
369
|
+
Load a DocxObject form a docx file. When assigned as a metadata property the DocxObject is transformed to the text representation of the Docx.
|
|
370
|
+
|
|
371
|
+
**Signature:** `docx (location: string) => DocxObject | DocxObject[]`
|
|
372
|
+
|
|
373
|
+
### media
|
|
374
|
+
|
|
375
|
+
**Signature:** `json (location: string, options?: MediaOptions) => MediaObject | MediaObject[]`
|
|
376
|
+
|
|
377
|
+
Load a MediaObject form a docx file. When assigned as a metadata property the MediaObject is transformed to text representation of the image which is the base64 encoded image.
|
|
378
|
+
|
|
379
|
+
The media command accepts an additional argument which has the shape:
|
|
380
|
+
|
|
381
|
+
```
|
|
382
|
+
export interface MediaOptions {
|
|
383
|
+
max_hw?: number;
|
|
384
|
+
format?: "jpeg" | "png";
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
You can thus convert the image before using it.
|
|
389
|
+
|
|
390
|
+
**Example:**
|
|
391
|
+
|
|
392
|
+
```js
|
|
393
|
+
import { pdf } from '@vertesia/memory-commands';
|
|
394
|
+
|
|
395
|
+
const images = media('./images/*.jpeg');
|
|
396
|
+
|
|
397
|
+
export default {
|
|
398
|
+
images: images,
|
|
399
|
+
};
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
In the example above the an array of images encoded as base64 will be injected in the `images` property pf the memory pack metadata.
|
|
403
|
+
|
|
404
|
+
### Custom commands
|
|
405
|
+
|
|
406
|
+
To create custom commands you have 2 options. Either you write the command in as a command line application and invoke it through the `exec` command, either you write a javascript function, package it in an external library and the import it in the recipe ts file.
|
|
407
|
+
|
|
408
|
+
Here is a template of custom command functions:
|
|
409
|
+
|
|
410
|
+
```js
|
|
411
|
+
import { getBuilder } from "@vertesia/memory-commands";
|
|
412
|
+
import fs from "node:fs";
|
|
413
|
+
|
|
414
|
+
export myCommand(message:string) {
|
|
415
|
+
const wd = builder.tmpdir();
|
|
416
|
+
// this is the current instance of the builder being used to build the memory pack.
|
|
417
|
+
const builder = getBuilder();
|
|
418
|
+
// you can add a variable in the build vars:
|
|
419
|
+
builder.vars.greeting = 'hello world!';
|
|
420
|
+
// or write a file named greeting.txt in the current build tmpdir
|
|
421
|
+
fs.writeFileSync(`${wd}/greeting.txt`, "hello world!", "utf-8");
|
|
422
|
+
// or create a tar entry named greeting.txt
|
|
423
|
+
builder.copyText("hello world!", "greeting.txt");
|
|
424
|
+
// refer to Builder API for other operations.
|
|
425
|
+
}
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
## Examples
|
|
429
|
+
|
|
430
|
+
### Release Highlights
|
|
431
|
+
|
|
432
|
+
This example builds a memory pack with the information on which issues were fixed between to commit SHA.
|
|
433
|
+
|
|
434
|
+
```js
|
|
435
|
+
import { copy, copyText, exec, tmpdir, vars } from "@vertesia/memory-commands";
|
|
436
|
+
|
|
437
|
+
const { start, end } = vars();
|
|
438
|
+
if (!start || !end) {
|
|
439
|
+
console.error("Please provide start and end tags using --var-start and --var-end");
|
|
440
|
+
process.exit(1);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const wd = tmpdir();
|
|
444
|
+
|
|
445
|
+
console.log(`Retrieving issues between ${start}and ${end}...`)
|
|
446
|
+
// Get list of commit logs containing '#' between the two tags and extract unique issue numbers
|
|
447
|
+
const issue_numbers = await exec(`git log ${start}..${end} --oneline | grep -o '#[0-9]\\+' | sed 's/#//' | sort -u`) as string;
|
|
448
|
+
|
|
449
|
+
for (const issue of issue_numbers.trim().split("\n")) {
|
|
450
|
+
console.log(`Processing issue #${issue}`)
|
|
451
|
+
const issue_content = await exec(`gh issue view ${issue}`) as string;
|
|
452
|
+
copyText(issue_content, `issues/${issue}.txt`);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
console.log("Generating diff");
|
|
456
|
+
await exec(`git diff --submodule=diff ${start}...${end} > ${wd}/range_diff.txt`)
|
|
457
|
+
copy(`${wd}/range_diff.txt`, "range_diff.txt");
|
|
458
|
+
|
|
459
|
+
export default {
|
|
460
|
+
from_version: start,
|
|
461
|
+
release_version: end,
|
|
462
|
+
}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
## Memory pack exports
|
|
466
|
+
|
|
467
|
+
When using a memory pack you will likely want to select the metadata object and some files inside the tar. At each run you may need to access different content files. The content you want to access will be exported as a JSON object by providing a `content mapping`.
|
|
468
|
+
|
|
469
|
+
TODO
|
|
470
|
+
|
|
471
|
+
## License
|
|
472
|
+
|
|
473
|
+
Apache-2.0
|
|
@@ -0,0 +1,186 @@
|
|
|
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.Builder = void 0;
|
|
7
|
+
exports.buildMemoryPack = buildMemoryPack;
|
|
8
|
+
const json_1 = require("@vertesia/json");
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const os_1 = __importDefault(require("os"));
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
const copy_js_1 = require("./commands/copy.js");
|
|
13
|
+
const exec_js_1 = require("./commands/exec.js");
|
|
14
|
+
const ContentObject_js_1 = require("./ContentObject.js");
|
|
15
|
+
const ContentSource_js_1 = require("./ContentSource.js");
|
|
16
|
+
const MemoryPack_js_1 = require("./MemoryPack.js");
|
|
17
|
+
const MemoryPackBuilder_js_1 = require("./MemoryPackBuilder.js");
|
|
18
|
+
class Builder {
|
|
19
|
+
options;
|
|
20
|
+
static instance;
|
|
21
|
+
static getInstance() {
|
|
22
|
+
if (!Builder.instance) {
|
|
23
|
+
throw new Error("No builder instance found");
|
|
24
|
+
}
|
|
25
|
+
return Builder.instance;
|
|
26
|
+
}
|
|
27
|
+
_vars;
|
|
28
|
+
_tmpdir;
|
|
29
|
+
memory;
|
|
30
|
+
constructor(options = {}) {
|
|
31
|
+
this.options = options;
|
|
32
|
+
this.memory = new MemoryPackBuilder_js_1.MemoryPackBuilder(this);
|
|
33
|
+
this._vars = options.vars || {};
|
|
34
|
+
Builder.instance = this;
|
|
35
|
+
}
|
|
36
|
+
vars() {
|
|
37
|
+
return this._vars;
|
|
38
|
+
}
|
|
39
|
+
tmpdir() {
|
|
40
|
+
if (!this._tmpdir) {
|
|
41
|
+
this._tmpdir = (0, fs_1.mkdtempSync)((0, path_1.join)(os_1.default.tmpdir(), 'becomposable-memo-'));
|
|
42
|
+
}
|
|
43
|
+
return this._tmpdir;
|
|
44
|
+
}
|
|
45
|
+
from(location, options) {
|
|
46
|
+
return (0, MemoryPack_js_1.loadMemoryPack)(location).then((memory) => {
|
|
47
|
+
return this.memory.load(memory, options);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
addEntry(path, source) {
|
|
51
|
+
this.memory.add(path, source);
|
|
52
|
+
}
|
|
53
|
+
copy(location, path, options = {}) {
|
|
54
|
+
(0, copy_js_1.copy)(this, location, path, options);
|
|
55
|
+
}
|
|
56
|
+
copyText(text, path) {
|
|
57
|
+
(0, copy_js_1.copy)(this, new ContentSource_js_1.TextSource(text), path);
|
|
58
|
+
}
|
|
59
|
+
exec(cmd, options) {
|
|
60
|
+
return (0, exec_js_1.exec)(cmd, options);
|
|
61
|
+
}
|
|
62
|
+
content(location, encoding) {
|
|
63
|
+
const source = ContentSource_js_1.AbstractContentSource.resolve(location);
|
|
64
|
+
if (Array.isArray(source)) {
|
|
65
|
+
return source.map(s => new ContentObject_js_1.ContentObject(this, s, encoding));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return new ContentObject_js_1.ContentObject(this, source, encoding);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
json(location) {
|
|
72
|
+
const source = ContentSource_js_1.AbstractContentSource.resolve(location);
|
|
73
|
+
if (Array.isArray(source)) {
|
|
74
|
+
return source.map(s => new ContentObject_js_1.JsonObject(this, s));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return new ContentObject_js_1.JsonObject(this, source);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
pdf(location) {
|
|
81
|
+
const source = ContentSource_js_1.AbstractContentSource.resolve(location);
|
|
82
|
+
if (Array.isArray(source)) {
|
|
83
|
+
return source.map(s => new ContentObject_js_1.PdfObject(this, s));
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
return new ContentObject_js_1.PdfObject(this, source);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
docx(location) {
|
|
90
|
+
const source = ContentSource_js_1.AbstractContentSource.resolve(location);
|
|
91
|
+
if (Array.isArray(source)) {
|
|
92
|
+
return source.map(s => new ContentObject_js_1.DocxObject(this, s));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return new ContentObject_js_1.DocxObject(this, source);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
media(location, options) {
|
|
99
|
+
const source = ContentSource_js_1.AbstractContentSource.resolve(location);
|
|
100
|
+
if (Array.isArray(source)) {
|
|
101
|
+
return source.map(s => new ContentObject_js_1.MediaObject(this, s, options));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return new ContentObject_js_1.MediaObject(this, source, options);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async build(object) {
|
|
108
|
+
try {
|
|
109
|
+
let { fileName, publishName } = this._getOutputNames();
|
|
110
|
+
// resolve all content objects values from the context object
|
|
111
|
+
object = await resolveContextObject(object);
|
|
112
|
+
// write the memory to a file
|
|
113
|
+
fileName = await this.memory.build(fileName, object);
|
|
114
|
+
let target = fileName;
|
|
115
|
+
if (publishName) {
|
|
116
|
+
try {
|
|
117
|
+
target = await this.options.publish(fileName, publishName);
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
(0, fs_1.rmSync)(fileName);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
this.options.quiet || console.log(`Memory saved to ${target}`);
|
|
124
|
+
return target;
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
if (this._tmpdir) {
|
|
128
|
+
(0, fs_1.rmSync)(this._tmpdir, { recursive: true });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
_getOutputNames() {
|
|
133
|
+
const options = this.options;
|
|
134
|
+
if (!options.out) {
|
|
135
|
+
options.out = "memory.tar";
|
|
136
|
+
}
|
|
137
|
+
let fileName;
|
|
138
|
+
let publishName;
|
|
139
|
+
const out = options.out;
|
|
140
|
+
if (out.startsWith("memory:")) {
|
|
141
|
+
if (!options.publish) {
|
|
142
|
+
throw new Error(`The publish option is required for "${out}" output`);
|
|
143
|
+
}
|
|
144
|
+
// force gzip when publishing
|
|
145
|
+
options.gzip = true;
|
|
146
|
+
// create a temporary path for the output
|
|
147
|
+
fileName = createTmpBaseName(this.tmpdir());
|
|
148
|
+
publishName = out.substring("memory:".length);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
fileName = (0, path_1.resolve)(out);
|
|
152
|
+
}
|
|
153
|
+
return { fileName, publishName };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.Builder = Builder;
|
|
157
|
+
function resolveContextObject(object) {
|
|
158
|
+
return new json_1.AsyncObjectWalker().map(object, async (_key, value) => {
|
|
159
|
+
if (value instanceof ContentObject_js_1.ContentObject) {
|
|
160
|
+
return await value.getText();
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
return value;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function createTmpBaseName(tmpdir) {
|
|
168
|
+
return (0, path_1.join)(tmpdir, `.composable-memory-${Date.now()}.tar`);
|
|
169
|
+
}
|
|
170
|
+
function buildMemoryPack(recipeFn, options) {
|
|
171
|
+
const builder = new Builder(options);
|
|
172
|
+
return recipeFn({
|
|
173
|
+
vars: builder.vars.bind(builder),
|
|
174
|
+
tmpdir: builder.tmpdir.bind(builder),
|
|
175
|
+
exec: builder.exec.bind(builder),
|
|
176
|
+
from: builder.from.bind(builder),
|
|
177
|
+
content: builder.content.bind(builder),
|
|
178
|
+
json: builder.json.bind(builder),
|
|
179
|
+
pdf: builder.pdf.bind(builder),
|
|
180
|
+
docx: builder.docx.bind(builder),
|
|
181
|
+
media: builder.media.bind(builder),
|
|
182
|
+
copy: builder.copy.bind(builder),
|
|
183
|
+
copyText: builder.copyText.bind(builder),
|
|
184
|
+
}).then(metadata => builder.build(metadata));
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=Builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Builder.js","sourceRoot":"","sources":["../../src/Builder.ts"],"names":[],"mappings":";;;;;;AA+NA,0CAeC;AA9OD,yCAAmD;AACnD,2BAAyC;AACzC,4CAAoB;AACpB,+BAAqC;AACrC,gDAAuD;AACvD,gDAAuD;AACvD,yDAAiH;AACjH,yDAAkG;AAClG,mDAAiD;AACjD,iEAAwE;AAoDxE,MAAa,OAAO;IAcG;IAbnB,MAAM,CAAC,QAAQ,CAAW;IAE1B,MAAM,CAAC,WAAW;QACd,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,OAAO,CAAC,QAAQ,CAAC;IAC5B,CAAC;IAED,KAAK,CAAsB;IAC3B,OAAO,CAAU;IACjB,MAAM,CAAoB;IAE1B,YAAmB,UAAwB,EAAE;QAA1B,YAAO,GAAP,OAAO,CAAmB;QACzC,IAAI,CAAC,MAAM,GAAG,IAAI,wCAAiB,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;QAChC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,IAAI;QACA,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,MAAM;QACF,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,GAAG,IAAA,gBAAW,EAAC,IAAA,WAAI,EAAC,YAAE,CAAC,MAAM,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAI,CAAC,QAAgB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