safeword 0.2.2 → 0.2.4

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.
Files changed (235) hide show
  1. package/.claude/commands/arch-review.md +32 -0
  2. package/.claude/commands/lint.md +6 -0
  3. package/.claude/commands/quality-review.md +13 -0
  4. package/.claude/commands/setup-linting.md +6 -0
  5. package/.claude/hooks/auto-lint.sh +6 -0
  6. package/.claude/hooks/auto-quality-review.sh +170 -0
  7. package/.claude/hooks/check-linting-sync.sh +17 -0
  8. package/.claude/hooks/inject-timestamp.sh +6 -0
  9. package/.claude/hooks/question-protocol.sh +12 -0
  10. package/.claude/hooks/run-linters.sh +8 -0
  11. package/.claude/hooks/run-quality-review.sh +76 -0
  12. package/.claude/hooks/version-check.sh +10 -0
  13. package/.claude/mcp/README.md +96 -0
  14. package/.claude/mcp/arcade.sample.json +9 -0
  15. package/.claude/mcp/context7.sample.json +7 -0
  16. package/.claude/mcp/playwright.sample.json +7 -0
  17. package/.claude/settings.json +62 -0
  18. package/.claude/skills/quality-reviewer/SKILL.md +190 -0
  19. package/.claude/skills/safeword-quality-reviewer/SKILL.md +13 -0
  20. package/.env.arcade.example +4 -0
  21. package/.env.example +11 -0
  22. package/.gitmodules +4 -0
  23. package/.safeword/SAFEWORD.md +33 -0
  24. package/.safeword/eslint/eslint-base.mjs +101 -0
  25. package/.safeword/guides/architecture-guide.md +404 -0
  26. package/.safeword/guides/code-philosophy.md +174 -0
  27. package/.safeword/guides/context-files-guide.md +405 -0
  28. package/.safeword/guides/data-architecture-guide.md +183 -0
  29. package/.safeword/guides/design-doc-guide.md +165 -0
  30. package/.safeword/guides/learning-extraction.md +515 -0
  31. package/.safeword/guides/llm-instruction-design.md +239 -0
  32. package/.safeword/guides/llm-prompting.md +95 -0
  33. package/.safeword/guides/tdd-best-practices.md +570 -0
  34. package/.safeword/guides/test-definitions-guide.md +243 -0
  35. package/.safeword/guides/testing-methodology.md +573 -0
  36. package/.safeword/guides/user-story-guide.md +237 -0
  37. package/.safeword/guides/zombie-process-cleanup.md +214 -0
  38. package/{templates → .safeword}/hooks/agents-md-check.sh +0 -0
  39. package/{templates → .safeword}/hooks/post-tool.sh +0 -0
  40. package/{templates → .safeword}/hooks/pre-commit.sh +0 -0
  41. package/.safeword/planning/002-user-story-quality-evaluation.md +1840 -0
  42. package/.safeword/planning/003-langsmith-eval-setup-prompt.md +363 -0
  43. package/.safeword/planning/004-llm-eval-test-cases.md +3226 -0
  44. package/.safeword/planning/005-architecture-enforcement-system.md +169 -0
  45. package/.safeword/planning/006-reactive-fix-prevention-research.md +135 -0
  46. package/.safeword/planning/011-cli-ux-vision.md +330 -0
  47. package/.safeword/planning/012-project-structure-cleanup.md +154 -0
  48. package/.safeword/planning/README.md +39 -0
  49. package/.safeword/planning/automation-plan-v2.md +1225 -0
  50. package/.safeword/planning/automation-plan-v3.md +1291 -0
  51. package/.safeword/planning/automation-plan.md +3058 -0
  52. package/.safeword/planning/design/005-cli-implementation.md +343 -0
  53. package/.safeword/planning/design/013-cli-self-contained-templates.md +596 -0
  54. package/.safeword/planning/design/013a-eslint-plugin-suite.md +256 -0
  55. package/.safeword/planning/design/013b-implementation-snippets.md +385 -0
  56. package/.safeword/planning/design/013c-config-isolation-strategy.md +242 -0
  57. package/.safeword/planning/design/code-philosophy-improvements.md +60 -0
  58. package/.safeword/planning/mcp-analysis.md +545 -0
  59. package/.safeword/planning/phase2-subagents-vs-skills-analysis.md +451 -0
  60. package/.safeword/planning/settings-improvements.md +970 -0
  61. package/.safeword/planning/test-definitions/005-cli-implementation.md +1301 -0
  62. package/.safeword/planning/test-definitions/cli-self-contained-templates.md +205 -0
  63. package/.safeword/planning/user-stories/001-guides-review-user-stories.md +1381 -0
  64. package/.safeword/planning/user-stories/003-reactive-fix-prevention.md +132 -0
  65. package/.safeword/planning/user-stories/004-technical-constraints.md +86 -0
  66. package/.safeword/planning/user-stories/005-cli-implementation.md +311 -0
  67. package/.safeword/planning/user-stories/cli-self-contained-templates.md +172 -0
  68. package/.safeword/planning/versioned-distribution.md +740 -0
  69. package/.safeword/prompts/arch-review.md +43 -0
  70. package/.safeword/prompts/quality-review.md +11 -0
  71. package/.safeword/scripts/arch-review.sh +235 -0
  72. package/.safeword/scripts/check-linting-sync.sh +58 -0
  73. package/.safeword/scripts/setup-linting.sh +559 -0
  74. package/.safeword/templates/architecture-template.md +136 -0
  75. package/.safeword/templates/ci/architecture-check.yml +79 -0
  76. package/.safeword/templates/design-doc-template.md +127 -0
  77. package/.safeword/templates/test-definitions-feature.md +100 -0
  78. package/.safeword/templates/ticket-template.md +74 -0
  79. package/.safeword/templates/user-stories-template.md +82 -0
  80. package/.safeword/tickets/001-guides-review-user-stories.md +83 -0
  81. package/.safeword/tickets/002-architecture-enforcement.md +211 -0
  82. package/.safeword/tickets/003-reactive-fix-prevention.md +57 -0
  83. package/.safeword/tickets/004-technical-constraints-in-user-stories.md +39 -0
  84. package/.safeword/tickets/005-cli-implementation.md +248 -0
  85. package/.safeword/tickets/006-flesh-out-skills.md +43 -0
  86. package/.safeword/tickets/007-flesh-out-questioning.md +44 -0
  87. package/.safeword/tickets/008-upgrade-questioning.md +58 -0
  88. package/.safeword/tickets/009-naming-conventions.md +41 -0
  89. package/.safeword/tickets/010-safeword-md-cleanup.md +34 -0
  90. package/.safeword/tickets/011-cursor-setup.md +86 -0
  91. package/.safeword/tickets/README.md +73 -0
  92. package/.safeword/version +1 -0
  93. package/AGENTS.md +59 -0
  94. package/CLAUDE.md +12 -0
  95. package/README.md +347 -0
  96. package/docs/001-cli-implementation-plan.md +856 -0
  97. package/docs/elite-dx-implementation-plan.md +1034 -0
  98. package/framework/README.md +131 -0
  99. package/framework/mcp/README.md +96 -0
  100. package/framework/mcp/arcade.sample.json +8 -0
  101. package/framework/mcp/context7.sample.json +6 -0
  102. package/framework/mcp/playwright.sample.json +6 -0
  103. package/framework/scripts/arch-review.sh +235 -0
  104. package/framework/scripts/check-linting-sync.sh +58 -0
  105. package/framework/scripts/load-env.sh +49 -0
  106. package/framework/scripts/setup-claude.sh +223 -0
  107. package/framework/scripts/setup-linting.sh +559 -0
  108. package/framework/scripts/setup-quality.sh +477 -0
  109. package/framework/scripts/setup-safeword.sh +550 -0
  110. package/framework/templates/ci/architecture-check.yml +78 -0
  111. package/learnings/ai-sdk-v5-breaking-changes.md +178 -0
  112. package/learnings/e2e-test-zombie-processes.md +231 -0
  113. package/learnings/milkdown-crepe-editor-property.md +96 -0
  114. package/learnings/prosemirror-fragment-traversal.md +119 -0
  115. package/package.json +19 -43
  116. package/packages/cli/AGENTS.md +1 -0
  117. package/packages/cli/ARCHITECTURE.md +279 -0
  118. package/packages/cli/package.json +51 -0
  119. package/packages/cli/src/cli.ts +63 -0
  120. package/packages/cli/src/commands/check.ts +166 -0
  121. package/packages/cli/src/commands/diff.ts +209 -0
  122. package/packages/cli/src/commands/reset.ts +190 -0
  123. package/packages/cli/src/commands/setup.ts +325 -0
  124. package/packages/cli/src/commands/upgrade.ts +163 -0
  125. package/packages/cli/src/index.ts +3 -0
  126. package/packages/cli/src/templates/config.ts +58 -0
  127. package/packages/cli/src/templates/content.ts +18 -0
  128. package/packages/cli/src/templates/index.ts +12 -0
  129. package/packages/cli/src/utils/agents-md.ts +66 -0
  130. package/packages/cli/src/utils/fs.ts +179 -0
  131. package/packages/cli/src/utils/git.ts +124 -0
  132. package/packages/cli/src/utils/hooks.ts +29 -0
  133. package/packages/cli/src/utils/output.ts +60 -0
  134. package/packages/cli/src/utils/project-detector.test.ts +185 -0
  135. package/packages/cli/src/utils/project-detector.ts +44 -0
  136. package/packages/cli/src/utils/version.ts +28 -0
  137. package/packages/cli/src/version.ts +6 -0
  138. package/packages/cli/templates/SAFEWORD.md +776 -0
  139. package/packages/cli/templates/doc-templates/architecture-template.md +136 -0
  140. package/packages/cli/templates/doc-templates/design-doc-template.md +134 -0
  141. package/packages/cli/templates/doc-templates/test-definitions-feature.md +131 -0
  142. package/packages/cli/templates/doc-templates/ticket-template.md +82 -0
  143. package/packages/cli/templates/doc-templates/user-stories-template.md +92 -0
  144. package/packages/cli/templates/guides/architecture-guide.md +423 -0
  145. package/packages/cli/templates/guides/code-philosophy.md +195 -0
  146. package/packages/cli/templates/guides/context-files-guide.md +457 -0
  147. package/packages/cli/templates/guides/data-architecture-guide.md +200 -0
  148. package/packages/cli/templates/guides/design-doc-guide.md +171 -0
  149. package/packages/cli/templates/guides/learning-extraction.md +552 -0
  150. package/packages/cli/templates/guides/llm-instruction-design.md +248 -0
  151. package/packages/cli/templates/guides/llm-prompting.md +102 -0
  152. package/packages/cli/templates/guides/tdd-best-practices.md +615 -0
  153. package/packages/cli/templates/guides/test-definitions-guide.md +334 -0
  154. package/packages/cli/templates/guides/testing-methodology.md +618 -0
  155. package/packages/cli/templates/guides/user-story-guide.md +256 -0
  156. package/packages/cli/templates/guides/zombie-process-cleanup.md +219 -0
  157. package/packages/cli/templates/hooks/agents-md-check.sh +27 -0
  158. package/packages/cli/templates/hooks/post-tool.sh +4 -0
  159. package/packages/cli/templates/hooks/pre-commit.sh +10 -0
  160. package/packages/cli/templates/prompts/arch-review.md +43 -0
  161. package/packages/cli/templates/prompts/quality-review.md +10 -0
  162. package/packages/cli/templates/skills/safeword-quality-reviewer/SKILL.md +207 -0
  163. package/packages/cli/tests/commands/check.test.ts +129 -0
  164. package/packages/cli/tests/commands/cli.test.ts +89 -0
  165. package/packages/cli/tests/commands/diff.test.ts +115 -0
  166. package/packages/cli/tests/commands/reset.test.ts +310 -0
  167. package/packages/cli/tests/commands/self-healing.test.ts +170 -0
  168. package/packages/cli/tests/commands/setup-blocking.test.ts +71 -0
  169. package/packages/cli/tests/commands/setup-core.test.ts +135 -0
  170. package/packages/cli/tests/commands/setup-git.test.ts +139 -0
  171. package/packages/cli/tests/commands/setup-hooks.test.ts +334 -0
  172. package/packages/cli/tests/commands/setup-linting.test.ts +189 -0
  173. package/packages/cli/tests/commands/setup-noninteractive.test.ts +80 -0
  174. package/packages/cli/tests/commands/setup-templates.test.ts +181 -0
  175. package/packages/cli/tests/commands/upgrade.test.ts +215 -0
  176. package/packages/cli/tests/helpers.ts +243 -0
  177. package/packages/cli/tests/npm-package.test.ts +83 -0
  178. package/packages/cli/tests/technical-constraints.test.ts +96 -0
  179. package/packages/cli/tsconfig.json +25 -0
  180. package/packages/cli/tsup.config.ts +11 -0
  181. package/packages/cli/vitest.config.ts +23 -0
  182. package/promptfoo.yaml +3270 -0
  183. package/dist/check-M73LGONJ.js +0 -129
  184. package/dist/check-M73LGONJ.js.map +0 -1
  185. package/dist/chunk-2XWIUEQK.js +0 -190
  186. package/dist/chunk-2XWIUEQK.js.map +0 -1
  187. package/dist/chunk-GZRQL3SX.js +0 -146
  188. package/dist/chunk-GZRQL3SX.js.map +0 -1
  189. package/dist/chunk-V5G6BGOK.js +0 -26
  190. package/dist/chunk-V5G6BGOK.js.map +0 -1
  191. package/dist/chunk-W66Z3C5H.js +0 -21
  192. package/dist/chunk-W66Z3C5H.js.map +0 -1
  193. package/dist/cli.d.ts +0 -1
  194. package/dist/cli.js +0 -34
  195. package/dist/cli.js.map +0 -1
  196. package/dist/diff-FSFDCBL5.js +0 -166
  197. package/dist/diff-FSFDCBL5.js.map +0 -1
  198. package/dist/index.d.ts +0 -11
  199. package/dist/index.js +0 -7
  200. package/dist/index.js.map +0 -1
  201. package/dist/reset-3ACTIYYE.js +0 -143
  202. package/dist/reset-3ACTIYYE.js.map +0 -1
  203. package/dist/setup-MKVVQTVA.js +0 -266
  204. package/dist/setup-MKVVQTVA.js.map +0 -1
  205. package/dist/upgrade-FQOL6AF5.js +0 -134
  206. package/dist/upgrade-FQOL6AF5.js.map +0 -1
  207. /package/{templates → framework}/SAFEWORD.md +0 -0
  208. /package/{templates → framework}/guides/architecture-guide.md +0 -0
  209. /package/{templates → framework}/guides/code-philosophy.md +0 -0
  210. /package/{templates → framework}/guides/context-files-guide.md +0 -0
  211. /package/{templates → framework}/guides/data-architecture-guide.md +0 -0
  212. /package/{templates → framework}/guides/design-doc-guide.md +0 -0
  213. /package/{templates → framework}/guides/learning-extraction.md +0 -0
  214. /package/{templates → framework}/guides/llm-instruction-design.md +0 -0
  215. /package/{templates → framework}/guides/llm-prompting.md +0 -0
  216. /package/{templates → framework}/guides/tdd-best-practices.md +0 -0
  217. /package/{templates → framework}/guides/test-definitions-guide.md +0 -0
  218. /package/{templates → framework}/guides/testing-methodology.md +0 -0
  219. /package/{templates → framework}/guides/user-story-guide.md +0 -0
  220. /package/{templates → framework}/guides/zombie-process-cleanup.md +0 -0
  221. /package/{templates → framework}/prompts/arch-review.md +0 -0
  222. /package/{templates → framework}/prompts/quality-review.md +0 -0
  223. /package/{templates/skills/safeword-quality-reviewer → framework/skills/quality-reviewer}/SKILL.md +0 -0
  224. /package/{templates/doc-templates → framework/templates}/architecture-template.md +0 -0
  225. /package/{templates/doc-templates → framework/templates}/design-doc-template.md +0 -0
  226. /package/{templates/doc-templates → framework/templates}/test-definitions-feature.md +0 -0
  227. /package/{templates/doc-templates → framework/templates}/ticket-template.md +0 -0
  228. /package/{templates/doc-templates → framework/templates}/user-stories-template.md +0 -0
  229. /package/{templates → packages/cli/templates}/commands/arch-review.md +0 -0
  230. /package/{templates → packages/cli/templates}/commands/lint.md +0 -0
  231. /package/{templates → packages/cli/templates}/commands/quality-review.md +0 -0
  232. /package/{templates → packages/cli/templates}/hooks/inject-timestamp.sh +0 -0
  233. /package/{templates → packages/cli/templates}/lib/common.sh +0 -0
  234. /package/{templates → packages/cli/templates}/lib/jq-fallback.sh +0 -0
  235. /package/{templates → packages/cli/templates}/markdownlint.jsonc +0 -0
