@agentvalet/register 0.1.4 → 0.1.5
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 +27 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -245,6 +245,10 @@ To refresh this file: \`agentvalet-register refresh\`
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
// src/commands/refresh.ts
|
|
248
|
+
var CLAUDE_START = "<!-- agentvalet:start -->";
|
|
249
|
+
var CLAUDE_END = "<!-- agentvalet:end -->";
|
|
250
|
+
var HOOK_COMMAND = "npx @agentvalet/register refresh --if-stale --quiet 2>/dev/null || true";
|
|
251
|
+
var HOOK_MARKER = "agentvalet/register refresh";
|
|
248
252
|
function base64url(input) {
|
|
249
253
|
return Buffer.from(input).toString("base64url");
|
|
250
254
|
}
|
|
@@ -274,9 +278,10 @@ async function runRefresh(options) {
|
|
|
274
278
|
if (options.ifStale) {
|
|
275
279
|
try {
|
|
276
280
|
const stat = statSync(outputPath);
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
281
|
+
const fileIsFresh = Date.now() - stat.mtimeMs < 36e5;
|
|
282
|
+
const claudeMdPath = resolve2("CLAUDE.md");
|
|
283
|
+
const claudeMdHasBlock = existsSync(claudeMdPath) && readFileSync(claudeMdPath, "utf-8").includes(CLAUDE_START);
|
|
284
|
+
if (fileIsFresh && claudeMdHasBlock) return;
|
|
280
285
|
} catch {
|
|
281
286
|
}
|
|
282
287
|
}
|
|
@@ -317,37 +322,39 @@ Run 'agentvalet-register' first to create it.`);
|
|
|
317
322
|
const content = generatePermissionsFile(agentId, ownerId, platforms);
|
|
318
323
|
mkdirSync(dirname2(outputPath), { recursive: true });
|
|
319
324
|
writeFileSync(outputPath, content, "utf-8");
|
|
320
|
-
|
|
325
|
+
embedInClaudeMd(content);
|
|
321
326
|
ensureHook();
|
|
322
327
|
if (!options.quiet) {
|
|
323
328
|
console.log(`Permissions refreshed \u2192 ${outputPath} (${platforms.length} platform${platforms.length !== 1 ? "s" : ""})`);
|
|
324
329
|
}
|
|
325
330
|
}
|
|
326
|
-
function
|
|
327
|
-
const importLine = `@${permissionsRelativePath.replace(/\\/g, "/").replace(/^\.\//, "")}`;
|
|
331
|
+
function embedInClaudeMd(permissionsContent) {
|
|
328
332
|
const claudeMdPath = resolve2("CLAUDE.md");
|
|
333
|
+
const block = `${CLAUDE_START}
|
|
334
|
+
${permissionsContent.trimEnd()}
|
|
335
|
+
${CLAUDE_END}`;
|
|
329
336
|
if (!existsSync(claudeMdPath)) {
|
|
330
|
-
writeFileSync(
|
|
331
|
-
claudeMdPath,
|
|
332
|
-
`# Agent Instructions
|
|
337
|
+
writeFileSync(claudeMdPath, `# Agent Instructions
|
|
333
338
|
|
|
334
|
-
|
|
335
|
-
`,
|
|
336
|
-
"utf-8"
|
|
337
|
-
);
|
|
339
|
+
${block}
|
|
340
|
+
`, "utf-8");
|
|
338
341
|
return;
|
|
339
342
|
}
|
|
340
343
|
const existing = readFileSync(claudeMdPath, "utf-8");
|
|
341
|
-
if (existing.includes(
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
344
|
+
if (existing.includes(CLAUDE_START)) {
|
|
345
|
+
const replaced = existing.replace(
|
|
346
|
+
new RegExp(`${CLAUDE_START}[\\s\\S]*?${CLAUDE_END}`, "m"),
|
|
347
|
+
block
|
|
348
|
+
);
|
|
349
|
+
writeFileSync(claudeMdPath, replaced, "utf-8");
|
|
350
|
+
} else {
|
|
351
|
+
const cleaned = existing.replace(/^@\.claude\/agentvalet-permissions\.md\s*$/m, "").trimEnd();
|
|
352
|
+
writeFileSync(claudeMdPath, `${cleaned}
|
|
345
353
|
|
|
346
|
-
${
|
|
354
|
+
${block}
|
|
347
355
|
`, "utf-8");
|
|
356
|
+
}
|
|
348
357
|
}
|
|
349
|
-
var HOOK_COMMAND = "npx @agentvalet/register refresh --if-stale --quiet 2>/dev/null || true";
|
|
350
|
-
var HOOK_MARKER = "agentvalet/register refresh";
|
|
351
358
|
function ensureHook() {
|
|
352
359
|
const settingsPath = resolve2(".claude/settings.local.json");
|
|
353
360
|
let settings = {};
|