@cg3/equip 0.2.22 → 0.4.0

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 (57) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +26 -10
  3. package/bin/equip.js +159 -68
  4. package/demo/README.md +1 -1
  5. package/dist/index.d.ts +74 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +175 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/lib/cli.d.ts +22 -0
  10. package/dist/lib/cli.d.ts.map +1 -0
  11. package/dist/lib/cli.js +148 -0
  12. package/dist/lib/cli.js.map +1 -0
  13. package/dist/lib/commands/doctor.d.ts +2 -0
  14. package/dist/lib/commands/doctor.d.ts.map +1 -0
  15. package/dist/lib/commands/doctor.js +162 -0
  16. package/dist/lib/commands/doctor.js.map +1 -0
  17. package/dist/lib/commands/status.d.ts +2 -0
  18. package/dist/lib/commands/status.d.ts.map +1 -0
  19. package/dist/lib/commands/status.js +134 -0
  20. package/dist/lib/commands/status.js.map +1 -0
  21. package/dist/lib/commands/update.d.ts +2 -0
  22. package/dist/lib/commands/update.d.ts.map +1 -0
  23. package/dist/lib/commands/update.js +93 -0
  24. package/dist/lib/commands/update.js.map +1 -0
  25. package/dist/lib/detect.d.ts +12 -0
  26. package/dist/lib/detect.d.ts.map +1 -0
  27. package/dist/lib/detect.js +109 -0
  28. package/dist/lib/detect.js.map +1 -0
  29. package/dist/lib/hooks.d.ts +40 -0
  30. package/dist/lib/hooks.d.ts.map +1 -0
  31. package/dist/lib/hooks.js +226 -0
  32. package/dist/lib/hooks.js.map +1 -0
  33. package/dist/lib/mcp.d.ts +73 -0
  34. package/dist/lib/mcp.d.ts.map +1 -0
  35. package/dist/lib/mcp.js +418 -0
  36. package/dist/lib/mcp.js.map +1 -0
  37. package/dist/lib/platforms.d.ts +67 -0
  38. package/dist/lib/platforms.d.ts.map +1 -0
  39. package/dist/lib/platforms.js +353 -0
  40. package/dist/lib/platforms.js.map +1 -0
  41. package/dist/lib/rules.d.ts +35 -0
  42. package/dist/lib/rules.d.ts.map +1 -0
  43. package/dist/lib/rules.js +161 -0
  44. package/dist/lib/rules.js.map +1 -0
  45. package/dist/lib/state.d.ts +33 -0
  46. package/dist/lib/state.d.ts.map +1 -0
  47. package/dist/lib/state.js +130 -0
  48. package/dist/lib/state.js.map +1 -0
  49. package/package.json +19 -13
  50. package/registry.json +9 -0
  51. package/index.js +0 -244
  52. package/lib/cli.js +0 -99
  53. package/lib/detect.js +0 -242
  54. package/lib/hooks.js +0 -238
  55. package/lib/mcp.js +0 -503
  56. package/lib/platforms.js +0 -184
  57. package/lib/rules.js +0 -170
