instrux 0.1.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 +279 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +186 -0
- package/dist/cli.js.map +1 -0
- package/dist/compiler.d.ts +35 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +218 -0
- package/dist/compiler.js.map +1 -0
- package/dist/engine.d.ts +39 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +229 -0
- package/dist/engine.js.map +1 -0
- package/dist/frontmatter.d.ts +26 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/frontmatter.js +122 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +34 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +254 -0
- package/dist/init.js.map +1 -0
- package/dist/types.d.ts +104 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# instrux
|
|
2
|
+
|
|
3
|
+
A CLI tool for composing modular AI agent instruction files into complete system prompts — from simple merge to a full **instruction compiler** with frontmatter tagging and Handlebars templates.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g instrux
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or use without installing:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx instrux <command>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### Simple mode — ordered file merge
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
instrux init MyAgent
|
|
23
|
+
# Edit agents/MyAgent/specialization.md
|
|
24
|
+
instrux build MyAgent
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Template mode — frontmatter tags + Handlebars
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
instrux init --template MyAgent
|
|
31
|
+
# Edit agents/base/*.md (tagged components)
|
|
32
|
+
# Edit agents/MyAgent/template.md (Handlebars entry point)
|
|
33
|
+
instrux build MyAgent
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Commands
|
|
37
|
+
|
|
38
|
+
| Command | Description |
|
|
39
|
+
|---|---|
|
|
40
|
+
| `instrux init <name>` | Scaffold a simple-merge agent |
|
|
41
|
+
| `instrux init -t <name>` | Scaffold a template-compiled agent |
|
|
42
|
+
| `instrux build <name>` | Build (merge or compile) an agent |
|
|
43
|
+
| `instrux build --all` | Build all agents |
|
|
44
|
+
| `instrux list` | List all agents |
|
|
45
|
+
| `instrux config <name>` | Show agent configuration |
|
|
46
|
+
| `instrux validate <name>` | Check required source files |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Simple Mode (v1)
|
|
51
|
+
|
|
52
|
+
Files are merged in the order listed in `agent.json`:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"name": "MyAgent",
|
|
57
|
+
"files": [
|
|
58
|
+
{ "path": "agents/base/instructions.md", "required": true },
|
|
59
|
+
{ "path": "agents/MyAgent/specialization.md", "required": true }
|
|
60
|
+
],
|
|
61
|
+
"mergeSettings": { "addSeparators": true, "separatorStyle": "---" }
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Template Mode (v2) — The Instruction Compiler
|
|
68
|
+
|
|
69
|
+
Template mode turns instrux into a build system for agent instructions:
|
|
70
|
+
|
|
71
|
+
1. **Source files** declare themselves via YAML frontmatter tags
|
|
72
|
+
2. An **entry template** uses Handlebars to compose them
|
|
73
|
+
3. The compiler **recursively resolves** all references
|
|
74
|
+
4. Output is a single, merged document
|
|
75
|
+
|
|
76
|
+
### Frontmatter
|
|
77
|
+
|
|
78
|
+
Every source file has YAML frontmatter. Standard fields (title, author, etc.) are yours to keep. The `instrux:` block drives compilation:
|
|
79
|
+
|
|
80
|
+
```yaml
|
|
81
|
+
---
|
|
82
|
+
title: Safety Guidelines # ← standard frontmatter (preserved if configured)
|
|
83
|
+
author: Platform Team
|
|
84
|
+
|
|
85
|
+
instrux: # ← compiler metadata (always stripped from output)
|
|
86
|
+
tags: [safety, compliance] # tags for referencing this file
|
|
87
|
+
order: 2 # sort order within a tag group
|
|
88
|
+
description: Core safety rules # description for iteration
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
# Safety Guidelines
|
|
92
|
+
|
|
93
|
+
- Always provide accurate information
|
|
94
|
+
- Decline harmful requests
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Handlebars Helpers
|
|
98
|
+
|
|
99
|
+
Use these in your entry template (or any source file — they resolve recursively):
|
|
100
|
+
|
|
101
|
+
#### `{{{tag "tagname"}}}`
|
|
102
|
+
|
|
103
|
+
Includes **all files** matching the tag, sorted by `instrux.order`, separated by the configured separator. Each file is itself compiled (recursive).
|
|
104
|
+
|
|
105
|
+
```markdown
|
|
106
|
+
# System Prompt
|
|
107
|
+
|
|
108
|
+
{{{tag "identity"}}}
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
{{{tag "safety"}}}
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
{{{tag "domain"}}}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### `{{{file "path/to/file.md"}}}`
|
|
120
|
+
|
|
121
|
+
Includes a **specific file** by path. Also recursively compiled.
|
|
122
|
+
|
|
123
|
+
```markdown
|
|
124
|
+
{{{file "agents/base/disclaimers.md"}}}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### `{{#each (tagged "tagname")}} ... {{/each}}`
|
|
128
|
+
|
|
129
|
+
Iterates over tagged files for custom rendering. Each item exposes:
|
|
130
|
+
|
|
131
|
+
| Property | Description |
|
|
132
|
+
|---|---|
|
|
133
|
+
| `this.body` | Recursively compiled content |
|
|
134
|
+
| `this.raw` | Uncompiled source content |
|
|
135
|
+
| `this.title` | Frontmatter title |
|
|
136
|
+
| `this.description` | Frontmatter or instrux description |
|
|
137
|
+
| `this.path` | Relative file path |
|
|
138
|
+
| `this.frontmatter` | Full frontmatter object |
|
|
139
|
+
| `this.instrux` | instrux metadata block |
|
|
140
|
+
|
|
141
|
+
```markdown
|
|
142
|
+
## Knowledge Base
|
|
143
|
+
|
|
144
|
+
{{#each (tagged "knowledge")}}
|
|
145
|
+
### {{this.title}}
|
|
146
|
+
|
|
147
|
+
{{{this.body}}}
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
{{/each}}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### `{{meta "key"}}`
|
|
155
|
+
|
|
156
|
+
Access the current file's frontmatter value:
|
|
157
|
+
|
|
158
|
+
```markdown
|
|
159
|
+
<!-- This document: {{meta "title"}} -->
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Agent Config (Template Mode)
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"name": "MyAgent",
|
|
167
|
+
"description": "Compiled instructions for MyAgent",
|
|
168
|
+
"outputDirectory": "out",
|
|
169
|
+
"outputFilePattern": "myagent_instructions.md",
|
|
170
|
+
"entry": "agents/MyAgent/template.md",
|
|
171
|
+
"sources": [
|
|
172
|
+
"agents/base/**/*.md",
|
|
173
|
+
"agents/MyAgent/**/*.md"
|
|
174
|
+
],
|
|
175
|
+
"frontmatter": {
|
|
176
|
+
"output": "strip"
|
|
177
|
+
},
|
|
178
|
+
"mergeSettings": {
|
|
179
|
+
"addSeparators": true,
|
|
180
|
+
"separatorStyle": "---"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
| Field | Description |
|
|
186
|
+
|---|---|
|
|
187
|
+
| `entry` | The Handlebars template that drives compilation |
|
|
188
|
+
| `sources` | Glob patterns for files to scan and index by tag |
|
|
189
|
+
| `frontmatter.output` | `"strip"` (default) or `"preserve"` entry file's non-instrux frontmatter |
|
|
190
|
+
|
|
191
|
+
### Project Layout (Template Mode)
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
agents/
|
|
195
|
+
base/
|
|
196
|
+
identity.md ← instrux.tags: [identity]
|
|
197
|
+
safety.md ← instrux.tags: [safety]
|
|
198
|
+
api_reference.md ← instrux.tags: [knowledge, api]
|
|
199
|
+
MyAgent/
|
|
200
|
+
agent.json ← config with entry + sources
|
|
201
|
+
template.md ← Handlebars entry template
|
|
202
|
+
domain.md ← instrux.tags: [domain]
|
|
203
|
+
protocols.md ← instrux.tags: [domain], order: 2
|
|
204
|
+
out/
|
|
205
|
+
myagent_instructions.md ← compiled output
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Recursive Compilation
|
|
209
|
+
|
|
210
|
+
Templates can include files that themselves contain Handlebars expressions. The compiler resolves everything recursively with **cycle detection** — if file A includes file B which includes file A, you get a clear error:
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
Circular reference detected:
|
|
214
|
+
agents/MyAgent/template.md → agents/base/intro.md → agents/MyAgent/template.md
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Merge Settings
|
|
220
|
+
|
|
221
|
+
| Setting | Default | Description |
|
|
222
|
+
|---|---|---|
|
|
223
|
+
| `addSeparators` | `true` | Insert separator between sections |
|
|
224
|
+
| `separatorStyle` | `"---"` | Separator string |
|
|
225
|
+
| `includeFileHeaders` | `false` | Add HTML comments with source file info |
|
|
226
|
+
| `preserveFormatting` | `true` | Keep original whitespace |
|
|
227
|
+
| `generateHash` | `false` | Append content hash to filename |
|
|
228
|
+
| `useTimestamp` | `false` | Append timestamp to filename |
|
|
229
|
+
|
|
230
|
+
## Multiple Agents
|
|
231
|
+
|
|
232
|
+
You can mix simple and template agents in the same project:
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
agents/
|
|
236
|
+
base/
|
|
237
|
+
identity.md
|
|
238
|
+
safety.md
|
|
239
|
+
CustomerSupport/ ← template mode
|
|
240
|
+
agent.json
|
|
241
|
+
template.md
|
|
242
|
+
product_knowledge.md
|
|
243
|
+
QuickBot/ ← simple mode
|
|
244
|
+
agent.json
|
|
245
|
+
specialization.md
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
instrux build --all # builds every agent
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Programmatic API
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
import { InstruxEngine, InstruxCompiler, initTemplateAgent } from 'instrux';
|
|
256
|
+
|
|
257
|
+
// Scaffold a template agent
|
|
258
|
+
await initTemplateAgent(process.cwd(), 'MyAgent');
|
|
259
|
+
|
|
260
|
+
// Build (auto-detects simple vs template mode)
|
|
261
|
+
const engine = new InstruxEngine();
|
|
262
|
+
const result = await engine.build('MyAgent');
|
|
263
|
+
console.log(result.outputPath);
|
|
264
|
+
|
|
265
|
+
// Or use the compiler directly
|
|
266
|
+
import { buildSourceIndex } from 'instrux';
|
|
267
|
+
const config = await engine.loadConfig('MyAgent');
|
|
268
|
+
const compiler = new InstruxCompiler(process.cwd(), config);
|
|
269
|
+
const { output, filesCompiled, tagsUsed } = await compiler.compile();
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## License
|
|
273
|
+
|
|
274
|
+
This project is dual-licensed under your choice of:
|
|
275
|
+
|
|
276
|
+
- [MIT License](LICENSE-MIT)
|
|
277
|
+
- [Apache License 2.0](LICENSE-APACHE)
|
|
278
|
+
|
|
279
|
+
You may use this project under the terms of either license.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* instrux — CLI for composing modular AI agent instructions.
|
|
4
|
+
*
|
|
5
|
+
* Commands:
|
|
6
|
+
* instrux init <name> Scaffold a new agent
|
|
7
|
+
* instrux build <name> Merge instruction files for an agent
|
|
8
|
+
* instrux build --all Build all agents
|
|
9
|
+
* instrux list List available agents
|
|
10
|
+
* instrux config <name> Show agent configuration
|
|
11
|
+
* instrux validate <name> Validate source files exist
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;GAUG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* instrux — CLI for composing modular AI agent instructions.
|
|
5
|
+
*
|
|
6
|
+
* Commands:
|
|
7
|
+
* instrux init <name> Scaffold a new agent
|
|
8
|
+
* instrux build <name> Merge instruction files for an agent
|
|
9
|
+
* instrux build --all Build all agents
|
|
10
|
+
* instrux list List available agents
|
|
11
|
+
* instrux config <name> Show agent configuration
|
|
12
|
+
* instrux validate <name> Validate source files exist
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const commander_1 = require("commander");
|
|
16
|
+
const engine_1 = require("./engine");
|
|
17
|
+
const init_1 = require("./init");
|
|
18
|
+
const pkg = require('../package.json');
|
|
19
|
+
const program = new commander_1.Command();
|
|
20
|
+
program
|
|
21
|
+
.name('instrux')
|
|
22
|
+
.description('Compose modular AI agent instruction files into complete system prompts')
|
|
23
|
+
.version(pkg.version);
|
|
24
|
+
// ── init ───────────────────────────────────────────────────
|
|
25
|
+
program
|
|
26
|
+
.command('init <name>')
|
|
27
|
+
.description('Scaffold a new agent with config and starter files')
|
|
28
|
+
.option('-t, --template', 'Use template mode with frontmatter tags & Handlebars')
|
|
29
|
+
.action(async (name, opts) => {
|
|
30
|
+
try {
|
|
31
|
+
const cwd = process.cwd();
|
|
32
|
+
const created = opts.template
|
|
33
|
+
? await (0, init_1.initTemplateAgent)(cwd, name)
|
|
34
|
+
: await (0, init_1.initAgent)(cwd, name);
|
|
35
|
+
const mode = opts.template ? 'template' : 'simple';
|
|
36
|
+
console.log(`\n\u2705 Agent "${name}" initialized (${mode} mode)!\n`);
|
|
37
|
+
console.log('Created:');
|
|
38
|
+
created.forEach(f => console.log(` ${f}`));
|
|
39
|
+
if (opts.template) {
|
|
40
|
+
console.log(`\nNext steps:`);
|
|
41
|
+
console.log(` 1. Edit agents/base/*.md to define shared instructions`);
|
|
42
|
+
console.log(` 2. Edit agents/${name}/domain.md with domain knowledge`);
|
|
43
|
+
console.log(` 3. Edit agents/${name}/template.md to compose via {{tag "..."}}`);
|
|
44
|
+
console.log(` 4. Run: instrux build ${name}\n`);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.log(`\nNext steps:`);
|
|
48
|
+
console.log(` 1. Edit agents/${name}/specialization.md with your instructions`);
|
|
49
|
+
console.log(` 2. Edit agents/${name}/agent.json to add more files if needed`);
|
|
50
|
+
console.log(` 3. Run: instrux build ${name}\n`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
console.error(`❌ ${err.message}`);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
// ── build ──────────────────────────────────────────────────
|
|
59
|
+
program
|
|
60
|
+
.command('build [name]')
|
|
61
|
+
.description('Build (merge) instruction files for an agent')
|
|
62
|
+
.option('--all', 'Build all agents')
|
|
63
|
+
.action(async (name, opts) => {
|
|
64
|
+
const engine = new engine_1.InstruxEngine();
|
|
65
|
+
try {
|
|
66
|
+
if (opts.all) {
|
|
67
|
+
const agents = await engine.listAgents();
|
|
68
|
+
if (agents.length === 0) {
|
|
69
|
+
console.log('No agents found. Run "instrux init <name>" first.');
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
for (const agent of agents) {
|
|
73
|
+
if (!agent.config) {
|
|
74
|
+
console.log(`⚠ Skipping ${agent.name} (invalid config)`);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
console.log(`\n🔨 Building ${agent.name}...`);
|
|
78
|
+
const result = await engine.build(agent.name);
|
|
79
|
+
printBuildResult(agent.name, result);
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (!name) {
|
|
84
|
+
console.error('❌ Agent name required. Usage: instrux build <name>');
|
|
85
|
+
console.log(' Run "instrux list" to see available agents.');
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
console.log(`\n🔨 Building ${name}...`);
|
|
89
|
+
const result = await engine.build(name);
|
|
90
|
+
printBuildResult(name, result);
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
console.error(`❌ ${err.message}`);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
// ── list ───────────────────────────────────────────────────
|
|
98
|
+
program
|
|
99
|
+
.command('list')
|
|
100
|
+
.description('List all available agents')
|
|
101
|
+
.action(async () => {
|
|
102
|
+
const engine = new engine_1.InstruxEngine();
|
|
103
|
+
const agents = await engine.listAgents();
|
|
104
|
+
if (agents.length === 0) {
|
|
105
|
+
console.log('\nNo agents found.');
|
|
106
|
+
console.log('Run "instrux init <name>" to create one.\n');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
console.log('\nAvailable agents:\n');
|
|
110
|
+
for (const agent of agents) {
|
|
111
|
+
if (agent.config) {
|
|
112
|
+
const mode = agent.config.entry ? 'template' : 'simple';
|
|
113
|
+
console.log(` ${agent.name} [${mode}]`);
|
|
114
|
+
console.log(` ${agent.config.description}`);
|
|
115
|
+
console.log(` Files: ${agent.config.files?.length ?? agent.config.sources?.length ?? 0} \u2192 ${agent.config.outputDirectory}/${agent.config.outputFilePattern}`);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
console.log(` ${agent.name} (invalid or missing agent.json)`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
console.log();
|
|
122
|
+
});
|
|
123
|
+
// ── config ─────────────────────────────────────────────────
|
|
124
|
+
program
|
|
125
|
+
.command('config <name>')
|
|
126
|
+
.description('Display the configuration for an agent')
|
|
127
|
+
.action(async (name) => {
|
|
128
|
+
const engine = new engine_1.InstruxEngine();
|
|
129
|
+
try {
|
|
130
|
+
const config = await engine.loadConfig(name);
|
|
131
|
+
console.log(`\n📋 ${config.name}\n`);
|
|
132
|
+
console.log(` Description: ${config.description}`);
|
|
133
|
+
console.log(` Output: ${config.outputDirectory}/${config.outputFilePattern}`);
|
|
134
|
+
console.log();
|
|
135
|
+
console.log(' Files:');
|
|
136
|
+
(config.files ?? []).forEach((f, i) => {
|
|
137
|
+
const tag = f.required ? 'required' : 'optional';
|
|
138
|
+
console.log(` ${i + 1}. ${f.path} [${tag}]`);
|
|
139
|
+
console.log(` ${f.description}`);
|
|
140
|
+
});
|
|
141
|
+
console.log();
|
|
142
|
+
console.log(' Merge settings:');
|
|
143
|
+
Object.entries(config.mergeSettings).forEach(([k, v]) => {
|
|
144
|
+
console.log(` ${k}: ${v}`);
|
|
145
|
+
});
|
|
146
|
+
console.log();
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
console.error(`❌ ${err.message}`);
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
// ── validate ───────────────────────────────────────────────
|
|
154
|
+
program
|
|
155
|
+
.command('validate <name>')
|
|
156
|
+
.description('Check that all required instruction files exist')
|
|
157
|
+
.action(async (name) => {
|
|
158
|
+
const engine = new engine_1.InstruxEngine();
|
|
159
|
+
try {
|
|
160
|
+
const config = await engine.loadConfig(name);
|
|
161
|
+
const result = await engine.validate(config);
|
|
162
|
+
result.warnings.forEach(w => console.log(` ⚠ ${w}`));
|
|
163
|
+
if (result.valid) {
|
|
164
|
+
console.log('✅ All required files are present.');
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
console.log('❌ Missing required files:');
|
|
168
|
+
result.missing.forEach(f => console.log(` - ${f}`));
|
|
169
|
+
process.exit(1);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
console.error(`❌ ${err.message}`);
|
|
174
|
+
process.exit(1);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
// ── helpers ────────────────────────────────────────────────
|
|
178
|
+
function printBuildResult(name, result) {
|
|
179
|
+
console.log(`✅ ${name} built successfully`);
|
|
180
|
+
console.log(` Output: ${result.outputPath}`);
|
|
181
|
+
console.log(` Size: ${result.contentLength.toLocaleString()} chars`);
|
|
182
|
+
console.log(` Hash: ${result.contentHash}`);
|
|
183
|
+
}
|
|
184
|
+
// ── go ─────────────────────────────────────────────────────
|
|
185
|
+
program.parse();
|
|
186
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;GAUG;;AAEH,yCAAoC;AAEpC,qCAAyC;AACzC,iCAAsD;AAEtD,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACvC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,yEAAyE,CAAC;KACtF,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAExB,8DAA8D;AAE9D,OAAO;KACJ,OAAO,CAAC,aAAa,CAAC;KACtB,WAAW,CAAC,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— Recursive Handlebars compiler.
|
|
3
|
+
*
|
|
4
|
+
* Compiles an entry template by resolving {{tag}}, {{file}}, and {{tagged}}
|
|
5
|
+
* helpers recursively, producing a single merged output document.
|
|
6
|
+
*
|
|
7
|
+
* Compilation pipeline:
|
|
8
|
+
* 1. Scan sources → parse frontmatter → build tag index
|
|
9
|
+
* 2. Starting from the entry file, compile as Handlebars template
|
|
10
|
+
* 3. Helpers resolve tags/files → each is itself compiled (recursion)
|
|
11
|
+
* 4. Cycle detection via a compile stack
|
|
12
|
+
* 5. Emit final output with optional frontmatter passthrough
|
|
13
|
+
*/
|
|
14
|
+
import { AgentConfig } from './types';
|
|
15
|
+
export interface CompileResult {
|
|
16
|
+
/** Final compiled output (may include frontmatter block) */
|
|
17
|
+
output: string;
|
|
18
|
+
/** Number of unique files that were compiled */
|
|
19
|
+
filesCompiled: number;
|
|
20
|
+
/** Tags that were referenced during compilation */
|
|
21
|
+
tagsUsed: string[];
|
|
22
|
+
}
|
|
23
|
+
export declare class InstruxCompiler {
|
|
24
|
+
private rootDir;
|
|
25
|
+
private config;
|
|
26
|
+
private index;
|
|
27
|
+
private compileStack;
|
|
28
|
+
private compiledFiles;
|
|
29
|
+
private tagsUsed;
|
|
30
|
+
constructor(rootDir: string, config: AgentConfig);
|
|
31
|
+
compile(): Promise<CompileResult>;
|
|
32
|
+
private compileFile;
|
|
33
|
+
private registerHelpers;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,EACL,WAAW,EAIZ,MAAM,SAAS,CAAC;AAQjB,MAAM,WAAW,aAAa;IAC5B,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,QAAQ,CAA0B;gBAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW;IAO1C,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAgDvC,OAAO,CAAC,WAAW;IA+CnB,OAAO,CAAC,eAAe;CA2ExB"}
|