agentinit 1.26.0 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +26 -1
- package/dist/cli.js +709 -84
- package/dist/cli.js.map +1 -1
- package/dist/commands/agentsMd.d.ts +3 -0
- package/dist/commands/agentsMd.d.ts.map +1 -0
- package/dist/commands/agentsMd.js +166 -0
- package/dist/commands/agentsMd.js.map +1 -0
- package/dist/commands/skills.d.ts.map +1 -1
- package/dist/commands/skills.js +34 -0
- package/dist/commands/skills.js.map +1 -1
- package/dist/commands/sync.d.ts +1 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +11 -0
- package/dist/commands/sync.js.map +1 -1
- package/dist/core/agentsMdManager.d.ts +61 -0
- package/dist/core/agentsMdManager.d.ts.map +1 -0
- package/dist/core/agentsMdManager.js +204 -0
- package/dist/core/agentsMdManager.js.map +1 -0
- package/dist/core/skillsManager.d.ts +1 -0
- package/dist/core/skillsManager.d.ts.map +1 -1
- package/dist/core/skillsManager.js +66 -0
- package/dist/core/skillsManager.js.map +1 -1
- package/dist/core/wellKnownDiscovery.d.ts +22 -0
- package/dist/core/wellKnownDiscovery.d.ts.map +1 -0
- package/dist/core/wellKnownDiscovery.js +89 -0
- package/dist/core/wellKnownDiscovery.js.map +1 -0
- package/dist/types/lockfile.d.ts +1 -1
- package/dist/types/lockfile.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/skills.d.ts +4 -1
- package/dist/types/skills.d.ts.map +1 -1
- package/dist/types/skills.js.map +1 -1
- package/dist/utils/http.d.ts +15 -0
- package/dist/utils/http.d.ts.map +1 -0
- package/dist/utils/http.js +31 -0
- package/dist/utils/http.js.map +1 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8501,6 +8501,89 @@ var init_logger = __esm(() => {
|
|
|
8501
8501
|
});
|
|
8502
8502
|
|
|
8503
8503
|
// dist/utils/fs.js
|
|
8504
|
+
var exports_fs = {};
|
|
8505
|
+
__export(exports_fs, {
|
|
8506
|
+
writeFile: () => {
|
|
8507
|
+
{
|
|
8508
|
+
return writeFile;
|
|
8509
|
+
}
|
|
8510
|
+
},
|
|
8511
|
+
resolveRealPathOrSelf: () => {
|
|
8512
|
+
{
|
|
8513
|
+
return resolveRealPathOrSelf;
|
|
8514
|
+
}
|
|
8515
|
+
},
|
|
8516
|
+
resolveParentSymlinks: () => {
|
|
8517
|
+
{
|
|
8518
|
+
return resolveParentSymlinks;
|
|
8519
|
+
}
|
|
8520
|
+
},
|
|
8521
|
+
readSymlinkTarget: () => {
|
|
8522
|
+
{
|
|
8523
|
+
return readSymlinkTarget;
|
|
8524
|
+
}
|
|
8525
|
+
},
|
|
8526
|
+
readFileIfExists: () => {
|
|
8527
|
+
{
|
|
8528
|
+
return readFileIfExists;
|
|
8529
|
+
}
|
|
8530
|
+
},
|
|
8531
|
+
pathsReferToSameLocation: () => {
|
|
8532
|
+
{
|
|
8533
|
+
return pathsReferToSameLocation;
|
|
8534
|
+
}
|
|
8535
|
+
},
|
|
8536
|
+
pathExists: () => {
|
|
8537
|
+
{
|
|
8538
|
+
return pathExists;
|
|
8539
|
+
}
|
|
8540
|
+
},
|
|
8541
|
+
listFiles: () => {
|
|
8542
|
+
{
|
|
8543
|
+
return listFiles;
|
|
8544
|
+
}
|
|
8545
|
+
},
|
|
8546
|
+
isDirectory: () => {
|
|
8547
|
+
{
|
|
8548
|
+
return isDirectory;
|
|
8549
|
+
}
|
|
8550
|
+
},
|
|
8551
|
+
getAgentInitTomlPath: () => {
|
|
8552
|
+
{
|
|
8553
|
+
return getAgentInitTomlPath;
|
|
8554
|
+
}
|
|
8555
|
+
},
|
|
8556
|
+
findFiles: () => {
|
|
8557
|
+
{
|
|
8558
|
+
return findFiles;
|
|
8559
|
+
}
|
|
8560
|
+
},
|
|
8561
|
+
fileExists: () => {
|
|
8562
|
+
{
|
|
8563
|
+
return fileExists;
|
|
8564
|
+
}
|
|
8565
|
+
},
|
|
8566
|
+
ensureDirectoryExists: () => {
|
|
8567
|
+
{
|
|
8568
|
+
return ensureDirectoryExists;
|
|
8569
|
+
}
|
|
8570
|
+
},
|
|
8571
|
+
ensureAgentInitDir: () => {
|
|
8572
|
+
{
|
|
8573
|
+
return ensureAgentInitDir;
|
|
8574
|
+
}
|
|
8575
|
+
},
|
|
8576
|
+
createRelativeSymlink: () => {
|
|
8577
|
+
{
|
|
8578
|
+
return createRelativeSymlink;
|
|
8579
|
+
}
|
|
8580
|
+
},
|
|
8581
|
+
copyFile: () => {
|
|
8582
|
+
{
|
|
8583
|
+
return copyFile;
|
|
8584
|
+
}
|
|
8585
|
+
}
|
|
8586
|
+
});
|
|
8504
8587
|
import {promises as fs} from "fs";
|
|
8505
8588
|
import {platform} from "os";
|
|
8506
8589
|
import {join, dirname, basename, resolve, relative} from "path";
|
|
@@ -19178,6 +19261,139 @@ var init_pluginManager = __esm(() => {
|
|
|
19178
19261
|
};
|
|
19179
19262
|
});
|
|
19180
19263
|
|
|
19264
|
+
// dist/utils/http.js
|
|
19265
|
+
async function fetchWithTimeout(url, options2 = {}) {
|
|
19266
|
+
const { timeout = 30000, ...fetchOptions } = options2;
|
|
19267
|
+
const controller = new AbortController;
|
|
19268
|
+
const timer = setTimeout(() => controller.abort(), timeout);
|
|
19269
|
+
try {
|
|
19270
|
+
const response = await fetch(url, {
|
|
19271
|
+
...fetchOptions,
|
|
19272
|
+
signal: controller.signal
|
|
19273
|
+
});
|
|
19274
|
+
return response;
|
|
19275
|
+
} catch (error) {
|
|
19276
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
19277
|
+
throw new HttpTimeoutError(url, timeout);
|
|
19278
|
+
}
|
|
19279
|
+
throw error;
|
|
19280
|
+
} finally {
|
|
19281
|
+
clearTimeout(timer);
|
|
19282
|
+
}
|
|
19283
|
+
}
|
|
19284
|
+
|
|
19285
|
+
class HttpTimeoutError extends Error {
|
|
19286
|
+
constructor(url, timeoutMs) {
|
|
19287
|
+
super(`Request to ${url} timed out after ${timeoutMs}ms`);
|
|
19288
|
+
this.name = "HttpTimeoutError";
|
|
19289
|
+
}
|
|
19290
|
+
}
|
|
19291
|
+
var init_http = __esm(() => {
|
|
19292
|
+
});
|
|
19293
|
+
|
|
19294
|
+
// dist/core/wellKnownDiscovery.js
|
|
19295
|
+
var exports_wellKnownDiscovery = {};
|
|
19296
|
+
__export(exports_wellKnownDiscovery, {
|
|
19297
|
+
WellKnownDiscoveryError: () => {
|
|
19298
|
+
{
|
|
19299
|
+
return WellKnownDiscoveryError;
|
|
19300
|
+
}
|
|
19301
|
+
},
|
|
19302
|
+
WellKnownDiscovery: () => {
|
|
19303
|
+
{
|
|
19304
|
+
return WellKnownDiscovery;
|
|
19305
|
+
}
|
|
19306
|
+
}
|
|
19307
|
+
});
|
|
19308
|
+
|
|
19309
|
+
class WellKnownDiscoveryError extends Error {
|
|
19310
|
+
constructor(message) {
|
|
19311
|
+
super(message);
|
|
19312
|
+
this.name = "WellKnownDiscoveryError";
|
|
19313
|
+
}
|
|
19314
|
+
}
|
|
19315
|
+
|
|
19316
|
+
class WellKnownDiscovery {
|
|
19317
|
+
async discover(baseUrl) {
|
|
19318
|
+
const urls = this.getCandidateUrls(baseUrl);
|
|
19319
|
+
const errors = [];
|
|
19320
|
+
for (const url of urls) {
|
|
19321
|
+
try {
|
|
19322
|
+
const response = await fetchWithTimeout(url, { timeout: 1e4 });
|
|
19323
|
+
if (!response.ok) {
|
|
19324
|
+
errors.push(`${url}: ${response.status} ${response.statusText}`);
|
|
19325
|
+
continue;
|
|
19326
|
+
}
|
|
19327
|
+
const data = await response.json();
|
|
19328
|
+
const parsed = this.parseIndex(data);
|
|
19329
|
+
if (!parsed) {
|
|
19330
|
+
errors.push(`${url}: invalid response structure`);
|
|
19331
|
+
continue;
|
|
19332
|
+
}
|
|
19333
|
+
return parsed.skills;
|
|
19334
|
+
} catch (error) {
|
|
19335
|
+
errors.push(`${url}: ${error instanceof Error ? error.message : "unknown error"}`);
|
|
19336
|
+
}
|
|
19337
|
+
}
|
|
19338
|
+
throw new WellKnownDiscoveryError(`Failed to discover skills from ${baseUrl}. Attempted URLs:\n${errors.map((e) => ` - ${e}`).join("\n")}`);
|
|
19339
|
+
}
|
|
19340
|
+
getCandidateUrls(source) {
|
|
19341
|
+
let parsed;
|
|
19342
|
+
try {
|
|
19343
|
+
parsed = new URL(source);
|
|
19344
|
+
} catch {
|
|
19345
|
+
throw new WellKnownDiscoveryError(`Invalid URL: ${source}`);
|
|
19346
|
+
}
|
|
19347
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
|
19348
|
+
throw new WellKnownDiscoveryError(`Unsupported URL protocol: ${parsed.protocol}`);
|
|
19349
|
+
}
|
|
19350
|
+
const urls = [];
|
|
19351
|
+
const normalizedInput = parsed.toString();
|
|
19352
|
+
const path = parsed.pathname.replace(/\/+$/, "");
|
|
19353
|
+
if (path && path !== "/") {
|
|
19354
|
+
urls.push(normalizedInput);
|
|
19355
|
+
}
|
|
19356
|
+
for (const wellKnownPath of WELL_KNOWN_PATHS) {
|
|
19357
|
+
urls.push(new URL(wellKnownPath, parsed.origin).toString());
|
|
19358
|
+
}
|
|
19359
|
+
return [...new Set(urls)];
|
|
19360
|
+
}
|
|
19361
|
+
parseIndex(value) {
|
|
19362
|
+
if (!value || typeof value !== "object" || !("skills" in value) || !Array.isArray(value.skills)) {
|
|
19363
|
+
return null;
|
|
19364
|
+
}
|
|
19365
|
+
const skills = [];
|
|
19366
|
+
for (const item of value.skills) {
|
|
19367
|
+
if (!item || typeof item !== "object") {
|
|
19368
|
+
return null;
|
|
19369
|
+
}
|
|
19370
|
+
const candidate = item;
|
|
19371
|
+
if (typeof candidate.name !== "string" || !candidate.name.trim()) {
|
|
19372
|
+
return null;
|
|
19373
|
+
}
|
|
19374
|
+
if (typeof candidate.source !== "string" || !candidate.source.trim()) {
|
|
19375
|
+
return null;
|
|
19376
|
+
}
|
|
19377
|
+
skills.push({
|
|
19378
|
+
name: candidate.name.trim(),
|
|
19379
|
+
source: candidate.source.trim(),
|
|
19380
|
+
...typeof candidate.description === "string" ? { description: candidate.description } : {},
|
|
19381
|
+
...typeof candidate.version === "string" ? { version: candidate.version } : {},
|
|
19382
|
+
...typeof candidate.author === "string" ? { author: candidate.author } : {}
|
|
19383
|
+
});
|
|
19384
|
+
}
|
|
19385
|
+
return { skills };
|
|
19386
|
+
}
|
|
19387
|
+
}
|
|
19388
|
+
var WELL_KNOWN_PATHS;
|
|
19389
|
+
var init_wellKnownDiscovery = __esm(() => {
|
|
19390
|
+
init_http();
|
|
19391
|
+
WELL_KNOWN_PATHS = [
|
|
19392
|
+
"/.well-known/agent-skills/index.json",
|
|
19393
|
+
"/.well-known/skills/index.json"
|
|
19394
|
+
];
|
|
19395
|
+
});
|
|
19396
|
+
|
|
19181
19397
|
// dist/core/skillsManager.js
|
|
19182
19398
|
import {resolve as resolve9, join as join7, relative as relative4, basename as basename3, dirname as dirname4} from "path";
|
|
19183
19399
|
import {promises as fs27} from "fs";
|
|
@@ -19201,6 +19417,9 @@ class SkillsManager {
|
|
|
19201
19417
|
if (httpSource) {
|
|
19202
19418
|
return httpSource;
|
|
19203
19419
|
}
|
|
19420
|
+
if (source.startsWith("http://") || source.startsWith("https://")) {
|
|
19421
|
+
return { type: "well-known", url: source };
|
|
19422
|
+
}
|
|
19204
19423
|
const sshSource = this.parseSshRepositorySource(source);
|
|
19205
19424
|
if (sshSource) {
|
|
19206
19425
|
return sshSource;
|
|
@@ -19646,6 +19865,20 @@ class SkillsManager {
|
|
|
19646
19865
|
cleanup
|
|
19647
19866
|
};
|
|
19648
19867
|
}
|
|
19868
|
+
if (resolved.type === "well-known") {
|
|
19869
|
+
if (!resolved.url) {
|
|
19870
|
+
throw new Error(`Invalid well-known source: ${source}`);
|
|
19871
|
+
}
|
|
19872
|
+
const discovered = await this.loadWellKnownSkillsContext(resolved.url, projectPath);
|
|
19873
|
+
return {
|
|
19874
|
+
skills: discovered.skills,
|
|
19875
|
+
warnings: discovered.warnings,
|
|
19876
|
+
cleanup: async () => {
|
|
19877
|
+
await discovered.cleanup();
|
|
19878
|
+
await cleanup();
|
|
19879
|
+
}
|
|
19880
|
+
};
|
|
19881
|
+
}
|
|
19649
19882
|
let repoPath;
|
|
19650
19883
|
if (resolved.type === "github" || resolved.type === "gitlab" || resolved.type === "bitbucket") {
|
|
19651
19884
|
if (!resolved.url) {
|
|
@@ -19683,6 +19916,50 @@ class SkillsManager {
|
|
|
19683
19916
|
throw error;
|
|
19684
19917
|
}
|
|
19685
19918
|
}
|
|
19919
|
+
async loadWellKnownSkillsContext(source, projectPath) {
|
|
19920
|
+
const { WellKnownDiscovery: WellKnownDiscovery2 } = await Promise.resolve().then(() => (init_wellKnownDiscovery(), exports_wellKnownDiscovery));
|
|
19921
|
+
const discovery = new WellKnownDiscovery2;
|
|
19922
|
+
const indexSkills = await discovery.discover(source);
|
|
19923
|
+
const contexts = [];
|
|
19924
|
+
const skills2 = [];
|
|
19925
|
+
const warnings = [];
|
|
19926
|
+
const cleanup = async () => {
|
|
19927
|
+
await Promise.all(contexts.map((context) => context.cleanup().catch(() => {
|
|
19928
|
+
})));
|
|
19929
|
+
contexts.length = 0;
|
|
19930
|
+
};
|
|
19931
|
+
try {
|
|
19932
|
+
for (const indexSkill of indexSkills) {
|
|
19933
|
+
const nestedSource = this.resolveSource(indexSkill.source);
|
|
19934
|
+
if (nestedSource.type === "well-known") {
|
|
19935
|
+
warnings.push(`Skipped "${indexSkill.name}": well-known indexes cannot reference another well-known index`);
|
|
19936
|
+
continue;
|
|
19937
|
+
}
|
|
19938
|
+
const context = await this.loadDiscoveredSkillsContext(indexSkill.source, projectPath);
|
|
19939
|
+
contexts.push(context);
|
|
19940
|
+
const exactMatches = context.skills.filter((skill) => skill.name.trim().toLowerCase() === indexSkill.name.trim().toLowerCase());
|
|
19941
|
+
const selectedSkills = exactMatches.length > 0 ? exactMatches : context.skills.length === 1 ? context.skills : [];
|
|
19942
|
+
if (selectedSkills.length === 0) {
|
|
19943
|
+
warnings.push(`Skipped "${indexSkill.name}": no matching skill found at ${indexSkill.source}`);
|
|
19944
|
+
continue;
|
|
19945
|
+
}
|
|
19946
|
+
for (const skill of selectedSkills) {
|
|
19947
|
+
skills2.push({
|
|
19948
|
+
...skill,
|
|
19949
|
+
name: indexSkill.name || skill.name,
|
|
19950
|
+
description: indexSkill.description || skill.description,
|
|
19951
|
+
source: "well-known",
|
|
19952
|
+
...indexSkill.author ? { author: indexSkill.author } : {},
|
|
19953
|
+
...indexSkill.version ? { version: indexSkill.version } : {}
|
|
19954
|
+
});
|
|
19955
|
+
}
|
|
19956
|
+
}
|
|
19957
|
+
return { skills: skills2, warnings, cleanup };
|
|
19958
|
+
} catch (error) {
|
|
19959
|
+
await cleanup();
|
|
19960
|
+
throw error;
|
|
19961
|
+
}
|
|
19962
|
+
}
|
|
19686
19963
|
async discoverFromSource(source, projectPath, options2 = {}) {
|
|
19687
19964
|
const context = await this.loadDiscoveredSkillsContext(source, projectPath, options2);
|
|
19688
19965
|
try {
|
|
@@ -20484,6 +20761,186 @@ var init_skillsManager = __esm(() => {
|
|
|
20484
20761
|
];
|
|
20485
20762
|
});
|
|
20486
20763
|
|
|
20764
|
+
// dist/core/agentsMdManager.js
|
|
20765
|
+
var exports_agentsMdManager = {};
|
|
20766
|
+
__export(exports_agentsMdManager, {
|
|
20767
|
+
AgentsMdManager: () => {
|
|
20768
|
+
{
|
|
20769
|
+
return AgentsMdManager;
|
|
20770
|
+
}
|
|
20771
|
+
}
|
|
20772
|
+
});
|
|
20773
|
+
import {promises as fs33} from "fs";
|
|
20774
|
+
import {resolve as resolve12} from "path";
|
|
20775
|
+
|
|
20776
|
+
class AgentsMdManager {
|
|
20777
|
+
projectPath;
|
|
20778
|
+
constructor(projectPath) {
|
|
20779
|
+
this.projectPath = projectPath;
|
|
20780
|
+
}
|
|
20781
|
+
getAgentsMdPath() {
|
|
20782
|
+
return resolve12(this.projectPath, "AGENTS.md");
|
|
20783
|
+
}
|
|
20784
|
+
getClaudeMdPath() {
|
|
20785
|
+
return resolve12(this.projectPath, "CLAUDE.md");
|
|
20786
|
+
}
|
|
20787
|
+
async read() {
|
|
20788
|
+
return readFileIfExists(this.getAgentsMdPath());
|
|
20789
|
+
}
|
|
20790
|
+
async readAgentFile(agentFileName) {
|
|
20791
|
+
return readFileIfExists(resolve12(this.projectPath, agentFileName));
|
|
20792
|
+
}
|
|
20793
|
+
parseSections(content) {
|
|
20794
|
+
return this.parseSectionRanges(content).map(({ heading, body, level }) => ({
|
|
20795
|
+
heading,
|
|
20796
|
+
body,
|
|
20797
|
+
level
|
|
20798
|
+
}));
|
|
20799
|
+
}
|
|
20800
|
+
findSection(sections, heading) {
|
|
20801
|
+
const normalized = heading.trim().toLowerCase();
|
|
20802
|
+
return sections.find((s) => s.heading.trim().toLowerCase() === normalized);
|
|
20803
|
+
}
|
|
20804
|
+
async setSection(options2) {
|
|
20805
|
+
const agentsMdPath = this.getAgentsMdPath();
|
|
20806
|
+
const heading = this.normalizeHeadingInput(options2.heading);
|
|
20807
|
+
const content = (await readFileIfExists(agentsMdPath) || "").replace(/\r\n/g, "\n");
|
|
20808
|
+
const sections = this.parseSectionRanges(content);
|
|
20809
|
+
const placement = this.parsePlacement(options2.placement);
|
|
20810
|
+
const existing = this.findSectionRange(sections, heading);
|
|
20811
|
+
let newContent;
|
|
20812
|
+
if (existing) {
|
|
20813
|
+
newContent = `${content.slice(0, existing.start)}${this.renderSection(existing.level, existing.heading, options2.body)}${content.slice(existing.end)}`;
|
|
20814
|
+
} else {
|
|
20815
|
+
const newSection = this.renderSection(2, heading, options2.body);
|
|
20816
|
+
if (placement.type === "after") {
|
|
20817
|
+
const after = this.findSectionRange(sections, placement.heading);
|
|
20818
|
+
newContent = after ? this.insertSection(content, after.end, newSection) : this.insertSection(content, content.length, newSection);
|
|
20819
|
+
} else if (placement.type === "prepend") {
|
|
20820
|
+
newContent = this.insertSection(content, 0, newSection);
|
|
20821
|
+
} else {
|
|
20822
|
+
newContent = this.insertSection(content, content.length, newSection);
|
|
20823
|
+
}
|
|
20824
|
+
}
|
|
20825
|
+
await writeFile(agentsMdPath, this.ensureTrailingNewline(newContent));
|
|
20826
|
+
}
|
|
20827
|
+
async removeSection(options2) {
|
|
20828
|
+
const agentsMdPath = this.getAgentsMdPath();
|
|
20829
|
+
const content = await readFileIfExists(agentsMdPath);
|
|
20830
|
+
if (!content)
|
|
20831
|
+
return false;
|
|
20832
|
+
const normalizedContent = content.replace(/\r\n/g, "\n");
|
|
20833
|
+
const section = this.findSectionRange(this.parseSectionRanges(normalizedContent), this.normalizeHeadingInput(options2.heading));
|
|
20834
|
+
if (!section)
|
|
20835
|
+
return false;
|
|
20836
|
+
const before = normalizedContent.slice(0, section.start).trimEnd();
|
|
20837
|
+
const after = normalizedContent.slice(section.end).trimStart();
|
|
20838
|
+
const newContent = [before, after].filter(Boolean).join("\n");
|
|
20839
|
+
await writeFile(agentsMdPath, this.ensureTrailingNewline(newContent));
|
|
20840
|
+
return true;
|
|
20841
|
+
}
|
|
20842
|
+
async symlinkClaude() {
|
|
20843
|
+
const agentsMdPath = this.getAgentsMdPath();
|
|
20844
|
+
const claudeMdPath = this.getClaudeMdPath();
|
|
20845
|
+
if (!await fileExists(agentsMdPath)) {
|
|
20846
|
+
throw new Error("AGENTS.md does not exist. Create AGENTS.md first.");
|
|
20847
|
+
}
|
|
20848
|
+
try {
|
|
20849
|
+
const stats = await fs33.lstat(claudeMdPath);
|
|
20850
|
+
if (!stats.isSymbolicLink()) {
|
|
20851
|
+
throw new Error("CLAUDE.md already exists and is not a symlink. Move or remove it before creating the alias.");
|
|
20852
|
+
}
|
|
20853
|
+
} catch (error) {
|
|
20854
|
+
if (!this.isMissingPathError(error)) {
|
|
20855
|
+
throw error;
|
|
20856
|
+
}
|
|
20857
|
+
}
|
|
20858
|
+
const created = await createRelativeSymlink(agentsMdPath, claudeMdPath);
|
|
20859
|
+
if (!created) {
|
|
20860
|
+
throw new Error("Failed to create symlink from CLAUDE.md to AGENTS.md");
|
|
20861
|
+
}
|
|
20862
|
+
}
|
|
20863
|
+
parseSectionRanges(content) {
|
|
20864
|
+
const sections = [];
|
|
20865
|
+
const headingPattern = /^(#{1,6})[ \t]+(.+?)\s*$/gm;
|
|
20866
|
+
let match;
|
|
20867
|
+
while ((match = headingPattern.exec(content)) !== null) {
|
|
20868
|
+
const lineEndIndex = content.indexOf("\n", match.index);
|
|
20869
|
+
sections.push({
|
|
20870
|
+
heading: match[2].trim(),
|
|
20871
|
+
level: match[1].length,
|
|
20872
|
+
start: match.index,
|
|
20873
|
+
headingEnd: lineEndIndex === -1 ? content.length : lineEndIndex + 1
|
|
20874
|
+
});
|
|
20875
|
+
}
|
|
20876
|
+
return sections.map((section, index) => {
|
|
20877
|
+
const nextPeerOrParent = sections.slice(index + 1).find((next) => next.level <= section.level);
|
|
20878
|
+
const end = nextPeerOrParent?.start ?? content.length;
|
|
20879
|
+
return {
|
|
20880
|
+
...section,
|
|
20881
|
+
end,
|
|
20882
|
+
body: content.slice(section.headingEnd, end).trimEnd()
|
|
20883
|
+
};
|
|
20884
|
+
});
|
|
20885
|
+
}
|
|
20886
|
+
findSectionRange(sections, heading) {
|
|
20887
|
+
const normalized = this.normalizeHeading(heading);
|
|
20888
|
+
return sections.find((s) => this.normalizeHeading(s.heading) === normalized);
|
|
20889
|
+
}
|
|
20890
|
+
normalizeHeadingInput(heading) {
|
|
20891
|
+
const normalized = heading.trim();
|
|
20892
|
+
if (!normalized || normalized.includes("\n") || normalized.includes("\r")) {
|
|
20893
|
+
throw new Error("Section heading must be a single non-empty line");
|
|
20894
|
+
}
|
|
20895
|
+
return normalized;
|
|
20896
|
+
}
|
|
20897
|
+
normalizeHeading(heading) {
|
|
20898
|
+
return heading.trim().toLowerCase();
|
|
20899
|
+
}
|
|
20900
|
+
parsePlacement(placement) {
|
|
20901
|
+
if (!placement || placement === "append") {
|
|
20902
|
+
return { type: "append" };
|
|
20903
|
+
}
|
|
20904
|
+
if (placement === "prepend") {
|
|
20905
|
+
return { type: "prepend" };
|
|
20906
|
+
}
|
|
20907
|
+
if (placement.startsWith("after ")) {
|
|
20908
|
+
return { type: "after", heading: this.normalizeHeadingInput(placement.slice(6)) };
|
|
20909
|
+
}
|
|
20910
|
+
throw new Error('Placement must be "append", "prepend", or "after <heading>"');
|
|
20911
|
+
}
|
|
20912
|
+
renderSection(level, heading, body) {
|
|
20913
|
+
const normalizedBody = body.replace(/\r\n/g, "\n").trimEnd();
|
|
20914
|
+
return normalizedBody ? `${"#".repeat(level)} ${heading}\n${normalizedBody}\n` : `${"#".repeat(level)} ${heading}\n`;
|
|
20915
|
+
}
|
|
20916
|
+
insertSection(content, index, renderedSection) {
|
|
20917
|
+
const before = content.slice(0, index).trimEnd();
|
|
20918
|
+
const after = content.slice(index).trimStart();
|
|
20919
|
+
if (!before && !after) {
|
|
20920
|
+
return renderedSection;
|
|
20921
|
+
}
|
|
20922
|
+
if (!before) {
|
|
20923
|
+
return `${renderedSection}\n${after}`;
|
|
20924
|
+
}
|
|
20925
|
+
if (!after) {
|
|
20926
|
+
return `${before}\n\n${renderedSection}`;
|
|
20927
|
+
}
|
|
20928
|
+
return `${before}\n\n${renderedSection}\n${after}`;
|
|
20929
|
+
}
|
|
20930
|
+
ensureTrailingNewline(content) {
|
|
20931
|
+
if (!content.trim()) {
|
|
20932
|
+
return "";
|
|
20933
|
+
}
|
|
20934
|
+
return content.endsWith("\n") ? content : `${content}\n`;
|
|
20935
|
+
}
|
|
20936
|
+
isMissingPathError(error) {
|
|
20937
|
+
return !!error && typeof error === "object" && "code" in error && error.code === "ENOENT";
|
|
20938
|
+
}
|
|
20939
|
+
}
|
|
20940
|
+
var init_agentsMdManager = __esm(() => {
|
|
20941
|
+
init_fs();
|
|
20942
|
+
});
|
|
20943
|
+
|
|
20487
20944
|
// node_modules/ajv/lib/refs/data.json
|
|
20488
20945
|
var require_data = __commonJS((exports, module) => {
|
|
20489
20946
|
module.exports = {
|
|
@@ -21405,7 +21862,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
21405
21862
|
target.fragment = relative7.fragment;
|
|
21406
21863
|
return target;
|
|
21407
21864
|
}
|
|
21408
|
-
function
|
|
21865
|
+
function resolve15(baseURI, relativeURI, options2) {
|
|
21409
21866
|
var schemelessOptions = assign({ scheme: "null" }, options2);
|
|
21410
21867
|
return serialize(resolveComponents(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
|
21411
21868
|
}
|
|
@@ -21673,7 +22130,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
21673
22130
|
exports2.removeDotSegments = removeDotSegments;
|
|
21674
22131
|
exports2.serialize = serialize;
|
|
21675
22132
|
exports2.resolveComponents = resolveComponents;
|
|
21676
|
-
exports2.resolve =
|
|
22133
|
+
exports2.resolve = resolve15;
|
|
21677
22134
|
exports2.normalize = normalize;
|
|
21678
22135
|
exports2.equal = equal;
|
|
21679
22136
|
exports2.escapeComponent = escapeComponent;
|
|
@@ -22036,13 +22493,13 @@ var require_json_schema_traverse = __commonJS((exports, module) => {
|
|
|
22036
22493
|
|
|
22037
22494
|
// node_modules/ajv/lib/compile/resolve.js
|
|
22038
22495
|
var require_resolve = __commonJS((exports, module) => {
|
|
22039
|
-
var
|
|
22496
|
+
var resolve15 = function(compile, root, ref) {
|
|
22040
22497
|
var refVal = this._refs[ref];
|
|
22041
22498
|
if (typeof refVal == "string") {
|
|
22042
22499
|
if (this._refs[refVal])
|
|
22043
22500
|
refVal = this._refs[refVal];
|
|
22044
22501
|
else
|
|
22045
|
-
return
|
|
22502
|
+
return resolve15.call(this, compile, root, refVal);
|
|
22046
22503
|
}
|
|
22047
22504
|
refVal = refVal || this._schemas[ref];
|
|
22048
22505
|
if (refVal instanceof SchemaObject) {
|
|
@@ -22247,13 +22704,13 @@ var require_resolve = __commonJS((exports, module) => {
|
|
|
22247
22704
|
var util6 = require_util3();
|
|
22248
22705
|
var SchemaObject = require_schema_obj();
|
|
22249
22706
|
var traverse = require_json_schema_traverse();
|
|
22250
|
-
module.exports =
|
|
22251
|
-
|
|
22252
|
-
|
|
22253
|
-
|
|
22254
|
-
|
|
22255
|
-
|
|
22256
|
-
|
|
22707
|
+
module.exports = resolve15;
|
|
22708
|
+
resolve15.normalizeId = normalizeId;
|
|
22709
|
+
resolve15.fullPath = getFullPath;
|
|
22710
|
+
resolve15.url = resolveUrl;
|
|
22711
|
+
resolve15.ids = resolveIds;
|
|
22712
|
+
resolve15.inlineRef = inlineRef;
|
|
22713
|
+
resolve15.schema = resolveSchema;
|
|
22257
22714
|
var PREVENT_SCOPE_CHANGE = util6.toHash(["properties", "patternProperties", "enum", "dependencies", "definitions"]);
|
|
22258
22715
|
var SIMPLE_INLINED = util6.toHash([
|
|
22259
22716
|
"type",
|
|
@@ -22284,15 +22741,15 @@ var require_error_classes = __commonJS((exports, module) => {
|
|
|
22284
22741
|
};
|
|
22285
22742
|
var MissingRefError = function(baseId, ref, message) {
|
|
22286
22743
|
this.message = message || MissingRefError.message(baseId, ref);
|
|
22287
|
-
this.missingRef =
|
|
22288
|
-
this.missingSchema =
|
|
22744
|
+
this.missingRef = resolve15.url(baseId, ref);
|
|
22745
|
+
this.missingSchema = resolve15.normalizeId(resolve15.fullPath(this.missingRef));
|
|
22289
22746
|
};
|
|
22290
22747
|
var errorSubclass = function(Subclass) {
|
|
22291
22748
|
Subclass.prototype = Object.create(Error.prototype);
|
|
22292
22749
|
Subclass.prototype.constructor = Subclass;
|
|
22293
22750
|
return Subclass;
|
|
22294
22751
|
};
|
|
22295
|
-
var
|
|
22752
|
+
var resolve15 = require_resolve();
|
|
22296
22753
|
module.exports = {
|
|
22297
22754
|
Validation: errorSubclass(ValidationError),
|
|
22298
22755
|
MissingRef: errorSubclass(MissingRefError)
|
|
@@ -22886,7 +23343,7 @@ var require_compile = __commonJS((exports, module) => {
|
|
|
22886
23343
|
RULES,
|
|
22887
23344
|
validate: validateGenerator,
|
|
22888
23345
|
util: util6,
|
|
22889
|
-
resolve:
|
|
23346
|
+
resolve: resolve15,
|
|
22890
23347
|
resolveRef,
|
|
22891
23348
|
usePattern,
|
|
22892
23349
|
useDefault,
|
|
@@ -22925,7 +23382,7 @@ var require_compile = __commonJS((exports, module) => {
|
|
|
22925
23382
|
return validate2;
|
|
22926
23383
|
}
|
|
22927
23384
|
function resolveRef(baseId2, ref, isRoot) {
|
|
22928
|
-
ref =
|
|
23385
|
+
ref = resolve15.url(baseId2, ref);
|
|
22929
23386
|
var refIndex = refs[ref];
|
|
22930
23387
|
var _refVal, refCode;
|
|
22931
23388
|
if (refIndex !== undefined) {
|
|
@@ -22942,11 +23399,11 @@ var require_compile = __commonJS((exports, module) => {
|
|
|
22942
23399
|
}
|
|
22943
23400
|
}
|
|
22944
23401
|
refCode = addLocalRef(ref);
|
|
22945
|
-
var v2 =
|
|
23402
|
+
var v2 = resolve15.call(self, localCompile, root, ref);
|
|
22946
23403
|
if (v2 === undefined) {
|
|
22947
23404
|
var localSchema = localRefs && localRefs[ref];
|
|
22948
23405
|
if (localSchema) {
|
|
22949
|
-
v2 =
|
|
23406
|
+
v2 = resolve15.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self, localSchema, root, localRefs, baseId2);
|
|
22950
23407
|
}
|
|
22951
23408
|
}
|
|
22952
23409
|
if (v2 === undefined) {
|
|
@@ -23088,7 +23545,7 @@ var require_compile = __commonJS((exports, module) => {
|
|
|
23088
23545
|
code += statement(i, arr);
|
|
23089
23546
|
return code;
|
|
23090
23547
|
};
|
|
23091
|
-
var
|
|
23548
|
+
var resolve15 = require_resolve();
|
|
23092
23549
|
var util6 = require_util3();
|
|
23093
23550
|
var errorClasses = require_error_classes();
|
|
23094
23551
|
var stableStringify = require_fast_json_stable_stringify();
|
|
@@ -26337,7 +26794,7 @@ var require_ajv = __commonJS((exports, module) => {
|
|
|
26337
26794
|
var id = this._getId(schema2);
|
|
26338
26795
|
if (id !== undefined && typeof id != "string")
|
|
26339
26796
|
throw new Error("schema id must be string");
|
|
26340
|
-
key =
|
|
26797
|
+
key = resolve15.normalizeId(key || id);
|
|
26341
26798
|
checkUnique(this, key);
|
|
26342
26799
|
this._schemas[key] = this._addSchema(schema2, _skipValidation, _meta, true);
|
|
26343
26800
|
return this;
|
|
@@ -26383,7 +26840,7 @@ var require_ajv = __commonJS((exports, module) => {
|
|
|
26383
26840
|
}
|
|
26384
26841
|
};
|
|
26385
26842
|
var _getSchemaFragment = function(self, ref) {
|
|
26386
|
-
var res =
|
|
26843
|
+
var res = resolve15.schema.call(self, { schema: {} }, ref);
|
|
26387
26844
|
if (res) {
|
|
26388
26845
|
var { schema: schema2, root, baseId } = res;
|
|
26389
26846
|
var v = compileSchema.call(self, schema2, root, undefined, baseId);
|
|
@@ -26399,7 +26856,7 @@ var require_ajv = __commonJS((exports, module) => {
|
|
|
26399
26856
|
}
|
|
26400
26857
|
};
|
|
26401
26858
|
var _getSchemaObj = function(self, keyRef) {
|
|
26402
|
-
keyRef =
|
|
26859
|
+
keyRef = resolve15.normalizeId(keyRef);
|
|
26403
26860
|
return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef];
|
|
26404
26861
|
};
|
|
26405
26862
|
var removeSchema = function(schemaKeyRef) {
|
|
@@ -26427,7 +26884,7 @@ var require_ajv = __commonJS((exports, module) => {
|
|
|
26427
26884
|
this._cache.del(cacheKey);
|
|
26428
26885
|
var id = this._getId(schemaKeyRef);
|
|
26429
26886
|
if (id) {
|
|
26430
|
-
id =
|
|
26887
|
+
id = resolve15.normalizeId(id);
|
|
26431
26888
|
delete this._schemas[id];
|
|
26432
26889
|
delete this._refs[id];
|
|
26433
26890
|
}
|
|
@@ -26452,14 +26909,14 @@ var require_ajv = __commonJS((exports, module) => {
|
|
|
26452
26909
|
if (cached)
|
|
26453
26910
|
return cached;
|
|
26454
26911
|
shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
|
|
26455
|
-
var id =
|
|
26912
|
+
var id = resolve15.normalizeId(this._getId(schema2));
|
|
26456
26913
|
if (id && shouldAddSchema)
|
|
26457
26914
|
checkUnique(this, id);
|
|
26458
26915
|
var willValidate = this._opts.validateSchema !== false && !skipValidation;
|
|
26459
26916
|
var recursiveMeta;
|
|
26460
|
-
if (willValidate && !(recursiveMeta = id && id ==
|
|
26917
|
+
if (willValidate && !(recursiveMeta = id && id == resolve15.normalizeId(schema2.$schema)))
|
|
26461
26918
|
this.validateSchema(schema2, true);
|
|
26462
|
-
var localRefs =
|
|
26919
|
+
var localRefs = resolve15.ids.call(this, schema2);
|
|
26463
26920
|
var schemaObj = new SchemaObject({
|
|
26464
26921
|
id,
|
|
26465
26922
|
schema: schema2,
|
|
@@ -26620,7 +27077,7 @@ var require_ajv = __commonJS((exports, module) => {
|
|
|
26620
27077
|
var noop = function() {
|
|
26621
27078
|
};
|
|
26622
27079
|
var compileSchema = require_compile();
|
|
26623
|
-
var
|
|
27080
|
+
var resolve15 = require_resolve();
|
|
26624
27081
|
var Cache = require_cache();
|
|
26625
27082
|
var SchemaObject = require_schema_obj();
|
|
26626
27083
|
var stableStringify = require_fast_json_stable_stringify();
|
|
@@ -26681,27 +27138,27 @@ var require_windows = __commonJS((exports, module) => {
|
|
|
26681
27138
|
return checkPathExt(path, options2);
|
|
26682
27139
|
};
|
|
26683
27140
|
var isexe = function(path, options2, cb) {
|
|
26684
|
-
|
|
27141
|
+
fs36.stat(path, function(er, stat) {
|
|
26685
27142
|
cb(er, er ? false : checkStat(stat, path, options2));
|
|
26686
27143
|
});
|
|
26687
27144
|
};
|
|
26688
27145
|
var sync = function(path, options2) {
|
|
26689
|
-
return checkStat(
|
|
27146
|
+
return checkStat(fs36.statSync(path), path, options2);
|
|
26690
27147
|
};
|
|
26691
27148
|
module.exports = isexe;
|
|
26692
27149
|
isexe.sync = sync;
|
|
26693
|
-
var
|
|
27150
|
+
var fs36 = __require("fs");
|
|
26694
27151
|
});
|
|
26695
27152
|
|
|
26696
27153
|
// node_modules/isexe/mode.js
|
|
26697
27154
|
var require_mode = __commonJS((exports, module) => {
|
|
26698
27155
|
var isexe = function(path, options2, cb) {
|
|
26699
|
-
|
|
27156
|
+
fs36.stat(path, function(er, stat) {
|
|
26700
27157
|
cb(er, er ? false : checkStat(stat, options2));
|
|
26701
27158
|
});
|
|
26702
27159
|
};
|
|
26703
27160
|
var sync = function(path, options2) {
|
|
26704
|
-
return checkStat(
|
|
27161
|
+
return checkStat(fs36.statSync(path), options2);
|
|
26705
27162
|
};
|
|
26706
27163
|
var checkStat = function(stat, options2) {
|
|
26707
27164
|
return stat.isFile() && checkMode(stat, options2);
|
|
@@ -26721,7 +27178,7 @@ var require_mode = __commonJS((exports, module) => {
|
|
|
26721
27178
|
};
|
|
26722
27179
|
module.exports = isexe;
|
|
26723
27180
|
isexe.sync = sync;
|
|
26724
|
-
var
|
|
27181
|
+
var fs36 = __require("fs");
|
|
26725
27182
|
});
|
|
26726
27183
|
|
|
26727
27184
|
// node_modules/isexe/index.js
|
|
@@ -26735,12 +27192,12 @@ var require_isexe = __commonJS((exports, module) => {
|
|
|
26735
27192
|
if (typeof Promise !== "function") {
|
|
26736
27193
|
throw new TypeError("callback not provided");
|
|
26737
27194
|
}
|
|
26738
|
-
return new Promise(function(
|
|
27195
|
+
return new Promise(function(resolve15, reject) {
|
|
26739
27196
|
isexe(path, options2 || {}, function(er, is) {
|
|
26740
27197
|
if (er) {
|
|
26741
27198
|
reject(er);
|
|
26742
27199
|
} else {
|
|
26743
|
-
|
|
27200
|
+
resolve15(is);
|
|
26744
27201
|
}
|
|
26745
27202
|
});
|
|
26746
27203
|
});
|
|
@@ -26766,7 +27223,7 @@ var require_isexe = __commonJS((exports, module) => {
|
|
|
26766
27223
|
}
|
|
26767
27224
|
}
|
|
26768
27225
|
};
|
|
26769
|
-
var
|
|
27226
|
+
var fs36 = __require("fs");
|
|
26770
27227
|
var core2;
|
|
26771
27228
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
26772
27229
|
core2 = require_windows();
|
|
@@ -26811,27 +27268,27 @@ var require_which = __commonJS((exports, module) => {
|
|
|
26811
27268
|
opt = {};
|
|
26812
27269
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
26813
27270
|
const found = [];
|
|
26814
|
-
const step = (i) => new Promise((
|
|
27271
|
+
const step = (i) => new Promise((resolve15, reject) => {
|
|
26815
27272
|
if (i === pathEnv.length)
|
|
26816
|
-
return opt.all && found.length ?
|
|
27273
|
+
return opt.all && found.length ? resolve15(found) : reject(getNotFoundError(cmd));
|
|
26817
27274
|
const ppRaw = pathEnv[i];
|
|
26818
27275
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
26819
27276
|
const pCmd = path.join(pathPart, cmd);
|
|
26820
27277
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
26821
|
-
|
|
27278
|
+
resolve15(subStep(p, i, 0));
|
|
26822
27279
|
});
|
|
26823
|
-
const subStep = (p, i, ii) => new Promise((
|
|
27280
|
+
const subStep = (p, i, ii) => new Promise((resolve15, reject) => {
|
|
26824
27281
|
if (ii === pathExt.length)
|
|
26825
|
-
return
|
|
27282
|
+
return resolve15(step(i + 1));
|
|
26826
27283
|
const ext = pathExt[ii];
|
|
26827
27284
|
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
26828
27285
|
if (!er && is) {
|
|
26829
27286
|
if (opt.all)
|
|
26830
27287
|
found.push(p + ext);
|
|
26831
27288
|
else
|
|
26832
|
-
return
|
|
27289
|
+
return resolve15(p + ext);
|
|
26833
27290
|
}
|
|
26834
|
-
return
|
|
27291
|
+
return resolve15(subStep(p, i, ii + 1));
|
|
26835
27292
|
});
|
|
26836
27293
|
});
|
|
26837
27294
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -26973,14 +27430,14 @@ var require_readShebang = __commonJS((exports, module) => {
|
|
|
26973
27430
|
const buffer = Buffer.alloc(size);
|
|
26974
27431
|
let fd;
|
|
26975
27432
|
try {
|
|
26976
|
-
fd =
|
|
26977
|
-
|
|
26978
|
-
|
|
27433
|
+
fd = fs36.openSync(command, "r");
|
|
27434
|
+
fs36.readSync(fd, buffer, 0, size, 0);
|
|
27435
|
+
fs36.closeSync(fd);
|
|
26979
27436
|
} catch (e) {
|
|
26980
27437
|
}
|
|
26981
27438
|
return shebangCommand(buffer.toString());
|
|
26982
27439
|
};
|
|
26983
|
-
var
|
|
27440
|
+
var fs36 = __require("fs");
|
|
26984
27441
|
var shebangCommand = require_shebang_command();
|
|
26985
27442
|
module.exports = readShebang;
|
|
26986
27443
|
});
|
|
@@ -32412,6 +32869,16 @@ async function syncCommand(options2) {
|
|
|
32412
32869
|
if (options2.backup && result.changes.some((c) => c.action === "backed_up")) {
|
|
32413
32870
|
logger.info("\uD83D\uDCBE Backup files created with .agentinit.backup extension");
|
|
32414
32871
|
}
|
|
32872
|
+
if (options2.symlink) {
|
|
32873
|
+
const { AgentsMdManager: AgentsMdManager2 } = await Promise.resolve().then(() => (init_agentsMdManager(), exports_agentsMdManager));
|
|
32874
|
+
const mdManager = new AgentsMdManager2(cwd);
|
|
32875
|
+
try {
|
|
32876
|
+
await mdManager.symlinkClaude();
|
|
32877
|
+
logger.info("\uD83D\uDD17 CLAUDE.md symlinked to AGENTS.md");
|
|
32878
|
+
} catch (error) {
|
|
32879
|
+
logger.warning(`Failed to create symlink: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
32880
|
+
}
|
|
32881
|
+
}
|
|
32415
32882
|
}
|
|
32416
32883
|
} else {
|
|
32417
32884
|
spinner.fail("Synchronization failed");
|
|
@@ -32702,14 +33169,14 @@ class MCPParser {
|
|
|
32702
33169
|
|
|
32703
33170
|
// dist/utils/ownPackageVersion.js
|
|
32704
33171
|
import {readFileSync as readFileSync2} from "node:fs";
|
|
32705
|
-
import {dirname as dirname6, resolve as
|
|
33172
|
+
import {dirname as dirname6, resolve as resolve13} from "node:path";
|
|
32706
33173
|
import {fileURLToPath} from "node:url";
|
|
32707
33174
|
function getOwnPackageVersion(fallback2 = "0.0.0") {
|
|
32708
33175
|
const moduleDir = dirname6(fileURLToPath(import.meta.url));
|
|
32709
33176
|
const candidates = [
|
|
32710
|
-
|
|
32711
|
-
|
|
32712
|
-
|
|
33177
|
+
resolve13(moduleDir, "../package.json"),
|
|
33178
|
+
resolve13(moduleDir, "../../package.json"),
|
|
33179
|
+
resolve13(process.cwd(), "package.json")
|
|
32713
33180
|
];
|
|
32714
33181
|
for (const packageJsonPath of candidates) {
|
|
32715
33182
|
try {
|
|
@@ -32748,7 +33215,7 @@ import {readFileSync as readFileSync4} from "fs";
|
|
|
32748
33215
|
|
|
32749
33216
|
// dist/core/rulesTemplateLoader.js
|
|
32750
33217
|
var toml = __toESM(require_toml(), 1);
|
|
32751
|
-
import {resolve as
|
|
33218
|
+
import {resolve as resolve14, dirname as dirname7} from "path";
|
|
32752
33219
|
import {fileURLToPath as fileURLToPath2} from "url";
|
|
32753
33220
|
import {readFileSync as readFileSync3, readdirSync, existsSync as existsSync2} from "fs";
|
|
32754
33221
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
@@ -32758,7 +33225,7 @@ class RulesTemplateLoader {
|
|
|
32758
33225
|
templatesPath;
|
|
32759
33226
|
templates = new Map;
|
|
32760
33227
|
constructor() {
|
|
32761
|
-
this.templatesPath =
|
|
33228
|
+
this.templatesPath = resolve14(__dirname2, "../templates/rules");
|
|
32762
33229
|
this.loadTemplates();
|
|
32763
33230
|
}
|
|
32764
33231
|
loadTemplates() {
|
|
@@ -32768,7 +33235,7 @@ class RulesTemplateLoader {
|
|
|
32768
33235
|
const files = readdirSync(this.templatesPath).filter((file) => file.endsWith(".toml"));
|
|
32769
33236
|
for (const file of files) {
|
|
32770
33237
|
try {
|
|
32771
|
-
const filePath =
|
|
33238
|
+
const filePath = resolve14(this.templatesPath, file);
|
|
32772
33239
|
const content = readFileSync3(filePath, "utf-8");
|
|
32773
33240
|
const parsed = toml.default.parse(content);
|
|
32774
33241
|
const template = {
|
|
@@ -38340,7 +38807,7 @@ class Protocol {
|
|
|
38340
38807
|
}
|
|
38341
38808
|
request(request, resultSchema, options2) {
|
|
38342
38809
|
const { relatedRequestId, resumptionToken, onresumptiontoken } = options2 !== null && options2 !== undefined ? options2 : {};
|
|
38343
|
-
return new Promise((
|
|
38810
|
+
return new Promise((resolve15, reject) => {
|
|
38344
38811
|
var _a, _b, _c, _d, _e, _f;
|
|
38345
38812
|
if (!this._transport) {
|
|
38346
38813
|
reject(new Error("Not connected"));
|
|
@@ -38391,7 +38858,7 @@ class Protocol {
|
|
|
38391
38858
|
}
|
|
38392
38859
|
try {
|
|
38393
38860
|
const result = resultSchema.parse(response.result);
|
|
38394
|
-
|
|
38861
|
+
resolve15(result);
|
|
38395
38862
|
} catch (error) {
|
|
38396
38863
|
reject(error);
|
|
38397
38864
|
}
|
|
@@ -38771,7 +39238,7 @@ class StdioClientTransport {
|
|
|
38771
39238
|
if (this._process) {
|
|
38772
39239
|
throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
38773
39240
|
}
|
|
38774
|
-
return new Promise((
|
|
39241
|
+
return new Promise((resolve15, reject) => {
|
|
38775
39242
|
var _a, _b, _c, _d, _e;
|
|
38776
39243
|
this._process = import_cross_spawn.default(this._serverParams.command, (_a = this._serverParams.args) !== null && _a !== undefined ? _a : [], {
|
|
38777
39244
|
env: {
|
|
@@ -38794,7 +39261,7 @@ class StdioClientTransport {
|
|
|
38794
39261
|
(_b2 = this.onerror) === null || _b2 === undefined || _b2.call(this, error);
|
|
38795
39262
|
});
|
|
38796
39263
|
this._process.on("spawn", () => {
|
|
38797
|
-
|
|
39264
|
+
resolve15();
|
|
38798
39265
|
});
|
|
38799
39266
|
this._process.on("close", (_code) => {
|
|
38800
39267
|
var _a2;
|
|
@@ -38849,16 +39316,16 @@ class StdioClientTransport {
|
|
|
38849
39316
|
this._readBuffer.clear();
|
|
38850
39317
|
}
|
|
38851
39318
|
send(message) {
|
|
38852
|
-
return new Promise((
|
|
39319
|
+
return new Promise((resolve15) => {
|
|
38853
39320
|
var _a;
|
|
38854
39321
|
if (!((_a = this._process) === null || _a === undefined ? undefined : _a.stdin)) {
|
|
38855
39322
|
throw new Error("Not connected");
|
|
38856
39323
|
}
|
|
38857
39324
|
const json2 = serializeMessage(message);
|
|
38858
39325
|
if (this._process.stdin.write(json2)) {
|
|
38859
|
-
|
|
39326
|
+
resolve15();
|
|
38860
39327
|
} else {
|
|
38861
|
-
this._process.stdin.once("drain",
|
|
39328
|
+
this._process.stdin.once("drain", resolve15);
|
|
38862
39329
|
}
|
|
38863
39330
|
});
|
|
38864
39331
|
}
|
|
@@ -40280,7 +40747,7 @@ class SSEClientTransport {
|
|
|
40280
40747
|
_startOrAuth() {
|
|
40281
40748
|
var _a, _b, _c;
|
|
40282
40749
|
const fetchImpl = (_c = (_b = (_a = this === null || this === undefined ? undefined : this._eventSourceInit) === null || _a === undefined ? undefined : _a.fetch) !== null && _b !== undefined ? _b : this._fetch) !== null && _c !== undefined ? _c : fetch;
|
|
40283
|
-
return new Promise((
|
|
40750
|
+
return new Promise((resolve15, reject) => {
|
|
40284
40751
|
this._eventSource = new EventSource(this._url.href, {
|
|
40285
40752
|
...this._eventSourceInit,
|
|
40286
40753
|
fetch: async (url, init2) => {
|
|
@@ -40300,7 +40767,7 @@ class SSEClientTransport {
|
|
|
40300
40767
|
this._eventSource.onerror = (event) => {
|
|
40301
40768
|
var _a2;
|
|
40302
40769
|
if (event.code === 401 && this._authProvider) {
|
|
40303
|
-
this._authThenStart().then(
|
|
40770
|
+
this._authThenStart().then(resolve15, reject);
|
|
40304
40771
|
return;
|
|
40305
40772
|
}
|
|
40306
40773
|
const error = new SseError(event.code, event.message, event);
|
|
@@ -40323,7 +40790,7 @@ class SSEClientTransport {
|
|
|
40323
40790
|
this.close();
|
|
40324
40791
|
return;
|
|
40325
40792
|
}
|
|
40326
|
-
|
|
40793
|
+
resolve15();
|
|
40327
40794
|
});
|
|
40328
40795
|
this._eventSource.onmessage = (event) => {
|
|
40329
40796
|
var _a2, _b2;
|
|
@@ -40990,7 +41457,7 @@ class MCPVerifier {
|
|
|
40990
41457
|
}
|
|
40991
41458
|
|
|
40992
41459
|
// dist/core/gitignoreManager.js
|
|
40993
|
-
import {promises as
|
|
41460
|
+
import {promises as fs36} from "fs";
|
|
40994
41461
|
import {dirname as dirname8, join as join9} from "path";
|
|
40995
41462
|
var normalizeIgnorePath = function(projectPath, value) {
|
|
40996
41463
|
const relative7 = value.startsWith(projectPath) ? value.slice(projectPath.length + 1) : value;
|
|
@@ -41043,7 +41510,7 @@ async function updateManagedIgnoreFile(projectPath, paths6, options2 = {}) {
|
|
|
41043
41510
|
if (options2.local) {
|
|
41044
41511
|
const gitDir = join9(projectPath, ".git");
|
|
41045
41512
|
try {
|
|
41046
|
-
const stat = await
|
|
41513
|
+
const stat = await fs36.stat(gitDir);
|
|
41047
41514
|
if (!stat.isDirectory()) {
|
|
41048
41515
|
throw new Error;
|
|
41049
41516
|
}
|
|
@@ -41054,13 +41521,13 @@ async function updateManagedIgnoreFile(projectPath, paths6, options2 = {}) {
|
|
|
41054
41521
|
const normalizedPaths = [...new Set(paths6.map((path) => normalizeIgnorePath(projectPath, path)).filter(Boolean))].sort();
|
|
41055
41522
|
let existingContent = "";
|
|
41056
41523
|
try {
|
|
41057
|
-
existingContent = await
|
|
41524
|
+
existingContent = await fs36.readFile(ignoreFilePath, "utf8");
|
|
41058
41525
|
} catch {
|
|
41059
41526
|
existingContent = "";
|
|
41060
41527
|
}
|
|
41061
41528
|
const updatedContent = updateManagedBlock(existingContent, normalizedPaths);
|
|
41062
|
-
await
|
|
41063
|
-
await
|
|
41529
|
+
await fs36.mkdir(dirname8(ignoreFilePath), { recursive: true });
|
|
41530
|
+
await fs36.writeFile(ignoreFilePath, updatedContent, "utf8");
|
|
41064
41531
|
return ignoreFilePath;
|
|
41065
41532
|
}
|
|
41066
41533
|
async function removeManagedIgnoreBlock(projectPath, options2 = {}) {
|
|
@@ -41068,7 +41535,7 @@ async function removeManagedIgnoreBlock(projectPath, options2 = {}) {
|
|
|
41068
41535
|
const ignoreFilePath = join9(projectPath, ignoreFile);
|
|
41069
41536
|
let content;
|
|
41070
41537
|
try {
|
|
41071
|
-
content = await
|
|
41538
|
+
content = await fs36.readFile(ignoreFilePath, "utf8");
|
|
41072
41539
|
} catch {
|
|
41073
41540
|
return false;
|
|
41074
41541
|
}
|
|
@@ -41084,13 +41551,13 @@ async function removeManagedIgnoreBlock(projectPath, options2 = {}) {
|
|
|
41084
41551
|
const afterBlock = content.slice(endIndex + END_MARKER.length).replace(/^\n+/, "");
|
|
41085
41552
|
let nextContent = `${beforeBlock}${afterBlock}`.replace(/\n{3,}/g, "\n\n").replace(/^\n+/, "");
|
|
41086
41553
|
if (nextContent.trim() === "") {
|
|
41087
|
-
await
|
|
41554
|
+
await fs36.rm(ignoreFilePath, { force: true }).catch(() => {
|
|
41088
41555
|
});
|
|
41089
41556
|
} else {
|
|
41090
41557
|
if (!nextContent.endsWith("\n")) {
|
|
41091
41558
|
nextContent += "\n";
|
|
41092
41559
|
}
|
|
41093
|
-
await
|
|
41560
|
+
await fs36.writeFile(ignoreFilePath, nextContent, "utf8");
|
|
41094
41561
|
}
|
|
41095
41562
|
return true;
|
|
41096
41563
|
}
|
|
@@ -42238,7 +42705,7 @@ var import_prompts3 = __toESM(require_prompts3(), 1);
|
|
|
42238
42705
|
init_colors();
|
|
42239
42706
|
init_logger();
|
|
42240
42707
|
import {homedir as homedir7} from "os";
|
|
42241
|
-
import {relative as relative8, resolve as
|
|
42708
|
+
import {relative as relative8, resolve as resolve15} from "path";
|
|
42242
42709
|
|
|
42243
42710
|
// dist/utils/promptUtils.js
|
|
42244
42711
|
var import_prompts2 = __toESM(require_prompts3(), 1);
|
|
@@ -42703,6 +43170,35 @@ function registerSkillsCommand(program2) {
|
|
|
42703
43170
|
}
|
|
42704
43171
|
}
|
|
42705
43172
|
});
|
|
43173
|
+
skills3.command("discover <url>").description("Discover skills from a well-known endpoint or URL").action(async (url, options2) => {
|
|
43174
|
+
logger.titleBox("AgentInit Skills Discovery");
|
|
43175
|
+
const spinner = ora(`Discovering skills from ${url}...`).start();
|
|
43176
|
+
try {
|
|
43177
|
+
const projectPath = process.cwd();
|
|
43178
|
+
const agentManager9 = new AgentManager;
|
|
43179
|
+
const skillsManager5 = new SkillsManager(agentManager9);
|
|
43180
|
+
const result = await skillsManager5.discoverFromSource(url, projectPath);
|
|
43181
|
+
spinner.stop();
|
|
43182
|
+
if (result.skills.length === 0) {
|
|
43183
|
+
logger.info("No skills discovered.");
|
|
43184
|
+
return;
|
|
43185
|
+
}
|
|
43186
|
+
for (const skill of result.skills) {
|
|
43187
|
+
logger.info(` ${green(skill.name)}${skill.version ? ` @ ${skill.version}` : ""}`);
|
|
43188
|
+
if (skill.description) {
|
|
43189
|
+
logger.info(` ${skill.description}`);
|
|
43190
|
+
}
|
|
43191
|
+
if (skill.author) {
|
|
43192
|
+
logger.info(` Author: ${skill.author}`);
|
|
43193
|
+
}
|
|
43194
|
+
}
|
|
43195
|
+
logger.info(`\nTotal: ${result.skills.length} skill(s)`);
|
|
43196
|
+
} catch (error) {
|
|
43197
|
+
spinner.fail("Discovery failed");
|
|
43198
|
+
logger.error(`Error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
43199
|
+
process.exit(1);
|
|
43200
|
+
}
|
|
43201
|
+
});
|
|
42706
43202
|
skills3.command("list").alias("ls").description("List installed skills").option("-g, --global", "List only global skills").option("-a, --agent <agents...>", "Filter by specific agent(s)").action(async (options2) => {
|
|
42707
43203
|
logger.titleBox("AgentInit Skills");
|
|
42708
43204
|
const agentManager9 = new AgentManager;
|
|
@@ -42875,7 +43371,7 @@ Dry run \u2014 no changes made.`));
|
|
|
42875
43371
|
const entries = await installLock3.getCurrentState({
|
|
42876
43372
|
kind: "skill",
|
|
42877
43373
|
name,
|
|
42878
|
-
projectPath:
|
|
43374
|
+
projectPath: resolve15(cwd),
|
|
42879
43375
|
scope: "project"
|
|
42880
43376
|
});
|
|
42881
43377
|
if (entries.length === 0) {
|
|
@@ -42931,7 +43427,7 @@ Dry run \u2014 no changes made.`));
|
|
|
42931
43427
|
} else {
|
|
42932
43428
|
const entries = await installLock3.getCurrentState({
|
|
42933
43429
|
kind: "skill",
|
|
42934
|
-
projectPath:
|
|
43430
|
+
projectPath: resolve15(cwd),
|
|
42935
43431
|
scope: "project"
|
|
42936
43432
|
});
|
|
42937
43433
|
if (entries.length === 0) {
|
|
@@ -43136,7 +43632,7 @@ var buildSkillGroups = function(agents, projectPath, global3) {
|
|
|
43136
43632
|
dirToAgents.set(skillsDir, existing);
|
|
43137
43633
|
}
|
|
43138
43634
|
return Array.from(dirToAgents.entries()).map(([dir, groupedAgents]) => {
|
|
43139
|
-
const canonicalShared =
|
|
43635
|
+
const canonicalShared = resolve15(dir) === getCanonicalSkillsDirForScope(projectPath, !!global3) && groupedAgents.every((agent) => agent.getProjectSkillsStandard() === "agents");
|
|
43140
43636
|
return {
|
|
43141
43637
|
dir,
|
|
43142
43638
|
displayDir: formatSkillsDir(projectPath, dir),
|
|
@@ -43159,7 +43655,7 @@ var prependCanonicalGlobalGroup = function(agentManager9, projectPath, groups) {
|
|
|
43159
43655
|
if (sharedAgents.length === 0) {
|
|
43160
43656
|
return groups;
|
|
43161
43657
|
}
|
|
43162
|
-
const existingCanonicalIndex = groups.findIndex((group) =>
|
|
43658
|
+
const existingCanonicalIndex = groups.findIndex((group) => resolve15(group.dir) === canonicalDir);
|
|
43163
43659
|
if (existingCanonicalIndex >= 0) {
|
|
43164
43660
|
const existingCanonical = groups[existingCanonicalIndex];
|
|
43165
43661
|
const remaining = groups.filter((_, index) => index !== existingCanonicalIndex);
|
|
@@ -43216,10 +43712,10 @@ var formatPromptPath = function(path) {
|
|
|
43216
43712
|
return normalizedPath;
|
|
43217
43713
|
};
|
|
43218
43714
|
var getCanonicalGlobalSkillsDir = function() {
|
|
43219
|
-
return
|
|
43715
|
+
return resolve15(homedir7(), ".agents/skills");
|
|
43220
43716
|
};
|
|
43221
43717
|
var getCanonicalSkillsDirForScope = function(projectPath, global3) {
|
|
43222
|
-
return global3 ? getCanonicalGlobalSkillsDir() :
|
|
43718
|
+
return global3 ? getCanonicalGlobalSkillsDir() : resolve15(projectPath, ".agents/skills");
|
|
43223
43719
|
};
|
|
43224
43720
|
var getCanonicalGlobalSkillsDisplayPath = function() {
|
|
43225
43721
|
return formatPromptPath(getCanonicalGlobalSkillsDir());
|
|
@@ -44348,7 +44844,7 @@ function registerRulesCommand(program2) {
|
|
|
44348
44844
|
// dist/commands/plugins.js
|
|
44349
44845
|
var import_prompts4 = __toESM(require_prompts3(), 1);
|
|
44350
44846
|
import {homedir as homedir8} from "os";
|
|
44351
|
-
import {dirname as dirname10, relative as relative9, resolve as
|
|
44847
|
+
import {dirname as dirname10, relative as relative9, resolve as resolve16} from "path";
|
|
44352
44848
|
init_logger();
|
|
44353
44849
|
init_pluginManager();
|
|
44354
44850
|
init_agentManager();
|
|
@@ -44969,7 +45465,7 @@ var buildGlobalPluginGroups = function(agentManager12, projectPath) {
|
|
|
44969
45465
|
compatibleAgentNames: [],
|
|
44970
45466
|
kind: "native"
|
|
44971
45467
|
}));
|
|
44972
|
-
const canonicalDir =
|
|
45468
|
+
const canonicalDir = resolve16(homedir8(), ".agents/skills");
|
|
44973
45469
|
const sharedAgents = agentManager12.getAllAgents().filter((agent) => agent.supportsSkills() && agent.getProjectSkillsStandard() === "agents" && !!agent.getSkillsDir(projectPath, true));
|
|
44974
45470
|
const claudeGroups = nativeGroups.filter((group) => group.agents.some((agent) => agent.id === "claude"));
|
|
44975
45471
|
const otherGroups = nativeGroups.filter((group) => !group.agents.some((agent) => agent.id === "claude"));
|
|
@@ -45083,7 +45579,7 @@ async function interactiveAgentSelect(pluginManager3, agentManager12, projectPat
|
|
|
45083
45579
|
init_colors();
|
|
45084
45580
|
init_logger();
|
|
45085
45581
|
init_installLock();
|
|
45086
|
-
import {resolve as
|
|
45582
|
+
import {resolve as resolve17} from "path";
|
|
45087
45583
|
var formatTimestamp = function(iso) {
|
|
45088
45584
|
const date = new Date(iso);
|
|
45089
45585
|
return date.toLocaleDateString("en-US", {
|
|
@@ -45113,7 +45609,7 @@ function registerLockCommand(program2) {
|
|
|
45113
45609
|
if (options2.kind)
|
|
45114
45610
|
queryOptions.kind = options2.kind;
|
|
45115
45611
|
if (options2.project)
|
|
45116
|
-
queryOptions.projectPath =
|
|
45612
|
+
queryOptions.projectPath = resolve17(options2.project);
|
|
45117
45613
|
if (options2.agent)
|
|
45118
45614
|
queryOptions.agent = options2.agent;
|
|
45119
45615
|
if (options2.scope)
|
|
@@ -46814,6 +47310,134 @@ function registerAgentCommand(program2) {
|
|
|
46814
47310
|
});
|
|
46815
47311
|
}
|
|
46816
47312
|
|
|
47313
|
+
// dist/commands/agentsMd.js
|
|
47314
|
+
init_colors();
|
|
47315
|
+
init_logger();
|
|
47316
|
+
init_agentsMdManager();
|
|
47317
|
+
function registerAgentsMdCommand(program2) {
|
|
47318
|
+
const agentsMd = program2.command("agents-md").description("Manage AGENTS.md and per-agent rule files");
|
|
47319
|
+
agentsMd.command("init").description("Initialize AGENTS.md if it does not exist").action(async () => {
|
|
47320
|
+
const projectPath = process.cwd();
|
|
47321
|
+
const manager = new AgentsMdManager(projectPath);
|
|
47322
|
+
const spinner = ora("Checking AGENTS.md...").start();
|
|
47323
|
+
try {
|
|
47324
|
+
const content = await manager.read();
|
|
47325
|
+
if (content) {
|
|
47326
|
+
spinner.succeed("AGENTS.md already exists");
|
|
47327
|
+
return;
|
|
47328
|
+
}
|
|
47329
|
+
await manager.setSection({
|
|
47330
|
+
heading: "Project Overview",
|
|
47331
|
+
body: "Add your project context here."
|
|
47332
|
+
});
|
|
47333
|
+
spinner.succeed("Created AGENTS.md");
|
|
47334
|
+
} catch (error) {
|
|
47335
|
+
spinner.fail("Failed to initialize AGENTS.md");
|
|
47336
|
+
logger.error(`Error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
47337
|
+
process.exit(1);
|
|
47338
|
+
}
|
|
47339
|
+
});
|
|
47340
|
+
agentsMd.command("set-section").description("Add or update a section in AGENTS.md").argument("<heading>", "Section heading").option("-b, --body <body>", "Section body text", "").option("-f, --file <path>", "Read body from file").option("--placement <placement>", 'Placement: append, prepend, or "after <heading>"', "append").action(async (heading, options2) => {
|
|
47341
|
+
const projectPath = process.cwd();
|
|
47342
|
+
const manager = new AgentsMdManager(projectPath);
|
|
47343
|
+
const spinner = ora(`Updating section "${heading}"...`).start();
|
|
47344
|
+
try {
|
|
47345
|
+
let body = options2.body;
|
|
47346
|
+
if (options2.file) {
|
|
47347
|
+
const { readFileIfExists: readFileIfExists2 } = await Promise.resolve().then(() => (init_fs(), exports_fs));
|
|
47348
|
+
const fileContent = await readFileIfExists2(options2.file);
|
|
47349
|
+
if (!fileContent) {
|
|
47350
|
+
spinner.fail(`File not found: ${options2.file}`);
|
|
47351
|
+
process.exit(1);
|
|
47352
|
+
}
|
|
47353
|
+
body = fileContent;
|
|
47354
|
+
}
|
|
47355
|
+
await manager.setSection({
|
|
47356
|
+
heading,
|
|
47357
|
+
body,
|
|
47358
|
+
placement: options2.placement
|
|
47359
|
+
});
|
|
47360
|
+
spinner.succeed(`Updated section "${heading}" in AGENTS.md`);
|
|
47361
|
+
} catch (error) {
|
|
47362
|
+
spinner.fail(`Failed to update section "${heading}"`);
|
|
47363
|
+
logger.error(`Error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
47364
|
+
process.exit(1);
|
|
47365
|
+
}
|
|
47366
|
+
});
|
|
47367
|
+
agentsMd.command("remove-section").description("Remove a section from AGENTS.md").argument("<heading>", "Section heading to remove").action(async (heading) => {
|
|
47368
|
+
const projectPath = process.cwd();
|
|
47369
|
+
const manager = new AgentsMdManager(projectPath);
|
|
47370
|
+
const spinner = ora(`Removing section "${heading}"...`).start();
|
|
47371
|
+
try {
|
|
47372
|
+
const removed = await manager.removeSection({ heading });
|
|
47373
|
+
if (removed) {
|
|
47374
|
+
spinner.succeed(`Removed section "${heading}"`);
|
|
47375
|
+
} else {
|
|
47376
|
+
spinner.warn(`Section "${heading}" not found`);
|
|
47377
|
+
}
|
|
47378
|
+
} catch (error) {
|
|
47379
|
+
spinner.fail(`Failed to remove section "${heading}"`);
|
|
47380
|
+
logger.error(`Error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
47381
|
+
process.exit(1);
|
|
47382
|
+
}
|
|
47383
|
+
});
|
|
47384
|
+
agentsMd.command("read").description("Read AGENTS.md content").action(async () => {
|
|
47385
|
+
const projectPath = process.cwd();
|
|
47386
|
+
const manager = new AgentsMdManager(projectPath);
|
|
47387
|
+
try {
|
|
47388
|
+
const content = await manager.read();
|
|
47389
|
+
if (!content) {
|
|
47390
|
+
logger.info("AGENTS.md does not exist");
|
|
47391
|
+
return;
|
|
47392
|
+
}
|
|
47393
|
+
logger.info(content);
|
|
47394
|
+
} catch (error) {
|
|
47395
|
+
logger.error(`Error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
47396
|
+
process.exit(1);
|
|
47397
|
+
}
|
|
47398
|
+
});
|
|
47399
|
+
agentsMd.command("symlink-claude").description("Create CLAUDE.md symlink pointing to AGENTS.md").action(async () => {
|
|
47400
|
+
const projectPath = process.cwd();
|
|
47401
|
+
const manager = new AgentsMdManager(projectPath);
|
|
47402
|
+
const spinner = ora("Creating CLAUDE.md -> AGENTS.md symlink...").start();
|
|
47403
|
+
try {
|
|
47404
|
+
await manager.symlinkClaude();
|
|
47405
|
+
spinner.succeed("CLAUDE.md now symlinks to AGENTS.md");
|
|
47406
|
+
} catch (error) {
|
|
47407
|
+
spinner.fail("Failed to create symlink");
|
|
47408
|
+
logger.error(`Error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
47409
|
+
process.exit(1);
|
|
47410
|
+
}
|
|
47411
|
+
});
|
|
47412
|
+
agentsMd.command("parse").description("Parse and list AGENTS.md sections").action(async () => {
|
|
47413
|
+
const projectPath = process.cwd();
|
|
47414
|
+
const manager = new AgentsMdManager(projectPath);
|
|
47415
|
+
try {
|
|
47416
|
+
const content = await manager.read();
|
|
47417
|
+
if (!content) {
|
|
47418
|
+
logger.info("AGENTS.md does not exist");
|
|
47419
|
+
return;
|
|
47420
|
+
}
|
|
47421
|
+
const sections = manager.parseSections(content);
|
|
47422
|
+
if (sections.length === 0) {
|
|
47423
|
+
logger.info("No sections found in AGENTS.md");
|
|
47424
|
+
return;
|
|
47425
|
+
}
|
|
47426
|
+
for (const section of sections) {
|
|
47427
|
+
logger.info(`${"#".repeat(section.level)} ${green(section.heading)}`);
|
|
47428
|
+
const bodyPreview = section.body.split("\n").slice(0, 3).join("\n");
|
|
47429
|
+
if (bodyPreview) {
|
|
47430
|
+
logger.info(bodyPreview);
|
|
47431
|
+
}
|
|
47432
|
+
logger.info("");
|
|
47433
|
+
}
|
|
47434
|
+
} catch (error) {
|
|
47435
|
+
logger.error(`Error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
47436
|
+
process.exit(1);
|
|
47437
|
+
}
|
|
47438
|
+
});
|
|
47439
|
+
}
|
|
47440
|
+
|
|
46817
47441
|
// dist/cli.js
|
|
46818
47442
|
init_logger();
|
|
46819
47443
|
var program2 = new Command;
|
|
@@ -46825,9 +47449,10 @@ registerPluginsCommand(program2);
|
|
|
46825
47449
|
registerConfigCommand(program2);
|
|
46826
47450
|
registerLockCommand(program2);
|
|
46827
47451
|
registerAgentCommand(program2);
|
|
47452
|
+
registerAgentsMdCommand(program2);
|
|
46828
47453
|
program2.command("init").description("Initialize agents.md configuration for the current project").option("-f, --force", "Overwrite existing configuration").option("-t, --template <template>", "Use specific template (web, cli, library)").action(initCommand);
|
|
46829
47454
|
program2.command("detect").description("Detect current project stack and existing agent configurations").option("-v, --verbose", "Show detailed detection results").action(detectCommand);
|
|
46830
|
-
program2.command("sync").description("Sync agents.md with agent-specific configuration files").option("-a, --agent <agents...>", "Target specific agent(s)").option("-d, --dry-run", "Show what would be changed without making changes").option("-b, --backup", "Create backup before syncing").action(syncCommand);
|
|
47455
|
+
program2.command("sync").description("Sync agents.md with agent-specific configuration files").option("-a, --agent <agents...>", "Target specific agent(s)").option("-d, --dry-run", "Show what would be changed without making changes").option("-b, --backup", "Create backup before syncing").option("--symlink", "Create CLAUDE.md symlink to AGENTS.md after sync").action(syncCommand);
|
|
46831
47456
|
program2.command("apply").description("Apply agents.md and project-owned skills to supported agent files").option("-a, --agent <agents...>", "Target specific agent(s)").option("-d, --dry-run", "Preview changes without writing files").option("-b, --backup", "Create sibling .agentinit.backup files before overwriting").option("--no-skills", "Disable project-owned skills propagation").option("--copy-skills", "Copy project-owned skills instead of using canonical symlink installs").option("--no-gitignore", "Disable managed ignore block updates").option("--gitignore-local", "Write ignore entries to .git/info/exclude instead of .gitignore").allowUnknownOption(true).action(async (options2, command) => {
|
|
46832
47457
|
const rawArgs = command.parent.rawArgs.slice(3);
|
|
46833
47458
|
if (hasLegacyApplyArgs(rawArgs)) {
|