@agents-txt/core 0.1.0 → 0.1.1
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/dist/index.cjs +20 -8
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -8
- package/package.json +56 -56
- package/LICENSE +0 -21
package/dist/index.cjs
CHANGED
|
@@ -108,7 +108,7 @@ function parse(input) {
|
|
|
108
108
|
if (trimmed === "" || trimmed.startsWith("#")) {
|
|
109
109
|
const specMatch = trimmed.match(/^#\s*Spec-Version:\s*(.+)/i);
|
|
110
110
|
if (specMatch) specVersion = specMatch[1].trim();
|
|
111
|
-
const genMatch = trimmed.match(/^#\s*Generated
|
|
111
|
+
const genMatch = trimmed.match(/^#\s*Generated(?:-At)?:\s*(.+)/i);
|
|
112
112
|
if (genMatch) generatedAt = genMatch[1].trim();
|
|
113
113
|
continue;
|
|
114
114
|
}
|
|
@@ -226,6 +226,12 @@ function parse(input) {
|
|
|
226
226
|
const key = trimmed.slice(0, colonIdx).trim();
|
|
227
227
|
const value = trimmed.slice(colonIdx + 1).trim();
|
|
228
228
|
switch (key) {
|
|
229
|
+
case "Spec-Version":
|
|
230
|
+
specVersion = value;
|
|
231
|
+
break;
|
|
232
|
+
case "Generated-At":
|
|
233
|
+
generatedAt = value;
|
|
234
|
+
break;
|
|
229
235
|
case "Site-Name":
|
|
230
236
|
site.name = value;
|
|
231
237
|
break;
|
|
@@ -268,7 +274,7 @@ function parse(input) {
|
|
|
268
274
|
state = "IN_CAPABILITY";
|
|
269
275
|
break;
|
|
270
276
|
case "Agent":
|
|
271
|
-
currentAgentName = value;
|
|
277
|
+
currentAgentName = value.toLowerCase();
|
|
272
278
|
currentAgentPolicy = {};
|
|
273
279
|
state = "IN_AGENT";
|
|
274
280
|
break;
|
|
@@ -307,7 +313,7 @@ function parse(input) {
|
|
|
307
313
|
}
|
|
308
314
|
function parseParam(value) {
|
|
309
315
|
const match = value.match(
|
|
310
|
-
/^(\w+)\s*\(\s*(\w+)\s*,\s*(\w+)(?:\s*,\s*(required))?\s*\)(?:\s
|
|
316
|
+
/^([\w.]+)\s*\(\s*(\w+)\s*,\s*(\w+)(?:\s*,\s*(required))?\s*\)(?:\s*-\s*(.+))?$/
|
|
311
317
|
);
|
|
312
318
|
if (!match) return null;
|
|
313
319
|
const [, name, location, type, req, description] = match;
|
|
@@ -411,9 +417,15 @@ function parseJSON(input) {
|
|
|
411
417
|
warnings: []
|
|
412
418
|
};
|
|
413
419
|
}
|
|
420
|
+
const doc = result.data;
|
|
421
|
+
const normalized = {};
|
|
422
|
+
for (const [name, policy] of Object.entries(doc.agents)) {
|
|
423
|
+
normalized[name === "*" ? "*" : name.toLowerCase()] = policy;
|
|
424
|
+
}
|
|
425
|
+
doc.agents = normalized;
|
|
414
426
|
return {
|
|
415
427
|
success: true,
|
|
416
|
-
document:
|
|
428
|
+
document: doc,
|
|
417
429
|
errors: [],
|
|
418
430
|
warnings: []
|
|
419
431
|
};
|
|
@@ -422,10 +434,10 @@ function parseJSON(input) {
|
|
|
422
434
|
// src/generator.ts
|
|
423
435
|
function generate(doc) {
|
|
424
436
|
const lines = [];
|
|
425
|
-
lines.push("# agents.txt
|
|
426
|
-
lines.push(
|
|
437
|
+
lines.push("# agents.txt - AI Agent Capability Declaration");
|
|
438
|
+
lines.push(`Spec-Version: ${doc.specVersion}`);
|
|
427
439
|
if (doc.generatedAt) {
|
|
428
|
-
lines.push(
|
|
440
|
+
lines.push(`Generated-At: ${doc.generatedAt}`);
|
|
429
441
|
}
|
|
430
442
|
lines.push("");
|
|
431
443
|
if (doc.declarationType) {
|
|
@@ -484,7 +496,7 @@ function generate(doc) {
|
|
|
484
496
|
const parts = [param.in, param.type];
|
|
485
497
|
if (param.required) parts.push("required");
|
|
486
498
|
let line = ` Param: ${param.name} (${parts.join(", ")})`;
|
|
487
|
-
if (param.description) line += `
|
|
499
|
+
if (param.description) line += ` - ${sanitizeValue(param.description)}`;
|
|
488
500
|
lines.push(line);
|
|
489
501
|
}
|
|
490
502
|
}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -65,7 +65,7 @@ function parse(input) {
|
|
|
65
65
|
if (trimmed === "" || trimmed.startsWith("#")) {
|
|
66
66
|
const specMatch = trimmed.match(/^#\s*Spec-Version:\s*(.+)/i);
|
|
67
67
|
if (specMatch) specVersion = specMatch[1].trim();
|
|
68
|
-
const genMatch = trimmed.match(/^#\s*Generated
|
|
68
|
+
const genMatch = trimmed.match(/^#\s*Generated(?:-At)?:\s*(.+)/i);
|
|
69
69
|
if (genMatch) generatedAt = genMatch[1].trim();
|
|
70
70
|
continue;
|
|
71
71
|
}
|
|
@@ -183,6 +183,12 @@ function parse(input) {
|
|
|
183
183
|
const key = trimmed.slice(0, colonIdx).trim();
|
|
184
184
|
const value = trimmed.slice(colonIdx + 1).trim();
|
|
185
185
|
switch (key) {
|
|
186
|
+
case "Spec-Version":
|
|
187
|
+
specVersion = value;
|
|
188
|
+
break;
|
|
189
|
+
case "Generated-At":
|
|
190
|
+
generatedAt = value;
|
|
191
|
+
break;
|
|
186
192
|
case "Site-Name":
|
|
187
193
|
site.name = value;
|
|
188
194
|
break;
|
|
@@ -225,7 +231,7 @@ function parse(input) {
|
|
|
225
231
|
state = "IN_CAPABILITY";
|
|
226
232
|
break;
|
|
227
233
|
case "Agent":
|
|
228
|
-
currentAgentName = value;
|
|
234
|
+
currentAgentName = value.toLowerCase();
|
|
229
235
|
currentAgentPolicy = {};
|
|
230
236
|
state = "IN_AGENT";
|
|
231
237
|
break;
|
|
@@ -264,7 +270,7 @@ function parse(input) {
|
|
|
264
270
|
}
|
|
265
271
|
function parseParam(value) {
|
|
266
272
|
const match = value.match(
|
|
267
|
-
/^(\w+)\s*\(\s*(\w+)\s*,\s*(\w+)(?:\s*,\s*(required))?\s*\)(?:\s
|
|
273
|
+
/^([\w.]+)\s*\(\s*(\w+)\s*,\s*(\w+)(?:\s*,\s*(required))?\s*\)(?:\s*-\s*(.+))?$/
|
|
268
274
|
);
|
|
269
275
|
if (!match) return null;
|
|
270
276
|
const [, name, location, type, req, description] = match;
|
|
@@ -368,9 +374,15 @@ function parseJSON(input) {
|
|
|
368
374
|
warnings: []
|
|
369
375
|
};
|
|
370
376
|
}
|
|
377
|
+
const doc = result.data;
|
|
378
|
+
const normalized = {};
|
|
379
|
+
for (const [name, policy] of Object.entries(doc.agents)) {
|
|
380
|
+
normalized[name === "*" ? "*" : name.toLowerCase()] = policy;
|
|
381
|
+
}
|
|
382
|
+
doc.agents = normalized;
|
|
371
383
|
return {
|
|
372
384
|
success: true,
|
|
373
|
-
document:
|
|
385
|
+
document: doc,
|
|
374
386
|
errors: [],
|
|
375
387
|
warnings: []
|
|
376
388
|
};
|
|
@@ -379,10 +391,10 @@ function parseJSON(input) {
|
|
|
379
391
|
// src/generator.ts
|
|
380
392
|
function generate(doc) {
|
|
381
393
|
const lines = [];
|
|
382
|
-
lines.push("# agents.txt
|
|
383
|
-
lines.push(
|
|
394
|
+
lines.push("# agents.txt - AI Agent Capability Declaration");
|
|
395
|
+
lines.push(`Spec-Version: ${doc.specVersion}`);
|
|
384
396
|
if (doc.generatedAt) {
|
|
385
|
-
lines.push(
|
|
397
|
+
lines.push(`Generated-At: ${doc.generatedAt}`);
|
|
386
398
|
}
|
|
387
399
|
lines.push("");
|
|
388
400
|
if (doc.declarationType) {
|
|
@@ -441,7 +453,7 @@ function generate(doc) {
|
|
|
441
453
|
const parts = [param.in, param.type];
|
|
442
454
|
if (param.required) parts.push("required");
|
|
443
455
|
let line = ` Param: ${param.name} (${parts.join(", ")})`;
|
|
444
|
-
if (param.description) line += `
|
|
456
|
+
if (param.description) line += ` - ${sanitizeValue(param.description)}`;
|
|
445
457
|
lines.push(line);
|
|
446
458
|
}
|
|
447
459
|
}
|
package/package.json
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@agents-txt/core",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Parser, generator, and validator for the agents.txt web standard",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"clean": "node -e \"require(\u0027node:fs\u0027).rmSync(\u0027dist\u0027,{ recursive: true, force: true })\""
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"agents.txt",
|
|
27
|
+
"agents-txt",
|
|
28
|
+
"ai-agents",
|
|
29
|
+
"llm",
|
|
30
|
+
"mcp",
|
|
31
|
+
"well-known",
|
|
32
|
+
"robots-txt",
|
|
33
|
+
"capability-declaration",
|
|
34
|
+
"web-standard",
|
|
35
|
+
"openai",
|
|
36
|
+
"anthropic",
|
|
37
|
+
"claude"
|
|
38
|
+
],
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/kaylacar/agents-txt.git",
|
|
42
|
+
"directory": "packages/core"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/kaylacar/agents-txt",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/kaylacar/agents-txt/issues"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"zod": "^3.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"tsup": "^8.0.0",
|
|
53
|
+
"typescript": "^5.0.0",
|
|
54
|
+
"vitest": "^4.0.0"
|
|
55
|
+
},
|
|
56
|
+
"license": "MIT"
|
|
57
57
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 agents-txt contributors
|
|
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.
|