code-warden 3.3.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CONFIGURE.md +39 -39
  2. package/DECISIONS.md +107 -107
  3. package/README.md +6 -0
  4. package/SKILL.md +169 -169
  5. package/bin/code-warden.js +82 -82
  6. package/codewarden.json +14 -14
  7. package/examples/governed-session.md +132 -132
  8. package/install.js +399 -399
  9. package/install.ps1 +32 -32
  10. package/install.sh +33 -33
  11. package/package.json +62 -62
  12. package/references/anti-drift.md +55 -55
  13. package/references/architecture.md +26 -26
  14. package/references/cleanup.md +30 -30
  15. package/references/cognition.md +36 -36
  16. package/references/operations.md +45 -45
  17. package/references/planning-gates.md +83 -83
  18. package/references/research-and-fit.md +51 -51
  19. package/references/safety.md +31 -31
  20. package/tools/auto-detect.js +91 -91
  21. package/tools/auto-targets.js +104 -104
  22. package/tools/auto-windsurf-adapter.js +75 -75
  23. package/tools/get-context.js +50 -50
  24. package/tools/governance-report.js +302 -302
  25. package/tools/hooks/claude/install-hooks.js +112 -112
  26. package/tools/hooks/claude/uninstall-hooks.js +75 -75
  27. package/tools/hooks/claude/warden-lint-hook.js +106 -106
  28. package/tools/hooks/claude/warden-secrets-hook.js +73 -73
  29. package/tools/hooks/codex/install-hooks.js +100 -100
  30. package/tools/hooks/codex/uninstall-hooks.js +53 -53
  31. package/tools/hooks/codex/warden-apply-patch-hook.js +113 -113
  32. package/tools/hooks/codex/warden-bash-hook.js +51 -51
  33. package/tools/lib/config.js +49 -49
  34. package/tools/lib/file-collection.js +5 -2
  35. package/tools/lib/line-count.js +28 -28
  36. package/tools/lib/secret-patterns.js +57 -57
  37. package/tools/tests/fixtures/clean.js +9 -9
  38. package/tools/tests/run-tests.js +210 -210
  39. package/tools/verify-secrets.js +26 -26
  40. package/tools/warden-lint.js +27 -27
