coding-friend-cli 1.17.4 → 1.18.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.
@@ -1,198 +0,0 @@
1
- import {
2
- readJson,
3
- writeJson
4
- } from "./chunk-RWUTFVRB.js";
5
-
6
- // src/lib/permissions.ts
7
- var PERMISSION_RULES = [
8
- // Core (hooks & infrastructure)
9
- {
10
- rule: "Bash(cat:*)",
11
- description: "[read-only] Read file contents (\u26A0 system-wide scope, project boundary enforced by Claude Code) \xB7 Used by: session-init hook",
12
- category: "Core",
13
- recommended: true
14
- },
15
- {
16
- rule: "Bash(grep:*)",
17
- description: "[read-only] Search file contents (\u26A0 system-wide scope, project boundary enforced by Claude Code) \xB7 Used by: session-init hook, skills",
18
- category: "Core",
19
- recommended: true
20
- },
21
- {
22
- rule: "Bash(sed:*)",
23
- description: "[modify] Text transformation \xB7 Used by: session-init hook",
24
- category: "Core",
25
- recommended: true
26
- },
27
- {
28
- rule: "Bash(tr:*)",
29
- description: "[read-only] Character translation \xB7 Used by: session-init hook",
30
- category: "Core",
31
- recommended: true
32
- },
33
- {
34
- rule: "Bash(wc:*)",
35
- description: "[read-only] Count lines/words \xB7 Used by: cf-verification, skills",
36
- category: "Core",
37
- recommended: true
38
- },
39
- {
40
- rule: "Bash(mkdir:*)",
41
- description: "[write] Create directories \xB7 Used by: docs folder setup",
42
- category: "Core",
43
- recommended: true
44
- },
45
- // Git Operations
46
- {
47
- rule: "Bash(git add:*)",
48
- description: "[modify] Stage files for commit \xB7 Used by: /cf-commit, /cf-ship",
49
- category: "Git",
50
- recommended: true
51
- },
52
- {
53
- rule: "Bash(git commit:*)",
54
- description: "[modify] Create commits \xB7 Used by: /cf-commit, /cf-ship",
55
- category: "Git",
56
- recommended: true
57
- },
58
- {
59
- rule: "Bash(git status:*)",
60
- description: "[read-only] Check working tree status \xB7 Used by: /cf-commit, /cf-review, cf-verification",
61
- category: "Git",
62
- recommended: true
63
- },
64
- {
65
- rule: "Bash(git diff:*)",
66
- description: "[read-only] View file changes \xB7 Used by: /cf-commit, /cf-review, cf-verification",
67
- category: "Git",
68
- recommended: true
69
- },
70
- {
71
- rule: "Bash(git log:*)",
72
- description: "[read-only] View commit history \xB7 Used by: /cf-commit, /cf-review, cf-sys-debug",
73
- category: "Git",
74
- recommended: true
75
- },
76
- {
77
- rule: "Bash(git push:*)",
78
- description: "[remote] Push commits to remote \xB7 Used by: /cf-ship",
79
- category: "Git",
80
- recommended: true
81
- },
82
- {
83
- rule: "Bash(git pull:*)",
84
- description: "[remote] Pull changes from remote \xB7 Used by: /cf-ship",
85
- category: "Git",
86
- recommended: true
87
- },
88
- {
89
- rule: "Bash(gh pr create:*)",
90
- description: "[remote] Create GitHub pull requests \xB7 Used by: /cf-ship",
91
- category: "Git",
92
- recommended: true
93
- },
94
- // Testing & Build
95
- {
96
- rule: "Bash(npm test:*)",
97
- description: "[execute] Run test suites \xB7 Used by: cf-verification, /cf-fix, cf-tdd",
98
- category: "Testing & Build",
99
- recommended: true
100
- },
101
- {
102
- rule: "Bash(npm run:*)",
103
- description: "[execute] Run npm scripts (build, lint, format) \xB7 Used by: cf-verification",
104
- category: "Testing & Build",
105
- recommended: true
106
- },
107
- // Web & Research
108
- {
109
- rule: "WebSearch",
110
- description: "[network] Perform web searches \xB7 Used by: /cf-research",
111
- category: "Web & Research",
112
- recommended: false
113
- },
114
- {
115
- rule: "WebFetch(domain:*)",
116
- description: "[network] Fetch content from web pages \xB7 Used by: /cf-research",
117
- category: "Web & Research",
118
- recommended: false
119
- }
120
- ];
121
- function getExistingRules(settingsPath) {
122
- const settings = readJson(settingsPath);
123
- if (!settings) return [];
124
- const permissions = settings.permissions;
125
- return permissions?.allow ?? [];
126
- }
127
- function getMissingRules(existing, rules) {
128
- return rules.filter((r) => !existing.includes(r.rule));
129
- }
130
- function buildLearnDirRules(learnPath, autoCommit) {
131
- const rules = [
132
- {
133
- rule: `Read(${learnPath}/**)`,
134
- description: "[read-only] Read learning docs \xB7 Used by: /cf-learn",
135
- category: "External Learn Directory",
136
- recommended: true
137
- },
138
- {
139
- rule: `Edit(${learnPath}/**)`,
140
- description: "[modify] Edit learning docs \xB7 Used by: /cf-learn",
141
- category: "External Learn Directory",
142
- recommended: true
143
- },
144
- {
145
- rule: `Write(${learnPath}/**)`,
146
- description: "[write] Write learning docs \xB7 Used by: /cf-learn",
147
- category: "External Learn Directory",
148
- recommended: true
149
- }
150
- ];
151
- if (autoCommit) {
152
- const quoted = learnPath.includes(" ") ? `"${learnPath}"` : learnPath;
153
- rules.push({
154
- rule: `Bash(cd ${quoted} && git add:*)`,
155
- description: "[modify] Stage learning docs for commit \xB7 Used by: /cf-learn auto-commit",
156
- category: "External Learn Directory",
157
- recommended: true
158
- });
159
- rules.push({
160
- rule: `Bash(cd ${quoted} && git commit:*)`,
161
- description: "[modify] Commit learning docs \xB7 Used by: /cf-learn auto-commit",
162
- category: "External Learn Directory",
163
- recommended: true
164
- });
165
- }
166
- return rules;
167
- }
168
- function applyPermissions(settingsPath, toAdd, toRemove) {
169
- const settings = readJson(settingsPath) ?? {};
170
- const permissions = settings.permissions ?? {};
171
- const existing = permissions.allow ?? [];
172
- const afterRemove = existing.filter((r) => !toRemove.includes(r));
173
- const afterAdd = [
174
- ...afterRemove,
175
- ...toAdd.filter((r) => !afterRemove.includes(r))
176
- ];
177
- permissions.allow = afterAdd;
178
- settings.permissions = permissions;
179
- writeJson(settingsPath, settings);
180
- }
181
- function groupByCategory(rules) {
182
- const groups = /* @__PURE__ */ new Map();
183
- for (const rule of rules) {
184
- const list = groups.get(rule.category) ?? [];
185
- list.push(rule);
186
- groups.set(rule.category, list);
187
- }
188
- return groups;
189
- }
190
-
191
- export {
192
- PERMISSION_RULES,
193
- getExistingRules,
194
- getMissingRules,
195
- buildLearnDirRules,
196
- applyPermissions,
197
- groupByCategory
198
- };