agency-rules 0.3.2 → 0.4.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 +7 -0
- package/README.md +19 -0
- package/bin/agency-rules.mjs +127 -0
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.4.0](https://github.com/deuriib/agency-rules/compare/v0.3.2...v0.4.0) (2026-10-31)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **cli:** expose agency-rules binary and router ([dfb6b95](https://github.com/deuriib/agency-rules/commit/dfb6b95b8b6d9ac6f4622479527f182d9c1e637c))
|
|
14
|
+
|
|
8
15
|
## [0.3.2](https://github.com/deuriib/agency-rules/compare/v0.3.1...v0.3.2) (2026-10-31)
|
|
9
16
|
|
|
10
17
|
|
package/README.md
CHANGED
|
@@ -29,6 +29,23 @@ with a single command, driven by a declarative contract (`tools.json`).
|
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
32
|
+
## Global CLI Usage
|
|
33
|
+
|
|
34
|
+
You can also use `agency-rules` directly via `npx` without cloning the repository:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Validate rules
|
|
38
|
+
npx agency-rules validate
|
|
39
|
+
|
|
40
|
+
# Compile rules
|
|
41
|
+
npx agency-rules convert
|
|
42
|
+
|
|
43
|
+
# Install rules interactively
|
|
44
|
+
npx agency-rules install
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
32
49
|
## Quick Start
|
|
33
50
|
|
|
34
51
|
```bash
|
|
@@ -140,6 +157,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md). Pull requests welcome.
|
|
|
140
157
|
|
|
141
158
|
See [SECURITY.md](SECURITY.md) for responsible disclosure.
|
|
142
159
|
|
|
160
|
+

|
|
161
|
+
|
|
143
162
|
## License
|
|
144
163
|
|
|
145
164
|
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const command = process.argv[2];
|
|
8
|
+
|
|
9
|
+
// ── Read version dynamically ──────────────────────────────────────────
|
|
10
|
+
const getVersion = async () => {
|
|
11
|
+
try {
|
|
12
|
+
const pkgPath = resolve(import.meta.dirname, '..', 'package.json');
|
|
13
|
+
const pkg = JSON.parse(await readFile(pkgPath, 'utf8'));
|
|
14
|
+
return pkg.version || '0.0.0';
|
|
15
|
+
} catch {
|
|
16
|
+
return '0.0.0';
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const version = await getVersion();
|
|
21
|
+
|
|
22
|
+
// ── Help Menus ────────────────────────────────────────────────────────
|
|
23
|
+
const showHelp = () => {
|
|
24
|
+
console.log(`
|
|
25
|
+
\x1b[36magency-rules\x1b[0m v${version}
|
|
26
|
+
Write rules once. Run them in every harness.
|
|
27
|
+
|
|
28
|
+
\x1b[33mUsage:\x1b[0m
|
|
29
|
+
$ agency-rules <command> [options]
|
|
30
|
+
|
|
31
|
+
\x1b[33mCommands:\x1b[0m
|
|
32
|
+
\x1b[32mconvert\x1b[0m Compile rules/ into each harness's native format
|
|
33
|
+
\x1b[32minstall\x1b[0m Install compiled artifacts into detected harnesses
|
|
34
|
+
\x1b[32mvalidate\x1b[0m Validate each rule's frontmatter against the schema
|
|
35
|
+
|
|
36
|
+
\x1b[33mGlobal Options:\x1b[0m
|
|
37
|
+
-h, --help Show this help message
|
|
38
|
+
-v, --version Show version number
|
|
39
|
+
|
|
40
|
+
\x1b[33mExamples:\x1b[0m
|
|
41
|
+
$ agency-rules validate
|
|
42
|
+
$ agency-rules convert
|
|
43
|
+
$ agency-rules convert --dry-run
|
|
44
|
+
$ agency-rules install --scope user --harness opencode
|
|
45
|
+
`);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const showCommandHelp = (cmd) => {
|
|
49
|
+
const helps = {
|
|
50
|
+
convert: `
|
|
51
|
+
\x1b[36magency-rules convert\x1b[0m
|
|
52
|
+
Compile rules/ into each harness's native format.
|
|
53
|
+
|
|
54
|
+
\x1b[33mOptions:\x1b[0m
|
|
55
|
+
--dry-run Preview which files would be written (no writes)
|
|
56
|
+
--harness <id> Limit compilation to a specific harness (e.g., antigravity)
|
|
57
|
+
|
|
58
|
+
\x1b[33mExamples:\x1b[0m
|
|
59
|
+
$ agency-rules convert
|
|
60
|
+
$ agency-rules convert --dry-run
|
|
61
|
+
$ agency-rules convert --harness pi-agent
|
|
62
|
+
`,
|
|
63
|
+
install: `
|
|
64
|
+
\x1b[36magency-rules install\x1b[0m
|
|
65
|
+
Install compiled artifacts into detected harnesses.
|
|
66
|
+
|
|
67
|
+
\x1b[33mOptions:\x1b[0m
|
|
68
|
+
--dry-run Preview which files would be copied (no writes)
|
|
69
|
+
--scope <project|user> Install local to project or global to user (default: project)
|
|
70
|
+
--harness <id> Install into a specific harness
|
|
71
|
+
--all Force installation for all harnesses, ignoring auto-detection
|
|
72
|
+
|
|
73
|
+
\x1b[33mExamples:\x1b[0m
|
|
74
|
+
$ agency-rules install
|
|
75
|
+
$ agency-rules install --dry-run
|
|
76
|
+
$ agency-rules install --scope user
|
|
77
|
+
$ agency-rules install --harness opencode --scope project
|
|
78
|
+
`,
|
|
79
|
+
validate: `
|
|
80
|
+
\x1b[36magency-rules validate\x1b[0m
|
|
81
|
+
Validate each rule's frontmatter against the schema.
|
|
82
|
+
|
|
83
|
+
\x1b[33mOptions:\x1b[0m
|
|
84
|
+
(No specific options)
|
|
85
|
+
|
|
86
|
+
\x1b[33mExamples:\x1b[0m
|
|
87
|
+
$ agency-rules validate
|
|
88
|
+
`,
|
|
89
|
+
};
|
|
90
|
+
console.log(helps[cmd] || '');
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// ── Global Flags ──────────────────────────────────────────────────────
|
|
94
|
+
if (process.argv.includes('--version') || process.argv.includes('-v')) {
|
|
95
|
+
console.log(version);
|
|
96
|
+
process.exit(0);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!command || command === 'help' || command === '--help' || command === '-h') {
|
|
100
|
+
showHelp();
|
|
101
|
+
process.exit(0);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!['convert', 'install', 'validate'].includes(command)) {
|
|
105
|
+
console.error(`\x1b[31mError:\x1b[0m Unknown command '${command}'`);
|
|
106
|
+
showHelp();
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ── Command-specific Help ─────────────────────────────────────────────
|
|
111
|
+
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
112
|
+
showCommandHelp(command);
|
|
113
|
+
process.exit(0);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ── Execute ───────────────────────────────────────────────────────────
|
|
117
|
+
// Remove the command from argv so the downstream script's parseArgs works cleanly
|
|
118
|
+
process.argv.splice(2, 1);
|
|
119
|
+
|
|
120
|
+
const scriptPath = resolve(import.meta.dirname, '..', 'scripts', `${command}.mjs`);
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
await import(pathToFileURL(scriptPath).href);
|
|
124
|
+
} catch (err) {
|
|
125
|
+
console.error(`\x1b[31m❌ Failed to execute '${command}':\x1b[0m`, err.message);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agency-rules",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Write rules once. Run them in every harness.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
"opencode",
|
|
23
23
|
"oh-my-pi"
|
|
24
24
|
],
|
|
25
|
+
"bin": {
|
|
26
|
+
"agency-rules": "./bin/agency-rules.mjs"
|
|
27
|
+
},
|
|
25
28
|
"engines": {
|
|
26
29
|
"node": ">=20.12"
|
|
27
30
|
},
|