safeword 0.5.2 → 0.6.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.
- package/dist/{check-3NGQ4NR5.js → check-INXMFCL5.js} +7 -5
- package/dist/{check-3NGQ4NR5.js.map → check-INXMFCL5.js.map} +1 -1
- package/dist/chunk-6CVTH67L.js +43 -0
- package/dist/chunk-6CVTH67L.js.map +1 -0
- package/dist/chunk-75FKNZUM.js +15 -0
- package/dist/chunk-75FKNZUM.js.map +1 -0
- package/dist/{chunk-GZRQL3SX.js → chunk-ARIAOK2F.js} +2 -38
- package/dist/chunk-ARIAOK2F.js.map +1 -0
- package/dist/chunk-FRPJITGG.js +35 -0
- package/dist/chunk-FRPJITGG.js.map +1 -0
- package/dist/chunk-IWWBZVHT.js +274 -0
- package/dist/chunk-IWWBZVHT.js.map +1 -0
- package/dist/cli.js +9 -5
- package/dist/cli.js.map +1 -1
- package/dist/{diff-Y6QTAW4O.js → diff-L7G22MG7.js} +7 -5
- package/dist/{diff-Y6QTAW4O.js.map → diff-L7G22MG7.js.map} +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/{reset-YPSS7BAB.js → reset-5SRM3P6J.js} +19 -17
- package/dist/reset-5SRM3P6J.js.map +1 -0
- package/dist/setup-65EVU5OT.js +437 -0
- package/dist/setup-65EVU5OT.js.map +1 -0
- package/dist/sync-4XBMKLXS.js +116 -0
- package/dist/sync-4XBMKLXS.js.map +1 -0
- package/dist/{upgrade-GQKC2ZKF.js → upgrade-P3WX3ODU.js} +34 -15
- package/dist/upgrade-P3WX3ODU.js.map +1 -0
- package/package.json +2 -1
- package/templates/SAFEWORD.md +4 -4
- package/templates/commands/architecture.md +27 -0
- package/templates/commands/lint.md +15 -54
- package/templates/commands/quality-review.md +16 -13
- package/templates/hooks/post-tool-lint.sh +14 -53
- package/dist/chunk-GZRQL3SX.js.map +0 -1
- package/dist/chunk-Z7MWRHVP.js +0 -266
- package/dist/chunk-Z7MWRHVP.js.map +0 -1
- package/dist/reset-YPSS7BAB.js.map +0 -1
- package/dist/setup-U35LUMIF.js +0 -298
- package/dist/setup-U35LUMIF.js.map +0 -1
- package/dist/upgrade-GQKC2ZKF.js.map +0 -1
- package/templates/commands/arch-review.md +0 -28
- package/templates/hooks/git-pre-commit.sh +0 -18
- /package/templates/{markdownlint.jsonc → markdownlint-cli2.jsonc} +0 -0
- /package/templates/prompts/{arch-review.md → architecture.md} +0 -0
- /package/templates/prompts/{quality-review.md → review.md} +0 -0
package/dist/chunk-Z7MWRHVP.js
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ensureDir,
|
|
3
|
-
exists,
|
|
4
|
-
makeExecutable,
|
|
5
|
-
readFile,
|
|
6
|
-
writeFile
|
|
7
|
-
} from "./chunk-GZRQL3SX.js";
|
|
8
|
-
|
|
9
|
-
// src/utils/git.ts
|
|
10
|
-
import { execSync } from "child_process";
|
|
11
|
-
import { join } from "path";
|
|
12
|
-
var MARKER_START = "# SAFEWORD_ARCH_CHECK_START";
|
|
13
|
-
var MARKER_END = "# SAFEWORD_ARCH_CHECK_END";
|
|
14
|
-
function isGitRepo(cwd) {
|
|
15
|
-
return exists(join(cwd, ".git"));
|
|
16
|
-
}
|
|
17
|
-
function getHookContent() {
|
|
18
|
-
return `
|
|
19
|
-
${MARKER_START}
|
|
20
|
-
# Safeword pre-commit linting
|
|
21
|
-
# This section is managed by safeword - do not edit manually
|
|
22
|
-
if [ -f ".safeword/hooks/git-pre-commit.sh" ]; then
|
|
23
|
-
bash .safeword/hooks/git-pre-commit.sh
|
|
24
|
-
fi
|
|
25
|
-
${MARKER_END}
|
|
26
|
-
`;
|
|
27
|
-
}
|
|
28
|
-
function installGitHook(cwd) {
|
|
29
|
-
const hooksDir = join(cwd, ".git", "hooks");
|
|
30
|
-
const hookPath = join(hooksDir, "pre-commit");
|
|
31
|
-
ensureDir(hooksDir);
|
|
32
|
-
let content = "";
|
|
33
|
-
if (exists(hookPath)) {
|
|
34
|
-
content = readFile(hookPath);
|
|
35
|
-
if (content.includes(MARKER_START)) {
|
|
36
|
-
content = removeMarkerSection(content);
|
|
37
|
-
}
|
|
38
|
-
} else {
|
|
39
|
-
content = "#!/bin/bash\n";
|
|
40
|
-
}
|
|
41
|
-
content = content.trimEnd() + "\n" + getHookContent();
|
|
42
|
-
writeFile(hookPath, content);
|
|
43
|
-
makeExecutable(hookPath);
|
|
44
|
-
}
|
|
45
|
-
function removeGitHook(cwd) {
|
|
46
|
-
const hookPath = join(cwd, ".git", "hooks", "pre-commit");
|
|
47
|
-
if (!exists(hookPath)) return;
|
|
48
|
-
let content = readFile(hookPath);
|
|
49
|
-
if (!content.includes(MARKER_START)) return;
|
|
50
|
-
content = removeMarkerSection(content);
|
|
51
|
-
writeFile(hookPath, content);
|
|
52
|
-
}
|
|
53
|
-
function removeMarkerSection(content) {
|
|
54
|
-
const lines = content.split("\n");
|
|
55
|
-
const result = [];
|
|
56
|
-
let inMarkerSection = false;
|
|
57
|
-
for (const line of lines) {
|
|
58
|
-
if (line.includes(MARKER_START)) {
|
|
59
|
-
inMarkerSection = true;
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (line.includes(MARKER_END)) {
|
|
63
|
-
inMarkerSection = false;
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
if (!inMarkerSection) {
|
|
67
|
-
result.push(line);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return result.join("\n").trim() + "\n";
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// src/utils/hooks.ts
|
|
74
|
-
function isHookEntry(h) {
|
|
75
|
-
return typeof h === "object" && h !== null && "hooks" in h && Array.isArray(h.hooks);
|
|
76
|
-
}
|
|
77
|
-
function isSafewordHook(h) {
|
|
78
|
-
if (!isHookEntry(h)) return false;
|
|
79
|
-
return h.hooks.some(
|
|
80
|
-
(cmd) => typeof cmd.command === "string" && cmd.command.includes(".safeword")
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
function filterOutSafewordHooks(hooks) {
|
|
84
|
-
return hooks.filter((h) => !isSafewordHook(h));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// src/templates/content.ts
|
|
88
|
-
var AGENTS_MD_LINK = `**\u26A0\uFE0F ALWAYS READ FIRST: @./.safeword/SAFEWORD.md**
|
|
89
|
-
|
|
90
|
-
The SAFEWORD.md file contains core development patterns, workflows, and conventions.
|
|
91
|
-
Read it BEFORE working on any task in this project.
|
|
92
|
-
|
|
93
|
-
---`;
|
|
94
|
-
var PRETTIERRC = `{
|
|
95
|
-
"semi": true,
|
|
96
|
-
"singleQuote": true,
|
|
97
|
-
"tabWidth": 2,
|
|
98
|
-
"trailingComma": "es5",
|
|
99
|
-
"printWidth": 100
|
|
100
|
-
}
|
|
101
|
-
`;
|
|
102
|
-
|
|
103
|
-
// src/templates/config.ts
|
|
104
|
-
function getEslintConfig(options) {
|
|
105
|
-
const imports = ['import js from "@eslint/js";'];
|
|
106
|
-
const configs = ["js.configs.recommended"];
|
|
107
|
-
const ignores = ["node_modules/", "dist/", "build/"];
|
|
108
|
-
if (options.typescript) {
|
|
109
|
-
imports.push('import tseslint from "typescript-eslint";');
|
|
110
|
-
configs.push("...tseslint.configs.recommended");
|
|
111
|
-
}
|
|
112
|
-
if (options.react || options.nextjs) {
|
|
113
|
-
imports.push('import react from "eslint-plugin-react";');
|
|
114
|
-
imports.push('import reactHooks from "eslint-plugin-react-hooks";');
|
|
115
|
-
configs.push("react.configs.flat.recommended");
|
|
116
|
-
configs.push('react.configs.flat["jsx-runtime"]');
|
|
117
|
-
configs.push(
|
|
118
|
-
'{ plugins: { "react-hooks": reactHooks }, rules: reactHooks.configs.recommended.rules }'
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
if (options.nextjs) {
|
|
122
|
-
imports.push('import nextPlugin from "@next/eslint-plugin-next";');
|
|
123
|
-
configs.push('{ plugins: { "@next/next": nextPlugin }, rules: nextPlugin.configs.recommended.rules }');
|
|
124
|
-
ignores.push(".next/");
|
|
125
|
-
}
|
|
126
|
-
if (options.astro) {
|
|
127
|
-
imports.push('import eslintPluginAstro from "eslint-plugin-astro";');
|
|
128
|
-
configs.push("...eslintPluginAstro.configs.recommended");
|
|
129
|
-
ignores.push(".astro/");
|
|
130
|
-
}
|
|
131
|
-
if (options.vue) {
|
|
132
|
-
imports.push('import pluginVue from "eslint-plugin-vue";');
|
|
133
|
-
configs.push('...pluginVue.configs["flat/recommended"]');
|
|
134
|
-
ignores.push(".nuxt/");
|
|
135
|
-
}
|
|
136
|
-
if (options.svelte) {
|
|
137
|
-
imports.push('import eslintPluginSvelte from "eslint-plugin-svelte";');
|
|
138
|
-
configs.push('...eslintPluginSvelte.configs["flat/recommended"]');
|
|
139
|
-
ignores.push(".svelte-kit/");
|
|
140
|
-
}
|
|
141
|
-
return `${imports.join("\n")}
|
|
142
|
-
|
|
143
|
-
export default [
|
|
144
|
-
${configs.join(",\n ")},
|
|
145
|
-
{
|
|
146
|
-
ignores: [${ignores.map((i) => `"${i}"`).join(", ")}],
|
|
147
|
-
},
|
|
148
|
-
];
|
|
149
|
-
`;
|
|
150
|
-
}
|
|
151
|
-
var SETTINGS_HOOKS = {
|
|
152
|
-
SessionStart: [
|
|
153
|
-
{
|
|
154
|
-
hooks: [
|
|
155
|
-
{
|
|
156
|
-
type: "command",
|
|
157
|
-
command: "bash .safeword/hooks/session-verify-agents.sh"
|
|
158
|
-
}
|
|
159
|
-
]
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
hooks: [
|
|
163
|
-
{
|
|
164
|
-
type: "command",
|
|
165
|
-
command: "bash .safeword/hooks/session-version.sh"
|
|
166
|
-
}
|
|
167
|
-
]
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
hooks: [
|
|
171
|
-
{
|
|
172
|
-
type: "command",
|
|
173
|
-
command: "bash .safeword/hooks/session-lint-check.sh"
|
|
174
|
-
}
|
|
175
|
-
]
|
|
176
|
-
}
|
|
177
|
-
],
|
|
178
|
-
UserPromptSubmit: [
|
|
179
|
-
{
|
|
180
|
-
hooks: [
|
|
181
|
-
{
|
|
182
|
-
type: "command",
|
|
183
|
-
command: "bash .safeword/hooks/prompt-timestamp.sh"
|
|
184
|
-
}
|
|
185
|
-
]
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
hooks: [
|
|
189
|
-
{
|
|
190
|
-
type: "command",
|
|
191
|
-
command: "bash .safeword/hooks/prompt-questions.sh"
|
|
192
|
-
}
|
|
193
|
-
]
|
|
194
|
-
}
|
|
195
|
-
],
|
|
196
|
-
Stop: [
|
|
197
|
-
{
|
|
198
|
-
hooks: [
|
|
199
|
-
{
|
|
200
|
-
type: "command",
|
|
201
|
-
command: "bash .safeword/hooks/stop-quality.sh"
|
|
202
|
-
}
|
|
203
|
-
]
|
|
204
|
-
}
|
|
205
|
-
],
|
|
206
|
-
PostToolUse: [
|
|
207
|
-
{
|
|
208
|
-
matcher: "Write|Edit|MultiEdit|NotebookEdit",
|
|
209
|
-
hooks: [
|
|
210
|
-
{
|
|
211
|
-
type: "command",
|
|
212
|
-
command: "bash .safeword/hooks/post-tool-lint.sh"
|
|
213
|
-
}
|
|
214
|
-
]
|
|
215
|
-
}
|
|
216
|
-
]
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
// src/utils/agents-md.ts
|
|
220
|
-
import { join as join2 } from "path";
|
|
221
|
-
var SAFEWORD_LINK_MARKER = "@./.safeword/SAFEWORD.md";
|
|
222
|
-
function ensureAgentsMdLink(cwd) {
|
|
223
|
-
const agentsMdPath = join2(cwd, "AGENTS.md");
|
|
224
|
-
if (!exists(agentsMdPath)) {
|
|
225
|
-
writeFile(agentsMdPath, `${AGENTS_MD_LINK}
|
|
226
|
-
`);
|
|
227
|
-
return "created";
|
|
228
|
-
}
|
|
229
|
-
const content = readFile(agentsMdPath);
|
|
230
|
-
if (!content.includes(SAFEWORD_LINK_MARKER)) {
|
|
231
|
-
writeFile(agentsMdPath, `${AGENTS_MD_LINK}
|
|
232
|
-
|
|
233
|
-
${content}`);
|
|
234
|
-
return "modified";
|
|
235
|
-
}
|
|
236
|
-
return "unchanged";
|
|
237
|
-
}
|
|
238
|
-
function removeAgentsMdLink(cwd) {
|
|
239
|
-
const agentsMdPath = join2(cwd, "AGENTS.md");
|
|
240
|
-
if (!exists(agentsMdPath)) return false;
|
|
241
|
-
const content = readFile(agentsMdPath);
|
|
242
|
-
let newContent = content.replace(AGENTS_MD_LINK, "");
|
|
243
|
-
const lines = newContent.split("\n").filter((line) => !line.includes(SAFEWORD_LINK_MARKER));
|
|
244
|
-
while (lines.length > 0 && (lines[0].trim() === "" || lines[0].trim() === "---")) {
|
|
245
|
-
lines.shift();
|
|
246
|
-
}
|
|
247
|
-
newContent = lines.join("\n");
|
|
248
|
-
if (newContent !== content) {
|
|
249
|
-
writeFile(agentsMdPath, newContent);
|
|
250
|
-
return true;
|
|
251
|
-
}
|
|
252
|
-
return false;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
export {
|
|
256
|
-
isGitRepo,
|
|
257
|
-
installGitHook,
|
|
258
|
-
removeGitHook,
|
|
259
|
-
filterOutSafewordHooks,
|
|
260
|
-
PRETTIERRC,
|
|
261
|
-
getEslintConfig,
|
|
262
|
-
SETTINGS_HOOKS,
|
|
263
|
-
ensureAgentsMdLink,
|
|
264
|
-
removeAgentsMdLink
|
|
265
|
-
};
|
|
266
|
-
//# sourceMappingURL=chunk-Z7MWRHVP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/git.ts","../src/utils/hooks.ts","../src/templates/content.ts","../src/templates/config.ts","../src/utils/agents-md.ts"],"sourcesContent":["/**\n * Git utilities for CLI operations\n */\n\nimport { execSync } from 'node:child_process';\nimport { join } from 'node:path';\nimport { exists, readFile, writeFile, ensureDir, makeExecutable } from './fs.js';\n\nconst MARKER_START = '# SAFEWORD_ARCH_CHECK_START';\nconst MARKER_END = '# SAFEWORD_ARCH_CHECK_END';\n\n/**\n * Check if directory is a git repository\n */\nexport function isGitRepo(cwd: string): boolean {\n return exists(join(cwd, '.git'));\n}\n\n/**\n * Initialize a git repository\n */\nexport function initGitRepo(cwd: string): void {\n execSync('git init', { cwd, stdio: 'pipe' });\n}\n\n/**\n * Get the pre-commit hook content to add\n */\nfunction getHookContent(): string {\n return `\n${MARKER_START}\n# Safeword pre-commit linting\n# This section is managed by safeword - do not edit manually\nif [ -f \".safeword/hooks/git-pre-commit.sh\" ]; then\n bash .safeword/hooks/git-pre-commit.sh\nfi\n${MARKER_END}\n`;\n}\n\n/**\n * Install safeword markers into pre-commit hook\n */\nexport function installGitHook(cwd: string): void {\n const hooksDir = join(cwd, '.git', 'hooks');\n const hookPath = join(hooksDir, 'pre-commit');\n\n ensureDir(hooksDir);\n\n let content = '';\n\n if (exists(hookPath)) {\n content = readFile(hookPath);\n\n // Check if already has safeword markers\n if (content.includes(MARKER_START)) {\n // Remove existing safeword section and re-add (update)\n content = removeMarkerSection(content);\n }\n } else {\n // Create new hook file with shebang\n content = '#!/bin/bash\\n';\n }\n\n // Add safeword section\n content = content.trimEnd() + '\\n' + getHookContent();\n\n writeFile(hookPath, content);\n makeExecutable(hookPath);\n}\n\n/**\n * Remove safeword markers from pre-commit hook\n */\nexport function removeGitHook(cwd: string): void {\n const hookPath = join(cwd, '.git', 'hooks', 'pre-commit');\n\n if (!exists(hookPath)) return;\n\n let content = readFile(hookPath);\n\n if (!content.includes(MARKER_START)) return;\n\n content = removeMarkerSection(content);\n\n // If only shebang remains, we could delete the file\n // but safer to leave it\n writeFile(hookPath, content);\n}\n\n/**\n * Remove the section between markers (inclusive)\n */\nfunction removeMarkerSection(content: string): string {\n const lines = content.split('\\n');\n const result: string[] = [];\n let inMarkerSection = false;\n\n for (const line of lines) {\n if (line.includes(MARKER_START)) {\n inMarkerSection = true;\n continue;\n }\n if (line.includes(MARKER_END)) {\n inMarkerSection = false;\n continue;\n }\n if (!inMarkerSection) {\n result.push(line);\n }\n }\n\n return result.join('\\n').trim() + '\\n';\n}\n\n/**\n * Check if git hooks have safeword markers\n */\nexport function hasGitHook(cwd: string): boolean {\n const hookPath = join(cwd, '.git', 'hooks', 'pre-commit');\n if (!exists(hookPath)) return false;\n const content = readFile(hookPath);\n return content.includes(MARKER_START);\n}\n","/**\n * Hook utilities for Claude Code settings\n */\n\ninterface HookCommand {\n type: string;\n command: string;\n}\n\ninterface HookEntry {\n matcher?: string;\n hooks: HookCommand[];\n}\n\n/**\n * Type guard to check if a value is a hook entry with hooks array\n */\nexport function isHookEntry(h: unknown): h is HookEntry {\n return (\n typeof h === 'object' &&\n h !== null &&\n 'hooks' in h &&\n Array.isArray((h as HookEntry).hooks)\n );\n}\n\n/**\n * Check if a hook entry contains a safeword hook (command contains '.safeword')\n */\nexport function isSafewordHook(h: unknown): boolean {\n if (!isHookEntry(h)) return false;\n return h.hooks.some(\n (cmd) => typeof cmd.command === 'string' && cmd.command.includes('.safeword'),\n );\n}\n\n/**\n * Filter out safeword hooks from an array of hook entries\n */\nexport function filterOutSafewordHooks(hooks: unknown[]): unknown[] {\n return hooks.filter((h) => !isSafewordHook(h));\n}\n","/**\n * Content templates - static string content\n *\n * Note: Most templates (SAFEWORD.md, hooks, skills, guides, etc.) are now\n * file-based in the templates/ directory. This file contains only small\n * string constants that are used inline.\n */\n\nexport const AGENTS_MD_LINK = `**⚠️ ALWAYS READ FIRST: @./.safeword/SAFEWORD.md**\n\nThe SAFEWORD.md file contains core development patterns, workflows, and conventions.\nRead it BEFORE working on any task in this project.\n\n---`;\n\nexport const PRETTIERRC = `{\n \"semi\": true,\n \"singleQuote\": true,\n \"tabWidth\": 2,\n \"trailingComma\": \"es5\",\n \"printWidth\": 100\n}\n`;\n","/**\n * Configuration templates - ESLint config generation and hook settings\n */\n\nexport function getEslintConfig(options: {\n typescript?: boolean;\n react?: boolean;\n nextjs?: boolean;\n astro?: boolean;\n vue?: boolean;\n svelte?: boolean;\n}): string {\n const imports: string[] = ['import js from \"@eslint/js\";'];\n const configs: string[] = ['js.configs.recommended'];\n const ignores: string[] = ['node_modules/', 'dist/', 'build/'];\n\n if (options.typescript) {\n imports.push('import tseslint from \"typescript-eslint\";');\n configs.push('...tseslint.configs.recommended');\n }\n\n if (options.react || options.nextjs) {\n imports.push('import react from \"eslint-plugin-react\";');\n imports.push('import reactHooks from \"eslint-plugin-react-hooks\";');\n configs.push('react.configs.flat.recommended');\n configs.push('react.configs.flat[\"jsx-runtime\"]');\n configs.push(\n '{ plugins: { \"react-hooks\": reactHooks }, rules: reactHooks.configs.recommended.rules }',\n );\n }\n\n if (options.nextjs) {\n imports.push('import nextPlugin from \"@next/eslint-plugin-next\";');\n configs.push('{ plugins: { \"@next/next\": nextPlugin }, rules: nextPlugin.configs.recommended.rules }');\n ignores.push('.next/');\n }\n\n if (options.astro) {\n imports.push('import eslintPluginAstro from \"eslint-plugin-astro\";');\n configs.push('...eslintPluginAstro.configs.recommended');\n ignores.push('.astro/');\n }\n\n if (options.vue) {\n imports.push('import pluginVue from \"eslint-plugin-vue\";');\n configs.push('...pluginVue.configs[\"flat/recommended\"]');\n ignores.push('.nuxt/');\n }\n\n if (options.svelte) {\n imports.push('import eslintPluginSvelte from \"eslint-plugin-svelte\";');\n configs.push('...eslintPluginSvelte.configs[\"flat/recommended\"]');\n ignores.push('.svelte-kit/');\n }\n\n return `${imports.join('\\n')}\n\nexport default [\n ${configs.join(',\\n ')},\n {\n ignores: [${ignores.map(i => `\"${i}\"`).join(', ')}],\n },\n];\n`;\n}\n\nexport const SETTINGS_HOOKS = {\n SessionStart: [\n {\n hooks: [\n {\n type: 'command',\n command: 'bash .safeword/hooks/session-verify-agents.sh',\n },\n ],\n },\n {\n hooks: [\n {\n type: 'command',\n command: 'bash .safeword/hooks/session-version.sh',\n },\n ],\n },\n {\n hooks: [\n {\n type: 'command',\n command: 'bash .safeword/hooks/session-lint-check.sh',\n },\n ],\n },\n ],\n UserPromptSubmit: [\n {\n hooks: [\n {\n type: 'command',\n command: 'bash .safeword/hooks/prompt-timestamp.sh',\n },\n ],\n },\n {\n hooks: [\n {\n type: 'command',\n command: 'bash .safeword/hooks/prompt-questions.sh',\n },\n ],\n },\n ],\n Stop: [\n {\n hooks: [\n {\n type: 'command',\n command: 'bash .safeword/hooks/stop-quality.sh',\n },\n ],\n },\n ],\n PostToolUse: [\n {\n matcher: 'Write|Edit|MultiEdit|NotebookEdit',\n hooks: [\n {\n type: 'command',\n command: 'bash .safeword/hooks/post-tool-lint.sh',\n },\n ],\n },\n ],\n};\n","/**\n * AGENTS.md file utilities\n */\n\nimport { join } from 'node:path';\nimport { exists, readFile, writeFile } from './fs.js';\nimport { AGENTS_MD_LINK } from '../templates/index.js';\n\nconst SAFEWORD_LINK_MARKER = '@./.safeword/SAFEWORD.md';\n\n/**\n * Check if AGENTS.md has the safeword link\n */\nexport function hasAgentsMdLink(cwd: string): boolean {\n const agentsMdPath = join(cwd, 'AGENTS.md');\n if (!exists(agentsMdPath)) return false;\n const content = readFile(agentsMdPath);\n return content.includes(SAFEWORD_LINK_MARKER);\n}\n\n/**\n * Ensure AGENTS.md exists and has the safeword link.\n * Returns 'created' | 'modified' | 'unchanged'\n */\nexport function ensureAgentsMdLink(cwd: string): 'created' | 'modified' | 'unchanged' {\n const agentsMdPath = join(cwd, 'AGENTS.md');\n\n if (!exists(agentsMdPath)) {\n writeFile(agentsMdPath, `${AGENTS_MD_LINK}\\n`);\n return 'created';\n }\n\n const content = readFile(agentsMdPath);\n if (!content.includes(SAFEWORD_LINK_MARKER)) {\n writeFile(agentsMdPath, `${AGENTS_MD_LINK}\\n\\n${content}`);\n return 'modified';\n }\n\n return 'unchanged';\n}\n\n/**\n * Remove safeword link block from AGENTS.md.\n * Returns true if link was removed.\n */\nexport function removeAgentsMdLink(cwd: string): boolean {\n const agentsMdPath = join(cwd, 'AGENTS.md');\n if (!exists(agentsMdPath)) return false;\n\n const content = readFile(agentsMdPath);\n\n // Remove the entire AGENTS_MD_LINK block if present\n let newContent = content.replace(AGENTS_MD_LINK, '');\n\n // Also handle legacy single-line format (filter any remaining lines with marker)\n const lines = newContent.split('\\n').filter((line) => !line.includes(SAFEWORD_LINK_MARKER));\n\n // Remove extra blank lines and separators at the start\n while (lines.length > 0 && (lines[0].trim() === '' || lines[0].trim() === '---')) {\n lines.shift();\n }\n\n newContent = lines.join('\\n');\n\n if (newContent !== content) {\n writeFile(agentsMdPath, newContent);\n return true;\n }\n\n return false;\n}\n"],"mappings":";;;;;;;;;AAIA,SAAS,gBAAgB;AACzB,SAAS,YAAY;AAGrB,IAAM,eAAe;AACrB,IAAM,aAAa;AAKZ,SAAS,UAAU,KAAsB;AAC9C,SAAO,OAAO,KAAK,KAAK,MAAM,CAAC;AACjC;AAYA,SAAS,iBAAyB;AAChC,SAAO;AAAA,EACP,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMZ,UAAU;AAAA;AAEZ;AAKO,SAAS,eAAe,KAAmB;AAChD,QAAM,WAAW,KAAK,KAAK,QAAQ,OAAO;AAC1C,QAAM,WAAW,KAAK,UAAU,YAAY;AAE5C,YAAU,QAAQ;AAElB,MAAI,UAAU;AAEd,MAAI,OAAO,QAAQ,GAAG;AACpB,cAAU,SAAS,QAAQ;AAG3B,QAAI,QAAQ,SAAS,YAAY,GAAG;AAElC,gBAAU,oBAAoB,OAAO;AAAA,IACvC;AAAA,EACF,OAAO;AAEL,cAAU;AAAA,EACZ;AAGA,YAAU,QAAQ,QAAQ,IAAI,OAAO,eAAe;AAEpD,YAAU,UAAU,OAAO;AAC3B,iBAAe,QAAQ;AACzB;AAKO,SAAS,cAAc,KAAmB;AAC/C,QAAM,WAAW,KAAK,KAAK,QAAQ,SAAS,YAAY;AAExD,MAAI,CAAC,OAAO,QAAQ,EAAG;AAEvB,MAAI,UAAU,SAAS,QAAQ;AAE/B,MAAI,CAAC,QAAQ,SAAS,YAAY,EAAG;AAErC,YAAU,oBAAoB,OAAO;AA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,EAAE,KAAK,MAAM,QAAQ;AAChF,UAAM,MAAM;AAAA,EACd;AAEA,eAAa,MAAM,KAAK,IAAI;AAE5B,MAAI,eAAe,SAAS;AAC1B,cAAU,cAAc,UAAU;AAClC,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":["join","join"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/reset.ts"],"sourcesContent":["/**\n * Reset command - Remove safeword configuration from project\n */\n\nimport { join } from 'node:path';\nimport { exists, remove, readJson, writeJson, listDir } from '../utils/fs.js';\nimport { info, success, error, header, listItem } from '../utils/output.js';\nimport { isGitRepo, removeGitHook } from '../utils/git.js';\nimport { filterOutSafewordHooks } from '../utils/hooks.js';\nimport { removeAgentsMdLink } from '../utils/agents-md.js';\n\nexport interface ResetOptions {\n yes?: boolean;\n}\n\nexport async function reset(options: ResetOptions): Promise<void> {\n const cwd = process.cwd();\n const safewordDir = join(cwd, '.safeword');\n\n // Check if configured\n if (!exists(safewordDir)) {\n info('Nothing to remove. Project is not configured with safeword.');\n return;\n }\n\n const isNonInteractive = options.yes || !process.stdin.isTTY;\n\n // Confirmation (in interactive mode without --yes)\n if (!isNonInteractive) {\n // In a real implementation, we'd prompt here\n // For now, non-TTY mode auto-confirms\n }\n\n header('Safeword Reset');\n info('Removing safeword configuration...');\n\n const removed: string[] = [];\n\n try {\n // 1. Remove .safeword directory\n if (exists(safewordDir)) {\n remove(safewordDir);\n removed.push('.safeword/');\n success('Removed .safeword directory');\n }\n\n // 2. Remove safeword hooks from .claude/settings.json\n const settingsPath = join(cwd, '.claude', 'settings.json');\n\n if (exists(settingsPath)) {\n info('\\nRemoving hooks from .claude/settings.json...');\n\n interface SettingsJson {\n hooks?: Record<string, unknown[]>;\n [key: string]: unknown;\n }\n\n const settings = readJson<SettingsJson>(settingsPath);\n\n if (settings?.hooks) {\n let modified = false;\n\n for (const [event, hooks] of Object.entries(settings.hooks)) {\n if (Array.isArray(hooks)) {\n const filtered = filterOutSafewordHooks(hooks);\n if (filtered.length !== hooks.length) {\n settings.hooks[event] = filtered;\n modified = true;\n }\n }\n }\n\n if (modified) {\n writeJson(settingsPath, settings);\n removed.push('.claude/settings.json (hooks)');\n success('Removed safeword hooks');\n }\n }\n }\n\n // 3. Remove safeword skills\n const skillsDir = join(cwd, '.claude', 'skills');\n\n if (exists(skillsDir)) {\n info('\\nRemoving safeword skills...');\n\n const skills = listDir(skillsDir);\n for (const skill of skills) {\n if (skill.startsWith('safeword-')) {\n remove(join(skillsDir, skill));\n removed.push(`.claude/skills/${skill}/`);\n }\n }\n\n if (removed.some(r => r.includes('skills'))) {\n success('Removed safeword skills');\n }\n }\n\n // 3.5. Remove safeword slash commands\n const commandsDir = join(cwd, '.claude', 'commands');\n const safewordCommands = ['quality-review.md', 'arch-review.md', 'lint.md'];\n\n if (exists(commandsDir)) {\n info('\\nRemoving safeword commands...');\n\n let commandsRemoved = false;\n for (const cmd of safewordCommands) {\n const cmdPath = join(commandsDir, cmd);\n if (exists(cmdPath)) {\n remove(cmdPath);\n removed.push(`.claude/commands/${cmd}`);\n commandsRemoved = true;\n }\n }\n\n if (commandsRemoved) {\n success('Removed safeword commands');\n }\n }\n\n // 3.6. Remove MCP servers from .mcp.json\n const mcpConfigPath = join(cwd, '.mcp.json');\n\n if (exists(mcpConfigPath)) {\n info('\\nRemoving MCP servers...');\n\n interface McpConfig {\n mcpServers?: Record<string, unknown>;\n [key: string]: unknown;\n }\n\n const mcpConfig = readJson<McpConfig>(mcpConfigPath);\n\n if (mcpConfig?.mcpServers) {\n // Remove safeword MCP servers\n delete mcpConfig.mcpServers.context7;\n delete mcpConfig.mcpServers.playwright;\n\n // If no servers left, remove the file\n if (Object.keys(mcpConfig.mcpServers).length === 0) {\n remove(mcpConfigPath);\n removed.push('.mcp.json');\n } else {\n writeJson(mcpConfigPath, mcpConfig);\n removed.push('.mcp.json (context7, playwright)');\n }\n\n success('Removed MCP servers');\n }\n }\n\n // 4. Remove git hook markers\n if (isGitRepo(cwd)) {\n info('\\nRemoving git hook markers...');\n removeGitHook(cwd);\n removed.push('.git/hooks/pre-commit (markers)');\n success('Removed git hook markers');\n }\n\n // 5. Remove link from AGENTS.md\n info('\\nCleaning AGENTS.md...');\n if (removeAgentsMdLink(cwd)) {\n removed.push('AGENTS.md (link)');\n success('Removed safeword link from AGENTS.md');\n }\n\n // Print summary\n header('Reset Complete');\n\n if (removed.length > 0) {\n info('\\nRemoved:');\n for (const item of removed) {\n listItem(item);\n }\n }\n\n // Note about preserved linting\n info('\\nPreserved (remove manually if desired):');\n listItem('eslint.config.mjs');\n listItem('.prettierrc');\n listItem('package.json lint/format scripts');\n listItem('ESLint/Prettier devDependencies');\n\n success('\\nSafeword configuration removed');\n } catch (err) {\n error(`Reset failed: ${err instanceof Error ? err.message : 'Unknown error'}`);\n process.exit(1);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA,SAAS,YAAY;AAWrB,eAAsB,MAAM,SAAsC;AAChE,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,cAAc,KAAK,KAAK,WAAW;AAGzC,MAAI,CAAC,OAAO,WAAW,GAAG;AACxB,SAAK,6DAA6D;AAClE;AAAA,EACF;AAEA,QAAM,mBAAmB,QAAQ,OAAO,CAAC,QAAQ,MAAM;AAGvD,MAAI,CAAC,kBAAkB;AAAA,EAGvB;AAEA,SAAO,gBAAgB;AACvB,OAAK,oCAAoC;AAEzC,QAAM,UAAoB,CAAC;AAE3B,MAAI;AAEF,QAAI,OAAO,WAAW,GAAG;AACvB,aAAO,WAAW;AAClB,cAAQ,KAAK,YAAY;AACzB,cAAQ,6BAA6B;AAAA,IACvC;AAGA,UAAM,eAAe,KAAK,KAAK,WAAW,eAAe;AAEzD,QAAI,OAAO,YAAY,GAAG;AACxB,WAAK,gDAAgD;AAOrD,YAAM,WAAW,SAAuB,YAAY;AAEpD,UAAI,UAAU,OAAO;AACnB,YAAI,WAAW;AAEf,mBAAW,CAAC,OAAO,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
7
|
-
ensureAgentsMdLink,
|
|
8
|
-
filterOutSafewordHooks,
|
|
9
|
-
getEslintConfig,
|
|
10
|
-
installGitHook,
|
|
11
|
-
isGitRepo
|
|
12
|
-
} from "./chunk-Z7MWRHVP.js";
|
|
13
|
-
import {
|
|
14
|
-
copyDir,
|
|
15
|
-
copyFile,
|
|
16
|
-
ensureDir,
|
|
17
|
-
error,
|
|
18
|
-
exists,
|
|
19
|
-
getTemplatesDir,
|
|
20
|
-
header,
|
|
21
|
-
info,
|
|
22
|
-
listItem,
|
|
23
|
-
makeScriptsExecutable,
|
|
24
|
-
readJson,
|
|
25
|
-
success,
|
|
26
|
-
updateJson,
|
|
27
|
-
warn,
|
|
28
|
-
writeFile,
|
|
29
|
-
writeJson
|
|
30
|
-
} from "./chunk-GZRQL3SX.js";
|
|
31
|
-
|
|
32
|
-
// src/commands/setup.ts
|
|
33
|
-
import { join, basename } from "path";
|
|
34
|
-
|
|
35
|
-
// src/utils/project-detector.ts
|
|
36
|
-
function detectProjectType(packageJson) {
|
|
37
|
-
const deps = packageJson.dependencies || {};
|
|
38
|
-
const devDeps = packageJson.devDependencies || {};
|
|
39
|
-
const allDeps = { ...deps, ...devDeps };
|
|
40
|
-
const hasTypescript = "typescript" in allDeps;
|
|
41
|
-
const hasReact = "react" in deps || "react" in devDeps;
|
|
42
|
-
const hasNextJs = "next" in deps;
|
|
43
|
-
const hasAstro = "astro" in deps || "astro" in devDeps;
|
|
44
|
-
const hasVue = "vue" in deps || "vue" in devDeps;
|
|
45
|
-
const hasNuxt = "nuxt" in deps;
|
|
46
|
-
const hasSvelte = "svelte" in deps || "svelte" in devDeps;
|
|
47
|
-
const hasSvelteKit = "@sveltejs/kit" in deps || "@sveltejs/kit" in devDeps;
|
|
48
|
-
const hasElectron = "electron" in deps || "electron" in devDeps;
|
|
49
|
-
return {
|
|
50
|
-
typescript: hasTypescript,
|
|
51
|
-
react: hasReact || hasNextJs,
|
|
52
|
-
// Next.js implies React
|
|
53
|
-
nextjs: hasNextJs,
|
|
54
|
-
astro: hasAstro,
|
|
55
|
-
vue: hasVue || hasNuxt,
|
|
56
|
-
// Nuxt implies Vue
|
|
57
|
-
nuxt: hasNuxt,
|
|
58
|
-
svelte: hasSvelte || hasSvelteKit,
|
|
59
|
-
// SvelteKit implies Svelte
|
|
60
|
-
sveltekit: hasSvelteKit,
|
|
61
|
-
electron: hasElectron
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// src/commands/setup.ts
|
|
66
|
-
async function setup(options) {
|
|
67
|
-
const cwd = process.cwd();
|
|
68
|
-
const safewordDir = join(cwd, ".safeword");
|
|
69
|
-
if (exists(safewordDir)) {
|
|
70
|
-
error("Already configured. Run `safeword upgrade` to update.");
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
const packageJsonPath = join(cwd, "package.json");
|
|
74
|
-
let packageJsonCreated = false;
|
|
75
|
-
if (!exists(packageJsonPath)) {
|
|
76
|
-
const dirName = basename(cwd) || "project";
|
|
77
|
-
const defaultPackageJson = {
|
|
78
|
-
name: dirName,
|
|
79
|
-
version: "0.1.0",
|
|
80
|
-
scripts: {}
|
|
81
|
-
};
|
|
82
|
-
writeJson(packageJsonPath, defaultPackageJson);
|
|
83
|
-
packageJsonCreated = true;
|
|
84
|
-
}
|
|
85
|
-
const isNonInteractive = options.yes || !process.stdin.isTTY;
|
|
86
|
-
header("Safeword Setup");
|
|
87
|
-
info(`Version: ${VERSION}`);
|
|
88
|
-
if (packageJsonCreated) {
|
|
89
|
-
info("Created package.json (none found)");
|
|
90
|
-
}
|
|
91
|
-
const created = packageJsonCreated ? ["package.json"] : [];
|
|
92
|
-
const modified = [];
|
|
93
|
-
try {
|
|
94
|
-
const templatesDir = getTemplatesDir();
|
|
95
|
-
info("\nCreating .safeword directory...");
|
|
96
|
-
ensureDir(safewordDir);
|
|
97
|
-
ensureDir(join(safewordDir, "learnings"));
|
|
98
|
-
ensureDir(join(safewordDir, "planning", "user-stories"));
|
|
99
|
-
ensureDir(join(safewordDir, "planning", "design"));
|
|
100
|
-
ensureDir(join(safewordDir, "tickets", "completed"));
|
|
101
|
-
copyFile(join(templatesDir, "SAFEWORD.md"), join(safewordDir, "SAFEWORD.md"));
|
|
102
|
-
writeFile(join(safewordDir, "version"), VERSION);
|
|
103
|
-
copyDir(join(templatesDir, "guides"), join(safewordDir, "guides"));
|
|
104
|
-
copyDir(join(templatesDir, "doc-templates"), join(safewordDir, "templates"));
|
|
105
|
-
copyDir(join(templatesDir, "prompts"), join(safewordDir, "prompts"));
|
|
106
|
-
copyDir(join(templatesDir, "lib"), join(safewordDir, "lib"));
|
|
107
|
-
makeScriptsExecutable(join(safewordDir, "lib"));
|
|
108
|
-
copyDir(join(templatesDir, "hooks"), join(safewordDir, "hooks"));
|
|
109
|
-
makeScriptsExecutable(join(safewordDir, "hooks"));
|
|
110
|
-
created.push(".safeword/");
|
|
111
|
-
success("Created .safeword directory");
|
|
112
|
-
info("\nConfiguring AGENTS.md...");
|
|
113
|
-
const agentsMdResult = ensureAgentsMdLink(cwd);
|
|
114
|
-
if (agentsMdResult === "created") {
|
|
115
|
-
created.push("AGENTS.md");
|
|
116
|
-
success("Created AGENTS.md");
|
|
117
|
-
} else if (agentsMdResult === "modified") {
|
|
118
|
-
modified.push("AGENTS.md");
|
|
119
|
-
success("Prepended link to AGENTS.md");
|
|
120
|
-
} else {
|
|
121
|
-
info("AGENTS.md already has safeword link");
|
|
122
|
-
}
|
|
123
|
-
info("\nRegistering Claude Code hooks...");
|
|
124
|
-
const claudeDir = join(cwd, ".claude");
|
|
125
|
-
const settingsPath = join(claudeDir, "settings.json");
|
|
126
|
-
ensureDir(claudeDir);
|
|
127
|
-
try {
|
|
128
|
-
updateJson(settingsPath, (existing) => {
|
|
129
|
-
const hooks = existing?.hooks ?? {};
|
|
130
|
-
for (const [event, newHooks] of Object.entries(SETTINGS_HOOKS)) {
|
|
131
|
-
const existingHooks = hooks[event] ?? [];
|
|
132
|
-
const nonSafewordHooks = filterOutSafewordHooks(existingHooks);
|
|
133
|
-
hooks[event] = [...nonSafewordHooks, ...newHooks];
|
|
134
|
-
}
|
|
135
|
-
return { ...existing, hooks };
|
|
136
|
-
});
|
|
137
|
-
if (exists(settingsPath)) {
|
|
138
|
-
modified.push(".claude/settings.json");
|
|
139
|
-
} else {
|
|
140
|
-
created.push(".claude/settings.json");
|
|
141
|
-
}
|
|
142
|
-
success("Registered hooks in .claude/settings.json");
|
|
143
|
-
} catch (err) {
|
|
144
|
-
error(`Failed to register hooks: ${err instanceof Error ? err.message : "Unknown error"}`);
|
|
145
|
-
process.exit(1);
|
|
146
|
-
}
|
|
147
|
-
info("\nInstalling skills...");
|
|
148
|
-
const skillsDir = join(claudeDir, "skills");
|
|
149
|
-
copyDir(join(templatesDir, "skills"), skillsDir);
|
|
150
|
-
created.push(".claude/skills/safeword-quality-reviewer/");
|
|
151
|
-
success("Installed skills");
|
|
152
|
-
info("\nInstalling slash commands...");
|
|
153
|
-
const commandsDir = join(claudeDir, "commands");
|
|
154
|
-
copyDir(join(templatesDir, "commands"), commandsDir);
|
|
155
|
-
created.push(".claude/commands/");
|
|
156
|
-
success("Installed slash commands");
|
|
157
|
-
info("\nConfiguring MCP servers...");
|
|
158
|
-
const mcpConfigPath = join(cwd, ".mcp.json");
|
|
159
|
-
updateJson(mcpConfigPath, (existing) => {
|
|
160
|
-
const mcpServers = existing?.mcpServers ?? {};
|
|
161
|
-
mcpServers.context7 = {
|
|
162
|
-
command: "npx",
|
|
163
|
-
args: ["-y", "@upstash/context7-mcp@latest"]
|
|
164
|
-
};
|
|
165
|
-
mcpServers.playwright = {
|
|
166
|
-
command: "npx",
|
|
167
|
-
args: ["@playwright/mcp@latest"]
|
|
168
|
-
};
|
|
169
|
-
return { ...existing, mcpServers };
|
|
170
|
-
});
|
|
171
|
-
if (exists(mcpConfigPath)) {
|
|
172
|
-
modified.push(".mcp.json");
|
|
173
|
-
} else {
|
|
174
|
-
created.push(".mcp.json");
|
|
175
|
-
}
|
|
176
|
-
success("Configured MCP servers");
|
|
177
|
-
info("\nConfiguring linting...");
|
|
178
|
-
const packageJson = readJson(packageJsonPath);
|
|
179
|
-
if (!packageJson) {
|
|
180
|
-
error("Failed to read package.json");
|
|
181
|
-
process.exit(1);
|
|
182
|
-
}
|
|
183
|
-
const projectType = detectProjectType(packageJson);
|
|
184
|
-
const eslintConfigPath = join(cwd, "eslint.config.mjs");
|
|
185
|
-
if (!exists(eslintConfigPath)) {
|
|
186
|
-
writeFile(eslintConfigPath, getEslintConfig(projectType));
|
|
187
|
-
created.push("eslint.config.mjs");
|
|
188
|
-
success("Created eslint.config.mjs");
|
|
189
|
-
} else {
|
|
190
|
-
info("eslint.config.mjs already exists");
|
|
191
|
-
}
|
|
192
|
-
const prettierrcPath = join(cwd, ".prettierrc");
|
|
193
|
-
if (!exists(prettierrcPath)) {
|
|
194
|
-
writeFile(prettierrcPath, PRETTIERRC);
|
|
195
|
-
created.push(".prettierrc");
|
|
196
|
-
success("Created .prettierrc");
|
|
197
|
-
} else {
|
|
198
|
-
info(".prettierrc already exists");
|
|
199
|
-
}
|
|
200
|
-
const markdownlintPath = join(cwd, ".markdownlint.jsonc");
|
|
201
|
-
if (!exists(markdownlintPath)) {
|
|
202
|
-
copyFile(join(templatesDir, "markdownlint.jsonc"), markdownlintPath);
|
|
203
|
-
created.push(".markdownlint.jsonc");
|
|
204
|
-
success("Created .markdownlint.jsonc");
|
|
205
|
-
} else {
|
|
206
|
-
info(".markdownlint.jsonc already exists");
|
|
207
|
-
}
|
|
208
|
-
try {
|
|
209
|
-
const scripts = packageJson.scripts ?? {};
|
|
210
|
-
let scriptsModified = false;
|
|
211
|
-
if (!scripts.lint) {
|
|
212
|
-
scripts.lint = "eslint .";
|
|
213
|
-
scriptsModified = true;
|
|
214
|
-
}
|
|
215
|
-
if (!scripts["lint:md"]) {
|
|
216
|
-
scripts["lint:md"] = 'markdownlint-cli2 "**/*.md" "#node_modules"';
|
|
217
|
-
scriptsModified = true;
|
|
218
|
-
}
|
|
219
|
-
if (!scripts.format) {
|
|
220
|
-
scripts.format = "prettier --write .";
|
|
221
|
-
scriptsModified = true;
|
|
222
|
-
}
|
|
223
|
-
if (!scripts["format:check"]) {
|
|
224
|
-
scripts["format:check"] = "prettier --check .";
|
|
225
|
-
scriptsModified = true;
|
|
226
|
-
}
|
|
227
|
-
if (scriptsModified) {
|
|
228
|
-
packageJson.scripts = scripts;
|
|
229
|
-
writeJson(packageJsonPath, packageJson);
|
|
230
|
-
modified.push("package.json");
|
|
231
|
-
success("Added lint and format scripts");
|
|
232
|
-
}
|
|
233
|
-
} catch (err) {
|
|
234
|
-
error(
|
|
235
|
-
`Failed to update package.json: ${err instanceof Error ? err.message : "Unknown error"}`
|
|
236
|
-
);
|
|
237
|
-
process.exit(1);
|
|
238
|
-
}
|
|
239
|
-
info("\nConfiguring git...");
|
|
240
|
-
if (isGitRepo(cwd)) {
|
|
241
|
-
installGitHook(cwd);
|
|
242
|
-
modified.push(".git/hooks/pre-commit");
|
|
243
|
-
success("Installed git pre-commit hook");
|
|
244
|
-
} else if (isNonInteractive) {
|
|
245
|
-
warn("Skipped git initialization (non-interactive mode)");
|
|
246
|
-
warn("Git hooks not installed (no repository)");
|
|
247
|
-
} else {
|
|
248
|
-
warn("Skipped git initialization (no .git directory)");
|
|
249
|
-
warn("Git hooks not installed (no repository)");
|
|
250
|
-
}
|
|
251
|
-
info("\nNote: Install linting dependencies manually:");
|
|
252
|
-
listItem("npm install -D eslint prettier @eslint/js");
|
|
253
|
-
if (projectType.typescript) {
|
|
254
|
-
listItem("npm install -D typescript-eslint");
|
|
255
|
-
}
|
|
256
|
-
if (projectType.react && !projectType.nextjs) {
|
|
257
|
-
listItem("npm install -D eslint-plugin-react eslint-plugin-react-hooks");
|
|
258
|
-
}
|
|
259
|
-
if (projectType.nextjs) {
|
|
260
|
-
listItem("npm install -D eslint-plugin-react eslint-plugin-react-hooks @next/eslint-plugin-next");
|
|
261
|
-
}
|
|
262
|
-
if (projectType.astro) {
|
|
263
|
-
listItem("npm install -D eslint-plugin-astro");
|
|
264
|
-
}
|
|
265
|
-
if (projectType.vue) {
|
|
266
|
-
listItem("npm install -D eslint-plugin-vue");
|
|
267
|
-
}
|
|
268
|
-
if (projectType.svelte) {
|
|
269
|
-
listItem("npm install -D eslint-plugin-svelte");
|
|
270
|
-
}
|
|
271
|
-
header("Setup Complete");
|
|
272
|
-
if (created.length > 0) {
|
|
273
|
-
info("\nCreated:");
|
|
274
|
-
for (const file of created) {
|
|
275
|
-
listItem(file);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (modified.length > 0) {
|
|
279
|
-
info("\nModified:");
|
|
280
|
-
for (const file of modified) {
|
|
281
|
-
listItem(file);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
info("\nNext steps:");
|
|
285
|
-
listItem("Install linting dependencies (see above)");
|
|
286
|
-
listItem("Run `safeword check` to verify setup");
|
|
287
|
-
listItem("Commit the new files to git");
|
|
288
|
-
success(`
|
|
289
|
-
Safeword ${VERSION} installed successfully!`);
|
|
290
|
-
} catch (err) {
|
|
291
|
-
error(`Setup failed: ${err instanceof Error ? err.message : "Unknown error"}`);
|
|
292
|
-
process.exit(1);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
export {
|
|
296
|
-
setup
|
|
297
|
-
};
|
|
298
|
-
//# sourceMappingURL=setup-U35LUMIF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/setup.ts","../src/utils/project-detector.ts"],"sourcesContent":["/**\n * Setup command - Initialize safeword in a project\n */\n\nimport { join, basename } from 'node:path';\nimport { VERSION } from '../version.js';\nimport {\n exists,\n ensureDir,\n writeFile,\n readJson,\n writeJson,\n updateJson,\n copyDir,\n copyFile,\n getTemplatesDir,\n makeScriptsExecutable,\n} from '../utils/fs.js';\nimport { info, success, warn, error, header, listItem } from '../utils/output.js';\nimport { isGitRepo, installGitHook } from '../utils/git.js';\nimport { detectProjectType } from '../utils/project-detector.js';\nimport { filterOutSafewordHooks } from '../utils/hooks.js';\nimport { ensureAgentsMdLink } from '../utils/agents-md.js';\nimport { PRETTIERRC, getEslintConfig, SETTINGS_HOOKS } from '../templates/index.js';\n\nexport interface SetupOptions {\n yes?: boolean;\n}\n\ninterface PackageJson {\n name?: string;\n version?: string;\n scripts?: Record<string, string>;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n}\n\nexport async function setup(options: SetupOptions): Promise<void> {\n const cwd = process.cwd();\n const safewordDir = join(cwd, '.safeword');\n\n // Check if already configured\n if (exists(safewordDir)) {\n error('Already configured. Run `safeword upgrade` to update.');\n process.exit(1);\n }\n\n // Check for package.json, create if missing\n const packageJsonPath = join(cwd, 'package.json');\n let packageJsonCreated = false;\n if (!exists(packageJsonPath)) {\n const dirName = basename(cwd) || 'project';\n const defaultPackageJson: PackageJson = {\n name: dirName,\n version: '0.1.0',\n scripts: {},\n };\n writeJson(packageJsonPath, defaultPackageJson);\n packageJsonCreated = true;\n }\n\n const isNonInteractive = options.yes || !process.stdin.isTTY;\n\n header('Safeword Setup');\n info(`Version: ${VERSION}`);\n\n if (packageJsonCreated) {\n info('Created package.json (none found)');\n }\n\n // Track created files for summary\n const created: string[] = packageJsonCreated ? ['package.json'] : [];\n const modified: string[] = [];\n\n try {\n const templatesDir = getTemplatesDir();\n\n // 1. Create .safeword directory structure and copy templates\n info('\\nCreating .safeword directory...');\n\n ensureDir(safewordDir);\n ensureDir(join(safewordDir, 'learnings'));\n ensureDir(join(safewordDir, 'planning', 'user-stories'));\n ensureDir(join(safewordDir, 'planning', 'design'));\n ensureDir(join(safewordDir, 'tickets', 'completed'));\n\n // Copy full SAFEWORD.md from templates\n copyFile(join(templatesDir, 'SAFEWORD.md'), join(safewordDir, 'SAFEWORD.md'));\n writeFile(join(safewordDir, 'version'), VERSION);\n\n // Copy methodology guides\n copyDir(join(templatesDir, 'guides'), join(safewordDir, 'guides'));\n\n // Copy document templates (to 'templates' to match links in SAFEWORD.md)\n copyDir(join(templatesDir, 'doc-templates'), join(safewordDir, 'templates'));\n\n // Copy review prompts\n copyDir(join(templatesDir, 'prompts'), join(safewordDir, 'prompts'));\n\n // Copy lib scripts and make executable\n copyDir(join(templatesDir, 'lib'), join(safewordDir, 'lib'));\n makeScriptsExecutable(join(safewordDir, 'lib'));\n\n // Copy hook scripts and make executable\n copyDir(join(templatesDir, 'hooks'), join(safewordDir, 'hooks'));\n makeScriptsExecutable(join(safewordDir, 'hooks'));\n\n created.push('.safeword/');\n success('Created .safeword directory');\n\n // 2. Handle AGENTS.md\n info('\\nConfiguring AGENTS.md...');\n const agentsMdResult = ensureAgentsMdLink(cwd);\n if (agentsMdResult === 'created') {\n created.push('AGENTS.md');\n success('Created AGENTS.md');\n } else if (agentsMdResult === 'modified') {\n modified.push('AGENTS.md');\n success('Prepended link to AGENTS.md');\n } else {\n info('AGENTS.md already has safeword link');\n }\n\n // 3. Register Claude Code hooks\n info('\\nRegistering Claude Code hooks...');\n\n const claudeDir = join(cwd, '.claude');\n const settingsPath = join(claudeDir, 'settings.json');\n\n ensureDir(claudeDir);\n\n try {\n updateJson<{ hooks?: Record<string, unknown[]> }>(settingsPath, existing => {\n const hooks = existing?.hooks ?? {};\n\n // Merge hooks, preserving existing non-safeword hooks\n for (const [event, newHooks] of Object.entries(SETTINGS_HOOKS)) {\n const existingHooks = (hooks[event] as unknown[]) ?? [];\n const nonSafewordHooks = filterOutSafewordHooks(existingHooks);\n hooks[event] = [...nonSafewordHooks, ...newHooks];\n }\n\n return { ...existing, hooks };\n });\n\n if (exists(settingsPath)) {\n modified.push('.claude/settings.json');\n } else {\n created.push('.claude/settings.json');\n }\n success('Registered hooks in .claude/settings.json');\n } catch (err) {\n error(`Failed to register hooks: ${err instanceof Error ? err.message : 'Unknown error'}`);\n process.exit(1);\n }\n\n // 4. Copy skills\n info('\\nInstalling skills...');\n\n const skillsDir = join(claudeDir, 'skills');\n copyDir(join(templatesDir, 'skills'), skillsDir);\n\n created.push('.claude/skills/safeword-quality-reviewer/');\n success('Installed skills');\n\n // 5. Copy slash commands\n info('\\nInstalling slash commands...');\n\n const commandsDir = join(claudeDir, 'commands');\n copyDir(join(templatesDir, 'commands'), commandsDir);\n\n created.push('.claude/commands/');\n success('Installed slash commands');\n\n // 6. Setup MCP servers\n info('\\nConfiguring MCP servers...');\n\n const mcpConfigPath = join(cwd, '.mcp.json');\n\n updateJson<{ mcpServers?: Record<string, unknown> }>(mcpConfigPath, existing => {\n const mcpServers = existing?.mcpServers ?? {};\n\n // Add safeword MCP servers (context7 and playwright)\n mcpServers.context7 = {\n command: 'npx',\n args: ['-y', '@upstash/context7-mcp@latest'],\n };\n mcpServers.playwright = {\n command: 'npx',\n args: ['@playwright/mcp@latest'],\n };\n\n return { ...existing, mcpServers };\n });\n\n if (exists(mcpConfigPath)) {\n modified.push('.mcp.json');\n } else {\n created.push('.mcp.json');\n }\n success('Configured MCP servers');\n\n // 7. Setup linting\n info('\\nConfiguring linting...');\n\n const packageJson = readJson<PackageJson>(packageJsonPath);\n if (!packageJson) {\n error('Failed to read package.json');\n process.exit(1);\n }\n\n const projectType = detectProjectType(packageJson);\n\n // Create ESLint config\n const eslintConfigPath = join(cwd, 'eslint.config.mjs');\n if (!exists(eslintConfigPath)) {\n writeFile(eslintConfigPath, getEslintConfig(projectType));\n created.push('eslint.config.mjs');\n success('Created eslint.config.mjs');\n } else {\n info('eslint.config.mjs already exists');\n }\n\n // Create Prettier config\n const prettierrcPath = join(cwd, '.prettierrc');\n if (!exists(prettierrcPath)) {\n writeFile(prettierrcPath, PRETTIERRC);\n created.push('.prettierrc');\n success('Created .prettierrc');\n } else {\n info('.prettierrc already exists');\n }\n\n // Create markdownlint config\n const markdownlintPath = join(cwd, '.markdownlint.jsonc');\n if (!exists(markdownlintPath)) {\n copyFile(join(templatesDir, 'markdownlint.jsonc'), markdownlintPath);\n created.push('.markdownlint.jsonc');\n success('Created .markdownlint.jsonc');\n } else {\n info('.markdownlint.jsonc already exists');\n }\n\n // Add scripts to package.json\n try {\n const scripts = packageJson.scripts ?? {};\n let scriptsModified = false;\n\n if (!scripts.lint) {\n scripts.lint = 'eslint .';\n scriptsModified = true;\n }\n\n if (!scripts['lint:md']) {\n scripts['lint:md'] = 'markdownlint-cli2 \"**/*.md\" \"#node_modules\"';\n scriptsModified = true;\n }\n\n if (!scripts.format) {\n scripts.format = 'prettier --write .';\n scriptsModified = true;\n }\n\n if (!scripts['format:check']) {\n scripts['format:check'] = 'prettier --check .';\n scriptsModified = true;\n }\n\n if (scriptsModified) {\n packageJson.scripts = scripts;\n writeJson(packageJsonPath, packageJson);\n modified.push('package.json');\n success('Added lint and format scripts');\n }\n } catch (err) {\n error(\n `Failed to update package.json: ${err instanceof Error ? err.message : 'Unknown error'}`,\n );\n process.exit(1);\n }\n\n // 8. Handle git repository\n info('\\nConfiguring git...');\n\n if (isGitRepo(cwd)) {\n installGitHook(cwd);\n modified.push('.git/hooks/pre-commit');\n success('Installed git pre-commit hook');\n } else if (isNonInteractive) {\n warn('Skipped git initialization (non-interactive mode)');\n warn('Git hooks not installed (no repository)');\n } else {\n // Interactive mode - would prompt here\n // For now, skip in all cases\n warn('Skipped git initialization (no .git directory)');\n warn('Git hooks not installed (no repository)');\n }\n\n // 9. Note about dependencies\n info('\\nNote: Install linting dependencies manually:');\n listItem('npm install -D eslint prettier @eslint/js');\n if (projectType.typescript) {\n listItem('npm install -D typescript-eslint');\n }\n if (projectType.react && !projectType.nextjs) {\n listItem('npm install -D eslint-plugin-react eslint-plugin-react-hooks');\n }\n if (projectType.nextjs) {\n listItem('npm install -D eslint-plugin-react eslint-plugin-react-hooks @next/eslint-plugin-next');\n }\n if (projectType.astro) {\n listItem('npm install -D eslint-plugin-astro');\n }\n if (projectType.vue) {\n listItem('npm install -D eslint-plugin-vue');\n }\n if (projectType.svelte) {\n listItem('npm install -D eslint-plugin-svelte');\n }\n\n // Print summary\n header('Setup Complete');\n\n if (created.length > 0) {\n info('\\nCreated:');\n for (const file of created) {\n listItem(file);\n }\n }\n\n if (modified.length > 0) {\n info('\\nModified:');\n for (const file of modified) {\n listItem(file);\n }\n }\n\n info('\\nNext steps:');\n listItem('Install linting dependencies (see above)');\n listItem('Run `safeword check` to verify setup');\n listItem('Commit the new files to git');\n\n success(`\\nSafeword ${VERSION} installed successfully!`);\n } catch (err) {\n error(`Setup failed: ${err instanceof Error ? err.message : 'Unknown error'}`);\n process.exit(1);\n }\n}\n","/**\n * Project type detection from package.json\n *\n * Detects frameworks and tools used in the project to configure\n * appropriate linting rules.\n */\n\nexport interface PackageJson {\n name?: string;\n version?: string;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n}\n\nexport interface ProjectType {\n typescript: boolean;\n react: boolean;\n nextjs: boolean;\n astro: boolean;\n vue: boolean;\n nuxt: boolean;\n svelte: boolean;\n sveltekit: boolean;\n electron: boolean;\n}\n\n/**\n * Detects project type from package.json contents\n */\nexport function detectProjectType(packageJson: PackageJson): ProjectType {\n const deps = packageJson.dependencies || {};\n const devDeps = packageJson.devDependencies || {};\n const allDeps = { ...deps, ...devDeps };\n\n const hasTypescript = 'typescript' in allDeps;\n const hasReact = 'react' in deps || 'react' in devDeps;\n const hasNextJs = 'next' in deps;\n const hasAstro = 'astro' in deps || 'astro' in devDeps;\n const hasVue = 'vue' in deps || 'vue' in devDeps;\n const hasNuxt = 'nuxt' in deps;\n const hasSvelte = 'svelte' in deps || 'svelte' in devDeps;\n const hasSvelteKit = '@sveltejs/kit' in deps || '@sveltejs/kit' in devDeps;\n const hasElectron = 'electron' in deps || 'electron' in devDeps;\n\n return {\n typescript: hasTypescript,\n react: hasReact || hasNextJs, // Next.js implies React\n nextjs: hasNextJs,\n astro: hasAstro,\n vue: hasVue || hasNuxt, // Nuxt implies Vue\n nuxt: hasNuxt,\n svelte: hasSvelte || hasSvelteKit, // SvelteKit implies Svelte\n sveltekit: hasSvelteKit,\n electron: hasElectron,\n };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