@@ -1,104 +1,104 @@
1
- #!/usr/bin/env node
2
- /**
3
- * auto-targets.js
4
- * Target registry for the code-warden auto-installer.
5
- * Each entry describes one AI app, how to detect it, and where to install.
6
- *
7
- * format values:
8
- * 'skill-md' - copy the full skill folder (SKILL.md + references/ + tools/)
9
- * 'windsurf-flat' - concatenate into a single .md file via auto-windsurf-adapter.js
10
- */
11
-
12
- const os = require('os');
13
- const path = require('path');
14
-
15
- const HOME = os.homedir();
16
- const LOCALAPPDATA = process.env.LOCALAPPDATA || '';
17
- const APPDATA = process.env.APPDATA || '';
18
-
19
- const TARGETS = [
20
- {
21
- id: 'claude',
22
- name: 'Claude Code',
23
- format: 'skill-md',
24
- skillsDir: path.join(HOME, '.claude', 'skills'),
25
- detect: {
26
- binaries: ['claude'],
27
- dirs: [path.join(HOME, '.claude')],
28
- apps: {
29
- darwin: ['/Applications/Claude.app'],
30
- win32: [path.join(LOCALAPPDATA, 'Programs', 'claude', 'claude.exe')],
31
- linux: [],
32
- },
33
- },
34
- },
35
- {
36
- id: 'cursor',
37
- name: 'Cursor',
38
- format: 'skill-md',
39
- skillsDir: path.join(HOME, '.cursor', 'skills'),
40
- detect: {
41
- binaries: ['cursor'],
42
- dirs: [path.join(HOME, '.cursor')],
43
- apps: {
44
- darwin: ['/Applications/Cursor.app'],
45
- win32: [path.join(LOCALAPPDATA, 'Programs', 'cursor', 'Cursor.exe')],
46
- linux: [path.join(HOME, '.local', 'share', 'cursor')],
47
- },
48
- },
49
- },
50
- {
51
- id: 'warp',
52
- name: 'Warp',
53
- format: 'skill-md',
54
- skillsDir: path.join(HOME, '.warp', 'skills'),
55
- detect: {
56
- binaries: ['warp', 'warp-terminal'],
57
- dirs: [path.join(HOME, '.warp')],
58
- apps: {
59
- darwin: ['/Applications/Warp.app'],
60
- win32: [path.join(LOCALAPPDATA, 'Programs', 'Warp', 'Warp.exe')],
61
- linux: [],
62
- },
63
- },
64
- },
65
- {
66
- id: 'codex',
67
- name: 'OpenAI Codex',
68
- format: 'skill-md',
69
- skillsDir: path.join(HOME, '.codex', 'skills'),
70
- detect: {
71
- binaries: ['codex'],
72
- dirs: [path.join(HOME, '.codex')],
73
- apps: { darwin: [], win32: [], linux: [] },
74
- },
75
- },
76
- {
77
- id: 'agents',
78
- name: 'Generic Agents',
79
- format: 'skill-md',
80
- skillsDir: path.join(HOME, '.agents', 'skills'),
81
- detect: {
82
- binaries: [],
83
- dirs: [path.join(HOME, '.agents')],
84
- apps: { darwin: [], win32: [], linux: [] },
85
- },
86
- },
87
- {
88
- id: 'windsurf',
89
- name: 'Windsurf',
90
- format: 'windsurf-flat',
91
- skillsDir: path.join(HOME, '.windsurf', 'rules'),
92
- detect: {
93
- binaries: ['windsurf'],
94
- dirs: [path.join(HOME, '.windsurf')],
95
- apps: {
96
- darwin: ['/Applications/Windsurf.app'],
97
- win32: [path.join(LOCALAPPDATA, 'Programs', 'Windsurf', 'Windsurf.exe')],
98
- linux: [],
99
- },
100
- },
101
- },
102
- ];
103
-
104
- module.exports = { TARGETS };
1
+ #!/usr/bin/env node
2
+ /**
3
+ * auto-targets.js
4
+ * Target registry for the code-warden auto-installer.
5
+ * Each entry describes one AI app, how to detect it, and where to install.
6
+ *
7
+ * format values:
8
+ * 'skill-md' - copy the full skill folder (SKILL.md + references/ + tools/)
9
+ * 'windsurf-flat' - concatenate into a single .md file via auto-windsurf-adapter.js
10
+ */
11
+
12
+ const os = require('os');
13
+ const path = require('path');
14
+
15
+ const HOME = os.homedir();
16
+ const LOCALAPPDATA = process.env.LOCALAPPDATA || '';
17
+ const APPDATA = process.env.APPDATA || '';
18
+
19
+ const TARGETS = [
20
+ {
21
+ id: 'claude',
22
+ name: 'Claude Code',
23
+ format: 'skill-md',
24
+ skillsDir: path.join(HOME, '.claude', 'skills'),
25
+ detect: {
26
+ binaries: ['claude'],
27
+ dirs: [path.join(HOME, '.claude')],
28
+ apps: {
29
+ darwin: ['/Applications/Claude.app'],
30
+ win32: [path.join(LOCALAPPDATA, 'Programs', 'claude', 'claude.exe')],
31
+ linux: [],
32
+ },
33
+ },
34
+ },
35
+ {
36
+ id: 'cursor',
37
+ name: 'Cursor',
38
+ format: 'skill-md',
39
+ skillsDir: path.join(HOME, '.cursor', 'skills'),
40
+ detect: {
41
+ binaries: ['cursor'],
42
+ dirs: [path.join(HOME, '.cursor')],
43
+ apps: {
44
+ darwin: ['/Applications/Cursor.app'],
45
+ win32: [path.join(LOCALAPPDATA, 'Programs', 'cursor', 'Cursor.exe')],
46
+ linux: [path.join(HOME, '.local', 'share', 'cursor')],
47
+ },
48
+ },
49
+ },
50
+ {
51
+ id: 'warp',
52
+ name: 'Warp',
53
+ format: 'skill-md',
54
+ skillsDir: path.join(HOME, '.warp', 'skills'),
55
+ detect: {
56
+ binaries: ['warp', 'warp-terminal'],
57
+ dirs: [path.join(HOME, '.warp')],
58
+ apps: {
59
+ darwin: ['/Applications/Warp.app'],
60
+ win32: [path.join(LOCALAPPDATA, 'Programs', 'Warp', 'Warp.exe')],
61
+ linux: [],
62
+ },
63
+ },
64
+ },
65
+ {
66
+ id: 'codex',
67
+ name: 'OpenAI Codex',
68
+ format: 'skill-md',
69
+ skillsDir: path.join(HOME, '.codex', 'skills'),
70
+ detect: {
71
+ binaries: ['codex'],
72
+ dirs: [path.join(HOME, '.codex')],
73
+ apps: { darwin: [], win32: [], linux: [] },
74
+ },
75
+ },
76
+ {
77
+ id: 'agents',
78
+ name: 'Generic Agents',
79
+ format: 'skill-md',
80
+ skillsDir: path.join(HOME, '.agents', 'skills'),
81
+ detect: {
82
+ binaries: [],
83
+ dirs: [path.join(HOME, '.agents')],
84
+ apps: { darwin: [], win32: [], linux: [] },
85
+ },
86
+ },
87
+ {
88
+ id: 'windsurf',
89
+ name: 'Windsurf',
90
+ format: 'windsurf-flat',
91
+ skillsDir: path.join(HOME, '.windsurf', 'rules'),
92
+ detect: {
93
+ binaries: ['windsurf'],
94
+ dirs: [path.join(HOME, '.windsurf')],
95
+ apps: {
96
+ darwin: ['/Applications/Windsurf.app'],
97
+ win32: [path.join(LOCALAPPDATA, 'Programs', 'Windsurf', 'Windsurf.exe')],
98
+ linux: [],
99
+ },
100
+ },
101
+ },
102
+ ];
103
+
104
+ module.exports = { TARGETS };
@@ -1,75 +1,75 @@
1
- #!/usr/bin/env node
2
- /**
3
- * auto-windsurf-adapter.js
4
- * Converts the modular code-warden skill into a single flat markdown file
5
- * compatible with Windsurf's rules format (.windsurf/rules/).
6
- *
7
- * Concatenation order:
8
- * SKILL.md -> planning-gates -> architecture -> safety -> cognition -> cleanup
9
- * -> anti-drift -> operations -> research-and-fit
10
- */
11
-
12
- const fs = require('fs');
13
- const path = require('path');
14
-
15
- const REFERENCE_ORDER = [
16
- 'planning-gates',
17
- 'architecture',
18
- 'safety',
19
- 'cognition',
20
- 'cleanup',
21
- 'anti-drift',
22
- 'operations',
23
- 'research-and-fit',
24
- ];
25
-
26
- const OUTPUT_FILENAME = 'code-warden.md';
27
-
28
- /**
29
- * Reads a file and returns its content.
30
- * - SKILL.md missing: throws (hard fail — output is meaningless without it)
31
- * - Reference missing: warns to stderr, inserts a comment, continues
32
- */
33
- function readSafe(filePath, label) {
34
- if (!fs.existsSync(filePath)) {
35
- if (label === 'SKILL.md') {
36
- throw new Error(`SKILL.md not found at ${filePath} — cannot generate Windsurf output.`);
37
- }
38
- console.warn(`[CodeWarden] WARN ${label} not found, skipping.`);
39
- return `\n<!-- [CodeWarden] WARNING: ${label} not found — section omitted -->\n`;
40
- }
41
- return fs.readFileSync(filePath, 'utf8');
42
- }
43
-
44
- /**
45
- * Builds and writes the flat Windsurf rules file.
46
- * @param {string} sourceDir - root of the code-warden skill source
47
- * @param {string} destDir - target directory (e.g. ~/.windsurf/rules)
48
- * @returns {string} - full path of the written file
49
- */
50
- function installWindsurf(sourceDir, destDir) {
51
- const sections = [];
52
-
53
- sections.push('<!-- Generated by code-warden auto-installer. Do not edit manually. -->');
54
- sections.push('<!-- Source: https://github.com/Kodaxadev/Code-Warden -->');
55
- sections.push('');
56
-
57
- const skillMdPath = path.join(sourceDir, 'SKILL.md');
58
- sections.push(readSafe(skillMdPath, 'SKILL.md'));
59
-
60
- for (const ref of REFERENCE_ORDER) {
61
- const refPath = path.join(sourceDir, 'references', `${ref}.md`);
62
- sections.push(`\n---\n`);
63
- sections.push(readSafe(refPath, `references/${ref}.md`));
64
- }
65
-
66
- const output = sections.join('\n');
67
-
68
- fs.mkdirSync(destDir, { recursive: true });
69
- const outPath = path.join(destDir, OUTPUT_FILENAME);
70
- fs.writeFileSync(outPath, output, 'utf8');
71
-
72
- return outPath;
73
- }
74
-
75
- module.exports = { installWindsurf };
1
+ #!/usr/bin/env node
2
+ /**
3
+ * auto-windsurf-adapter.js
4
+ * Converts the modular code-warden skill into a single flat markdown file
5
+ * compatible with Windsurf's rules format (.windsurf/rules/).
6
+ *
7
+ * Concatenation order:
8
+ * SKILL.md -> planning-gates -> architecture -> safety -> cognition -> cleanup
9
+ * -> anti-drift -> operations -> research-and-fit
10
+ */
11
+
12
+ const fs = require('fs');
13
+ const path = require('path');
14
+
15
+ const REFERENCE_ORDER = [
16
+ 'planning-gates',
17
+ 'architecture',
18
+ 'safety',
19
+ 'cognition',
20
+ 'cleanup',
21
+ 'anti-drift',
22
+ 'operations',
23
+ 'research-and-fit',
24
+ ];
25
+
26
+ const OUTPUT_FILENAME = 'code-warden.md';
27
+
28
+ /**
29
+ * Reads a file and returns its content.
30
+ * - SKILL.md missing: throws (hard fail — output is meaningless without it)
31
+ * - Reference missing: warns to stderr, inserts a comment, continues
32
+ */
33
+ function readSafe(filePath, label) {
34
+ if (!fs.existsSync(filePath)) {
35
+ if (label === 'SKILL.md') {
36
+ throw new Error(`SKILL.md not found at ${filePath} — cannot generate Windsurf output.`);
37
+ }
38
+ console.warn(`[CodeWarden] WARN ${label} not found, skipping.`);
39
+ return `\n<!-- [CodeWarden] WARNING: ${label} not found — section omitted -->\n`;
40
+ }
41
+ return fs.readFileSync(filePath, 'utf8');
42
+ }
43
+
44
+ /**
45
+ * Builds and writes the flat Windsurf rules file.
46
+ * @param {string} sourceDir - root of the code-warden skill source
47
+ * @param {string} destDir - target directory (e.g. ~/.windsurf/rules)
48
+ * @returns {string} - full path of the written file
49
+ */
50
+ function installWindsurf(sourceDir, destDir) {
51
+ const sections = [];
52
+
53
+ sections.push('<!-- Generated by code-warden auto-installer. Do not edit manually. -->');
54
+ sections.push('<!-- Source: https://github.com/Kodaxadev/Code-Warden -->');
55
+ sections.push('');
56
+
57
+ const skillMdPath = path.join(sourceDir, 'SKILL.md');
58
+ sections.push(readSafe(skillMdPath, 'SKILL.md'));
59
+
60
+ for (const ref of REFERENCE_ORDER) {
61
+ const refPath = path.join(sourceDir, 'references', `${ref}.md`);
62
+ sections.push(`\n---\n`);
63
+ sections.push(readSafe(refPath, `references/${ref}.md`));
64
+ }
65
+
66
+ const output = sections.join('\n');
67
+
68
+ fs.mkdirSync(destDir, { recursive: true });
69
+ const outPath = path.join(destDir, OUTPUT_FILENAME);
70
+ fs.writeFileSync(outPath, output, 'utf8');
71
+
72
+ return outPath;
73
+ }
74
+
75
+ module.exports = { installWindsurf };
@@ -1,50 +1,50 @@
1
- #!/usr/bin/env node
2
- const fs = require('fs');
3
- const path = require('path');
4
-
5
- const candidates = [
6
- 'AGENTS.md',
7
- '.codex/AGENTS.md',
8
- 'ARCHITECTURE.md',
9
- 'docs/ARCHITECTURE.md',
10
- '.agents/AGENTS.md',
11
- '.claude/CLAUDE.md',
12
- 'CLAUDE.md',
13
- 'README.md',
14
- 'docs/README.md',
15
- 'PRD.md',
16
- ];
17
-
18
- function findContextFile(startDir) {
19
- let currDir = path.resolve(startDir);
20
-
21
- while (true) {
22
- for (const candidate of candidates) {
23
- const fullPath = path.join(currDir, candidate);
24
- if (fs.existsSync(fullPath)) {
25
- return fullPath;
26
- }
27
- }
28
-
29
- const parentDir = path.dirname(currDir);
30
- if (parentDir === currDir) {
31
- return null;
32
- }
33
- currDir = parentDir;
34
- }
35
- }
36
-
37
- const contextFile = findContextFile(process.cwd());
38
-
39
- if (contextFile) {
40
- console.log(`Found architectural context at: ${contextFile}\n`);
41
- const content = fs.readFileSync(contextFile, 'utf8');
42
- if (content.length > 5000) {
43
- console.log(`${content.substring(0, 5000)}\n...[Content truncated]`);
44
- } else {
45
- console.log(content);
46
- }
47
- } else {
48
- console.log('[WARN] No AGENTS.md, architecture doc, CLAUDE.md, PRD, or README found in the repository hierarchy.');
49
- process.exit(1);
50
- }
1
+ #!/usr/bin/env node
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ const candidates = [
6
+ 'AGENTS.md',
7
+ '.codex/AGENTS.md',
8
+ 'ARCHITECTURE.md',
9
+ 'docs/ARCHITECTURE.md',
10
+ '.agents/AGENTS.md',
11
+ '.claude/CLAUDE.md',
12
+ 'CLAUDE.md',
13
+ 'README.md',
14
+ 'docs/README.md',
15
+ 'PRD.md',
16
+ ];
17
+
18
+ function findContextFile(startDir) {
19
+ let currDir = path.resolve(startDir);
20
+
21
+ while (true) {
22
+ for (const candidate of candidates) {
23
+ const fullPath = path.join(currDir, candidate);
24
+ if (fs.existsSync(fullPath)) {
25
+ return fullPath;
26
+ }
27
+ }
28
+
29
+ const parentDir = path.dirname(currDir);
30
+ if (parentDir === currDir) {
31
+ return null;
32
+ }
33
+ currDir = parentDir;
34
+ }
35
+ }
36
+
37
+ const contextFile = findContextFile(process.cwd());
38
+
39
+ if (contextFile) {
40
+ console.log(`Found architectural context at: ${contextFile}\n`);
41
+ const content = fs.readFileSync(contextFile, 'utf8');
42
+ if (content.length > 5000) {
43
+ console.log(`${content.substring(0, 5000)}\n...[Content truncated]`);
44
+ } else {
45
+ console.log(content);
46
+ }
47
+ } else {
48
+ console.log('[WARN] No AGENTS.md, architecture doc, CLAUDE.md, PRD, or README found in the repository hierarchy.');
49
+ process.exit(1);
50
+ }