agentpacks 1.7.13 → 1.8.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/dist/api.js +48 -3658
- package/dist/cli/export-cmd.js +7 -1027
- package/dist/cli/generate.js +39 -2731
- package/dist/cli/import-cmd.js +19 -770
- package/dist/cli/info.js +4 -231
- package/dist/cli/init.js +9 -185
- package/dist/cli/install.js +4 -902
- package/dist/cli/login.js +6 -201
- package/dist/cli/models-explain.js +14 -1266
- package/dist/cli/pack/create.js +4 -146
- package/dist/cli/pack/enable.js +2 -65
- package/dist/cli/pack/list.js +5 -893
- package/dist/cli/pack/validate.js +4 -642
- package/dist/cli/publish.js +8 -679
- package/dist/cli/search.js +4 -209
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.js +1 -145
- package/dist/core/dependency-resolver.js +1 -126
- package/dist/core/feature-merger.js +3 -398
- package/dist/core/index.js +5 -1129
- package/dist/core/lockfile.js +2 -43
- package/dist/core/metarepo.js +1 -183
- package/dist/core/pack-loader.js +4 -841
- package/dist/core/profile-resolver.js +1 -110
- package/dist/exporters/cursor-plugin.js +6 -404
- package/dist/exporters/index.js +6 -404
- package/dist/features/agents.js +3 -161
- package/dist/features/commands.js +3 -161
- package/dist/features/hooks.js +3 -153
- package/dist/features/ignore.js +2 -43
- package/dist/features/index.js +4 -629
- package/dist/features/mcp.js +3 -143
- package/dist/features/models.js +3 -292
- package/dist/features/plugins.js +3 -139
- package/dist/features/rules.d.ts +0 -1
- package/dist/features/rules.js +3 -169
- package/dist/features/skills.js +3 -228
- package/dist/importers/claude-code.js +6 -195
- package/dist/importers/cursor.js +5 -355
- package/dist/importers/opencode.js +6 -346
- package/dist/importers/rulesync.js +5 -365
- package/dist/index.js +89 -4934
- package/dist/node/api.js +48 -3659
- package/dist/node/cli/export-cmd.js +7 -1028
- package/dist/node/cli/generate.js +39 -2732
- package/dist/node/cli/import-cmd.js +19 -771
- package/dist/node/cli/info.js +4 -232
- package/dist/node/cli/init.js +9 -186
- package/dist/node/cli/install.js +4 -903
- package/dist/node/cli/login.js +6 -202
- package/dist/node/cli/models-explain.js +14 -1267
- package/dist/node/cli/pack/create.js +4 -147
- package/dist/node/cli/pack/enable.js +2 -66
- package/dist/node/cli/pack/list.js +5 -894
- package/dist/node/cli/pack/validate.js +4 -643
- package/dist/node/cli/publish.js +8 -680
- package/dist/node/cli/search.js +4 -210
- package/dist/node/core/config.js +1 -146
- package/dist/node/core/dependency-resolver.js +1 -127
- package/dist/node/core/feature-merger.js +3 -399
- package/dist/node/core/index.js +5 -1130
- package/dist/node/core/lockfile.js +2 -44
- package/dist/node/core/metarepo.js +1 -184
- package/dist/node/core/pack-loader.js +4 -842
- package/dist/node/core/profile-resolver.js +1 -111
- package/dist/node/exporters/cursor-plugin.js +6 -405
- package/dist/node/exporters/index.js +6 -405
- package/dist/node/features/agents.js +3 -162
- package/dist/node/features/commands.js +3 -162
- package/dist/node/features/hooks.js +3 -154
- package/dist/node/features/ignore.js +2 -44
- package/dist/node/features/index.js +4 -630
- package/dist/node/features/mcp.js +3 -144
- package/dist/node/features/models.js +3 -293
- package/dist/node/features/plugins.js +3 -140
- package/dist/node/features/rules.js +3 -170
- package/dist/node/features/skills.js +3 -229
- package/dist/node/importers/claude-code.js +6 -196
- package/dist/node/importers/cursor.js +5 -356
- package/dist/node/importers/opencode.js +6 -347
- package/dist/node/importers/rulesync.js +5 -366
- package/dist/node/index.js +89 -4935
- package/dist/node/sources/git-ref.js +1 -56
- package/dist/node/sources/git.js +2 -222
- package/dist/node/sources/index.js +4 -714
- package/dist/node/sources/local.js +1 -24
- package/dist/node/sources/npm-ref.js +1 -56
- package/dist/node/sources/npm.js +2 -184
- package/dist/node/sources/registry-ref.js +1 -37
- package/dist/node/sources/registry.js +4 -355
- package/dist/node/targets/additional-targets.js +6 -587
- package/dist/node/targets/base-target.js +1 -23
- package/dist/node/targets/claude-code.js +6 -714
- package/dist/node/targets/codex-cli.js +3 -324
- package/dist/node/targets/copilot.js +5 -603
- package/dist/node/targets/cursor.js +6 -700
- package/dist/node/targets/gemini-cli.js +10 -319
- package/dist/node/targets/generic-md-target.js +6 -478
- package/dist/node/targets/index.js +32 -1873
- package/dist/node/targets/mistral-vibe.js +7 -661
- package/dist/node/targets/opencode.js +13 -723
- package/dist/node/targets/registry.js +32 -1864
- package/dist/node/utils/credentials.js +3 -38
- package/dist/node/utils/diff.js +5 -132
- package/dist/node/utils/filesystem.js +3 -124
- package/dist/node/utils/frontmatter.js +1 -24
- package/dist/node/utils/global.js +1 -53
- package/dist/node/utils/markdown.js +3 -30
- package/dist/node/utils/model-allowlist.js +1 -126
- package/dist/node/utils/model-guidance.js +2 -78
- package/dist/node/utils/registry-client.js +1 -142
- package/dist/node/utils/tarball.js +1 -49
- package/dist/sources/git-ref.js +1 -55
- package/dist/sources/git.js +2 -221
- package/dist/sources/index.js +4 -713
- package/dist/sources/local.js +1 -23
- package/dist/sources/npm-ref.js +1 -55
- package/dist/sources/npm.js +2 -183
- package/dist/sources/registry-ref.js +1 -36
- package/dist/sources/registry.js +4 -354
- package/dist/targets/additional-targets.js +6 -586
- package/dist/targets/base-target.js +1 -22
- package/dist/targets/claude-code.js +6 -713
- package/dist/targets/codex-cli.js +3 -323
- package/dist/targets/copilot.js +5 -602
- package/dist/targets/cursor.js +6 -699
- package/dist/targets/gemini-cli.js +10 -318
- package/dist/targets/generic-md-target.js +6 -477
- package/dist/targets/index.d.ts +0 -1
- package/dist/targets/index.js +32 -1872
- package/dist/targets/mistral-vibe.js +7 -660
- package/dist/targets/opencode.js +13 -722
- package/dist/targets/registry.js +32 -1863
- package/dist/utils/credentials.js +3 -37
- package/dist/utils/diff.js +5 -131
- package/dist/utils/filesystem.js +3 -123
- package/dist/utils/frontmatter.js +1 -23
- package/dist/utils/global.js +1 -52
- package/dist/utils/markdown.js +3 -29
- package/dist/utils/model-allowlist.js +1 -125
- package/dist/utils/model-guidance.js +2 -77
- package/dist/utils/registry-client.js +1 -141
- package/dist/utils/tarball.js +1 -48
- package/package.json +4 -16
- package/dist/node/targets/agents-md.js +0 -211
- package/dist/targets/agents-md.d.ts +0 -13
- package/dist/targets/agents-md.js +0 -211
|
@@ -1,142 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
// src/utils/registry-client.ts
|
|
5
|
-
var DEFAULT_REGISTRY_URL = "https://registry.agentpacks.dev";
|
|
6
|
-
function createRegistryClient(config) {
|
|
7
|
-
return new RegistryClient({
|
|
8
|
-
registryUrl: config?.registryUrl ?? DEFAULT_REGISTRY_URL,
|
|
9
|
-
authToken: config?.authToken,
|
|
10
|
-
timeout: config?.timeout ?? 30000
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
class RegistryClient {
|
|
15
|
-
config;
|
|
16
|
-
constructor(config) {
|
|
17
|
-
this.config = {
|
|
18
|
-
registryUrl: config.registryUrl.replace(/\/+$/, ""),
|
|
19
|
-
authToken: config.authToken,
|
|
20
|
-
timeout: config.timeout ?? 30000
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
async search(params) {
|
|
24
|
-
const searchParams = new URLSearchParams;
|
|
25
|
-
if (params.query)
|
|
26
|
-
searchParams.set("q", params.query);
|
|
27
|
-
if (params.tags?.length)
|
|
28
|
-
searchParams.set("tags", params.tags.join(","));
|
|
29
|
-
if (params.targets?.length)
|
|
30
|
-
searchParams.set("targets", params.targets.join(","));
|
|
31
|
-
if (params.features?.length)
|
|
32
|
-
searchParams.set("features", params.features.join(","));
|
|
33
|
-
if (params.author)
|
|
34
|
-
searchParams.set("author", params.author);
|
|
35
|
-
if (params.sort)
|
|
36
|
-
searchParams.set("sort", params.sort);
|
|
37
|
-
if (params.limit)
|
|
38
|
-
searchParams.set("limit", String(params.limit));
|
|
39
|
-
if (params.offset)
|
|
40
|
-
searchParams.set("offset", String(params.offset));
|
|
41
|
-
const url = `${this.config.registryUrl}/packs?${searchParams.toString()}`;
|
|
42
|
-
const res = await this.fetch(url);
|
|
43
|
-
return res;
|
|
44
|
-
}
|
|
45
|
-
async info(packName) {
|
|
46
|
-
const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}`;
|
|
47
|
-
const res = await this.fetch(url);
|
|
48
|
-
return res;
|
|
49
|
-
}
|
|
50
|
-
async download(packName, version = "latest") {
|
|
51
|
-
const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}/versions/${encodeURIComponent(version)}/download`;
|
|
52
|
-
const response = await fetch(url, {
|
|
53
|
-
headers: this.headers(),
|
|
54
|
-
signal: AbortSignal.timeout(this.config.timeout)
|
|
55
|
-
});
|
|
56
|
-
if (!response.ok) {
|
|
57
|
-
throw new RegistryApiError(response.status, `Failed to download ${packName}@${version}: ${response.statusText}`);
|
|
58
|
-
}
|
|
59
|
-
const integrity = response.headers.get("x-integrity") ?? "";
|
|
60
|
-
const data = await response.arrayBuffer();
|
|
61
|
-
return { data, integrity };
|
|
62
|
-
}
|
|
63
|
-
async publish(tarball, metadata) {
|
|
64
|
-
if (!this.config.authToken) {
|
|
65
|
-
throw new Error("Authentication required. Run `agentpacks login` first.");
|
|
66
|
-
}
|
|
67
|
-
const formData = new FormData;
|
|
68
|
-
formData.append("tarball", new Blob([tarball], { type: "application/gzip" }), `${metadata.name}-${metadata.version}.tgz`);
|
|
69
|
-
formData.append("metadata", JSON.stringify(metadata));
|
|
70
|
-
const url = `${this.config.registryUrl}/packs`;
|
|
71
|
-
const response = await fetch(url, {
|
|
72
|
-
method: "POST",
|
|
73
|
-
headers: {
|
|
74
|
-
Authorization: `Bearer ${this.config.authToken}`
|
|
75
|
-
},
|
|
76
|
-
body: formData,
|
|
77
|
-
signal: AbortSignal.timeout(this.config.timeout)
|
|
78
|
-
});
|
|
79
|
-
if (!response.ok) {
|
|
80
|
-
const body = await response.text();
|
|
81
|
-
throw new RegistryApiError(response.status, `Publish failed: ${body || response.statusText}`);
|
|
82
|
-
}
|
|
83
|
-
return await response.json();
|
|
84
|
-
}
|
|
85
|
-
async featured(limit) {
|
|
86
|
-
const url = limit ? `${this.config.registryUrl}/featured?limit=${limit}` : `${this.config.registryUrl}/featured`;
|
|
87
|
-
const res = await this.fetch(url);
|
|
88
|
-
return res.packs;
|
|
89
|
-
}
|
|
90
|
-
async tags() {
|
|
91
|
-
const url = `${this.config.registryUrl}/tags`;
|
|
92
|
-
const res = await this.fetch(url);
|
|
93
|
-
return res.tags;
|
|
94
|
-
}
|
|
95
|
-
async stats() {
|
|
96
|
-
const url = `${this.config.registryUrl}/stats`;
|
|
97
|
-
return await this.fetch(url);
|
|
98
|
-
}
|
|
99
|
-
async health() {
|
|
100
|
-
try {
|
|
101
|
-
const url = `${this.config.registryUrl}/health`;
|
|
102
|
-
await this.fetch(url);
|
|
103
|
-
return true;
|
|
104
|
-
} catch {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
async fetch(url) {
|
|
109
|
-
const response = await fetch(url, {
|
|
110
|
-
headers: this.headers(),
|
|
111
|
-
signal: AbortSignal.timeout(this.config.timeout)
|
|
112
|
-
});
|
|
113
|
-
if (!response.ok) {
|
|
114
|
-
const body = await response.text();
|
|
115
|
-
throw new RegistryApiError(response.status, body || response.statusText);
|
|
116
|
-
}
|
|
117
|
-
return response.json();
|
|
118
|
-
}
|
|
119
|
-
headers() {
|
|
120
|
-
const h = {
|
|
121
|
-
Accept: "application/json"
|
|
122
|
-
};
|
|
123
|
-
if (this.config.authToken) {
|
|
124
|
-
h["Authorization"] = `Bearer ${this.config.authToken}`;
|
|
125
|
-
}
|
|
126
|
-
return h;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
class RegistryApiError extends Error {
|
|
131
|
-
status;
|
|
132
|
-
constructor(status, message) {
|
|
133
|
-
super(message);
|
|
134
|
-
this.name = "RegistryApiError";
|
|
135
|
-
this.status = status;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
export {
|
|
139
|
-
createRegistryClient,
|
|
140
|
-
RegistryClient,
|
|
141
|
-
RegistryApiError
|
|
142
|
-
};
|
|
2
|
+
var K=import.meta.require;function M(j){return new J({registryUrl:j?.registryUrl??"https://registry.agentpacks.dev",authToken:j?.authToken,timeout:j?.timeout??30000})}class J{config;constructor(j){this.config={registryUrl:j.registryUrl.replace(/\/+$/,""),authToken:j.authToken,timeout:j.timeout??30000}}async search(j){let q=new URLSearchParams;if(j.query)q.set("q",j.query);if(j.tags?.length)q.set("tags",j.tags.join(","));if(j.targets?.length)q.set("targets",j.targets.join(","));if(j.features?.length)q.set("features",j.features.join(","));if(j.author)q.set("author",j.author);if(j.sort)q.set("sort",j.sort);if(j.limit)q.set("limit",String(j.limit));if(j.offset)q.set("offset",String(j.offset));let x=`${this.config.registryUrl}/packs?${q.toString()}`;return await this.fetch(x)}async info(j){let q=`${this.config.registryUrl}/packs/${encodeURIComponent(j)}`;return await this.fetch(q)}async download(j,q="latest"){let x=`${this.config.registryUrl}/packs/${encodeURIComponent(j)}/versions/${encodeURIComponent(q)}/download`,z=await fetch(x,{headers:this.headers(),signal:AbortSignal.timeout(this.config.timeout)});if(!z.ok)throw new F(z.status,`Failed to download ${j}@${q}: ${z.statusText}`);let B=z.headers.get("x-integrity")??"";return{data:await z.arrayBuffer(),integrity:B}}async publish(j,q){if(!this.config.authToken)throw Error("Authentication required. Run `agentpacks login` first.");let x=new FormData;x.append("tarball",new Blob([j],{type:"application/gzip"}),`${q.name}-${q.version}.tgz`),x.append("metadata",JSON.stringify(q));let z=`${this.config.registryUrl}/packs`,B=await fetch(z,{method:"POST",headers:{Authorization:`Bearer ${this.config.authToken}`},body:x,signal:AbortSignal.timeout(this.config.timeout)});if(!B.ok){let G=await B.text();throw new F(B.status,`Publish failed: ${G||B.statusText}`)}return await B.json()}async featured(j){let q=j?`${this.config.registryUrl}/featured?limit=${j}`:`${this.config.registryUrl}/featured`;return(await this.fetch(q)).packs}async tags(){let j=`${this.config.registryUrl}/tags`;return(await this.fetch(j)).tags}async stats(){let j=`${this.config.registryUrl}/stats`;return await this.fetch(j)}async health(){try{let j=`${this.config.registryUrl}/health`;return await this.fetch(j),!0}catch{return!1}}async fetch(j){let q=await fetch(j,{headers:this.headers(),signal:AbortSignal.timeout(this.config.timeout)});if(!q.ok){let x=await q.text();throw new F(q.status,x||q.statusText)}return q.json()}headers(){let j={Accept:"application/json"};if(this.config.authToken)j.Authorization=`Bearer ${this.config.authToken}`;return j}}class F extends Error{status;constructor(j,q){super(q);this.name="RegistryApiError",this.status=j}}export{M as createRegistryClient,J as RegistryClient,F as RegistryApiError};
|
package/dist/utils/tarball.js
CHANGED
|
@@ -1,49 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
// src/utils/tarball.ts
|
|
5
|
-
import { execSync } from "child_process";
|
|
6
|
-
import { createHash } from "crypto";
|
|
7
|
-
import { existsSync, mkdirSync, readFileSync, rmSync } from "fs";
|
|
8
|
-
import { tmpdir } from "os";
|
|
9
|
-
import { join, resolve } from "path";
|
|
10
|
-
async function createTarball(packDir) {
|
|
11
|
-
const absDir = resolve(packDir);
|
|
12
|
-
const tmpFile = join(tmpdir(), `agentpacks-${Date.now()}.tgz`);
|
|
13
|
-
try {
|
|
14
|
-
execSync(`tar -czf "${tmpFile}" -C "${absDir}" .`, {
|
|
15
|
-
stdio: "pipe"
|
|
16
|
-
});
|
|
17
|
-
const buffer = readFileSync(tmpFile);
|
|
18
|
-
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
19
|
-
} finally {
|
|
20
|
-
if (existsSync(tmpFile)) {
|
|
21
|
-
rmSync(tmpFile);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
async function extractTarball(data, targetDir) {
|
|
26
|
-
mkdirSync(targetDir, { recursive: true });
|
|
27
|
-
const tmpFile = join(tmpdir(), `agentpacks-${Date.now()}.tgz`);
|
|
28
|
-
try {
|
|
29
|
-
const buffer = Buffer.from(data);
|
|
30
|
-
const { writeFileSync } = await import("fs");
|
|
31
|
-
writeFileSync(tmpFile, buffer);
|
|
32
|
-
execSync(`tar -xzf "${tmpFile}" -C "${targetDir}"`, {
|
|
33
|
-
stdio: "pipe"
|
|
34
|
-
});
|
|
35
|
-
} finally {
|
|
36
|
-
if (existsSync(tmpFile)) {
|
|
37
|
-
rmSync(tmpFile);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function computeTarballIntegrity(data) {
|
|
42
|
-
const hash = createHash("sha256").update(Buffer.from(data)).digest("hex");
|
|
43
|
-
return `sha256-${hash}`;
|
|
44
|
-
}
|
|
45
|
-
export {
|
|
46
|
-
extractTarball,
|
|
47
|
-
createTarball,
|
|
48
|
-
computeTarballIntegrity
|
|
49
|
-
};
|
|
2
|
+
var O=import.meta.require;import{execSync as I}from"child_process";import{createHash as P}from"crypto";import{existsSync as J,mkdirSync as Q,readFileSync as R,rmSync as K}from"fs";import{tmpdir as L}from"os";import{join as M,resolve as T}from"path";async function $(E){let G=T(E),q=M(L(),`agentpacks-${Date.now()}.tgz`);try{I(`tar -czf "${q}" -C "${G}" .`,{stdio:"pipe"});let z=R(q);return z.buffer.slice(z.byteOffset,z.byteOffset+z.byteLength)}finally{if(J(q))K(q)}}async function v(E,G){Q(G,{recursive:!0});let q=M(L(),`agentpacks-${Date.now()}.tgz`);try{let z=Buffer.from(E),{writeFileSync:N}=await import("fs");N(q,z),I(`tar -xzf "${q}" -C "${G}"`,{stdio:"pipe"})}finally{if(J(q))K(q)}}function w(E){return`sha256-${P("sha256").update(Buffer.from(E)).digest("hex")}`}export{v as extractTarball,$ as createTarball,w as computeTarballIntegrity};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentpacks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Composable AI agent configuration manager. Pack-based rules, commands, skills, hooks, and MCP sync across OpenCode, Cursor, Claude Code, Codex, Gemini, Copilot, and more.",
|
|
6
6
|
"keywords": [
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"dev": "contractspec-bun-build dev",
|
|
28
28
|
"clean": "rimraf dist .turbo",
|
|
29
29
|
"lint": "bun lint:fix",
|
|
30
|
-
"lint:fix": "biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .",
|
|
31
|
-
"lint:check": "biome check .",
|
|
30
|
+
"lint:fix": "node ../../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../../scripts/biome.cjs check --write .",
|
|
31
|
+
"lint:check": "node ../../../scripts/biome.cjs check .",
|
|
32
32
|
"test": "bun test --pass-with-no-tests",
|
|
33
33
|
"prebuild": "contractspec-bun-build prebuild",
|
|
34
34
|
"typecheck": "tsc --noEmit"
|
|
@@ -337,12 +337,6 @@
|
|
|
337
337
|
"node": "./dist/node/targets/additional-targets.js",
|
|
338
338
|
"default": "./dist/targets/additional-targets.js"
|
|
339
339
|
},
|
|
340
|
-
"./targets/agents-md": {
|
|
341
|
-
"types": "./dist/targets/agents-md.d.ts",
|
|
342
|
-
"bun": "./dist/targets/agents-md.js",
|
|
343
|
-
"node": "./dist/node/targets/agents-md.js",
|
|
344
|
-
"default": "./dist/targets/agents-md.js"
|
|
345
|
-
},
|
|
346
340
|
"./targets/base-target": {
|
|
347
341
|
"types": "./dist/targets/base-target.d.ts",
|
|
348
342
|
"bun": "./dist/targets/base-target.js",
|
|
@@ -480,7 +474,7 @@
|
|
|
480
474
|
},
|
|
481
475
|
"devDependencies": {
|
|
482
476
|
"@contractspec/tool.typescript": "3.7.13",
|
|
483
|
-
"@contractspec/tool.bun": "3.7.
|
|
477
|
+
"@contractspec/tool.bun": "3.7.14",
|
|
484
478
|
"typescript": "^5.9.3"
|
|
485
479
|
},
|
|
486
480
|
"publishConfig": {
|
|
@@ -787,12 +781,6 @@
|
|
|
787
781
|
"node": "./dist/node/targets/additional-targets.js",
|
|
788
782
|
"default": "./dist/targets/additional-targets.js"
|
|
789
783
|
},
|
|
790
|
-
"./targets/agents-md": {
|
|
791
|
-
"types": "./dist/targets/agents-md.d.ts",
|
|
792
|
-
"bun": "./dist/targets/agents-md.js",
|
|
793
|
-
"node": "./dist/node/targets/agents-md.js",
|
|
794
|
-
"default": "./dist/targets/agents-md.js"
|
|
795
|
-
},
|
|
796
784
|
"./targets/base-target": {
|
|
797
785
|
"types": "./dist/targets/base-target.d.ts",
|
|
798
786
|
"bun": "./dist/targets/base-target.js",
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
-
|
|
4
|
-
// src/utils/filesystem.ts
|
|
5
|
-
import {
|
|
6
|
-
existsSync,
|
|
7
|
-
mkdirSync,
|
|
8
|
-
readdirSync,
|
|
9
|
-
readFileSync,
|
|
10
|
-
rmSync,
|
|
11
|
-
statSync,
|
|
12
|
-
writeFileSync
|
|
13
|
-
} from "fs";
|
|
14
|
-
import { dirname, join, relative } from "path";
|
|
15
|
-
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
|
-
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
|
-
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
18
|
-
function writeGeneratedFile(filepath, content, options = {}) {
|
|
19
|
-
const { header = true, type } = options;
|
|
20
|
-
const ext = type ?? inferFileType(filepath);
|
|
21
|
-
ensureDir(dirname(filepath));
|
|
22
|
-
let output = content;
|
|
23
|
-
if (header) {
|
|
24
|
-
const headerComment = getHeader(ext);
|
|
25
|
-
if (headerComment) {
|
|
26
|
-
output = `${headerComment}
|
|
27
|
-
${content}`;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
writeFileSync(filepath, output, "utf-8");
|
|
31
|
-
}
|
|
32
|
-
function writeGeneratedJson(filepath, data, options = {}) {
|
|
33
|
-
const json = JSON.stringify(data, null, 2);
|
|
34
|
-
writeGeneratedFile(filepath, json + `
|
|
35
|
-
`, { ...options, type: "json" });
|
|
36
|
-
}
|
|
37
|
-
function readFileOrNull(filepath) {
|
|
38
|
-
if (!existsSync(filepath))
|
|
39
|
-
return null;
|
|
40
|
-
return readFileSync(filepath, "utf-8");
|
|
41
|
-
}
|
|
42
|
-
function readJsonOrNull(filepath) {
|
|
43
|
-
const content = readFileOrNull(filepath);
|
|
44
|
-
if (content === null)
|
|
45
|
-
return null;
|
|
46
|
-
return JSON.parse(content);
|
|
47
|
-
}
|
|
48
|
-
function ensureDir(dirPath) {
|
|
49
|
-
if (!existsSync(dirPath)) {
|
|
50
|
-
mkdirSync(dirPath, { recursive: true });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function removeIfExists(targetPath) {
|
|
54
|
-
if (existsSync(targetPath)) {
|
|
55
|
-
rmSync(targetPath, { recursive: true, force: true });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function listFiles(dirPath, options = {}) {
|
|
59
|
-
const { extension, recursive = false } = options;
|
|
60
|
-
if (!existsSync(dirPath))
|
|
61
|
-
return [];
|
|
62
|
-
const results = [];
|
|
63
|
-
const entries = readdirSync(dirPath);
|
|
64
|
-
for (const entry of entries) {
|
|
65
|
-
const fullPath = join(dirPath, entry);
|
|
66
|
-
const stat = statSync(fullPath);
|
|
67
|
-
if (stat.isDirectory() && recursive) {
|
|
68
|
-
results.push(...listFiles(fullPath, options));
|
|
69
|
-
} else if (stat.isFile()) {
|
|
70
|
-
if (!extension || entry.endsWith(extension)) {
|
|
71
|
-
results.push(fullPath);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return results;
|
|
76
|
-
}
|
|
77
|
-
function listDirs(dirPath) {
|
|
78
|
-
if (!existsSync(dirPath))
|
|
79
|
-
return [];
|
|
80
|
-
return readdirSync(dirPath).map((entry) => join(dirPath, entry)).filter((fullPath) => statSync(fullPath).isDirectory());
|
|
81
|
-
}
|
|
82
|
-
function relPath(projectRoot, filepath) {
|
|
83
|
-
return relative(projectRoot, filepath);
|
|
84
|
-
}
|
|
85
|
-
function isGeneratedFile(filepath) {
|
|
86
|
-
const content = readFileOrNull(filepath);
|
|
87
|
-
if (!content)
|
|
88
|
-
return false;
|
|
89
|
-
return content.startsWith(GENERATED_HEADER_MD) || content.startsWith(GENERATED_HEADER_JSON) || content.startsWith(GENERATED_HEADER_JS);
|
|
90
|
-
}
|
|
91
|
-
function inferFileType(filepath) {
|
|
92
|
-
if (filepath.endsWith(".json") || filepath.endsWith(".jsonc"))
|
|
93
|
-
return "json";
|
|
94
|
-
if (filepath.endsWith(".ts") || filepath.endsWith(".mts"))
|
|
95
|
-
return "ts";
|
|
96
|
-
if (filepath.endsWith(".js") || filepath.endsWith(".mjs"))
|
|
97
|
-
return "js";
|
|
98
|
-
return "md";
|
|
99
|
-
}
|
|
100
|
-
function getHeader(type) {
|
|
101
|
-
switch (type) {
|
|
102
|
-
case "md":
|
|
103
|
-
return GENERATED_HEADER_MD;
|
|
104
|
-
case "json":
|
|
105
|
-
return GENERATED_HEADER_JSON;
|
|
106
|
-
case "js":
|
|
107
|
-
case "ts":
|
|
108
|
-
return GENERATED_HEADER_JS;
|
|
109
|
-
default:
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/utils/frontmatter.ts
|
|
115
|
-
import matter from "gray-matter";
|
|
116
|
-
function parseFrontmatter(source) {
|
|
117
|
-
const { data, content } = matter(source);
|
|
118
|
-
return {
|
|
119
|
-
data,
|
|
120
|
-
content: content.trim(),
|
|
121
|
-
raw: source
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function serializeFrontmatter(data, content) {
|
|
125
|
-
const filtered = Object.fromEntries(Object.entries(data).filter(([, v]) => v !== undefined));
|
|
126
|
-
if (Object.keys(filtered).length === 0) {
|
|
127
|
-
return content;
|
|
128
|
-
}
|
|
129
|
-
return matter.stringify(content, filtered);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// src/features/rules.ts
|
|
133
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
134
|
-
import { basename } from "path";
|
|
135
|
-
function parseRules(rulesDir, packName) {
|
|
136
|
-
const files = listFiles(rulesDir, { extension: ".md" });
|
|
137
|
-
return files.map((filepath) => parseRuleFile(filepath, packName));
|
|
138
|
-
}
|
|
139
|
-
function parseRuleFile(filepath, packName) {
|
|
140
|
-
const raw = readFileSync2(filepath, "utf-8");
|
|
141
|
-
const { data, content } = parseFrontmatter(raw);
|
|
142
|
-
return {
|
|
143
|
-
name: basename(filepath, ".md"),
|
|
144
|
-
sourcePath: filepath,
|
|
145
|
-
packName,
|
|
146
|
-
meta: data,
|
|
147
|
-
content
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function ruleMatchesTarget(rule, targetId) {
|
|
151
|
-
const { targets } = rule.meta;
|
|
152
|
-
if (!targets || targets === "*")
|
|
153
|
-
return true;
|
|
154
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
155
|
-
return true;
|
|
156
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
157
|
-
}
|
|
158
|
-
function getRootRules(rules) {
|
|
159
|
-
return rules.filter((r) => r.meta.root === true);
|
|
160
|
-
}
|
|
161
|
-
function getDetailRules(rules) {
|
|
162
|
-
return rules.filter((r) => r.meta.root !== true);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// src/targets/base-target.ts
|
|
166
|
-
class BaseTarget {
|
|
167
|
-
supportsFeature(feature) {
|
|
168
|
-
return this.supportedFeatures.includes(feature);
|
|
169
|
-
}
|
|
170
|
-
getEffectiveFeatures(enabledFeatures) {
|
|
171
|
-
return enabledFeatures.filter((f) => this.supportsFeature(f));
|
|
172
|
-
}
|
|
173
|
-
createResult(filesWritten = [], filesDeleted = [], warnings = []) {
|
|
174
|
-
return {
|
|
175
|
-
targetId: this.id,
|
|
176
|
-
filesWritten,
|
|
177
|
-
filesDeleted,
|
|
178
|
-
warnings
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// src/targets/agents-md.ts
|
|
184
|
-
import { resolve } from "path";
|
|
185
|
-
class AgentsMdTarget extends BaseTarget {
|
|
186
|
-
id = "agentsmd";
|
|
187
|
-
name = "AGENTS.md";
|
|
188
|
-
supportedFeatures = ["rules"];
|
|
189
|
-
generate(options) {
|
|
190
|
-
const { projectRoot, baseDir, features } = options;
|
|
191
|
-
const root = resolve(projectRoot, baseDir);
|
|
192
|
-
const filesWritten = [];
|
|
193
|
-
const warnings = [];
|
|
194
|
-
const rootRules = getRootRules(features.rules);
|
|
195
|
-
if (rootRules.length === 0) {
|
|
196
|
-
warnings.push("No root rules found. AGENTS.md will not be generated.");
|
|
197
|
-
return this.createResult(filesWritten, [], warnings);
|
|
198
|
-
}
|
|
199
|
-
const sections = rootRules.map((r) => r.content);
|
|
200
|
-
const content = sections.join(`
|
|
201
|
-
|
|
202
|
-
`);
|
|
203
|
-
const filepath = resolve(root, "AGENTS.md");
|
|
204
|
-
writeGeneratedFile(filepath, content);
|
|
205
|
-
filesWritten.push(filepath);
|
|
206
|
-
return this.createResult(filesWritten, [], warnings);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
export {
|
|
210
|
-
AgentsMdTarget
|
|
211
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { FeatureId } from '../core/config.js';
|
|
2
|
-
import { BaseTarget, type GenerateOptions, type GenerateResult } from './base-target.js';
|
|
3
|
-
/**
|
|
4
|
-
* AGENTS.md target generator.
|
|
5
|
-
* Generates a universal AGENTS.md file from root rules.
|
|
6
|
-
* This is auto-included and consumed by OpenCode, Codex, and any AGENTS.md-aware tool.
|
|
7
|
-
*/
|
|
8
|
-
export declare class AgentsMdTarget extends BaseTarget {
|
|
9
|
-
readonly id = "agentsmd";
|
|
10
|
-
readonly name = "AGENTS.md";
|
|
11
|
-
readonly supportedFeatures: FeatureId[];
|
|
12
|
-
generate(options: GenerateOptions): GenerateResult;
|
|
13
|
-
}
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
var __require = import.meta.require;
|
|
3
|
-
|
|
4
|
-
// src/utils/filesystem.ts
|
|
5
|
-
import {
|
|
6
|
-
existsSync,
|
|
7
|
-
mkdirSync,
|
|
8
|
-
readdirSync,
|
|
9
|
-
readFileSync,
|
|
10
|
-
rmSync,
|
|
11
|
-
statSync,
|
|
12
|
-
writeFileSync
|
|
13
|
-
} from "fs";
|
|
14
|
-
import { dirname, join, relative } from "path";
|
|
15
|
-
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
|
-
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
|
-
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
18
|
-
function writeGeneratedFile(filepath, content, options = {}) {
|
|
19
|
-
const { header = true, type } = options;
|
|
20
|
-
const ext = type ?? inferFileType(filepath);
|
|
21
|
-
ensureDir(dirname(filepath));
|
|
22
|
-
let output = content;
|
|
23
|
-
if (header) {
|
|
24
|
-
const headerComment = getHeader(ext);
|
|
25
|
-
if (headerComment) {
|
|
26
|
-
output = `${headerComment}
|
|
27
|
-
${content}`;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
writeFileSync(filepath, output, "utf-8");
|
|
31
|
-
}
|
|
32
|
-
function writeGeneratedJson(filepath, data, options = {}) {
|
|
33
|
-
const json = JSON.stringify(data, null, 2);
|
|
34
|
-
writeGeneratedFile(filepath, json + `
|
|
35
|
-
`, { ...options, type: "json" });
|
|
36
|
-
}
|
|
37
|
-
function readFileOrNull(filepath) {
|
|
38
|
-
if (!existsSync(filepath))
|
|
39
|
-
return null;
|
|
40
|
-
return readFileSync(filepath, "utf-8");
|
|
41
|
-
}
|
|
42
|
-
function readJsonOrNull(filepath) {
|
|
43
|
-
const content = readFileOrNull(filepath);
|
|
44
|
-
if (content === null)
|
|
45
|
-
return null;
|
|
46
|
-
return JSON.parse(content);
|
|
47
|
-
}
|
|
48
|
-
function ensureDir(dirPath) {
|
|
49
|
-
if (!existsSync(dirPath)) {
|
|
50
|
-
mkdirSync(dirPath, { recursive: true });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function removeIfExists(targetPath) {
|
|
54
|
-
if (existsSync(targetPath)) {
|
|
55
|
-
rmSync(targetPath, { recursive: true, force: true });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function listFiles(dirPath, options = {}) {
|
|
59
|
-
const { extension, recursive = false } = options;
|
|
60
|
-
if (!existsSync(dirPath))
|
|
61
|
-
return [];
|
|
62
|
-
const results = [];
|
|
63
|
-
const entries = readdirSync(dirPath);
|
|
64
|
-
for (const entry of entries) {
|
|
65
|
-
const fullPath = join(dirPath, entry);
|
|
66
|
-
const stat = statSync(fullPath);
|
|
67
|
-
if (stat.isDirectory() && recursive) {
|
|
68
|
-
results.push(...listFiles(fullPath, options));
|
|
69
|
-
} else if (stat.isFile()) {
|
|
70
|
-
if (!extension || entry.endsWith(extension)) {
|
|
71
|
-
results.push(fullPath);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return results;
|
|
76
|
-
}
|
|
77
|
-
function listDirs(dirPath) {
|
|
78
|
-
if (!existsSync(dirPath))
|
|
79
|
-
return [];
|
|
80
|
-
return readdirSync(dirPath).map((entry) => join(dirPath, entry)).filter((fullPath) => statSync(fullPath).isDirectory());
|
|
81
|
-
}
|
|
82
|
-
function relPath(projectRoot, filepath) {
|
|
83
|
-
return relative(projectRoot, filepath);
|
|
84
|
-
}
|
|
85
|
-
function isGeneratedFile(filepath) {
|
|
86
|
-
const content = readFileOrNull(filepath);
|
|
87
|
-
if (!content)
|
|
88
|
-
return false;
|
|
89
|
-
return content.startsWith(GENERATED_HEADER_MD) || content.startsWith(GENERATED_HEADER_JSON) || content.startsWith(GENERATED_HEADER_JS);
|
|
90
|
-
}
|
|
91
|
-
function inferFileType(filepath) {
|
|
92
|
-
if (filepath.endsWith(".json") || filepath.endsWith(".jsonc"))
|
|
93
|
-
return "json";
|
|
94
|
-
if (filepath.endsWith(".ts") || filepath.endsWith(".mts"))
|
|
95
|
-
return "ts";
|
|
96
|
-
if (filepath.endsWith(".js") || filepath.endsWith(".mjs"))
|
|
97
|
-
return "js";
|
|
98
|
-
return "md";
|
|
99
|
-
}
|
|
100
|
-
function getHeader(type) {
|
|
101
|
-
switch (type) {
|
|
102
|
-
case "md":
|
|
103
|
-
return GENERATED_HEADER_MD;
|
|
104
|
-
case "json":
|
|
105
|
-
return GENERATED_HEADER_JSON;
|
|
106
|
-
case "js":
|
|
107
|
-
case "ts":
|
|
108
|
-
return GENERATED_HEADER_JS;
|
|
109
|
-
default:
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/utils/frontmatter.ts
|
|
115
|
-
import matter from "gray-matter";
|
|
116
|
-
function parseFrontmatter(source) {
|
|
117
|
-
const { data, content } = matter(source);
|
|
118
|
-
return {
|
|
119
|
-
data,
|
|
120
|
-
content: content.trim(),
|
|
121
|
-
raw: source
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function serializeFrontmatter(data, content) {
|
|
125
|
-
const filtered = Object.fromEntries(Object.entries(data).filter(([, v]) => v !== undefined));
|
|
126
|
-
if (Object.keys(filtered).length === 0) {
|
|
127
|
-
return content;
|
|
128
|
-
}
|
|
129
|
-
return matter.stringify(content, filtered);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// src/features/rules.ts
|
|
133
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
134
|
-
import { basename } from "path";
|
|
135
|
-
function parseRules(rulesDir, packName) {
|
|
136
|
-
const files = listFiles(rulesDir, { extension: ".md" });
|
|
137
|
-
return files.map((filepath) => parseRuleFile(filepath, packName));
|
|
138
|
-
}
|
|
139
|
-
function parseRuleFile(filepath, packName) {
|
|
140
|
-
const raw = readFileSync2(filepath, "utf-8");
|
|
141
|
-
const { data, content } = parseFrontmatter(raw);
|
|
142
|
-
return {
|
|
143
|
-
name: basename(filepath, ".md"),
|
|
144
|
-
sourcePath: filepath,
|
|
145
|
-
packName,
|
|
146
|
-
meta: data,
|
|
147
|
-
content
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function ruleMatchesTarget(rule, targetId) {
|
|
151
|
-
const { targets } = rule.meta;
|
|
152
|
-
if (!targets || targets === "*")
|
|
153
|
-
return true;
|
|
154
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
155
|
-
return true;
|
|
156
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
157
|
-
}
|
|
158
|
-
function getRootRules(rules) {
|
|
159
|
-
return rules.filter((r) => r.meta.root === true);
|
|
160
|
-
}
|
|
161
|
-
function getDetailRules(rules) {
|
|
162
|
-
return rules.filter((r) => r.meta.root !== true);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// src/targets/base-target.ts
|
|
166
|
-
class BaseTarget {
|
|
167
|
-
supportsFeature(feature) {
|
|
168
|
-
return this.supportedFeatures.includes(feature);
|
|
169
|
-
}
|
|
170
|
-
getEffectiveFeatures(enabledFeatures) {
|
|
171
|
-
return enabledFeatures.filter((f) => this.supportsFeature(f));
|
|
172
|
-
}
|
|
173
|
-
createResult(filesWritten = [], filesDeleted = [], warnings = []) {
|
|
174
|
-
return {
|
|
175
|
-
targetId: this.id,
|
|
176
|
-
filesWritten,
|
|
177
|
-
filesDeleted,
|
|
178
|
-
warnings
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// src/targets/agents-md.ts
|
|
184
|
-
import { resolve } from "path";
|
|
185
|
-
class AgentsMdTarget extends BaseTarget {
|
|
186
|
-
id = "agentsmd";
|
|
187
|
-
name = "AGENTS.md";
|
|
188
|
-
supportedFeatures = ["rules"];
|
|
189
|
-
generate(options) {
|
|
190
|
-
const { projectRoot, baseDir, features } = options;
|
|
191
|
-
const root = resolve(projectRoot, baseDir);
|
|
192
|
-
const filesWritten = [];
|
|
193
|
-
const warnings = [];
|
|
194
|
-
const rootRules = getRootRules(features.rules);
|
|
195
|
-
if (rootRules.length === 0) {
|
|
196
|
-
warnings.push("No root rules found. AGENTS.md will not be generated.");
|
|
197
|
-
return this.createResult(filesWritten, [], warnings);
|
|
198
|
-
}
|
|
199
|
-
const sections = rootRules.map((r) => r.content);
|
|
200
|
-
const content = sections.join(`
|
|
201
|
-
|
|
202
|
-
`);
|
|
203
|
-
const filepath = resolve(root, "AGENTS.md");
|
|
204
|
-
writeGeneratedFile(filepath, content);
|
|
205
|
-
filesWritten.push(filepath);
|
|
206
|
-
return this.createResult(filesWritten, [], warnings);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
export {
|
|
210
|
-
AgentsMdTarget
|
|
211
|
-
};
|