package/lib/rules.js DELETED
@@ -1,170 +0,0 @@
1
- // Behavioral rules installation — marker-based versioned blocks.
2
- // Handles appending, updating, and removing rules from shared files.
3
- // Zero dependencies.
4
-
5
- "use strict";
6
-
7
- const fs = require("fs");
8
- const path = require("path");
9
-
10
- // ─── Constants ──────────────────────────────────────────────
11
-
12
- /**
13
- * Create regex patterns for a given marker name.
14
- * @param {string} marker - Marker name (e.g., "prior")
15
- * @returns {{ MARKER_RE: RegExp, BLOCK_RE: RegExp }}
16
- */
17
- function markerPatterns(marker) {
18
- return {
19
- MARKER_RE: new RegExp(`<!-- ${marker}:v[\\d.]+ -->`),
20
- BLOCK_RE: new RegExp(`<!-- ${marker}:v[\\d.]+ -->[\\s\\S]*?<!-- \\/${marker} -->\\n?`),
21
- };
22
- }
23
-
24
- /**
25
- * Parse version from marker in content.
26
- * @param {string} content
27
- * @param {string} marker
28
- * @returns {string|null}
29
- */
30
- function parseRulesVersion(content, marker) {
31
- const m = content.match(new RegExp(`<!-- ${marker}:v([\\d.]+) -->`));
32
- return m ? m[1] : null;
33
- }
34
-
35
- // ─── Install ─────────────────────────────────────────────────
36
-
37
- /**
38
- * Install behavioral rules to a platform's rules file.
39
- * Supports: file-based (append/update), standalone file, or clipboard.
40
- *
41
- * @param {object} platform - Platform object with rulesPath
42
- * @param {object} options
43
- * @param {string} options.content - Rules content (with markers)
44
- * @param {string} options.version - Current version string
45
- * @param {string} options.marker - Marker name for tracking
46
- * @param {string} [options.fileName] - For standalone file platforms (e.g., "prior.md")
47
- * @param {string[]} [options.clipboardPlatforms] - Platform ids that use clipboard
48
- * @param {boolean} [options.dryRun]
49
- * @param {Function} [options.copyToClipboard] - Clipboard function
50
- * @returns {{ action: string }} "created" | "updated" | "skipped" | "clipboard"
51
- */
52
- function installRules(platform, options) {
53
- const {
54
- content,
55
- version,
56
- marker,
57
- fileName,
58
- clipboardPlatforms = ["cursor", "vscode"],
59
- dryRun = false,
60
- copyToClipboard,
61
- } = options;
62
-
63
- // Clipboard-only platforms
64
- if (clipboardPlatforms.includes(platform.platform)) {
65
- if (!dryRun && copyToClipboard) {
66
- copyToClipboard(content);
67
- }
68
- return { action: "clipboard" };
69
- }
70
-
71
- if (!platform.rulesPath) return { action: "skipped" };
72
-
73
- // Determine actual file path — standalone file (directory-based) vs append (file-based)
74
- // Only use fileName if rulesPath is a directory (or doesn't exist yet as a file)
75
- let rulesPath;
76
- if (fileName) {
77
- try {
78
- const stat = fs.statSync(platform.rulesPath);
79
- rulesPath = stat.isDirectory() ? path.join(platform.rulesPath, fileName) : platform.rulesPath;
80
- } catch {
81
- // Path doesn't exist — check if it looks like a file (has extension) or directory
82
- rulesPath = path.extname(platform.rulesPath) ? platform.rulesPath : path.join(platform.rulesPath, fileName);
83
- }
84
- } else {
85
- rulesPath = platform.rulesPath;
86
- }
87
-
88
- const { MARKER_RE, BLOCK_RE } = markerPatterns(marker);
89
-
90
- let existing = "";
91
- try { existing = fs.readFileSync(rulesPath, "utf-8"); } catch {}
92
-
93
- const existingVersion = parseRulesVersion(existing, marker);
94
-
95
- if (existingVersion === version) {
96
- return { action: "skipped" };
97
- }
98
-
99
- if (!dryRun) {
100
- const dir = path.dirname(rulesPath);
101
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
102
-
103
- if (existingVersion) {
104
- // Replace existing block
105
- const updated = existing.replace(BLOCK_RE, content + "\n");
106
- fs.writeFileSync(rulesPath, updated);
107
- return { action: "updated" };
108
- }
109
-
110
- // Append
111
- const sep = existing && !existing.endsWith("\n\n") ? (existing.endsWith("\n") ? "\n" : "\n\n") : "";
112
- fs.writeFileSync(rulesPath, existing + sep + content + "\n");
113
- return { action: "created" };
114
- }
115
-
116
- return { action: existingVersion ? "updated" : "created" };
117
- }
118
-
119
- /**
120
- * Remove rules from a platform's rules file.
121
- * @param {object} platform - Platform object
122
- * @param {object} options
123
- * @param {string} options.marker - Marker name
124
- * @param {string} [options.fileName] - For standalone file platforms
125
- * @param {boolean} [options.dryRun]
126
- * @returns {boolean} Whether anything was removed
127
- */
128
- function uninstallRules(platform, options) {
129
- const { marker, fileName, dryRun = false } = options;
130
-
131
- if (!platform.rulesPath) return false;
132
-
133
- let rulesPath;
134
- if (fileName) {
135
- try {
136
- const stat = fs.statSync(platform.rulesPath);
137
- rulesPath = stat.isDirectory() ? path.join(platform.rulesPath, fileName) : platform.rulesPath;
138
- } catch {
139
- rulesPath = path.extname(platform.rulesPath) ? platform.rulesPath : path.join(platform.rulesPath, fileName);
140
- }
141
- } else {
142
- rulesPath = platform.rulesPath;
143
- }
144
-
145
- try {
146
- if (!fs.statSync(rulesPath).isFile()) return false;
147
- } catch { return false; }
148
-
149
- try {
150
- const content = fs.readFileSync(rulesPath, "utf-8");
151
- const { MARKER_RE, BLOCK_RE } = markerPatterns(marker);
152
- if (!MARKER_RE.test(content)) return false;
153
- if (!dryRun) {
154
- const cleaned = content.replace(BLOCK_RE, "").replace(/\n{3,}/g, "\n\n").trim();
155
- if (cleaned) {
156
- fs.writeFileSync(rulesPath, cleaned + "\n");
157
- } else {
158
- fs.unlinkSync(rulesPath);
159
- }
160
- }
161
- return true;
162
- } catch { return false; }
163
- }
164
-
165
- module.exports = {
166
- markerPatterns,
167
- parseRulesVersion,
168
- installRules,
169
- uninstallRules,
170
- };