artifact-contracts 0.1.1 → 0.2.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 +254 -2
- package/cli-contract.yaml +529 -0
- package/dist/agents/index.d.ts +3 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +2 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/orchestrator.d.ts +3 -0
- package/dist/agents/orchestrator.d.ts.map +1 -0
- package/dist/agents/orchestrator.js +109 -0
- package/dist/agents/orchestrator.js.map +1 -0
- package/dist/agents/types.d.ts +21 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +2 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/cli/audit.d.ts +12 -0
- package/dist/cli/audit.d.ts.map +1 -0
- package/dist/cli/audit.js +122 -0
- package/dist/cli/audit.js.map +1 -0
- package/dist/cli/explain.d.ts +5 -0
- package/dist/cli/explain.d.ts.map +1 -0
- package/dist/cli/explain.js +47 -0
- package/dist/cli/explain.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +35 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/list.d.ts +7 -0
- package/dist/cli/list.d.ts.map +1 -0
- package/dist/cli/list.js +49 -0
- package/dist/cli/list.js.map +1 -0
- package/dist/cli/resolve.d.ts +5 -0
- package/dist/cli/resolve.d.ts.map +1 -0
- package/dist/cli/resolve.js +21 -0
- package/dist/cli/resolve.js.map +1 -0
- package/dist/cli/validate.d.ts +5 -0
- package/dist/cli/validate.d.ts.map +1 -0
- package/dist/cli/validate.js +36 -0
- package/dist/cli/validate.js.map +1 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/lookup.d.ts +12 -0
- package/dist/core/lookup.d.ts.map +1 -0
- package/dist/core/lookup.js +24 -0
- package/dist/core/lookup.js.map +1 -0
- package/dist/core/matcher.d.ts +3 -0
- package/dist/core/matcher.d.ts.map +1 -0
- package/dist/core/matcher.js +14 -0
- package/dist/core/matcher.js.map +1 -0
- package/dist/core/resolver.d.ts +18 -0
- package/dist/core/resolver.d.ts.map +1 -0
- package/dist/core/resolver.js +98 -0
- package/dist/core/resolver.js.map +1 -0
- package/dist/core/schema.d.ts +160 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +69 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/validator.d.ts +16 -0
- package/dist/core/validator.d.ts.map +1 -0
- package/dist/core/validator.js +86 -0
- package/dist/core/validator.js.map +1 -0
- package/dist/generated/commands.d.ts +2 -0
- package/dist/generated/commands.d.ts.map +1 -0
- package/dist/generated/commands.js +2 -0
- package/dist/generated/commands.js.map +1 -0
- package/dist/generated/dsl/agents.d.ts +34 -0
- package/dist/generated/dsl/agents.d.ts.map +1 -0
- package/dist/generated/dsl/agents.js +42 -0
- package/dist/generated/dsl/agents.js.map +1 -0
- package/dist/generated/dsl/handoffs.d.ts +339 -0
- package/dist/generated/dsl/handoffs.d.ts.map +1 -0
- package/dist/generated/dsl/handoffs.js +74 -0
- package/dist/generated/dsl/handoffs.js.map +1 -0
- package/dist/generated/dsl/index.d.ts +13 -0
- package/dist/generated/dsl/index.d.ts.map +1 -0
- package/dist/generated/dsl/index.js +10 -0
- package/dist/generated/dsl/index.js.map +1 -0
- package/dist/generated/dsl/tasks.d.ts +23 -0
- package/dist/generated/dsl/tasks.d.ts.map +1 -0
- package/dist/generated/dsl/tasks.js +25 -0
- package/dist/generated/dsl/tasks.js.map +1 -0
- package/dist/generated/dsl/workflows.d.ts +31 -0
- package/dist/generated/dsl/workflows.d.ts.map +1 -0
- package/dist/generated/dsl/workflows.js +32 -0
- package/dist/generated/dsl/workflows.js.map +1 -0
- package/dist/generated/index.d.ts +7 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +7 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/policy.d.ts +146 -0
- package/dist/generated/policy.d.ts.map +1 -0
- package/dist/generated/policy.js +236 -0
- package/dist/generated/policy.js.map +1 -0
- package/dist/generated/program.d.ts +33 -0
- package/dist/generated/program.d.ts.map +1 -0
- package/dist/generated/program.js +92 -0
- package/dist/generated/program.js.map +1 -0
- package/dist/generated/schemas.d.ts +471 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +640 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +187 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +3 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -0
- package/package.json +47 -10
- package/schemas/2026A.config.json +47 -0
- package/schemas/2026A.json +116 -0
package/README.md
CHANGED
|
@@ -1,13 +1,265 @@
|
|
|
1
1
|
# artifact-contracts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Declarative artifact registry — define file physical properties, resolve paths to artifact IDs, and detect definition overlaps. Part of the `*-contracts` family alongside [cli-contracts](https://www.npmjs.com/package/cli-contracts) and [agent-contracts](https://www.npmjs.com/package/agent-contracts).
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
artifact-contracts cli-contracts
|
|
9
|
+
(file properties) (command interfaces)
|
|
10
|
+
▲ ▲
|
|
11
|
+
│ $ref │ cli_contract
|
|
12
|
+
│ │
|
|
13
|
+
└───────── agent-contracts ──┘
|
|
14
|
+
(team contracts)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
artifact-contracts answers one question: **"What are the files in this project?"** It declares the physical nature of every file — type, authority, editability, change control — without referencing tools, agents, or commands. agent-contracts references artifact IDs when assigning ownership and permissions.
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
6
20
|
|
|
7
21
|
```bash
|
|
8
22
|
npm install artifact-contracts
|
|
9
23
|
```
|
|
10
24
|
|
|
25
|
+
Create `artifact-contracts.yaml` in your project root:
|
|
26
|
+
|
|
27
|
+
```yaml
|
|
28
|
+
artifactContracts: 0.1.0
|
|
29
|
+
|
|
30
|
+
system:
|
|
31
|
+
id: my-project
|
|
32
|
+
name: My Project
|
|
33
|
+
|
|
34
|
+
artifacts:
|
|
35
|
+
application-code:
|
|
36
|
+
type: source
|
|
37
|
+
authority: canonical
|
|
38
|
+
path_patterns:
|
|
39
|
+
- "src/**/*.ts"
|
|
40
|
+
exclude_patterns:
|
|
41
|
+
- "src/generated/**"
|
|
42
|
+
|
|
43
|
+
generated-api:
|
|
44
|
+
type: generated-code
|
|
45
|
+
authority: generated
|
|
46
|
+
path_patterns:
|
|
47
|
+
- "src/generated/**/*.ts"
|
|
48
|
+
|
|
49
|
+
migration-files:
|
|
50
|
+
type: source
|
|
51
|
+
authority: canonical
|
|
52
|
+
change_control: approval-required
|
|
53
|
+
path_patterns:
|
|
54
|
+
- "db/migrations/**/*.sql"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Validate definitions
|
|
59
|
+
npx artifact-contracts validate
|
|
60
|
+
|
|
61
|
+
# Check for file overlaps against real repository files
|
|
62
|
+
npx artifact-contracts validate --check-files
|
|
63
|
+
|
|
64
|
+
# Ask "what is this file?"
|
|
65
|
+
npx artifact-contracts explain src/generated/client.ts
|
|
66
|
+
# → artifact: generated-api
|
|
67
|
+
# authority: generated
|
|
68
|
+
# manual edit: forbidden
|
|
69
|
+
# change control: regeneration-required
|
|
70
|
+
|
|
71
|
+
# LLM-powered semantic audit (requires agent-contracts-runtime + API key)
|
|
72
|
+
npx artifact-contracts audit --adapter openai
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Design Principles
|
|
76
|
+
|
|
77
|
+
- **Pure artifact registry**: Declares file properties only. No references to tools, agents, or commands — no circular dependencies
|
|
78
|
+
- **Path → artifact ID resolution**: Every file in the project resolves to at most one artifact ID. Ambiguity (overlap) is a definition error
|
|
79
|
+
- **Authority-driven defaults**: `authority` determines sensible defaults for `manual_edit` and `change_control`, reducing boilerplate
|
|
80
|
+
- **Agent-native**: Structured output for all commands. LLM agents and CI systems consume the same interface as humans
|
|
81
|
+
|
|
82
|
+
## DSL Schema
|
|
83
|
+
|
|
84
|
+
### Required Fields
|
|
85
|
+
|
|
86
|
+
| Property | Type | Description |
|
|
87
|
+
|----------|------|-------------|
|
|
88
|
+
| `type` | string | Artifact kind: `source`, `generated-code`, `generated-doc`, `generated-config`, `config`, `lockfile`, `schema`, etc. |
|
|
89
|
+
| `authority` | enum | `canonical` (human-authored SSoT), `derived` (derived from SSoT), `generated` (fully tool-generated), `control` (configuration/settings) |
|
|
90
|
+
| `path_patterns` | string[] | Glob patterns for files belonging to this artifact |
|
|
91
|
+
|
|
92
|
+
### Optional Fields
|
|
93
|
+
|
|
94
|
+
| Property | Type | Description |
|
|
95
|
+
|----------|------|-------------|
|
|
96
|
+
| `description` | string | Human-readable description |
|
|
97
|
+
| `manual_edit` | enum | `allowed`, `discouraged`, `forbidden`. Default based on authority |
|
|
98
|
+
| `change_control` | enum | `none`, `approval-required`, `regeneration-required`. Default based on authority |
|
|
99
|
+
| `exclude_patterns` | string[] | Glob patterns to exclude from `path_patterns` |
|
|
100
|
+
| `visibility` | enum | `public`, `internal`, `private`. Default: `internal` |
|
|
101
|
+
| `states` | string[] | Valid states for this artifact |
|
|
102
|
+
|
|
103
|
+
### Authority Defaults
|
|
104
|
+
|
|
105
|
+
`authority` determines sensible defaults. Explicit values override these.
|
|
106
|
+
|
|
107
|
+
| authority | manual_edit | change_control | Typical use |
|
|
108
|
+
|-----------|-------------|----------------|-------------|
|
|
109
|
+
| `canonical` | `allowed` | `none` | Human-authored source of truth |
|
|
110
|
+
| `derived` | `forbidden` | `regeneration-required` | Derived from another SSoT |
|
|
111
|
+
| `generated` | `forbidden` | `regeneration-required` | Fully tool-generated files |
|
|
112
|
+
| `control` | `allowed` | `approval-required` | Configuration and settings |
|
|
113
|
+
|
|
114
|
+
### Artifact ID Naming
|
|
115
|
+
|
|
116
|
+
IDs are YAML keys used as stable identifiers across `agent-contracts` and `cli-contracts`.
|
|
117
|
+
|
|
118
|
+
- Characters: lowercase alphanumeric and hyphens (`[a-z0-9-]+`)
|
|
119
|
+
- Format: `kebab-case`
|
|
120
|
+
- Reserved: IDs containing `.` are reserved for future namespace extension
|
|
121
|
+
|
|
122
|
+
### Path Resolution
|
|
123
|
+
|
|
124
|
+
A file matches an artifact if it matches any `path_patterns` glob AND does not match any `exclude_patterns` glob.
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
application-code:
|
|
128
|
+
path_patterns: ["src/**/*.ts"]
|
|
129
|
+
exclude_patterns: ["src/generated/**"]
|
|
130
|
+
|
|
131
|
+
generated-api:
|
|
132
|
+
path_patterns: ["src/generated/**/*.ts"]
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
If a file matches multiple artifacts, it is an **overlap** — a definition error detected by `validate --check-files`.
|
|
136
|
+
|
|
137
|
+
### Variable Expansion
|
|
138
|
+
|
|
139
|
+
`artifact-contracts.config.yaml` provides variables that expand `${vars.*}` references in the DSL:
|
|
140
|
+
|
|
141
|
+
```yaml
|
|
142
|
+
# artifact-contracts.config.yaml
|
|
143
|
+
variables:
|
|
144
|
+
doc_patterns:
|
|
145
|
+
- "docs/**/*.md"
|
|
146
|
+
- "packages/*/README.md"
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```yaml
|
|
150
|
+
# artifact-contracts.yaml
|
|
151
|
+
documentation:
|
|
152
|
+
path_patterns:
|
|
153
|
+
- "${vars.doc_patterns}"
|
|
154
|
+
# expands to: ["docs/**/*.md", "packages/*/README.md"]
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Commands
|
|
158
|
+
|
|
159
|
+
### Deterministic Commands
|
|
160
|
+
|
|
161
|
+
| Command | Description |
|
|
162
|
+
|---------|-------------|
|
|
163
|
+
| `validate [--check-files]` | Schema validation, ID naming check, and optional file-based overlap detection |
|
|
164
|
+
| `resolve [--format yaml\|json]` | Output fully-resolved definitions with authority-based defaults applied |
|
|
165
|
+
| `list [--authority TYPE] [--path FILE]` | List artifacts, optionally filtered by authority or reverse-lookup by path |
|
|
166
|
+
| `explain <path> [--format text\|json\|yaml]` | Show full governance properties for a file path |
|
|
167
|
+
|
|
168
|
+
### LLM-Powered Commands
|
|
169
|
+
|
|
170
|
+
| Command | Description |
|
|
171
|
+
|---------|-------------|
|
|
172
|
+
| `audit [--adapter NAME]` | Semantic quality audit — naming consistency, authority appropriateness, coverage gaps |
|
|
173
|
+
|
|
174
|
+
LLM commands require [agent-contracts-runtime](https://www.npmjs.com/package/agent-contracts-runtime) (optional peer dependency) and an adapter API key. Use `--show-prompt` or `--dry-run` to inspect the prompt without calling the LLM.
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Install LLM runtime
|
|
178
|
+
npm install agent-contracts-runtime
|
|
179
|
+
|
|
180
|
+
# Run semantic audit
|
|
181
|
+
npx artifact-contracts audit --adapter openai
|
|
182
|
+
|
|
183
|
+
# Preview the prompt
|
|
184
|
+
npx artifact-contracts audit --show-prompt
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Exit Codes
|
|
188
|
+
|
|
189
|
+
| Code | Meaning |
|
|
190
|
+
|------|---------|
|
|
191
|
+
| `0` | Success |
|
|
192
|
+
| `1` | Validation errors / general error |
|
|
193
|
+
| `2` | Overlap detected (path matches multiple artifacts) |
|
|
194
|
+
| `3` | Config or input file not found / parse error |
|
|
195
|
+
| `10` | Audit findings above `--fail-on` threshold |
|
|
196
|
+
| `11` | `agent-contracts-runtime` not installed |
|
|
197
|
+
| `12` | Adapter initialization error (missing API key, etc.) |
|
|
198
|
+
|
|
199
|
+
## CI Integration
|
|
200
|
+
|
|
201
|
+
```yaml
|
|
202
|
+
name: Artifact Registry Check
|
|
203
|
+
on:
|
|
204
|
+
pull_request:
|
|
205
|
+
paths: ['artifact-contracts.yaml', 'artifact-contracts.config.yaml']
|
|
206
|
+
|
|
207
|
+
jobs:
|
|
208
|
+
check:
|
|
209
|
+
runs-on: ubuntu-latest
|
|
210
|
+
steps:
|
|
211
|
+
- uses: actions/checkout@v4
|
|
212
|
+
- uses: actions/setup-node@v4
|
|
213
|
+
with:
|
|
214
|
+
node-version: '20'
|
|
215
|
+
- run: npm ci
|
|
216
|
+
- run: npx artifact-contracts validate --check-files
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Programmatic API
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
import {
|
|
223
|
+
loadDocument,
|
|
224
|
+
resolveDocument,
|
|
225
|
+
lookupByPath,
|
|
226
|
+
validateDocument,
|
|
227
|
+
} from "artifact-contracts/core";
|
|
228
|
+
|
|
229
|
+
// Load and resolve definitions
|
|
230
|
+
const loadResult = loadDocument();
|
|
231
|
+
const resolved = resolveDocument(loadResult);
|
|
232
|
+
|
|
233
|
+
// Reverse-lookup: path → artifact ID
|
|
234
|
+
const matches = lookupByPath("src/generated/client.ts", resolved.artifacts);
|
|
235
|
+
console.log(matches[0].id); // "generated-api"
|
|
236
|
+
console.log(matches[0].artifact); // { type, authority, manual_edit, ... }
|
|
237
|
+
|
|
238
|
+
// Validate
|
|
239
|
+
const result = await validateDocument(loadResult, { checkFiles: true });
|
|
240
|
+
if (!result.valid) {
|
|
241
|
+
console.error(result.diagnostics);
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Agent-Readable Interface
|
|
246
|
+
|
|
247
|
+
Tool capabilities are described in machine-readable form via [cli-contract.yaml](cli-contract.yaml). LLM agents can introspect available commands, their effects, exit codes, and output schemas without parsing help text.
|
|
248
|
+
|
|
249
|
+
Agent and task definitions for LLM commands are in [dsl/](dsl/) using the [agent-contracts](https://www.npmjs.com/package/agent-contracts) DSL.
|
|
250
|
+
|
|
251
|
+
## Technology Stack
|
|
252
|
+
|
|
253
|
+
| Component | Technology |
|
|
254
|
+
|-----------|-----------|
|
|
255
|
+
| Language | TypeScript (Node.js) |
|
|
256
|
+
| Schema validation | [zod](https://github.com/colinhacks/zod) |
|
|
257
|
+
| Glob matching | [minimatch](https://github.com/isaacs/minimatch) |
|
|
258
|
+
| CLI framework | [commander](https://github.com/tj/commander.js) |
|
|
259
|
+
| CLI contract | [cli-contracts](https://www.npmjs.com/package/cli-contracts) |
|
|
260
|
+
| Agent DSL | [agent-contracts](https://www.npmjs.com/package/agent-contracts) |
|
|
261
|
+
| LLM integration | [agent-contracts-runtime](https://www.npmjs.com/package/agent-contracts-runtime) (optional peer dep) |
|
|
262
|
+
|
|
11
263
|
## License
|
|
12
264
|
|
|
13
265
|
MIT
|