@@ -1,166 +0,0 @@
1
- import {
2
- VERSION
3
- } from "./chunk-V5G6BGOK.js";
4
- import {
5
- error,
6
- exists,
7
- getTemplatesDir,
8
- header,
9
- info,
10
- listItem,
11
- readFileSafe,
12
- success
13
- } from "./chunk-GZRQL3SX.js";
14
-
15
- // src/commands/diff.ts
16
- import { join } from "path";
17
- function createUnifiedDiff(oldContent, newContent, filename) {
18
- const oldLines = oldContent.split("\n");
19
- const newLines = newContent.split("\n");
20
- const lines = [];
21
- lines.push(`--- a/${filename}`);
22
- lines.push(`+++ b/${filename}`);
23
- let hasChanges = false;
24
- const maxLines = Math.max(oldLines.length, newLines.length);
25
- for (let i = 0; i < maxLines; i++) {
26
- const oldLine = oldLines[i];
27
- const newLine = newLines[i];
28
- if (oldLine === newLine) {
29
- lines.push(` ${oldLine ?? ""}`);
30
- } else {
31
- hasChanges = true;
32
- if (oldLine !== void 0) {
33
- lines.push(`-${oldLine}`);
34
- }
35
- if (newLine !== void 0) {
36
- lines.push(`+${newLine}`);
37
- }
38
- }
39
- }
40
- if (!hasChanges) {
41
- return "";
42
- }
43
- lines.splice(2, 0, `@@ -1,${oldLines.length} +1,${newLines.length} @@`);
44
- return lines.join("\n");
45
- }
46
- function getFileDiffs(cwd) {
47
- const templatesDir = getTemplatesDir();
48
- const diffs = [];
49
- const files = [
50
- { templatePath: "SAFEWORD.md", installPath: ".safeword/SAFEWORD.md" },
51
- { templatePath: "hooks/agents-md-check.sh", installPath: ".safeword/hooks/agents-md-check.sh" },
52
- { templatePath: "hooks/pre-commit.sh", installPath: ".safeword/hooks/pre-commit.sh" },
53
- { templatePath: "hooks/post-tool.sh", installPath: ".safeword/hooks/post-tool.sh" },
54
- { templatePath: "hooks/inject-timestamp.sh", installPath: ".safeword/hooks/inject-timestamp.sh" },
55
- { templatePath: "skills/safeword-quality-reviewer/SKILL.md", installPath: ".claude/skills/safeword-quality-reviewer/SKILL.md" }
56
- ];
57
- const versionPath = join(cwd, ".safeword/version");
58
- const currentVersion = readFileSafe(versionPath);
59
- if (currentVersion === null) {
60
- diffs.push({ path: ".safeword/version", status: "added", newContent: VERSION });
61
- } else if (currentVersion.trim() !== VERSION) {
62
- diffs.push({ path: ".safeword/version", status: "modified", currentContent: currentVersion, newContent: VERSION });
63
- } else {
64
- diffs.push({ path: ".safeword/version", status: "unchanged", currentContent: currentVersion, newContent: VERSION });
65
- }
66
- for (const file of files) {
67
- const templateFullPath = join(templatesDir, file.templatePath);
68
- const installFullPath = join(cwd, file.installPath);
69
- const newContent = readFileSafe(templateFullPath);
70
- if (newContent === null) continue;
71
- const currentContent = readFileSafe(installFullPath);
72
- if (currentContent === null) {
73
- diffs.push({
74
- path: file.installPath,
75
- status: "added",
76
- newContent
77
- });
78
- } else if (currentContent.trim() !== newContent.trim()) {
79
- diffs.push({
80
- path: file.installPath,
81
- status: "modified",
82
- currentContent,
83
- newContent
84
- });
85
- } else {
86
- diffs.push({
87
- path: file.installPath,
88
- status: "unchanged",
89
- currentContent,
90
- newContent
91
- });
92
- }
93
- }
94
- return diffs;
95
- }
96
- async function diff(options) {
97
- const cwd = process.cwd();
98
- const safewordDir = join(cwd, ".safeword");
99
- if (!exists(safewordDir)) {
100
- error("Not configured. Run `safeword setup` first.");
101
- process.exit(1);
102
- }
103
- const versionPath = join(safewordDir, "version");
104
- const projectVersion = readFileSafe(versionPath)?.trim() ?? "unknown";
105
- header("Safeword Diff");
106
- info(`Changes from v${projectVersion} \u2192 v${VERSION}`);
107
- const diffs = getFileDiffs(cwd);
108
- const added = diffs.filter((d) => d.status === "added");
109
- const modified = diffs.filter((d) => d.status === "modified");
110
- const unchanged = diffs.filter((d) => d.status === "unchanged");
111
- info(
112
- `
113
- Summary: ${added.length} added, ${modified.length} modified, ${unchanged.length} unchanged`
114
- );
115
- if (added.length > 0) {
116
- info("\nAdded:");
117
- for (const file of added) {
118
- listItem(file.path);
119
- }
120
- }
121
- if (modified.length > 0) {
122
- info("\nModified:");
123
- for (const file of modified) {
124
- listItem(file.path);
125
- }
126
- }
127
- if (unchanged.length > 0) {
128
- info("\nUnchanged:");
129
- for (const file of unchanged) {
130
- listItem(file.path);
131
- }
132
- }
133
- if (options.verbose) {
134
- header("Detailed Changes");
135
- for (const file of modified) {
136
- if (file.currentContent) {
137
- info(`
138
- ${file.path}:`);
139
- const diffOutput = createUnifiedDiff(file.currentContent, file.newContent, file.path);
140
- if (diffOutput) {
141
- console.log(diffOutput);
142
- }
143
- }
144
- }
145
- for (const file of added) {
146
- info(`
147
- ${file.path}: (new file)`);
148
- const lines = file.newContent.split("\n").slice(0, 10);
149
- for (const line of lines) {
150
- console.log(`+${line}`);
151
- }
152
- if (file.newContent.split("\n").length > 10) {
153
- console.log("... (truncated)");
154
- }
155
- }
156
- }
157
- if (added.length === 0 && modified.length === 0) {
158
- success("\nNo changes needed - configuration is up to date");
159
- } else {
160
- info("\nRun `safeword upgrade` to apply these changes");
161
- }
162
- }
163
- export {
164
- diff
165
- };
166
- //# sourceMappingURL=diff-FSFDCBL5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/diff.ts"],"sourcesContent":["/**\n * Diff command - Preview changes that would be made by upgrade\n */\n\nimport { join } from 'node:path';\nimport { VERSION } from '../version.js';\nimport { exists, readFileSafe, getTemplatesDir } from '../utils/fs.js';\nimport { info, success, error, header, listItem } from '../utils/output.js';\n\nexport interface DiffOptions {\n verbose?: boolean;\n}\n\ninterface FileDiff {\n path: string;\n status: 'added' | 'modified' | 'unchanged';\n currentContent?: string;\n newContent: string;\n}\n\n/**\n * Create a unified diff between two strings\n */\nfunction createUnifiedDiff(oldContent: string, newContent: string, filename: string): string {\n const oldLines = oldContent.split('\\n');\n const newLines = newContent.split('\\n');\n\n const lines: string[] = [];\n lines.push(`--- a/${filename}`);\n lines.push(`+++ b/${filename}`);\n\n // Simple diff - show all changes\n // A real implementation would use a proper diff algorithm\n let hasChanges = false;\n\n const maxLines = Math.max(oldLines.length, newLines.length);\n\n for (let i = 0; i < maxLines; i++) {\n const oldLine = oldLines[i];\n const newLine = newLines[i];\n\n if (oldLine === newLine) {\n lines.push(` ${oldLine ?? ''}`);\n } else {\n hasChanges = true;\n if (oldLine !== undefined) {\n lines.push(`-${oldLine}`);\n }\n if (newLine !== undefined) {\n lines.push(`+${newLine}`);\n }\n }\n }\n\n if (!hasChanges) {\n return '';\n }\n\n // Add context marker\n lines.splice(2, 0, `@@ -1,${oldLines.length} +1,${newLines.length} @@`);\n\n return lines.join('\\n');\n}\n\n/**\n * Get all files that would be changed by upgrade\n */\nfunction getFileDiffs(cwd: string): FileDiff[] {\n const templatesDir = getTemplatesDir();\n const diffs: FileDiff[] = [];\n\n // Define files to check (template source -> install destination)\n const files: Array<{ templatePath: string; installPath: string }> = [\n { templatePath: 'SAFEWORD.md', installPath: '.safeword/SAFEWORD.md' },\n { templatePath: 'hooks/agents-md-check.sh', installPath: '.safeword/hooks/agents-md-check.sh' },\n { templatePath: 'hooks/pre-commit.sh', installPath: '.safeword/hooks/pre-commit.sh' },\n { templatePath: 'hooks/post-tool.sh', installPath: '.safeword/hooks/post-tool.sh' },\n { templatePath: 'hooks/inject-timestamp.sh', installPath: '.safeword/hooks/inject-timestamp.sh' },\n { templatePath: 'skills/safeword-quality-reviewer/SKILL.md', installPath: '.claude/skills/safeword-quality-reviewer/SKILL.md' },\n ];\n\n // Add version file (not from templates)\n const versionPath = join(cwd, '.safeword/version');\n const currentVersion = readFileSafe(versionPath);\n if (currentVersion === null) {\n diffs.push({ path: '.safeword/version', status: 'added', newContent: VERSION });\n } else if (currentVersion.trim() !== VERSION) {\n diffs.push({ path: '.safeword/version', status: 'modified', currentContent: currentVersion, newContent: VERSION });\n } else {\n diffs.push({ path: '.safeword/version', status: 'unchanged', currentContent: currentVersion, newContent: VERSION });\n }\n\n for (const file of files) {\n const templateFullPath = join(templatesDir, file.templatePath);\n const installFullPath = join(cwd, file.installPath);\n\n const newContent = readFileSafe(templateFullPath);\n if (newContent === null) continue; // Skip if template doesn't exist\n\n const currentContent = readFileSafe(installFullPath);\n\n if (currentContent === null) {\n diffs.push({\n path: file.installPath,\n status: 'added',\n newContent,\n });\n } else if (currentContent.trim() !== newContent.trim()) {\n diffs.push({\n path: file.installPath,\n status: 'modified',\n currentContent,\n newContent,\n });\n } else {\n diffs.push({\n path: file.installPath,\n status: 'unchanged',\n currentContent,\n newContent,\n });\n }\n }\n\n return diffs;\n}\n\nexport async function diff(options: DiffOptions): Promise<void> {\n const cwd = process.cwd();\n const safewordDir = join(cwd, '.safeword');\n\n // Check if configured\n if (!exists(safewordDir)) {\n error('Not configured. Run `safeword setup` first.');\n process.exit(1);\n }\n\n // Read project version\n const versionPath = join(safewordDir, 'version');\n const projectVersion = readFileSafe(versionPath)?.trim() ?? 'unknown';\n\n header('Safeword Diff');\n info(`Changes from v${projectVersion} → v${VERSION}`);\n\n const diffs = getFileDiffs(cwd);\n\n const added = diffs.filter(d => d.status === 'added');\n const modified = diffs.filter(d => d.status === 'modified');\n const unchanged = diffs.filter(d => d.status === 'unchanged');\n\n // Summary\n info(\n `\\nSummary: ${added.length} added, ${modified.length} modified, ${unchanged.length} unchanged`,\n );\n\n // List by category\n if (added.length > 0) {\n info('\\nAdded:');\n for (const file of added) {\n listItem(file.path);\n }\n }\n\n if (modified.length > 0) {\n info('\\nModified:');\n for (const file of modified) {\n listItem(file.path);\n }\n }\n\n if (unchanged.length > 0) {\n info('\\nUnchanged:');\n for (const file of unchanged) {\n listItem(file.path);\n }\n }\n\n // Verbose output - show actual diffs\n if (options.verbose) {\n header('Detailed Changes');\n\n for (const file of modified) {\n if (file.currentContent) {\n info(`\\n${file.path}:`);\n const diffOutput = createUnifiedDiff(file.currentContent, file.newContent, file.path);\n if (diffOutput) {\n console.log(diffOutput);\n }\n }\n }\n\n for (const file of added) {\n info(`\\n${file.path}: (new file)`);\n const lines = file.newContent.split('\\n').slice(0, 10);\n for (const line of lines) {\n console.log(`+${line}`);\n }\n if (file.newContent.split('\\n').length > 10) {\n console.log('... (truncated)');\n }\n }\n }\n\n if (added.length === 0 && modified.length === 0) {\n success('\\nNo changes needed - configuration is up to date');\n } else {\n info('\\nRun `safeword upgrade` to apply these changes');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAIA,SAAS,YAAY;AAmBrB,SAAS,kBAAkB,YAAoB,YAAoB,UAA0B;AAC3F,QAAM,WAAW,WAAW,MAAM,IAAI;AACtC,QAAM,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AI;AAC3C,gBAAQ,IAAI,iBAAiB;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AAEA,MAAI,MAAM,WAAW,KAAK,SAAS,WAAW,GAAG;AAC/C,YAAQ,mDAAmD;AAAA,EAC7D,OAAO;AACL,SAAK,iDAAiD;AAAA,EACxD;AACF;","names":[]}
package/dist/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- declare const VERSION: string;
2
-
3
- interface ProjectType {
4
- typescript: boolean;
5
- react: boolean;
6
- nextjs: boolean;
7
- astro: boolean;
8
- electron: boolean;
9
- }
10
-
11
- export { type ProjectType, VERSION };
package/dist/index.js DELETED
@@ -1,7 +0,0 @@
1
- import {
2
- VERSION
3
- } from "./chunk-V5G6BGOK.js";
4
- export {
5
- VERSION
6
- };
7
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,143 +0,0 @@
1
- import {
2
- filterOutSafewordHooks,
3
- isGitRepo,
4
- removeAgentsMdLink,
5
- removeGitHook
6
- } from "./chunk-2XWIUEQK.js";
7
- import {
8
- error,
9
- exists,
10
- header,
11
- info,
12
- listDir,
13
- listItem,
14
- readJson,
15
- remove,
16
- success,
17
- writeJson
18
- } from "./chunk-GZRQL3SX.js";
19
-
20
- // src/commands/reset.ts
21
- import { join } from "path";
22
- async function reset(options) {
23
- const cwd = process.cwd();
24
- const safewordDir = join(cwd, ".safeword");
25
- if (!exists(safewordDir)) {
26
- info("Nothing to remove. Project is not configured with safeword.");
27
- return;
28
- }
29
- const isNonInteractive = options.yes || !process.stdin.isTTY;
30
- if (!isNonInteractive) {
31
- }
32
- header("Safeword Reset");
33
- info("Removing safeword configuration...");
34
- const removed = [];
35
- try {
36
- if (exists(safewordDir)) {
37
- remove(safewordDir);
38
- removed.push(".safeword/");
39
- success("Removed .safeword directory");
40
- }
41
- const settingsPath = join(cwd, ".claude", "settings.json");
42
- if (exists(settingsPath)) {
43
- info("\nRemoving hooks from .claude/settings.json...");
44
- const settings = readJson(settingsPath);
45
- if (settings?.hooks) {
46
- let modified = false;
47
- for (const [event, hooks] of Object.entries(settings.hooks)) {
48
- if (Array.isArray(hooks)) {
49
- const filtered = filterOutSafewordHooks(hooks);
50
- if (filtered.length !== hooks.length) {
51
- settings.hooks[event] = filtered;
52
- modified = true;
53
- }
54
- }
55
- }
56
- if (modified) {
57
- writeJson(settingsPath, settings);
58
- removed.push(".claude/settings.json (hooks)");
59
- success("Removed safeword hooks");
60
- }
61
- }
62
- }
63
- const skillsDir = join(cwd, ".claude", "skills");
64
- if (exists(skillsDir)) {
65
- info("\nRemoving safeword skills...");
66
- const skills = listDir(skillsDir);
67
- for (const skill of skills) {
68
- if (skill.startsWith("safeword-")) {
69
- remove(join(skillsDir, skill));
70
- removed.push(`.claude/skills/${skill}/`);
71
- }
72
- }
73
- if (removed.some((r) => r.includes("skills"))) {
74
- success("Removed safeword skills");
75
- }
76
- }
77
- const commandsDir = join(cwd, ".claude", "commands");
78
- const safewordCommands = ["quality-review.md", "arch-review.md", "lint.md"];
79
- if (exists(commandsDir)) {
80
- info("\nRemoving safeword commands...");
81
- let commandsRemoved = false;
82
- for (const cmd of safewordCommands) {
83
- const cmdPath = join(commandsDir, cmd);
84
- if (exists(cmdPath)) {
85
- remove(cmdPath);
86
- removed.push(`.claude/commands/${cmd}`);
87
- commandsRemoved = true;
88
- }
89
- }
90
- if (commandsRemoved) {
91
- success("Removed safeword commands");
92
- }
93
- }
94
- const mcpConfigPath = join(cwd, ".mcp.json");
95
- if (exists(mcpConfigPath)) {
96
- info("\nRemoving MCP servers...");
97
- const mcpConfig = readJson(mcpConfigPath);
98
- if (mcpConfig?.mcpServers) {
99
- delete mcpConfig.mcpServers.context7;
100
- delete mcpConfig.mcpServers.playwright;
101
- if (Object.keys(mcpConfig.mcpServers).length === 0) {
102
- remove(mcpConfigPath);
103
- removed.push(".mcp.json");
104
- } else {
105
- writeJson(mcpConfigPath, mcpConfig);
106
- removed.push(".mcp.json (context7, playwright)");
107
- }
108
- success("Removed MCP servers");
109
- }
110
- }
111
- if (isGitRepo(cwd)) {
112
- info("\nRemoving git hook markers...");
113
- removeGitHook(cwd);
114
- removed.push(".git/hooks/pre-commit (markers)");
115
- success("Removed git hook markers");
116
- }
117
- info("\nCleaning AGENTS.md...");
118
- if (removeAgentsMdLink(cwd)) {
119
- removed.push("AGENTS.md (link)");
120
- success("Removed safeword link from AGENTS.md");
121
- }
122
- header("Reset Complete");
123
- if (removed.length > 0) {
124
- info("\nRemoved:");
125
- for (const item of removed) {
126
- listItem(item);
127
- }
128
- }
129
- info("\nPreserved (remove manually if desired):");
130
- listItem("eslint.config.mjs");
131
- listItem(".prettierrc");
132
- listItem("package.json lint/format scripts");
133
- listItem("ESLint/Prettier devDependencies");
134
- success("\nSafeword configuration removed");
135
- } catch (err) {
136
- error(`Reset failed: ${err instanceof Error ? err.message : "Unknown error"}`);
137
- process.exit(1);
138
- }
139
- }
140
- export {
141
- reset
142
- };
143
- //# sourceMappingURL=reset-3ACTIYYE.js.map
@@ -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,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ACf;AAAA,IACF;AAGA,SAAK,2CAA2C;AAChD,aAAS,mBAAmB;AAC5B,aAAS,aAAa;AACtB,aAAS,kCAAkC;AAC3C,aAAS,iCAAiC;AAE1C,YAAQ,kCAAkC;AAAA,EAC5C,SAAS,KAAK;AACZ,UAAM,iBAAiB,eAAe,QAAQ,IAAI,UAAU,eAAe,EAAE;AAC7E,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":[]}
@@ -1,266 +0,0 @@
1
- import {
2
- VERSION
3
- } from "./chunk-V5G6BGOK.js";
4
- import {
5
- PRETTIERRC,
6
- SETTINGS_HOOKS,
7
- ensureAgentsMdLink,
8
- filterOutSafewordHooks,
9
- getEslintConfig,
10
- installGitHook,
11
- isGitRepo
12
- } from "./chunk-2XWIUEQK.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 } 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 hasElectron = "electron" in deps || "electron" in devDeps;
45
- return {
46
- typescript: hasTypescript,
47
- react: hasReact || hasNextJs,
48
- // Next.js implies React
49
- nextjs: hasNextJs,
50
- astro: hasAstro,
51
- electron: hasElectron
52
- };
53
- }
54
-
55
- // src/commands/setup.ts
56
- async function setup(options) {
57
- const cwd = process.cwd();
58
- const safewordDir = join(cwd, ".safeword");
59
- if (exists(safewordDir)) {
60
- error("Already configured. Run `safeword upgrade` to update.");
61
- process.exit(1);
62
- }
63
- const packageJsonPath = join(cwd, "package.json");
64
- if (!exists(packageJsonPath)) {
65
- error("No package.json found. Run this command in a Node.js project.");
66
- process.exit(1);
67
- }
68
- const isNonInteractive = options.yes || !process.stdin.isTTY;
69
- header("Safeword Setup");
70
- info(`Version: ${VERSION}`);
71
- const created = [];
72
- const modified = [];
73
- try {
74
- const templatesDir = getTemplatesDir();
75
- info("\nCreating .safeword directory...");
76
- ensureDir(safewordDir);
77
- ensureDir(join(safewordDir, "learnings"));
78
- ensureDir(join(safewordDir, "planning", "user-stories"));
79
- ensureDir(join(safewordDir, "planning", "design"));
80
- ensureDir(join(safewordDir, "tickets", "completed"));
81
- copyFile(join(templatesDir, "SAFEWORD.md"), join(safewordDir, "SAFEWORD.md"));
82
- writeFile(join(safewordDir, "version"), VERSION);
83
- copyDir(join(templatesDir, "guides"), join(safewordDir, "guides"));
84
- copyDir(join(templatesDir, "doc-templates"), join(safewordDir, "templates"));
85
- copyDir(join(templatesDir, "prompts"), join(safewordDir, "prompts"));
86
- copyDir(join(templatesDir, "lib"), join(safewordDir, "lib"));
87
- makeScriptsExecutable(join(safewordDir, "lib"));
88
- copyDir(join(templatesDir, "hooks"), join(safewordDir, "hooks"));
89
- makeScriptsExecutable(join(safewordDir, "hooks"));
90
- created.push(".safeword/");
91
- success("Created .safeword directory");
92
- info("\nConfiguring AGENTS.md...");
93
- const agentsMdResult = ensureAgentsMdLink(cwd);
94
- if (agentsMdResult === "created") {
95
- created.push("AGENTS.md");
96
- success("Created AGENTS.md");
97
- } else if (agentsMdResult === "modified") {
98
- modified.push("AGENTS.md");
99
- success("Prepended link to AGENTS.md");
100
- } else {
101
- info("AGENTS.md already has safeword link");
102
- }
103
- info("\nRegistering Claude Code hooks...");
104
- const claudeDir = join(cwd, ".claude");
105
- const settingsPath = join(claudeDir, "settings.json");
106
- ensureDir(claudeDir);
107
- try {
108
- updateJson(settingsPath, (existing) => {
109
- const hooks = existing?.hooks ?? {};
110
- for (const [event, newHooks] of Object.entries(SETTINGS_HOOKS)) {
111
- const existingHooks = hooks[event] ?? [];
112
- const nonSafewordHooks = filterOutSafewordHooks(existingHooks);
113
- hooks[event] = [...nonSafewordHooks, ...newHooks];
114
- }
115
- return { ...existing, hooks };
116
- });
117
- if (exists(settingsPath)) {
118
- modified.push(".claude/settings.json");
119
- } else {
120
- created.push(".claude/settings.json");
121
- }
122
- success("Registered hooks in .claude/settings.json");
123
- } catch (err) {
124
- error(`Failed to register hooks: ${err instanceof Error ? err.message : "Unknown error"}`);
125
- process.exit(1);
126
- }
127
- info("\nInstalling skills...");
128
- const skillsDir = join(claudeDir, "skills");
129
- copyDir(join(templatesDir, "skills"), skillsDir);
130
- created.push(".claude/skills/safeword-quality-reviewer/");
131
- success("Installed skills");
132
- info("\nInstalling slash commands...");
133
- const commandsDir = join(claudeDir, "commands");
134
- copyDir(join(templatesDir, "commands"), commandsDir);
135
- created.push(".claude/commands/");
136
- success("Installed slash commands");
137
- info("\nConfiguring MCP servers...");
138
- const mcpConfigPath = join(cwd, ".mcp.json");
139
- updateJson(mcpConfigPath, (existing) => {
140
- const mcpServers = existing?.mcpServers ?? {};
141
- mcpServers.context7 = {
142
- command: "npx",
143
- args: ["-y", "@upstash/context7-mcp@latest"]
144
- };
145
- mcpServers.playwright = {
146
- command: "npx",
147
- args: ["@playwright/mcp@latest"]
148
- };
149
- return { ...existing, mcpServers };
150
- });
151
- if (exists(mcpConfigPath)) {
152
- modified.push(".mcp.json");
153
- } else {
154
- created.push(".mcp.json");
155
- }
156
- success("Configured MCP servers");
157
- info("\nConfiguring linting...");
158
- const packageJson = readJson(packageJsonPath);
159
- if (!packageJson) {
160
- error("Failed to read package.json");
161
- process.exit(1);
162
- }
163
- const projectType = detectProjectType(packageJson);
164
- const eslintConfigPath = join(cwd, "eslint.config.mjs");
165
- if (!exists(eslintConfigPath)) {
166
- writeFile(eslintConfigPath, getEslintConfig(projectType));
167
- created.push("eslint.config.mjs");
168
- success("Created eslint.config.mjs");
169
- } else {
170
- info("eslint.config.mjs already exists");
171
- }
172
- const prettierrcPath = join(cwd, ".prettierrc");
173
- if (!exists(prettierrcPath)) {
174
- writeFile(prettierrcPath, PRETTIERRC);
175
- created.push(".prettierrc");
176
- success("Created .prettierrc");
177
- } else {
178
- info(".prettierrc already exists");
179
- }
180
- const markdownlintPath = join(cwd, ".markdownlint.jsonc");
181
- if (!exists(markdownlintPath)) {
182
- copyFile(join(templatesDir, "markdownlint.jsonc"), markdownlintPath);
183
- created.push(".markdownlint.jsonc");
184
- success("Created .markdownlint.jsonc");
185
- } else {
186
- info(".markdownlint.jsonc already exists");
187
- }
188
- try {
189
- const scripts = packageJson.scripts ?? {};
190
- let scriptsModified = false;
191
- if (!scripts.lint) {
192
- scripts.lint = "eslint .";
193
- scriptsModified = true;
194
- }
195
- if (!scripts["lint:md"]) {
196
- scripts["lint:md"] = 'markdownlint-cli2 "**/*.md" "#node_modules"';
197
- scriptsModified = true;
198
- }
199
- if (!scripts.format) {
200
- scripts.format = "prettier --write .";
201
- scriptsModified = true;
202
- }
203
- if (!scripts["format:check"]) {
204
- scripts["format:check"] = "prettier --check .";
205
- scriptsModified = true;
206
- }
207
- if (scriptsModified) {
208
- packageJson.scripts = scripts;
209
- writeJson(packageJsonPath, packageJson);
210
- modified.push("package.json");
211
- success("Added lint and format scripts");
212
- }
213
- } catch (err) {
214
- error(
215
- `Failed to update package.json: ${err instanceof Error ? err.message : "Unknown error"}`
216
- );
217
- process.exit(1);
218
- }
219
- info("\nConfiguring git...");
220
- if (isGitRepo(cwd)) {
221
- installGitHook(cwd);
222
- modified.push(".git/hooks/pre-commit");
223
- success("Installed git pre-commit hook");
224
- } else if (isNonInteractive) {
225
- warn("Skipped git initialization (non-interactive mode)");
226
- warn("Git hooks not installed (no repository)");
227
- } else {
228
- warn("Skipped git initialization (no .git directory)");
229
- warn("Git hooks not installed (no repository)");
230
- }
231
- info("\nNote: Install linting dependencies manually:");
232
- listItem("npm install -D eslint prettier @eslint/js");
233
- if (projectType.typescript) {
234
- listItem("npm install -D typescript-eslint");
235
- }
236
- if (projectType.react) {
237
- listItem("npm install -D eslint-plugin-react eslint-plugin-react-hooks");
238
- }
239
- header("Setup Complete");
240
- if (created.length > 0) {
241
- info("\nCreated:");
242
- for (const file of created) {
243
- listItem(file);
244
- }
245
- }
246
- if (modified.length > 0) {
247
- info("\nModified:");
248
- for (const file of modified) {
249
- listItem(file);
250
- }
251
- }
252
- info("\nNext steps:");
253
- listItem("Install linting dependencies (see above)");
254
- listItem("Run `safeword check` to verify setup");
255
- listItem("Commit the new files to git");
256
- success(`
257
- Safeword ${VERSION} installed successfully!`);
258
- } catch (err) {
259
- error(`Setup failed: ${err instanceof Error ? err.message : "Unknown error"}`);
260
- process.exit(1);
261
- }
262
- }
263
- export {
264
- setup
265
- };
266
- //# sourceMappingURL=setup-MKVVQTVA.js.map