agentpacks 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/dist/api.d.ts +32 -0
- package/dist/api.js +2852 -0
- package/dist/cli/export-cmd.d.ts +12 -0
- package/dist/cli/export-cmd.js +786 -0
- package/dist/cli/generate.d.ts +13 -0
- package/dist/cli/generate.js +2018 -0
- package/dist/cli/import-cmd.d.ts +9 -0
- package/dist/cli/import-cmd.js +691 -0
- package/dist/cli/init.d.ts +5 -0
- package/dist/cli/init.js +214 -0
- package/dist/cli/install.d.ts +11 -0
- package/dist/cli/install.js +610 -0
- package/dist/cli/pack/create.d.ts +4 -0
- package/dist/cli/pack/create.js +175 -0
- package/dist/cli/pack/enable.d.ts +8 -0
- package/dist/cli/pack/enable.js +96 -0
- package/dist/cli/pack/list.d.ts +4 -0
- package/dist/cli/pack/list.js +699 -0
- package/dist/cli/pack/validate.d.ts +4 -0
- package/dist/cli/pack/validate.js +364 -0
- package/dist/core/config.d.ts +77 -0
- package/dist/core/config.js +181 -0
- package/dist/core/dependency-resolver.d.ts +38 -0
- package/dist/core/dependency-resolver.js +151 -0
- package/dist/core/feature-merger.d.ts +61 -0
- package/dist/core/feature-merger.js +139 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.js +924 -0
- package/dist/core/lockfile.d.ts +50 -0
- package/dist/core/lockfile.js +72 -0
- package/dist/core/metarepo.d.ts +26 -0
- package/dist/core/metarepo.js +218 -0
- package/dist/core/pack-loader.d.ts +61 -0
- package/dist/core/pack-loader.js +646 -0
- package/dist/exporters/cursor-plugin.d.ts +29 -0
- package/dist/exporters/cursor-plugin.js +258 -0
- package/dist/exporters/index.d.ts +1 -0
- package/dist/exporters/index.js +258 -0
- package/dist/features/agents.d.ts +48 -0
- package/dist/features/agents.js +190 -0
- package/dist/features/commands.d.ts +33 -0
- package/dist/features/commands.js +190 -0
- package/dist/features/hooks.d.ts +33 -0
- package/dist/features/hooks.js +182 -0
- package/dist/features/ignore.d.ts +21 -0
- package/dist/features/ignore.js +72 -0
- package/dist/features/index.d.ts +8 -0
- package/dist/features/index.js +426 -0
- package/dist/features/mcp.d.ts +34 -0
- package/dist/features/mcp.js +172 -0
- package/dist/features/plugins.d.ts +23 -0
- package/dist/features/plugins.js +168 -0
- package/dist/features/rules.d.ts +53 -0
- package/dist/features/rules.js +198 -0
- package/dist/features/skills.d.ts +42 -0
- package/dist/features/skills.js +198 -0
- package/dist/importers/claude-code.d.ts +5 -0
- package/dist/importers/claude-code.js +224 -0
- package/dist/importers/cursor.d.ts +5 -0
- package/dist/importers/cursor.js +288 -0
- package/dist/importers/opencode.d.ts +5 -0
- package/dist/importers/opencode.js +261 -0
- package/dist/importers/rulesync.d.ts +14 -0
- package/dist/importers/rulesync.js +280 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3464 -0
- package/dist/node/api.js +2852 -0
- package/dist/node/cli/export-cmd.js +786 -0
- package/dist/node/cli/generate.js +2018 -0
- package/dist/node/cli/import-cmd.js +691 -0
- package/dist/node/cli/init.js +214 -0
- package/dist/node/cli/install.js +610 -0
- package/dist/node/cli/pack/create.js +175 -0
- package/dist/node/cli/pack/enable.js +96 -0
- package/dist/node/cli/pack/list.js +699 -0
- package/dist/node/cli/pack/validate.js +364 -0
- package/dist/node/core/config.js +181 -0
- package/dist/node/core/dependency-resolver.js +151 -0
- package/dist/node/core/feature-merger.js +139 -0
- package/dist/node/core/index.js +924 -0
- package/dist/node/core/lockfile.js +72 -0
- package/dist/node/core/metarepo.js +218 -0
- package/dist/node/core/pack-loader.js +646 -0
- package/dist/node/exporters/cursor-plugin.js +258 -0
- package/dist/node/exporters/index.js +258 -0
- package/dist/node/features/agents.js +190 -0
- package/dist/node/features/commands.js +190 -0
- package/dist/node/features/hooks.js +182 -0
- package/dist/node/features/ignore.js +72 -0
- package/dist/node/features/index.js +426 -0
- package/dist/node/features/mcp.js +172 -0
- package/dist/node/features/plugins.js +168 -0
- package/dist/node/features/rules.js +198 -0
- package/dist/node/features/skills.js +198 -0
- package/dist/node/importers/claude-code.js +224 -0
- package/dist/node/importers/cursor.js +288 -0
- package/dist/node/importers/opencode.js +261 -0
- package/dist/node/importers/rulesync.js +280 -0
- package/dist/node/index.js +3464 -0
- package/dist/node/sources/git-ref.js +79 -0
- package/dist/node/sources/git.js +245 -0
- package/dist/node/sources/index.js +416 -0
- package/dist/node/sources/local.js +52 -0
- package/dist/node/sources/npm-ref.js +84 -0
- package/dist/node/sources/npm.js +211 -0
- package/dist/node/targets/additional-targets.js +428 -0
- package/dist/node/targets/agents-md.js +239 -0
- package/dist/node/targets/base-target.js +51 -0
- package/dist/node/targets/claude-code.js +490 -0
- package/dist/node/targets/codex-cli.js +297 -0
- package/dist/node/targets/copilot.js +390 -0
- package/dist/node/targets/cursor.js +441 -0
- package/dist/node/targets/gemini-cli.js +352 -0
- package/dist/node/targets/generic-md-target.js +319 -0
- package/dist/node/targets/index.js +1351 -0
- package/dist/node/targets/opencode.js +556 -0
- package/dist/node/targets/registry.js +1343 -0
- package/dist/node/utils/diff.js +144 -0
- package/dist/node/utils/filesystem.js +152 -0
- package/dist/node/utils/frontmatter.js +52 -0
- package/dist/node/utils/global.js +81 -0
- package/dist/node/utils/markdown.js +62 -0
- package/dist/sources/git-ref.d.ts +27 -0
- package/dist/sources/git-ref.js +79 -0
- package/dist/sources/git.d.ts +29 -0
- package/dist/sources/git.js +245 -0
- package/dist/sources/index.d.ts +5 -0
- package/dist/sources/index.js +416 -0
- package/dist/sources/local.d.ts +8 -0
- package/dist/sources/local.js +52 -0
- package/dist/sources/npm-ref.d.ts +30 -0
- package/dist/sources/npm-ref.js +84 -0
- package/dist/sources/npm.d.ts +20 -0
- package/dist/sources/npm.js +211 -0
- package/dist/targets/additional-targets.d.ts +65 -0
- package/dist/targets/additional-targets.js +428 -0
- package/dist/targets/agents-md.d.ts +13 -0
- package/dist/targets/agents-md.js +239 -0
- package/dist/targets/base-target.d.ts +61 -0
- package/dist/targets/base-target.js +51 -0
- package/dist/targets/claude-code.d.ts +13 -0
- package/dist/targets/claude-code.js +490 -0
- package/dist/targets/codex-cli.d.ts +12 -0
- package/dist/targets/codex-cli.js +297 -0
- package/dist/targets/copilot.d.ts +12 -0
- package/dist/targets/copilot.js +390 -0
- package/dist/targets/cursor.d.ts +13 -0
- package/dist/targets/cursor.js +441 -0
- package/dist/targets/gemini-cli.d.ts +12 -0
- package/dist/targets/gemini-cli.js +352 -0
- package/dist/targets/generic-md-target.d.ts +25 -0
- package/dist/targets/generic-md-target.js +319 -0
- package/dist/targets/index.d.ts +9 -0
- package/dist/targets/index.js +1351 -0
- package/dist/targets/opencode.d.ts +13 -0
- package/dist/targets/opencode.js +556 -0
- package/dist/targets/registry.d.ts +17 -0
- package/dist/targets/registry.js +1343 -0
- package/dist/utils/diff.d.ts +13 -0
- package/dist/utils/diff.js +144 -0
- package/dist/utils/filesystem.d.ts +49 -0
- package/dist/utils/filesystem.js +152 -0
- package/dist/utils/frontmatter.d.ts +19 -0
- package/dist/utils/frontmatter.js +52 -0
- package/dist/utils/global.d.ts +17 -0
- package/dist/utils/global.js +81 -0
- package/dist/utils/markdown.d.ts +20 -0
- package/dist/utils/markdown.js +62 -0
- package/package.json +808 -0
- package/templates/pack/pack.json +10 -0
- package/templates/pack/rules/overview.md +22 -0
- package/templates/workspace/agentpacks.jsonc +34 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
set: (newValue) => all[name] = () => newValue
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
|
+
|
|
32
|
+
// src/utils/diff.ts
|
|
33
|
+
import { existsSync, readFileSync } from "fs";
|
|
34
|
+
function diffFile(filepath, newContent) {
|
|
35
|
+
if (!existsSync(filepath)) {
|
|
36
|
+
return {
|
|
37
|
+
filepath,
|
|
38
|
+
status: "added",
|
|
39
|
+
diffLines: formatAddedDiff(filepath, newContent)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const existing = readFileSync(filepath, "utf-8");
|
|
43
|
+
if (existing === newContent) {
|
|
44
|
+
return { filepath, status: "unchanged", diffLines: [] };
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
filepath,
|
|
48
|
+
status: "modified",
|
|
49
|
+
diffLines: computeUnifiedDiff(filepath, existing, newContent)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function formatAddedDiff(filepath, content) {
|
|
53
|
+
const lines = [
|
|
54
|
+
`--- /dev/null`,
|
|
55
|
+
`+++ ${filepath}`,
|
|
56
|
+
`@@ -0,0 +1,${content.split(`
|
|
57
|
+
`).length} @@`
|
|
58
|
+
];
|
|
59
|
+
for (const line of content.split(`
|
|
60
|
+
`)) {
|
|
61
|
+
lines.push(`+${line}`);
|
|
62
|
+
}
|
|
63
|
+
return lines;
|
|
64
|
+
}
|
|
65
|
+
function computeUnifiedDiff(filepath, oldContent, newContent) {
|
|
66
|
+
const oldLines = oldContent.split(`
|
|
67
|
+
`);
|
|
68
|
+
const newLines = newContent.split(`
|
|
69
|
+
`);
|
|
70
|
+
const result = [`--- ${filepath}`, `+++ ${filepath}`];
|
|
71
|
+
const hunks = findHunks(oldLines, newLines);
|
|
72
|
+
for (const hunk of hunks) {
|
|
73
|
+
result.push(`@@ -${hunk.oldStart + 1},${hunk.oldCount} +${hunk.newStart + 1},${hunk.newCount} @@`);
|
|
74
|
+
for (const line of hunk.lines) {
|
|
75
|
+
result.push(line);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
function findHunks(oldLines, newLines) {
|
|
81
|
+
const CONTEXT = 3;
|
|
82
|
+
const changes = [];
|
|
83
|
+
let oi = 0;
|
|
84
|
+
let ni = 0;
|
|
85
|
+
while (oi < oldLines.length || ni < newLines.length) {
|
|
86
|
+
if (oi < oldLines.length && ni < newLines.length && oldLines[oi] === newLines[ni]) {
|
|
87
|
+
changes.push({ type: " ", line: oldLines[oi], oldIdx: oi, newIdx: ni });
|
|
88
|
+
oi++;
|
|
89
|
+
ni++;
|
|
90
|
+
} else if (ni < newLines.length && (oi >= oldLines.length || !newLines.slice(ni).includes(oldLines[oi]))) {
|
|
91
|
+
changes.push({ type: "+", line: newLines[ni], oldIdx: oi, newIdx: ni });
|
|
92
|
+
ni++;
|
|
93
|
+
} else {
|
|
94
|
+
changes.push({ type: "-", line: oldLines[oi], oldIdx: oi, newIdx: oi });
|
|
95
|
+
oi++;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const hunks = [];
|
|
99
|
+
let currentHunk = null;
|
|
100
|
+
let unchangedCount = 0;
|
|
101
|
+
for (const change of changes) {
|
|
102
|
+
if (change.type === " ") {
|
|
103
|
+
unchangedCount++;
|
|
104
|
+
if (currentHunk && unchangedCount <= CONTEXT) {
|
|
105
|
+
currentHunk.lines.push(` ${change.line}`);
|
|
106
|
+
currentHunk.oldCount++;
|
|
107
|
+
currentHunk.newCount++;
|
|
108
|
+
} else if (currentHunk && unchangedCount > CONTEXT * 2) {
|
|
109
|
+
hunks.push(currentHunk);
|
|
110
|
+
currentHunk = null;
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
if (!currentHunk) {
|
|
114
|
+
const contextStart = Math.max(0, changes.indexOf(change) - CONTEXT);
|
|
115
|
+
currentHunk = {
|
|
116
|
+
oldStart: change.oldIdx - Math.min(CONTEXT, changes.indexOf(change) - contextStart),
|
|
117
|
+
oldCount: 0,
|
|
118
|
+
newStart: change.newIdx - Math.min(CONTEXT, changes.indexOf(change) - contextStart),
|
|
119
|
+
newCount: 0,
|
|
120
|
+
lines: []
|
|
121
|
+
};
|
|
122
|
+
for (let i = contextStart;i < changes.indexOf(change); i++) {
|
|
123
|
+
if (changes[i].type === " ") {
|
|
124
|
+
currentHunk.lines.push(` ${changes[i].line}`);
|
|
125
|
+
currentHunk.oldCount++;
|
|
126
|
+
currentHunk.newCount++;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
unchangedCount = 0;
|
|
131
|
+
currentHunk.lines.push(`${change.type}${change.line}`);
|
|
132
|
+
if (change.type === "-")
|
|
133
|
+
currentHunk.oldCount++;
|
|
134
|
+
if (change.type === "+")
|
|
135
|
+
currentHunk.newCount++;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (currentHunk)
|
|
139
|
+
hunks.push(currentHunk);
|
|
140
|
+
return hunks;
|
|
141
|
+
}
|
|
142
|
+
export {
|
|
143
|
+
diffFile
|
|
144
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
set: (newValue) => all[name] = () => newValue
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
|
+
|
|
32
|
+
// src/utils/filesystem.ts
|
|
33
|
+
import {
|
|
34
|
+
existsSync,
|
|
35
|
+
mkdirSync,
|
|
36
|
+
readFileSync,
|
|
37
|
+
writeFileSync,
|
|
38
|
+
readdirSync,
|
|
39
|
+
statSync
|
|
40
|
+
} from "fs";
|
|
41
|
+
import { dirname, relative, join } from "path";
|
|
42
|
+
import { removeSync } from "fs-extra";
|
|
43
|
+
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
44
|
+
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
45
|
+
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
46
|
+
function writeGeneratedFile(filepath, content, options = {}) {
|
|
47
|
+
const { header = true, type } = options;
|
|
48
|
+
const ext = type ?? inferFileType(filepath);
|
|
49
|
+
ensureDir(dirname(filepath));
|
|
50
|
+
let output = content;
|
|
51
|
+
if (header) {
|
|
52
|
+
const headerComment = getHeader(ext);
|
|
53
|
+
if (headerComment) {
|
|
54
|
+
output = `${headerComment}
|
|
55
|
+
${content}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
writeFileSync(filepath, output, "utf-8");
|
|
59
|
+
}
|
|
60
|
+
function writeGeneratedJson(filepath, data, options = {}) {
|
|
61
|
+
const json = JSON.stringify(data, null, 2);
|
|
62
|
+
writeGeneratedFile(filepath, json + `
|
|
63
|
+
`, { ...options, type: "json" });
|
|
64
|
+
}
|
|
65
|
+
function readFileOrNull(filepath) {
|
|
66
|
+
if (!existsSync(filepath))
|
|
67
|
+
return null;
|
|
68
|
+
return readFileSync(filepath, "utf-8");
|
|
69
|
+
}
|
|
70
|
+
function readJsonOrNull(filepath) {
|
|
71
|
+
const content = readFileOrNull(filepath);
|
|
72
|
+
if (content === null)
|
|
73
|
+
return null;
|
|
74
|
+
return JSON.parse(content);
|
|
75
|
+
}
|
|
76
|
+
function ensureDir(dirPath) {
|
|
77
|
+
if (!existsSync(dirPath)) {
|
|
78
|
+
mkdirSync(dirPath, { recursive: true });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function removeIfExists(targetPath) {
|
|
82
|
+
if (existsSync(targetPath)) {
|
|
83
|
+
removeSync(targetPath);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function listFiles(dirPath, options = {}) {
|
|
87
|
+
const { extension, recursive = false } = options;
|
|
88
|
+
if (!existsSync(dirPath))
|
|
89
|
+
return [];
|
|
90
|
+
const results = [];
|
|
91
|
+
const entries = readdirSync(dirPath);
|
|
92
|
+
for (const entry of entries) {
|
|
93
|
+
const fullPath = join(dirPath, entry);
|
|
94
|
+
const stat = statSync(fullPath);
|
|
95
|
+
if (stat.isDirectory() && recursive) {
|
|
96
|
+
results.push(...listFiles(fullPath, options));
|
|
97
|
+
} else if (stat.isFile()) {
|
|
98
|
+
if (!extension || entry.endsWith(extension)) {
|
|
99
|
+
results.push(fullPath);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return results;
|
|
104
|
+
}
|
|
105
|
+
function listDirs(dirPath) {
|
|
106
|
+
if (!existsSync(dirPath))
|
|
107
|
+
return [];
|
|
108
|
+
return readdirSync(dirPath).map((entry) => join(dirPath, entry)).filter((fullPath) => statSync(fullPath).isDirectory());
|
|
109
|
+
}
|
|
110
|
+
function relPath(projectRoot, filepath) {
|
|
111
|
+
return relative(projectRoot, filepath);
|
|
112
|
+
}
|
|
113
|
+
function isGeneratedFile(filepath) {
|
|
114
|
+
const content = readFileOrNull(filepath);
|
|
115
|
+
if (!content)
|
|
116
|
+
return false;
|
|
117
|
+
return content.startsWith(GENERATED_HEADER_MD) || content.startsWith(GENERATED_HEADER_JSON) || content.startsWith(GENERATED_HEADER_JS);
|
|
118
|
+
}
|
|
119
|
+
function inferFileType(filepath) {
|
|
120
|
+
if (filepath.endsWith(".json") || filepath.endsWith(".jsonc"))
|
|
121
|
+
return "json";
|
|
122
|
+
if (filepath.endsWith(".ts") || filepath.endsWith(".mts"))
|
|
123
|
+
return "ts";
|
|
124
|
+
if (filepath.endsWith(".js") || filepath.endsWith(".mjs"))
|
|
125
|
+
return "js";
|
|
126
|
+
return "md";
|
|
127
|
+
}
|
|
128
|
+
function getHeader(type) {
|
|
129
|
+
switch (type) {
|
|
130
|
+
case "md":
|
|
131
|
+
return GENERATED_HEADER_MD;
|
|
132
|
+
case "json":
|
|
133
|
+
return GENERATED_HEADER_JSON;
|
|
134
|
+
case "js":
|
|
135
|
+
case "ts":
|
|
136
|
+
return GENERATED_HEADER_JS;
|
|
137
|
+
default:
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
writeGeneratedJson,
|
|
143
|
+
writeGeneratedFile,
|
|
144
|
+
removeIfExists,
|
|
145
|
+
relPath,
|
|
146
|
+
readJsonOrNull,
|
|
147
|
+
readFileOrNull,
|
|
148
|
+
listFiles,
|
|
149
|
+
listDirs,
|
|
150
|
+
isGeneratedFile,
|
|
151
|
+
ensureDir
|
|
152
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
set: (newValue) => all[name] = () => newValue
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
|
+
|
|
32
|
+
// src/utils/frontmatter.ts
|
|
33
|
+
import matter from "gray-matter";
|
|
34
|
+
function parseFrontmatter(source) {
|
|
35
|
+
const { data, content } = matter(source);
|
|
36
|
+
return {
|
|
37
|
+
data,
|
|
38
|
+
content: content.trim(),
|
|
39
|
+
raw: source
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function serializeFrontmatter(data, content) {
|
|
43
|
+
const filtered = Object.fromEntries(Object.entries(data).filter(([, v]) => v !== undefined));
|
|
44
|
+
if (Object.keys(filtered).length === 0) {
|
|
45
|
+
return content;
|
|
46
|
+
}
|
|
47
|
+
return matter.stringify(content, filtered);
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
serializeFrontmatter,
|
|
51
|
+
parseFrontmatter
|
|
52
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
set: (newValue) => all[name] = () => newValue
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
|
+
|
|
32
|
+
// src/utils/global.ts
|
|
33
|
+
import { homedir } from "os";
|
|
34
|
+
import { join, resolve } from "path";
|
|
35
|
+
import { existsSync } from "fs";
|
|
36
|
+
function globalConfigDir() {
|
|
37
|
+
return resolve(process.env.AGENTPACKS_GLOBAL_DIR ?? join(homedir(), ".agentpacks"));
|
|
38
|
+
}
|
|
39
|
+
function globalConfigFile() {
|
|
40
|
+
return join(globalConfigDir(), "agentpacks.jsonc");
|
|
41
|
+
}
|
|
42
|
+
function hasGlobalConfig() {
|
|
43
|
+
return existsSync(globalConfigFile());
|
|
44
|
+
}
|
|
45
|
+
function globalTargetDir(targetId, platform = process.platform) {
|
|
46
|
+
const home = homedir();
|
|
47
|
+
switch (targetId) {
|
|
48
|
+
case "opencode":
|
|
49
|
+
return join(xdgConfig(platform, home), "opencode");
|
|
50
|
+
case "cursor":
|
|
51
|
+
return join(home, ".cursor");
|
|
52
|
+
case "claudecode":
|
|
53
|
+
return join(home, ".claude");
|
|
54
|
+
case "codexcli":
|
|
55
|
+
return join(xdgConfig(platform, home), "codex");
|
|
56
|
+
case "geminicli":
|
|
57
|
+
return join(xdgConfig(platform, home), "gemini");
|
|
58
|
+
case "copilot":
|
|
59
|
+
return join(xdgConfig(platform, home), "github-copilot");
|
|
60
|
+
default:
|
|
61
|
+
return join(xdgConfig(platform, home), targetId);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function xdgConfig(platform, home) {
|
|
65
|
+
if (process.env.XDG_CONFIG_HOME) {
|
|
66
|
+
return process.env.XDG_CONFIG_HOME;
|
|
67
|
+
}
|
|
68
|
+
if (platform === "darwin") {
|
|
69
|
+
return join(home, "Library", "Application Support");
|
|
70
|
+
}
|
|
71
|
+
if (platform === "win32") {
|
|
72
|
+
return process.env.APPDATA ?? join(home, "AppData", "Roaming");
|
|
73
|
+
}
|
|
74
|
+
return join(home, ".config");
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
hasGlobalConfig,
|
|
78
|
+
globalTargetDir,
|
|
79
|
+
globalConfigFile,
|
|
80
|
+
globalConfigDir
|
|
81
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
set: (newValue) => all[name] = () => newValue
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
|
+
|
|
32
|
+
// src/utils/markdown.ts
|
|
33
|
+
function stripGeneratedHeader(content) {
|
|
34
|
+
return content.replace(/^<!-- Generated by agentpacks.*-->\n/, "").replace(/^\/\/ Generated by agentpacks.*\n/, "");
|
|
35
|
+
}
|
|
36
|
+
function packNameToIdentifier(packName) {
|
|
37
|
+
return packName.split(/[-_.]/).filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
38
|
+
}
|
|
39
|
+
function extractFirstHeading(content) {
|
|
40
|
+
const match = content.match(/^#{1,6}\s+(.+)$/m);
|
|
41
|
+
return match?.[1]?.trim() ?? null;
|
|
42
|
+
}
|
|
43
|
+
function combineMarkdown(sections, separator = `
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
`) {
|
|
48
|
+
return sections.filter(Boolean).join(separator);
|
|
49
|
+
}
|
|
50
|
+
function wrapSection(heading, content, level = 2) {
|
|
51
|
+
const prefix = "#".repeat(level);
|
|
52
|
+
return `${prefix} ${heading}
|
|
53
|
+
|
|
54
|
+
${content}`;
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
wrapSection,
|
|
58
|
+
stripGeneratedHeader,
|
|
59
|
+
packNameToIdentifier,
|
|
60
|
+
extractFirstHeading,
|
|
61
|
+
combineMarkdown
|
|
62
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git source reference types and pure parsing utilities.
|
|
3
|
+
* No I/O or network calls — pure functions only.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Parsed git source reference.
|
|
7
|
+
* Format: owner/repo, owner/repo@ref, owner/repo@ref:path
|
|
8
|
+
* Or: github:owner/repo[@ref][:path]
|
|
9
|
+
*/
|
|
10
|
+
export interface GitSourceRef {
|
|
11
|
+
owner: string;
|
|
12
|
+
repo: string;
|
|
13
|
+
ref: string;
|
|
14
|
+
path: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parse a git source reference string.
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseGitSourceRef(source: string): GitSourceRef;
|
|
20
|
+
/**
|
|
21
|
+
* Check if a pack reference is a git source.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isGitPackRef(packRef: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Build a canonical source key for lockfile entries.
|
|
26
|
+
*/
|
|
27
|
+
export declare function gitSourceKey(parsed: GitSourceRef): string;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
set: (newValue) => all[name] = () => newValue
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
|
+
var __require = import.meta.require;
|
|
31
|
+
|
|
32
|
+
// src/sources/git-ref.ts
|
|
33
|
+
function parseGitSourceRef(source) {
|
|
34
|
+
let s = source;
|
|
35
|
+
if (s.startsWith("github:")) {
|
|
36
|
+
s = s.slice(7);
|
|
37
|
+
}
|
|
38
|
+
let path = "";
|
|
39
|
+
const atIdx = s.indexOf("@");
|
|
40
|
+
const colonIdx = s.indexOf(":", atIdx > -1 ? atIdx : 0);
|
|
41
|
+
if (colonIdx > -1) {
|
|
42
|
+
path = s.slice(colonIdx + 1);
|
|
43
|
+
s = s.slice(0, colonIdx);
|
|
44
|
+
}
|
|
45
|
+
let ref = "main";
|
|
46
|
+
if (atIdx > -1) {
|
|
47
|
+
ref = s.slice(atIdx + 1);
|
|
48
|
+
s = s.slice(0, atIdx);
|
|
49
|
+
}
|
|
50
|
+
const parts = s.split("/");
|
|
51
|
+
if (parts.length < 2) {
|
|
52
|
+
throw new Error(`Invalid git source reference: "${source}". Expected owner/repo format.`);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
owner: parts[0],
|
|
56
|
+
repo: parts[1],
|
|
57
|
+
ref,
|
|
58
|
+
path: path || ""
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function isGitPackRef(packRef) {
|
|
62
|
+
if (packRef.startsWith("github:"))
|
|
63
|
+
return true;
|
|
64
|
+
if (packRef.startsWith("./") || packRef.startsWith("../") || packRef.startsWith("/")) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (packRef.startsWith("@") || packRef.startsWith("npm:"))
|
|
68
|
+
return false;
|
|
69
|
+
const parts = packRef.split("/");
|
|
70
|
+
return parts.length === 2 && !packRef.includes("node_modules");
|
|
71
|
+
}
|
|
72
|
+
function gitSourceKey(parsed) {
|
|
73
|
+
return `${parsed.owner}/${parsed.repo}`;
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
parseGitSourceRef,
|
|
77
|
+
isGitPackRef,
|
|
78
|
+
gitSourceKey
|
|
79
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Lockfile } from '../core/lockfile.js';
|
|
2
|
+
import { type GitSourceRef } from './git-ref.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve git ref to a commit SHA using GitHub API.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveGitRef(parsed: GitSourceRef, token?: string): Promise<string>;
|
|
7
|
+
/**
|
|
8
|
+
* Fetch a directory listing from GitHub Contents API.
|
|
9
|
+
*/
|
|
10
|
+
export declare function fetchGitDirectory(parsed: GitSourceRef, sha: string, subpath: string, token?: string): Promise<Array<{
|
|
11
|
+
name: string;
|
|
12
|
+
type: string;
|
|
13
|
+
download_url: string | null;
|
|
14
|
+
}>>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetch a single file content from a GitHub download URL.
|
|
17
|
+
*/
|
|
18
|
+
export declare function fetchGitFile(downloadUrl: string, token?: string): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Install a git-based pack source into .agentpacks/.curated/.
|
|
21
|
+
*/
|
|
22
|
+
export declare function installGitSource(projectRoot: string, source: string, lockfile: Lockfile, options?: {
|
|
23
|
+
update?: boolean;
|
|
24
|
+
frozen?: boolean;
|
|
25
|
+
token?: string;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
installed: string[];
|
|
28
|
+
warnings: string[];
|
|
29
|
+
}>;
|