hivecode-mcp 0.6.0 → 0.8.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.
package/token.js CHANGED
@@ -146,6 +146,26 @@ export function pathAllowed(globs, relPath) {
146
146
  return inAllow && !matches(neg)
147
147
  }
148
148
 
149
+ // Phase 5: within a scope, which VISIBLE paths are also WRITABLE. `writePaths` is
150
+ // an optional subset of `paths`: a file the scope can see is read-only unless it
151
+ // ALSO matches writePaths. This is what lets one agent read frontend/ for context
152
+ // but only edit backend/. Semantics, chosen to fail safe:
153
+ // - role 'reader' -> never writable (whole grant is view-only)
154
+ // - no writePaths key -> every visible path is writable (back-compat: a plain
155
+ // writer/agent edits everything it can see)
156
+ // - writePaths: [] -> nothing writable (explicit view-only everywhere)
157
+ // - writePaths: [globs] -> writable IFF the path matches the globs
158
+ // The relay enforces this by connecting an out-of-write-scope file-room as a
159
+ // reader (so makeReadOnly drops its writes); clients use it for read-only UX.
160
+ export function writeAllowed(scope, relPath) {
161
+ if (!scope) return false
162
+ if ((scope.role || 'writer') === 'reader') return false
163
+ const wp = scope.writePaths
164
+ if (wp == null) return true
165
+ if (!Array.isArray(wp) || wp.length === 0) return false
166
+ return pathAllowed(wp, relPath)
167
+ }
168
+
149
169
  // --- self-certifying secured rooms (no server-side key registry, no secret files) ---
150
170
  // A secured room's id embeds a fingerprint of the OWNER's public key:
151
171
  // hs_<fp>_<rand> fp = base64url(sha256(spki-DER)).slice(0, 22)