@agentvalet/register 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +25 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -189,7 +189,7 @@ async function saveOutput(opts) {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
// src/commands/refresh.ts
|
|
192
|
-
import { readFileSync, writeFileSync, mkdirSync, statSync } from "fs";
|
|
192
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync } from "fs";
|
|
193
193
|
import { createSign, createPrivateKey } from "crypto";
|
|
194
194
|
import { dirname as dirname2, resolve as resolve2 } from "path";
|
|
195
195
|
|
|
@@ -317,10 +317,34 @@ Run 'agentvalet-register' first to create it.`);
|
|
|
317
317
|
const content = generatePermissionsFile(agentId, ownerId, platforms);
|
|
318
318
|
mkdirSync(dirname2(outputPath), { recursive: true });
|
|
319
319
|
writeFileSync(outputPath, content, "utf-8");
|
|
320
|
+
ensureClaudeMd(options.outputPath);
|
|
320
321
|
if (!options.quiet) {
|
|
321
322
|
console.log(`Permissions refreshed \u2192 ${outputPath} (${platforms.length} platform${platforms.length !== 1 ? "s" : ""})`);
|
|
322
323
|
}
|
|
323
324
|
}
|
|
325
|
+
function ensureClaudeMd(permissionsRelativePath) {
|
|
326
|
+
const importLine = `@${permissionsRelativePath.replace(/\\/g, "/").replace(/^\.\//, "")}`;
|
|
327
|
+
const claudeMdPath = resolve2("CLAUDE.md");
|
|
328
|
+
if (!existsSync(claudeMdPath)) {
|
|
329
|
+
writeFileSync(
|
|
330
|
+
claudeMdPath,
|
|
331
|
+
`# Agent Instructions
|
|
332
|
+
|
|
333
|
+
@.claude/agentvalet-permissions.md
|
|
334
|
+
`,
|
|
335
|
+
"utf-8"
|
|
336
|
+
);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
const existing = readFileSync(claudeMdPath, "utf-8");
|
|
340
|
+
if (existing.includes(importLine) || existing.includes("@.claude/agentvalet-permissions.md")) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
writeFileSync(claudeMdPath, `${existing.trimEnd()}
|
|
344
|
+
|
|
345
|
+
${importLine}
|
|
346
|
+
`, "utf-8");
|
|
347
|
+
}
|
|
324
348
|
|
|
325
349
|
// src/index.ts
|
|
326
350
|
function collectScope(value, previous) {
|