ruleloom 0.0.0-stage → 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/CHANGELOG.md +12 -0
- package/LICENSE +21 -0
- package/README.md +151 -2
- package/dist/adapters/claude.d.ts +3 -0
- package/dist/adapters/claude.d.ts.map +1 -0
- package/dist/adapters/claude.js +59 -0
- package/dist/adapters/claude.js.map +1 -0
- package/dist/adapters/codex.d.ts +3 -0
- package/dist/adapters/codex.d.ts.map +1 -0
- package/dist/adapters/codex.js +84 -0
- package/dist/adapters/codex.js.map +1 -0
- package/dist/adapters/copilot.d.ts +3 -0
- package/dist/adapters/copilot.d.ts.map +1 -0
- package/dist/adapters/copilot.js +53 -0
- package/dist/adapters/copilot.js.map +1 -0
- package/dist/adapters/format.d.ts +27 -0
- package/dist/adapters/format.d.ts.map +1 -0
- package/dist/adapters/format.js +55 -0
- package/dist/adapters/format.js.map +1 -0
- package/dist/adapters/index.d.ts +10 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +11 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/types.d.ts +19 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +2 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/assemble.d.ts +61 -0
- package/dist/assemble.d.ts.map +1 -0
- package/dist/assemble.js +133 -0
- package/dist/assemble.js.map +1 -0
- package/dist/blocks.d.ts +32 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +59 -0
- package/dist/blocks.js.map +1 -0
- package/dist/bundle.d.ts +121 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +157 -0
- package/dist/bundle.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +141 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +360 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +207 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +16 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/project.d.ts +149 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +102 -0
- package/dist/project.js.map +1 -0
- package/dist/prompt.d.ts +62 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +91 -0
- package/dist/prompt.js.map +1 -0
- package/dist/resources.d.ts +39 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +118 -0
- package/dist/resources.js.map +1 -0
- package/dist/select.d.ts +14 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +25 -0
- package/dist/select.js.map +1 -0
- package/dist/slots.d.ts +35 -0
- package/dist/slots.d.ts.map +1 -0
- package/dist/slots.js +86 -0
- package/dist/slots.js.map +1 -0
- package/docs/agent-definition.md +86 -0
- package/docs/api.md +65 -0
- package/docs/architecture.md +47 -0
- package/docs/cli.md +28 -0
- package/docs/errors.md +76 -0
- package/docs/targets.md +49 -0
- package/package.json +51 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 — 2026-11-30
|
|
4
|
+
|
|
5
|
+
First release, extracted from the agent compiler of the Foliora template factory.
|
|
6
|
+
|
|
7
|
+
- `agent.json` / `ruleloom.json` schemas: modules (rule, skill, mission), tags and retry selection, modes, `data` and `random` slots, preamble, shared rules, skill preload, MCP servers, per-target settings.
|
|
8
|
+
- Shared referentials: local directories and Git repositories pinned to a ref, commit recorded in every build manifest.
|
|
9
|
+
- `compilePrompt`: one string, static (cacheable) then dynamic half, run blocks from numbered templates.
|
|
10
|
+
- Adapters: Claude Code (`.claude/`, `.mcp.json`), OpenAI Codex (`AGENTS.md`, `.agents/skills/`, `.codex/config.toml`), GitHub Copilot (`.github/agents/`, `.github/instructions/`, `.github/skills/`, `.mcp.json`).
|
|
11
|
+
- Deterministic bundles with `build-manifest.json`; `writeBundles` with drift check; `materialiseAgent` refusing a non-isolated root.
|
|
12
|
+
- CLI: `validate`, `compile [--check]`, `prompt`, `materialise`, `list`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Youness Aghazzaf
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,152 @@
|
|
|
1
|
-
#
|
|
1
|
+
# RuleLoom
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Define an AI agent once. Compile it into the native configuration of Claude Code, OpenAI Codex and GitHub Copilot.**
|
|
4
|
+
|
|
5
|
+
RuleLoom reads an agent written as plain files — rules, skills, a mission, MCP servers, variables — and produces what each platform loads by itself: `.claude/` for Claude Code, `AGENTS.md` and `.agents/skills/` for Codex, `.github/agents/` and `.github/instructions/` for Copilot. The same definition also compiles to one prompt string, for a completion API.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
agents/ .ruleloom/build/
|
|
9
|
+
shared/rules/00_HONESTY.md claude/writer/.claude/agents/acme-writer.md
|
|
10
|
+
writer/ .claude/rules/10-shape.md
|
|
11
|
+
agent.json ruleloom compile .claude/skills/20-changelog-style/SKILL.md
|
|
12
|
+
source/mission.md ─────────────▶ codex/writer/AGENTS.md
|
|
13
|
+
source/rules/10_SHAPE.md .agents/skills/20-changelog-style/SKILL.md
|
|
14
|
+
source/skills/20_CHANGELOG_STYLE.md copilot/writer/.github/agents/acme-writer.agent.md
|
|
15
|
+
.github/instructions/10-shape.instructions.md
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- **One source, three platforms.** Rules, skills and MCP servers are written once; each adapter writes the platform's own format.
|
|
19
|
+
- **Deterministic.** Same inputs, same bytes, same checksum. No timestamp, no globbing: `ruleloom compile --check` fails CI when generated files drift.
|
|
20
|
+
- **Refuses rather than guesses.** A typo in a slot, a mode or a preload is a compile error with a stable code, not a silently ignored line.
|
|
21
|
+
- **No secrets in definitions.** MCP servers list environment variable *names*; values are injected at runtime.
|
|
22
|
+
- **Shared referentials.** Rules can come from a local directory or a Git repository pinned to a tag or commit; the commit read is recorded in every build manifest.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install --save-dev ruleloom
|
|
28
|
+
# or: pnpm add -D ruleloom
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Node.js 20 or later.
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
my-project/
|
|
37
|
+
ruleloom.json
|
|
38
|
+
agents/
|
|
39
|
+
shared/rules/00_HONESTY.md
|
|
40
|
+
writer/
|
|
41
|
+
agent.json
|
|
42
|
+
source/mission.md
|
|
43
|
+
source/rules/10_SHAPE.md
|
|
44
|
+
source/skills/20_CHANGELOG_STYLE.md
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`ruleloom.json`:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"agentsDir": "agents",
|
|
52
|
+
"namePrefix": "acme-",
|
|
53
|
+
"targets": ["claude", "codex", "copilot"]
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`agents/writer/agent.json`:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"name": "writer",
|
|
62
|
+
"version": "1.0.0",
|
|
63
|
+
"summary": "Writes a release note from a brief.",
|
|
64
|
+
"data": { "TONE": "plain, never salesy" },
|
|
65
|
+
"random": { "SHAPE": ["list", "prose", "table"] },
|
|
66
|
+
"preamble": ["# WRITER", "TONE: ${{TONE}}"],
|
|
67
|
+
"sharedRules": ["00_HONESTY.md"],
|
|
68
|
+
"mcp": {
|
|
69
|
+
"tracker": { "command": "npx", "args": ["-y", "tracker-mcp"], "env": ["TRACKER_TOKEN"] }
|
|
70
|
+
},
|
|
71
|
+
"targets": {
|
|
72
|
+
"claude": { "tools": "Read, Write" },
|
|
73
|
+
"copilot": { "tools": ["read", "edit"] }
|
|
74
|
+
},
|
|
75
|
+
"modules": [
|
|
76
|
+
{ "path": "source/mission.md", "kind": "mission" },
|
|
77
|
+
{ "path": "source/rules/10_SHAPE.md", "tags": ["SHAPE_WRONG"] },
|
|
78
|
+
{ "path": "source/skills/20_CHANGELOG_STYLE.md" }
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`agents/writer/source/rules/10_SHAPE.md`:
|
|
84
|
+
|
|
85
|
+
```md
|
|
86
|
+
# [10] SHAPE
|
|
87
|
+
|
|
88
|
+
Write the note as **${{SHAPE}}**.
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Then:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npx ruleloom validate # compile every agent for every target, in memory
|
|
95
|
+
npx ruleloom compile # write .ruleloom/build/<target>/<agent>/
|
|
96
|
+
npx ruleloom compile --check # exit 1 if the files on disk drifted
|
|
97
|
+
npx ruleloom prompt --agent writer --random SHAPE=table # one prompt string
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Concepts
|
|
101
|
+
|
|
102
|
+
| Concept | What it is |
|
|
103
|
+
|---|---|
|
|
104
|
+
| **Agent** | A directory with an `agent.json` listing its modules in order. |
|
|
105
|
+
| **Module** | A markdown file: a *rule* (a constraint, always loaded), a *skill* (a procedure, offered on demand) or the *mission* (the agent's own prompt). |
|
|
106
|
+
| **Slot** | `${{NAME}}` in a module, filled from `data` (a constant) or `random` (a list the run draws from). |
|
|
107
|
+
| **Run block** | `{{NAME}}` — what a run appends after the static text in a compiled prompt (the data to work on, the feedback of the last attempt). One template per block in `shared/blocks/`. |
|
|
108
|
+
| **Mode** | A variant of the agent: modules bound to a mode are compiled only for it. |
|
|
109
|
+
| **Tags** | Verification codes a module helps fix: a retry recompiles only the modules tagged with what failed. |
|
|
110
|
+
| **Target** | `claude`, `codex` or `copilot`, each with its adapter. |
|
|
111
|
+
| **Resource** | A shared referential — local directory or Git repository at a pinned ref — cited as `@alias/rules/…`. |
|
|
112
|
+
|
|
113
|
+
## What each target receives
|
|
114
|
+
|
|
115
|
+
| | Claude Code | Codex | GitHub Copilot |
|
|
116
|
+
|---|---|---|---|
|
|
117
|
+
| Agent | `.claude/agents/<name>.md` | `AGENTS.md` | `.github/agents/<name>.agent.md` |
|
|
118
|
+
| Rules | `.claude/rules/<slug>.md` | sections of `AGENTS.md` | `.github/instructions/<slug>.instructions.md` |
|
|
119
|
+
| Skills | `.claude/skills/<slug>/SKILL.md` | `.agents/skills/<slug>/SKILL.md` | `.github/skills/<slug>/SKILL.md` |
|
|
120
|
+
| MCP | `.mcp.json` | `.codex/config.toml` | `.mcp.json` |
|
|
121
|
+
| Skill preload | `skills:` frontmatter | — | — |
|
|
122
|
+
|
|
123
|
+
Details, limits and sources: [docs/targets.md](docs/targets.md).
|
|
124
|
+
|
|
125
|
+
## Library
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import { loadProject, compileBundle, compilePrompt, writeBundles } from 'ruleloom';
|
|
129
|
+
|
|
130
|
+
const project = loadProject('.');
|
|
131
|
+
|
|
132
|
+
const bundle = compileBundle({ project, agent: 'writer', target: 'codex' });
|
|
133
|
+
bundle.files; // Map<path, content>, build-manifest.json included
|
|
134
|
+
bundle.manifest.checksum; // one hash over every emitted file
|
|
135
|
+
|
|
136
|
+
const prompt = compilePrompt({ project, agent: 'writer', values: { BRIEF: '…' } });
|
|
137
|
+
prompt.static; // cacheable prefix
|
|
138
|
+
prompt.text; // what to send
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Documentation
|
|
142
|
+
|
|
143
|
+
- [Architecture](docs/architecture.md) — referentials, compiler, workspaces, orchestration
|
|
144
|
+
- [Agent definition](docs/agent-definition.md) — every field of `agent.json` and `ruleloom.json`
|
|
145
|
+
- [Targets](docs/targets.md) — what each adapter writes, with the platform documentation it follows
|
|
146
|
+
- [CLI](docs/cli.md)
|
|
147
|
+
- [API](docs/api.md)
|
|
148
|
+
- [Error codes](docs/errors.md)
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/adapters/claude.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAmB1C,eAAO,MAAM,aAAa,EAAE,OA+C3B,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { RuleLoomError } from '../errors.js';
|
|
2
|
+
import { frontmatter, mcpJson } from './format.js';
|
|
3
|
+
/**
|
|
4
|
+
* Claude Code (https://code.claude.com/docs/en/memory, /skills, /sub-agents, /mcp).
|
|
5
|
+
*
|
|
6
|
+
* .claude/rules/<slug>.md each rule, loaded at launch (no `paths`)
|
|
7
|
+
* .claude/skills/<slug>/SKILL.md each skill, offered by its description
|
|
8
|
+
* .claude/agents/<name>.md the agent: preamble, mission, constraints
|
|
9
|
+
* .mcp.json MCP servers, `${VAR}` for secrets
|
|
10
|
+
*
|
|
11
|
+
* Rules stay rules, one file each, rather than being concatenated into the
|
|
12
|
+
* agent: Claude Code loads `.claude/rules/` on its own, and a separate file is
|
|
13
|
+
* what lets a human see which rule an agent is following.
|
|
14
|
+
*/
|
|
15
|
+
/** Frontmatter keys this adapter writes itself; an override cannot replace them. */
|
|
16
|
+
const OWN_KEYS = new Set(['name', 'description', 'skills']);
|
|
17
|
+
export const claudeAdapter = {
|
|
18
|
+
target: 'claude',
|
|
19
|
+
inheritedConfig: ['.claude', 'CLAUDE.md', 'CLAUDE.local.md'],
|
|
20
|
+
emit(agent) {
|
|
21
|
+
const files = new Map();
|
|
22
|
+
for (const rule of agent.rules)
|
|
23
|
+
files.set(`.claude/rules/${rule.slug}.md`, `${rule.body}\n`);
|
|
24
|
+
for (const skill of agent.skills) {
|
|
25
|
+
files.set(`.claude/skills/${skill.slug}/SKILL.md`, [frontmatter([['name', skill.slug], ['description', skill.description]]), '', skill.body, ''].join('\n'));
|
|
26
|
+
}
|
|
27
|
+
const overrides = Object.entries(agent.overrides);
|
|
28
|
+
for (const [key, value] of overrides) {
|
|
29
|
+
if (OWN_KEYS.has(key))
|
|
30
|
+
throw new RuleLoomError('TARGET_OVERRIDE_RESERVED', `claude.${key} is written by RuleLoom`);
|
|
31
|
+
// Never from a definition: a generated agent that skips every permission
|
|
32
|
+
// check is one copy away from running somewhere it should not.
|
|
33
|
+
if (key === 'permissionMode' && value === 'bypassPermissions') {
|
|
34
|
+
throw new RuleLoomError('TARGET_OVERRIDE_FORBIDDEN', 'claude.permissionMode bypassPermissions');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const head = frontmatter([
|
|
38
|
+
['name', agent.name],
|
|
39
|
+
['description', agent.summary],
|
|
40
|
+
...(agent.preload.length > 0 ? [['skills', agent.preload.join(', ')]] : []),
|
|
41
|
+
...overrides,
|
|
42
|
+
]);
|
|
43
|
+
const body = [
|
|
44
|
+
...(agent.preamble ? [agent.preamble, ''] : []),
|
|
45
|
+
...(agent.mission ? [agent.mission, ''] : []),
|
|
46
|
+
...(agent.constraints ? [agent.constraints, ''] : []),
|
|
47
|
+
].join('\n');
|
|
48
|
+
files.set(`.claude/agents/${agent.name}.md`, `${head}\n\n${body}`);
|
|
49
|
+
if (Object.keys(agent.mcp).length > 0)
|
|
50
|
+
files.set('.mcp.json', mcpJson(agent.mcp));
|
|
51
|
+
return {
|
|
52
|
+
files,
|
|
53
|
+
notes: Object.keys(agent.mcp).length > 0
|
|
54
|
+
? ['.mcp.json: Claude Code asks the user to approve project MCP servers on first use']
|
|
55
|
+
: [],
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=claude.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/adapters/claude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;GAWG;AAEH,oFAAoF;AACpF,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,aAAa,GAAY;IAC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@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/adapters/codex.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AA4B1C,eAAO,MAAM,YAAY,EAAE,OAmE1B,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { RuleLoomError } from '../errors.js';
|
|
2
|
+
import { frontmatter, tomlArray, tomlString } from './format.js';
|
|
3
|
+
/**
|
|
4
|
+
* OpenAI Codex (https://learn.chatgpt.com/docs/agent-configuration/agents-md,
|
|
5
|
+
* /docs/build-skills, /docs/extend/mcp, /docs/config-file/config-reference).
|
|
6
|
+
*
|
|
7
|
+
* AGENTS.md preamble, mission, constraints, then every
|
|
8
|
+
* rule — Codex has no modular rules
|
|
9
|
+
* directory, only AGENTS.md files
|
|
10
|
+
* .agents/skills/<slug>/SKILL.md each skill (`name`, `description`)
|
|
11
|
+
* .codex/config.toml MCP servers, and the instruction budget
|
|
12
|
+
* when AGENTS.md outgrows the default
|
|
13
|
+
*
|
|
14
|
+
* Codex stops reading project instructions at `project_doc_max_bytes`
|
|
15
|
+
* (32 KiB by default). An AGENTS.md past it would be cut silently, so the
|
|
16
|
+
* budget is raised in `.codex/config.toml` instead — which Codex loads only
|
|
17
|
+
* for a project the user marked as trusted, and the compiler says so.
|
|
18
|
+
*
|
|
19
|
+
* Codex has no skill preload and no project-level prompt files: every skill
|
|
20
|
+
* is offered for discovery.
|
|
21
|
+
*/
|
|
22
|
+
const DEFAULT_DOC_BUDGET = 32 * 1024;
|
|
23
|
+
/** Top-level `config.toml` keys a definition may set, all documented strings. */
|
|
24
|
+
const ALLOWED_OVERRIDES = new Set(['model', 'model_reasoning_effort', 'sandbox_mode', 'approval_policy']);
|
|
25
|
+
export const codexAdapter = {
|
|
26
|
+
target: 'codex',
|
|
27
|
+
inheritedConfig: ['AGENTS.md', 'AGENTS.override.md', '.codex'],
|
|
28
|
+
emit(agent) {
|
|
29
|
+
const files = new Map();
|
|
30
|
+
const notes = [];
|
|
31
|
+
const sections = [
|
|
32
|
+
`# ${agent.name}`,
|
|
33
|
+
agent.summary,
|
|
34
|
+
...(agent.preamble ? [agent.preamble] : []),
|
|
35
|
+
...(agent.mission ? [agent.mission] : []),
|
|
36
|
+
...(agent.constraints ? [agent.constraints] : []),
|
|
37
|
+
...agent.rules.map((rule) => rule.body),
|
|
38
|
+
];
|
|
39
|
+
const instructions = `${sections.join('\n\n---\n\n')}\n`;
|
|
40
|
+
files.set('AGENTS.md', instructions);
|
|
41
|
+
for (const skill of agent.skills) {
|
|
42
|
+
files.set(`.agents/skills/${skill.slug}/SKILL.md`, [frontmatter([['name', skill.slug], ['description', skill.description]]), '', skill.body, ''].join('\n'));
|
|
43
|
+
}
|
|
44
|
+
const config = [];
|
|
45
|
+
for (const [key, value] of Object.entries(agent.overrides)) {
|
|
46
|
+
if (!ALLOWED_OVERRIDES.has(key) || Array.isArray(value)) {
|
|
47
|
+
throw new RuleLoomError('TARGET_OVERRIDE_UNKNOWN', `codex.${key} — accepted: ${[...ALLOWED_OVERRIDES].join(', ')} (strings)`);
|
|
48
|
+
}
|
|
49
|
+
if (key === 'sandbox_mode' && value === 'danger-full-access') {
|
|
50
|
+
throw new RuleLoomError('TARGET_OVERRIDE_FORBIDDEN', 'codex.sandbox_mode danger-full-access');
|
|
51
|
+
}
|
|
52
|
+
config.push(`${key} = ${tomlString(value)}`);
|
|
53
|
+
}
|
|
54
|
+
const bytes = Buffer.byteLength(instructions, 'utf8');
|
|
55
|
+
if (bytes > DEFAULT_DOC_BUDGET) {
|
|
56
|
+
const budget = Math.ceil(bytes / 1024) * 1024;
|
|
57
|
+
config.push(`project_doc_max_bytes = ${budget}`);
|
|
58
|
+
notes.push(`AGENTS.md is ${bytes} bytes, over Codex's 32 KiB default: .codex/config.toml raises the budget, `
|
|
59
|
+
+ 'and Codex reads it only once the project is trusted');
|
|
60
|
+
}
|
|
61
|
+
for (const [name, server] of Object.entries(agent.mcp).sort(([a], [b]) => a.localeCompare(b))) {
|
|
62
|
+
config.push('', `[mcp_servers.${name}]`);
|
|
63
|
+
if (server.url) {
|
|
64
|
+
config.push(`url = ${tomlString(server.url)}`);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
config.push(`command = ${tomlString(server.command)}`);
|
|
68
|
+
if (server.args.length > 0)
|
|
69
|
+
config.push(`args = ${tomlArray(server.args)}`);
|
|
70
|
+
// Names only: Codex forwards these variables from its own environment.
|
|
71
|
+
if (server.env.length > 0)
|
|
72
|
+
config.push(`env_vars = ${tomlArray(server.env)}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (config.length > 0) {
|
|
76
|
+
files.set('.codex/config.toml', `${config.join('\n').trimStart()}\n`);
|
|
77
|
+
if (Object.keys(agent.mcp).length > 0) {
|
|
78
|
+
notes.push('.codex/config.toml: Codex loads a project config only for a trusted project');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return { files, notes };
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=codex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/adapters/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,CAAC;AAErC,iFAAiF;AACjF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAE1G,MAAM,CAAC,MAAM,YAAY,GAAY;IACnC,MAAM,EAAE,OAAO;IACf,eAAe,EAAE,CAAC,WAAW,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,CAAC;AAwB1C,eAAO,MAAM,cAAc,EAAE,OA8C5B,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { RuleLoomError } from '../errors.js';
|
|
2
|
+
import { frontmatter, mcpJson } from './format.js';
|
|
3
|
+
/**
|
|
4
|
+
* GitHub Copilot (https://docs.github.com/en/copilot/reference/custom-agents-configuration,
|
|
5
|
+
* https://code.visualstudio.com/docs/agents/reference/custom-instructions-reference,
|
|
6
|
+
* https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/create-skills,
|
|
7
|
+
* https://code.visualstudio.com/docs/agents/reference/mcp-configuration).
|
|
8
|
+
*
|
|
9
|
+
* .github/agents/<name>.agent.md the agent: preamble, mission, constraints
|
|
10
|
+
* .github/instructions/<slug>.instructions.md each rule, `applyTo: "**"`
|
|
11
|
+
* .github/skills/<slug>/SKILL.md each skill (`name` = directory)
|
|
12
|
+
* .mcp.json MCP servers (Copilot harness)
|
|
13
|
+
*
|
|
14
|
+
* The cloud coding agent reads MCP servers from the repository settings,
|
|
15
|
+
* not from a file; the compiler says so rather than pretending `.mcp.json`
|
|
16
|
+
* reaches it.
|
|
17
|
+
*/
|
|
18
|
+
/** An agent body past this is refused by GitHub. */
|
|
19
|
+
const AGENT_BODY_MAX = 30_000;
|
|
20
|
+
const AGENT_FILE_NAME = /^[A-Za-z0-9._-]+$/;
|
|
21
|
+
const OWN_KEYS = new Set(['name', 'description']);
|
|
22
|
+
export const copilotAdapter = {
|
|
23
|
+
target: 'copilot',
|
|
24
|
+
inheritedConfig: [],
|
|
25
|
+
emit(agent) {
|
|
26
|
+
const files = new Map();
|
|
27
|
+
const notes = [];
|
|
28
|
+
if (!AGENT_FILE_NAME.test(agent.name)) {
|
|
29
|
+
throw new RuleLoomError('AGENT_NAME_INVALID', `${agent.name} — Copilot agent files take letters, digits, ".", "-", "_"`);
|
|
30
|
+
}
|
|
31
|
+
for (const key of Object.keys(agent.overrides)) {
|
|
32
|
+
if (OWN_KEYS.has(key))
|
|
33
|
+
throw new RuleLoomError('TARGET_OVERRIDE_RESERVED', `copilot.${key} is written by RuleLoom`);
|
|
34
|
+
}
|
|
35
|
+
const body = [agent.preamble, agent.mission, agent.constraints].filter(Boolean).join('\n\n');
|
|
36
|
+
if (body.length > AGENT_BODY_MAX) {
|
|
37
|
+
throw new RuleLoomError('COPILOT_AGENT_TOO_LARGE', `${agent.name}: ${body.length} characters, GitHub accepts ${AGENT_BODY_MAX} — move text from the mission into rules`);
|
|
38
|
+
}
|
|
39
|
+
files.set(`.github/agents/${agent.name}.agent.md`, `${frontmatter([['name', agent.name], ['description', agent.summary], ...Object.entries(agent.overrides)])}\n\n${body}\n`);
|
|
40
|
+
for (const rule of agent.rules) {
|
|
41
|
+
files.set(`.github/instructions/${rule.slug}.instructions.md`, `${frontmatter([['applyTo', '**']])}\n\n${rule.body}\n`);
|
|
42
|
+
}
|
|
43
|
+
for (const skill of agent.skills) {
|
|
44
|
+
files.set(`.github/skills/${skill.slug}/SKILL.md`, [frontmatter([['name', skill.slug], ['description', skill.description]]), '', skill.body, ''].join('\n'));
|
|
45
|
+
}
|
|
46
|
+
if (Object.keys(agent.mcp).length > 0) {
|
|
47
|
+
files.set('.mcp.json', mcpJson(agent.mcp));
|
|
48
|
+
notes.push('.mcp.json reaches Copilot in VS Code; the cloud coding agent reads MCP servers from the repository settings');
|
|
49
|
+
}
|
|
50
|
+
return { files, notes };
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=copilot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot.js","sourceRoot":"","sources":["../../src/adapters/copilot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;;;;GAcG;AAEH,oDAAoD;AACpD,MAAM,cAAc,GAAG,MAAM,C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it back unchanged — the common case, and what a
|
|
6
|
+
* human would write — double-quoted otherwise. `description: Turns a: b`
|
|
7
|
+
* written plain is a YAML error, and a platform that cannot parse an agent's
|
|
8
|
+
* frontmatter skips the agent without a word.
|
|
9
|
+
*/
|
|
10
|
+
export declare function yamlScalar(value: string): string;
|
|
11
|
+
/** One frontmatter line: a scalar, or a flow list of quoted strings. */
|
|
12
|
+
export declare function yamlEntry(key: string, value: string | string[]): string;
|
|
13
|
+
/** A frontmatter block, `---` to `---`. */
|
|
14
|
+
export declare function frontmatter(entries: [string, string | string[]][]): string;
|
|
15
|
+
/** A TOML basic string. */
|
|
16
|
+
export declare function tomlString(value: string): string;
|
|
17
|
+
/** A TOML multi-line literal string, or a basic one when the text holds `'''`. */
|
|
18
|
+
export declare function tomlText(value: string): string;
|
|
19
|
+
/** A TOML array of strings. */
|
|
20
|
+
export declare function tomlArray(values: string[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* `.mcp.json`, read by Claude Code and by the Copilot harness alike, with
|
|
23
|
+
* the same `mcpServers` root. Environment values are `${NAME}` references,
|
|
24
|
+
* expanded by the platform at launch: the secret never reaches the file.
|
|
25
|
+
*/
|
|
26
|
+
export declare function mcpJson(servers: Record<string, McpServer>): string;
|
|
27
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/adapters/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQhD;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAIvE;AAED,2CAA2C;AAC3C,wBAAgB,WAAW,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,CAE1E;AAED,2BAA2B;AAC3B,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,+BAA+B;AAC/B,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAElD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,CASlE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A YAML scalar for one frontmatter line.
|
|
3
|
+
*
|
|
4
|
+
* Plain when YAML would read it back unchanged — the common case, and what a
|
|
5
|
+
* human would write — double-quoted otherwise. `description: Turns a: b`
|
|
6
|
+
* written plain is a YAML error, and a platform that cannot parse an agent's
|
|
7
|
+
* frontmatter skips the agent without a word.
|
|
8
|
+
*/
|
|
9
|
+
export function yamlScalar(value) {
|
|
10
|
+
const plain = /^[^\s'"#&*!|>%@`{}[\],?:-]/.test(value)
|
|
11
|
+
&& !/[\n\r]/.test(value)
|
|
12
|
+
&& !/:\s|:$/.test(value)
|
|
13
|
+
&& !/\s#/.test(value)
|
|
14
|
+
&& !/\s$/.test(value)
|
|
15
|
+
&& !/^(?:true|false|null|yes|no|on|off|~|[-+]?\d[\d_.eE+-]*)$/i.test(value);
|
|
16
|
+
return plain ? value : JSON.stringify(value);
|
|
17
|
+
}
|
|
18
|
+
/** One frontmatter line: a scalar, or a flow list of quoted strings. */
|
|
19
|
+
export function yamlEntry(key, value) {
|
|
20
|
+
return Array.isArray(value)
|
|
21
|
+
? `${key}: [${value.map((item) => JSON.stringify(item)).join(', ')}]`
|
|
22
|
+
: `${key}: ${yamlScalar(value)}`;
|
|
23
|
+
}
|
|
24
|
+
/** A frontmatter block, `---` to `---`. */
|
|
25
|
+
export function frontmatter(entries) {
|
|
26
|
+
return ['---', ...entries.map(([key, value]) => yamlEntry(key, value)), '---'].join('\n');
|
|
27
|
+
}
|
|
28
|
+
/** A TOML basic string. */
|
|
29
|
+
export function tomlString(value) {
|
|
30
|
+
return JSON.stringify(value);
|
|
31
|
+
}
|
|
32
|
+
/** A TOML multi-line literal string, or a basic one when the text holds `'''`. */
|
|
33
|
+
export function tomlText(value) {
|
|
34
|
+
return value.includes("'''") ? JSON.stringify(value) : `'''\n${value}'''`;
|
|
35
|
+
}
|
|
36
|
+
/** A TOML array of strings. */
|
|
37
|
+
export function tomlArray(values) {
|
|
38
|
+
return `[${values.map(tomlString).join(', ')}]`;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* `.mcp.json`, read by Claude Code and by the Copilot harness alike, with
|
|
42
|
+
* the same `mcpServers` root. Environment values are `${NAME}` references,
|
|
43
|
+
* expanded by the platform at launch: the secret never reaches the file.
|
|
44
|
+
*/
|
|
45
|
+
export function mcpJson(servers) {
|
|
46
|
+
const entries = Object.entries(servers).sort(([a], [b]) => a.localeCompare(b)).map(([name, server]) => {
|
|
47
|
+
const env = Object.fromEntries(server.env.map((variable) => [variable, `\${${variable}}`]));
|
|
48
|
+
const entry = server.url
|
|
49
|
+
? { type: 'http', url: server.url }
|
|
50
|
+
: { type: 'stdio', command: server.command, args: server.args, ...(server.env.length > 0 ? { env } : {}) };
|
|
51
|
+
return [name, entry];
|
|
52
|
+
});
|
|
53
|
+
return `${JSON.stringify({ mcpServers: Object.fromEntries(entries) }, null, 2)}\n`;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/adapters/format.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,MAAM,KAAK,GAAG,4BAA4B,CAAC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AO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Target } from '../project.js';
|
|
2
|
+
import { claudeAdapter } from './claude.js';
|
|
3
|
+
import { codexAdapter } from './codex.js';
|
|
4
|
+
import { copilotAdapter } from './copilot.js';
|
|
5
|
+
import type { Adapter } from './types.js';
|
|
6
|
+
export declare const ADAPTERS: Readonly<Record<Target, Adapter>>;
|
|
7
|
+
export { claudeAdapter, codexAdapter, copilotAdapter };
|
|
8
|
+
export type { Adapter, AdapterOutput } from './types.js';
|
|
9
|
+
export { frontmatter, mcpJson, yamlScalar } from './format.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAItD,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AACvD,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { claudeAdapter } from './claude.js';
|
|
2
|
+
import { codexAdapter } from './codex.js';
|
|
3
|
+
import { copilotAdapter } from './copilot.js';
|
|
4
|
+
export const ADAPTERS = {
|
|
5
|
+
claude: claudeAdapter,
|
|
6
|
+
codex: codexAdapter,
|
|
7
|
+
copilot: copilotAdapter,
|
|
8
|
+
};
|
|
9
|
+
export { claudeAdapter, codexAdapter, copilotAdapter };
|
|
10
|
+
export { frontmatter, mcpJson, yamlScalar } from './format.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,MAAM,CAAC,MAAM,QAAQ,GAAsC;IACzD,MAAM,EAAE,aAAa;IACrB,KAAK,EAAE,YAAY;IACnB,OAAO,EAAE,cAAc;CACxB,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AssembledAgent } from '../assemble.js';
|
|
2
|
+
import type { Target } from '../project.js';
|
|
3
|
+
/** What an adapter returns: published path → content, and anything the reader should know. */
|
|
4
|
+
export interface AdapterOutput {
|
|
5
|
+
files: Map<string, string>;
|
|
6
|
+
/** Facts about the output a human must act on, e.g. a project config that needs trust. */
|
|
7
|
+
notes: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface Adapter {
|
|
10
|
+
target: Target;
|
|
11
|
+
/** Turns one assembled agent into this platform's native files. */
|
|
12
|
+
emit(agent: AssembledAgent): AdapterOutput;
|
|
13
|
+
/**
|
|
14
|
+
* Files or directories that, found in a parent of a workspace, the
|
|
15
|
+
* platform would load into it. A dedicated workspace must have none above.
|
|
16
|
+
*/
|
|
17
|
+
inheritedConfig: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/adapters/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,8FAA8F;AAC9F,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,0FAA0F;IAC1F,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,IAAI,CAAC,KAAK,EAAE,cAAc,GAAG,aAAa,CAAC;IAC3C;;;OAGG;IACH,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/adapters/types.ts"],"names":[],"mappings":""}
|