@punks/cli 2.3.0 → 2.3.1
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
cp,
|
|
2
3
|
lstat,
|
|
3
4
|
mkdir,
|
|
4
5
|
readFile,
|
|
@@ -52,6 +53,10 @@ const cursorManagedComment =
|
|
|
52
53
|
"<!-- Generated by scripts/sync-subagents.mjs. Edit .agents/subagents/manifest.mjs instead. -->";
|
|
53
54
|
const opencodeManagedComment =
|
|
54
55
|
"<!-- Generated by scripts/sync-subagents.mjs. Edit .agents/subagents/manifest.mjs instead. -->";
|
|
56
|
+
const claudeUpdateCheckCommand =
|
|
57
|
+
'node "$CLAUDE_PROJECT_DIR"/.claude/hooks/scaffold-update-check.mjs claude';
|
|
58
|
+
const claudeFormatCommand =
|
|
59
|
+
'node "$CLAUDE_PROJECT_DIR"/.claude/hooks/format-edited-file.mjs claude';
|
|
55
60
|
|
|
56
61
|
function buildCodexAgentConfig({ hasFormatHook, hasUpdateCheckHook }) {
|
|
57
62
|
const lines = [
|
|
@@ -100,39 +105,80 @@ function buildCodexAgentConfig({ hasFormatHook, hasUpdateCheckHook }) {
|
|
|
100
105
|
return lines.join("\n");
|
|
101
106
|
}
|
|
102
107
|
|
|
103
|
-
function
|
|
104
|
-
|
|
108
|
+
function isObject(value) {
|
|
109
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function removeClaudeHookCommand(entries, command) {
|
|
113
|
+
if (!Array.isArray(entries)) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return entries.flatMap((entry) => {
|
|
118
|
+
if (!isObject(entry) || !Array.isArray(entry.hooks)) {
|
|
119
|
+
return [entry];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const hooks = entry.hooks.filter((hook) => !isObject(hook) || hook.command !== command);
|
|
123
|
+
return hooks.length === 0 ? [] : [{ ...entry, hooks }];
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function setClaudeHookEntries(hooks, key, entries) {
|
|
128
|
+
if (entries.length > 0) {
|
|
129
|
+
hooks[key] = entries;
|
|
130
|
+
} else {
|
|
131
|
+
delete hooks[key];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function buildClaudeSettingsConfig(existingConfig, { hasFormatHook, hasUpdateCheckHook }) {
|
|
136
|
+
const config = isObject(existingConfig) ? existingConfig : {};
|
|
137
|
+
const existingHooks = isObject(config.hooks) ? config.hooks : {};
|
|
138
|
+
const hooks = { ...existingHooks };
|
|
139
|
+
const sessionStartHooks = removeClaudeHookCommand(
|
|
140
|
+
existingHooks.SessionStart,
|
|
141
|
+
claudeUpdateCheckCommand,
|
|
142
|
+
);
|
|
143
|
+
const postToolUseHooks = removeClaudeHookCommand(existingHooks.PostToolUse, claudeFormatCommand);
|
|
105
144
|
|
|
106
145
|
if (hasUpdateCheckHook) {
|
|
107
146
|
hooks.SessionStart = [
|
|
147
|
+
...sessionStartHooks,
|
|
108
148
|
{
|
|
109
149
|
hooks: [
|
|
110
150
|
{
|
|
111
151
|
type: "command",
|
|
112
|
-
command:
|
|
152
|
+
command: claudeUpdateCheckCommand,
|
|
113
153
|
timeout: 60,
|
|
114
154
|
},
|
|
115
155
|
],
|
|
116
156
|
},
|
|
117
157
|
];
|
|
158
|
+
} else {
|
|
159
|
+
setClaudeHookEntries(hooks, "SessionStart", sessionStartHooks);
|
|
118
160
|
}
|
|
119
161
|
|
|
120
162
|
if (hasFormatHook) {
|
|
121
163
|
hooks.PostToolUse = [
|
|
164
|
+
...postToolUseHooks,
|
|
122
165
|
{
|
|
123
166
|
matcher: "Edit|Write|MultiEdit",
|
|
124
167
|
hooks: [
|
|
125
168
|
{
|
|
126
169
|
type: "command",
|
|
127
|
-
command:
|
|
170
|
+
command: claudeFormatCommand,
|
|
128
171
|
timeout: 30,
|
|
129
172
|
},
|
|
130
173
|
],
|
|
131
174
|
},
|
|
132
175
|
];
|
|
176
|
+
} else {
|
|
177
|
+
setClaudeHookEntries(hooks, "PostToolUse", postToolUseHooks);
|
|
133
178
|
}
|
|
134
179
|
|
|
135
180
|
return {
|
|
181
|
+
...config,
|
|
136
182
|
hooks,
|
|
137
183
|
};
|
|
138
184
|
}
|
|
@@ -390,7 +436,23 @@ async function ensureSymlink(linkPath, targetPath) {
|
|
|
390
436
|
}
|
|
391
437
|
|
|
392
438
|
await rm(linkPath, { force: true, recursive: true });
|
|
393
|
-
await
|
|
439
|
+
const targetStat = process.platform === "win32" ? await lstat(targetPath) : undefined;
|
|
440
|
+
const symlinkType = targetStat?.isDirectory() ? "junction" : undefined;
|
|
441
|
+
|
|
442
|
+
try {
|
|
443
|
+
await symlink(symlinkType === "junction" ? targetPath : relativeTarget, linkPath, symlinkType);
|
|
444
|
+
} catch (error) {
|
|
445
|
+
if (!(error && typeof error === "object" && "code" in error && error.code === "EPERM")) {
|
|
446
|
+
throw error;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const copyTargetStat = await lstat(targetPath);
|
|
450
|
+
await cp(targetPath, linkPath, {
|
|
451
|
+
recursive: copyTargetStat.isDirectory(),
|
|
452
|
+
force: true,
|
|
453
|
+
errorOnExist: false,
|
|
454
|
+
});
|
|
455
|
+
}
|
|
394
456
|
}
|
|
395
457
|
|
|
396
458
|
async function pathExists(filePath) {
|
|
@@ -499,7 +561,7 @@ async function main() {
|
|
|
499
561
|
await rm(path.join(codexDir, "hooks.json"), { force: true });
|
|
500
562
|
await writeFile(
|
|
501
563
|
claudeSettingsPath,
|
|
502
|
-
encodeJson(buildClaudeSettingsConfig(availableHooks)),
|
|
564
|
+
encodeJson(buildClaudeSettingsConfig(await readJsonFile(claudeSettingsPath), availableHooks)),
|
|
503
565
|
"utf8",
|
|
504
566
|
);
|
|
505
567
|
await writeFile(cursorHooksJsonPath, encodeJson(buildCursorHooksConfig(availableHooks)), "utf8");
|
package/dist/index.js
CHANGED
|
@@ -52254,7 +52254,7 @@ var embeddedAssets = [];
|
|
|
52254
52254
|
|
|
52255
52255
|
// package.json
|
|
52256
52256
|
var name = "@punks/cli";
|
|
52257
|
-
var version = "2.3.
|
|
52257
|
+
var version = "2.3.1";
|
|
52258
52258
|
// src/content/data.ts
|
|
52259
52259
|
var findFirst8 = (candidates) => candidates.find((candidate) => existsSync(candidate));
|
|
52260
52260
|
var executableSignature = () => {
|