@vertesia/memory-commands 0.80.0-dev.20251121 → 0.80.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.
- package/README.md +153 -0
- package/package.json +11 -2
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# @vertesia/memory-commands
|
|
2
|
+
|
|
3
|
+
Commands for building Vertesia memory packs from recipe scripts. This package provides the DSL (Domain Specific Language) used in memory recipe scripts.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Recipe DSL**: Simple commands for building memory packs
|
|
8
|
+
- **TypeScript Support**: Direct execution of TypeScript recipe files
|
|
9
|
+
- **File Operations**: Copy files, text, JSON, and media into memory packs
|
|
10
|
+
- **Document Processing**: Built-in support for PDF and DOCX conversion
|
|
11
|
+
- **Shell Execution**: Run shell commands during build
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @vertesia/memory-commands
|
|
17
|
+
# or
|
|
18
|
+
pnpm add @vertesia/memory-commands
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Writing Recipe Scripts
|
|
24
|
+
|
|
25
|
+
Recipe scripts use the exported commands to define memory pack contents:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { from, copy, json, content, vars } from '@vertesia/memory-commands';
|
|
29
|
+
|
|
30
|
+
// Set the base directory for file operations
|
|
31
|
+
from('./src');
|
|
32
|
+
|
|
33
|
+
// Copy files into the memory pack
|
|
34
|
+
copy('**/*.ts', { to: 'source/' });
|
|
35
|
+
|
|
36
|
+
// Add JSON data
|
|
37
|
+
json({ version: vars().version, name: 'my-project' }, 'metadata.json');
|
|
38
|
+
|
|
39
|
+
// Add text content directly
|
|
40
|
+
content('# Project Documentation\n\nThis is the main documentation.', 'docs/README.md');
|
|
41
|
+
|
|
42
|
+
export default {}; // Required default export
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Building Programmatically
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { build } from '@vertesia/memory-commands';
|
|
49
|
+
|
|
50
|
+
await build('recipe.ts', {
|
|
51
|
+
out: 'memory.tar',
|
|
52
|
+
gzip: true,
|
|
53
|
+
vars: { version: '1.0.0' }
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Available Commands
|
|
58
|
+
|
|
59
|
+
### File Operations
|
|
60
|
+
|
|
61
|
+
| Command | Description |
|
|
62
|
+
|---------|-------------|
|
|
63
|
+
| `from(path)` | Set the base directory for file operations |
|
|
64
|
+
| `copy(glob, options?)` | Copy files matching glob pattern |
|
|
65
|
+
| `copyText(glob, options?)` | Copy text files with optional transformation |
|
|
66
|
+
| `content(text, path)` | Add text content directly |
|
|
67
|
+
| `json(data, path)` | Add JSON data |
|
|
68
|
+
|
|
69
|
+
### Document Processing
|
|
70
|
+
|
|
71
|
+
| Command | Description |
|
|
72
|
+
|---------|-------------|
|
|
73
|
+
| `pdf(path, options?)` | Extract text from PDF files |
|
|
74
|
+
| `docx(path, options?)` | Convert DOCX files to markdown |
|
|
75
|
+
| `media(path, options?)` | Add media files with optional transformation |
|
|
76
|
+
|
|
77
|
+
### Utilities
|
|
78
|
+
|
|
79
|
+
| Command | Description |
|
|
80
|
+
|---------|-------------|
|
|
81
|
+
| `vars()` | Access variables passed via CLI |
|
|
82
|
+
| `tmpdir()` | Get a temporary directory for intermediate files |
|
|
83
|
+
| `exec(command)` | Execute a shell command |
|
|
84
|
+
|
|
85
|
+
## Examples
|
|
86
|
+
|
|
87
|
+
### Copy Source Code
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { from, copy } from '@vertesia/memory-commands';
|
|
91
|
+
|
|
92
|
+
from('./src');
|
|
93
|
+
copy('**/*.ts', { to: 'code/' });
|
|
94
|
+
copy('**/*.json', { to: 'config/' });
|
|
95
|
+
|
|
96
|
+
export default {};
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Process Documents
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { from, pdf, docx } from '@vertesia/memory-commands';
|
|
103
|
+
|
|
104
|
+
from('./docs');
|
|
105
|
+
pdf('*.pdf', { to: 'text/' });
|
|
106
|
+
docx('*.docx', { to: 'markdown/' });
|
|
107
|
+
|
|
108
|
+
export default {};
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Dynamic Content
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { json, content, vars } from '@vertesia/memory-commands';
|
|
115
|
+
|
|
116
|
+
const config = vars();
|
|
117
|
+
|
|
118
|
+
json({
|
|
119
|
+
name: config.name,
|
|
120
|
+
version: config.version,
|
|
121
|
+
timestamp: new Date().toISOString()
|
|
122
|
+
}, 'manifest.json');
|
|
123
|
+
|
|
124
|
+
content(`# ${config.name}\n\nVersion: ${config.version}`, 'README.md');
|
|
125
|
+
|
|
126
|
+
export default {};
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## API
|
|
130
|
+
|
|
131
|
+
### build(script, options?)
|
|
132
|
+
|
|
133
|
+
Execute a recipe script to build a memory pack.
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
interface BuildOptions {
|
|
137
|
+
out?: string; // Output file (default: 'memory.tar')
|
|
138
|
+
gzip?: boolean; // Compress output
|
|
139
|
+
indent?: number; // JSON indentation
|
|
140
|
+
quiet?: boolean; // Suppress output
|
|
141
|
+
test?: boolean; // Test mode (don't write files)
|
|
142
|
+
vars?: Record<string, any>; // Variables for the script
|
|
143
|
+
transpileDir?: string; // Directory for transpiled TypeScript
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### getBuilder()
|
|
148
|
+
|
|
149
|
+
Get the current builder instance (for advanced use cases).
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vertesia/memory-commands",
|
|
3
3
|
"description": "Memory commands for memory recipe scripts",
|
|
4
|
-
"version": "0.80.0
|
|
4
|
+
"version": "0.80.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./lib/types/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"typescript": "^5.6.3",
|
|
19
|
-
"@vertesia/memory": "0.80.0
|
|
19
|
+
"@vertesia/memory": "0.80.0"
|
|
20
20
|
},
|
|
21
21
|
"ts_dual_module": {
|
|
22
22
|
"outDir": "lib"
|
|
@@ -31,6 +31,15 @@
|
|
|
31
31
|
"url": "https://github.com/vertesia/composableai.git",
|
|
32
32
|
"directory": "packages/memory-commands"
|
|
33
33
|
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"vertesia",
|
|
36
|
+
"memory",
|
|
37
|
+
"commands",
|
|
38
|
+
"recipe",
|
|
39
|
+
"llm",
|
|
40
|
+
"ai",
|
|
41
|
+
"typescript"
|
|
42
|
+
],
|
|
34
43
|
"scripts": {
|
|
35
44
|
"eslint": "eslint './src/**/*.{jsx,js,tsx,ts}'",
|
|
36
45
|
"build": "pnpm exec tsmod build",
|