@intutic/sync-daemon 2.1.0 → 2.2.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 (179) hide show
  1. package/dist/agentReporter.d.ts +1 -0
  2. package/dist/agentReporter.d.ts.map +1 -1
  3. package/dist/configReader.d.ts +44 -22
  4. package/dist/configReader.d.ts.map +1 -1
  5. package/dist/configReader.js +70 -44
  6. package/dist/configReader.js.map +1 -1
  7. package/dist/configWriter.d.ts +29 -41
  8. package/dist/configWriter.d.ts.map +1 -1
  9. package/dist/configWriter.js +26 -637
  10. package/dist/configWriter.js.map +1 -1
  11. package/dist/disconnect/harnesses.d.ts +31 -0
  12. package/dist/disconnect/harnesses.d.ts.map +1 -0
  13. package/dist/disconnect/harnesses.js +728 -0
  14. package/dist/disconnect/harnesses.js.map +1 -0
  15. package/dist/disconnect/index.d.ts +25 -0
  16. package/dist/disconnect/index.d.ts.map +1 -0
  17. package/dist/disconnect/index.js +82 -0
  18. package/dist/disconnect/index.js.map +1 -0
  19. package/dist/disconnect/mcp.d.ts +60 -0
  20. package/dist/disconnect/mcp.d.ts.map +1 -0
  21. package/dist/disconnect/mcp.js +283 -0
  22. package/dist/disconnect/mcp.js.map +1 -0
  23. package/dist/disconnect/originals.d.ts +88 -0
  24. package/dist/disconnect/originals.d.ts.map +1 -0
  25. package/dist/disconnect/originals.js +257 -0
  26. package/dist/disconnect/originals.js.map +1 -0
  27. package/dist/disconnect/plan.d.ts +175 -0
  28. package/dist/disconnect/plan.d.ts.map +1 -0
  29. package/dist/disconnect/plan.js +580 -0
  30. package/dist/disconnect/plan.js.map +1 -0
  31. package/dist/disconnect/recognise.d.ts +43 -0
  32. package/dist/disconnect/recognise.d.ts.map +1 -0
  33. package/dist/disconnect/recognise.js +98 -0
  34. package/dist/disconnect/recognise.js.map +1 -0
  35. package/dist/disconnect/tomlLines.d.ts +39 -0
  36. package/dist/disconnect/tomlLines.d.ts.map +1 -0
  37. package/dist/disconnect/tomlLines.js +105 -0
  38. package/dist/disconnect/tomlLines.js.map +1 -0
  39. package/dist/harness/aiderConfigMerger.d.ts +1 -0
  40. package/dist/harness/aiderConfigMerger.d.ts.map +1 -1
  41. package/dist/harness/aiderConfigMerger.js +4 -1
  42. package/dist/harness/aiderConfigMerger.js.map +1 -1
  43. package/dist/harness/antigravityHooks.d.ts.map +1 -1
  44. package/dist/harness/antigravityHooks.js +2 -0
  45. package/dist/harness/antigravityHooks.js.map +1 -1
  46. package/dist/harness/claudeCodeHooks.d.ts +1 -2
  47. package/dist/harness/claudeCodeHooks.d.ts.map +1 -1
  48. package/dist/harness/claudeCodeHooks.js +19 -6
  49. package/dist/harness/claudeCodeHooks.js.map +1 -1
  50. package/dist/harness/claudeDesktopHooks.d.ts +3 -0
  51. package/dist/harness/claudeDesktopHooks.d.ts.map +1 -1
  52. package/dist/harness/claudeDesktopHooks.js +3 -1
  53. package/dist/harness/claudeDesktopHooks.js.map +1 -1
  54. package/dist/harness/claudeProjectApproval.d.ts +53 -0
  55. package/dist/harness/claudeProjectApproval.d.ts.map +1 -0
  56. package/dist/harness/claudeProjectApproval.js +159 -0
  57. package/dist/harness/claudeProjectApproval.js.map +1 -0
  58. package/dist/harness/clineHooks.d.ts.map +1 -1
  59. package/dist/harness/clineHooks.js +3 -0
  60. package/dist/harness/clineHooks.js.map +1 -1
  61. package/dist/harness/codexConfigMerger.d.ts.map +1 -1
  62. package/dist/harness/codexConfigMerger.js +4 -0
  63. package/dist/harness/codexConfigMerger.js.map +1 -1
  64. package/dist/harness/codexHooks.d.ts.map +1 -1
  65. package/dist/harness/codexHooks.js +3 -0
  66. package/dist/harness/codexHooks.js.map +1 -1
  67. package/dist/harness/continueConfigMerger.d.ts.map +1 -1
  68. package/dist/harness/continueConfigMerger.js +4 -0
  69. package/dist/harness/continueConfigMerger.js.map +1 -1
  70. package/dist/harness/continueHooks.d.ts.map +1 -1
  71. package/dist/harness/continueHooks.js +3 -0
  72. package/dist/harness/continueHooks.js.map +1 -1
  73. package/dist/harness/cursorHooks.d.ts.map +1 -1
  74. package/dist/harness/cursorHooks.js +3 -0
  75. package/dist/harness/cursorHooks.js.map +1 -1
  76. package/dist/harness/dshHooks.d.ts.map +1 -1
  77. package/dist/harness/dshHooks.js +7 -0
  78. package/dist/harness/dshHooks.js.map +1 -1
  79. package/dist/harness/gateBody.d.ts +11 -2
  80. package/dist/harness/gateBody.d.ts.map +1 -1
  81. package/dist/harness/gateBody.js +33 -6
  82. package/dist/harness/gateBody.js.map +1 -1
  83. package/dist/harness/githubCopilotHooks.d.ts.map +1 -1
  84. package/dist/harness/githubCopilotHooks.js +4 -9
  85. package/dist/harness/githubCopilotHooks.js.map +1 -1
  86. package/dist/harness/gooseHooks.d.ts +15 -0
  87. package/dist/harness/gooseHooks.d.ts.map +1 -1
  88. package/dist/harness/gooseHooks.js +55 -43
  89. package/dist/harness/gooseHooks.js.map +1 -1
  90. package/dist/harness/grokHooks.d.ts.map +1 -1
  91. package/dist/harness/grokHooks.js +9 -12
  92. package/dist/harness/grokHooks.js.map +1 -1
  93. package/dist/harness/hermesHooks.d.ts.map +1 -1
  94. package/dist/harness/hermesHooks.js +7 -2
  95. package/dist/harness/hermesHooks.js.map +1 -1
  96. package/dist/harness/holdRedaction.d.ts +4 -1
  97. package/dist/harness/holdRedaction.d.ts.map +1 -1
  98. package/dist/harness/holdRedaction.js +32 -8
  99. package/dist/harness/holdRedaction.js.map +1 -1
  100. package/dist/harness/jetbrainsXmlConfig.d.ts +20 -0
  101. package/dist/harness/jetbrainsXmlConfig.d.ts.map +1 -1
  102. package/dist/harness/jetbrainsXmlConfig.js +39 -18
  103. package/dist/harness/jetbrainsXmlConfig.js.map +1 -1
  104. package/dist/harness/mcpAutoWrite.d.ts +39 -17
  105. package/dist/harness/mcpAutoWrite.d.ts.map +1 -1
  106. package/dist/harness/mcpAutoWrite.js +189 -71
  107. package/dist/harness/mcpAutoWrite.js.map +1 -1
  108. package/dist/harness/museHooks.d.ts.map +1 -1
  109. package/dist/harness/museHooks.js +6 -2
  110. package/dist/harness/museHooks.js.map +1 -1
  111. package/dist/harness/openCodeHooks.d.ts.map +1 -1
  112. package/dist/harness/openCodeHooks.js +2 -5
  113. package/dist/harness/openCodeHooks.js.map +1 -1
  114. package/dist/harness/openWebuiHooks.d.ts.map +1 -1
  115. package/dist/harness/openWebuiHooks.js +6 -2
  116. package/dist/harness/openWebuiHooks.js.map +1 -1
  117. package/dist/harness/openclawHooks.d.ts +5 -0
  118. package/dist/harness/openclawHooks.d.ts.map +1 -1
  119. package/dist/harness/openclawHooks.js +3 -1
  120. package/dist/harness/openclawHooks.js.map +1 -1
  121. package/dist/harness/openhandsHooks.d.ts +13 -1
  122. package/dist/harness/openhandsHooks.d.ts.map +1 -1
  123. package/dist/harness/openhandsHooks.js +106 -56
  124. package/dist/harness/openhandsHooks.js.map +1 -1
  125. package/dist/harness/piHooks.d.ts.map +1 -1
  126. package/dist/harness/piHooks.js +3 -0
  127. package/dist/harness/piHooks.js.map +1 -1
  128. package/dist/harness/rooCodeHooks.d.ts.map +1 -1
  129. package/dist/harness/rooCodeHooks.js +5 -10
  130. package/dist/harness/rooCodeHooks.js.map +1 -1
  131. package/dist/harness/windsurfHooks.d.ts +18 -2
  132. package/dist/harness/windsurfHooks.d.ts.map +1 -1
  133. package/dist/harness/windsurfHooks.js +37 -7
  134. package/dist/harness/windsurfHooks.js.map +1 -1
  135. package/dist/harness/windsurfJetBrainsProxy.d.ts +1 -1
  136. package/dist/harness/windsurfJetBrainsProxy.d.ts.map +1 -1
  137. package/dist/harness/windsurfJetBrainsProxy.js +5 -1
  138. package/dist/harness/windsurfJetBrainsProxy.js.map +1 -1
  139. package/dist/index.d.ts +9 -12
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js +8 -10
  142. package/dist/index.js.map +1 -1
  143. package/dist/lib/decisionsDigest.d.ts +1 -1
  144. package/dist/lib/decisionsDigest.js +1 -1
  145. package/dist/lib/policySnapshot.d.ts +18 -0
  146. package/dist/lib/policySnapshot.d.ts.map +1 -1
  147. package/dist/lib/policySnapshot.js +142 -7
  148. package/dist/lib/policySnapshot.js.map +1 -1
  149. package/dist/sessionReporter.d.ts +2 -2
  150. package/dist/sessionReporter.js +2 -2
  151. package/dist/syncCycle.d.ts +142 -0
  152. package/dist/syncCycle.d.ts.map +1 -0
  153. package/dist/syncCycle.js +315 -0
  154. package/dist/syncCycle.js.map +1 -0
  155. package/dist/trajectoryMonitor.d.ts +1 -1
  156. package/dist/trajectoryMonitor.d.ts.map +1 -1
  157. package/dist/trajectoryMonitor.js +1 -1
  158. package/dist/trajectoryMonitor.js.map +1 -1
  159. package/dist/watcher/settingsGuard.d.ts +4 -1
  160. package/dist/watcher/settingsGuard.d.ts.map +1 -1
  161. package/dist/watcher/settingsGuard.js +28 -3
  162. package/dist/watcher/settingsGuard.js.map +1 -1
  163. package/package.json +5 -5
  164. package/dist/hashReporter.d.ts +0 -33
  165. package/dist/hashReporter.d.ts.map +0 -1
  166. package/dist/hashReporter.js +0 -69
  167. package/dist/hashReporter.js.map +0 -1
  168. package/dist/integrityStore.d.ts +0 -35
  169. package/dist/integrityStore.d.ts.map +0 -1
  170. package/dist/integrityStore.js +0 -71
  171. package/dist/integrityStore.js.map +0 -1
  172. package/dist/lib/gitWorktrees.d.ts +0 -140
  173. package/dist/lib/gitWorktrees.d.ts.map +0 -1
  174. package/dist/lib/gitWorktrees.js +0 -191
  175. package/dist/lib/gitWorktrees.js.map +0 -1
  176. package/dist/syncLoop.d.ts +0 -172
  177. package/dist/syncLoop.d.ts.map +0 -1
  178. package/dist/syncLoop.js +0 -878
  179. package/dist/syncLoop.js.map +0 -1
@@ -1,13 +1,9 @@
1
1
  /**
2
- * configWriter.ts — Write SOP content to harness config files.
2
+ * configWriter.ts — the harness rules-file map, local SOP loading, SkillOpt
3
+ * config edits and the atomic write they share.
3
4
  *
4
- * Each harness (Cursor, Claude Code, Antigravity, Windsurf, Aider,
5
- * OpenHands, Codex) has a distinct config file format. This module
6
- * resolves paths, formats content, and performs atomic writes
7
- * (write-to-tmp → rename) to prevent partial/corrupt files.
8
- *
9
- * HLD §3.14 — Real-Time State Mirroring
10
- * LLD #8 — Sync Daemon / CLI
5
+ * The harness config files themselves are written by the CLI's adapters
6
+ * (tools/cli/src/harness), which `intutic connect` runs.
11
7
  *
12
8
  * @module
13
9
  */
@@ -15,15 +11,13 @@ import * as node_fs from 'node:fs/promises';
15
11
  import * as node_path from 'node:path';
16
12
  import { execFile as _execFile } from 'node:child_process';
17
13
  import { promisify } from 'node:util';
18
- import { newIso } from '@intutic/id';
19
- import { proxyHost } from '@intutic/shared-types';
20
14
  const execFile = promisify(_execFile);
21
15
  /**
22
- * Clear the macOS user-immutable flag before writing a file.
23
- * No-op on non-macOS platforms or if the file doesn't exist yet.
24
- * Called when bypassEnforcementTier === 'immutable'. (WS-5 Q3)
16
+ * Clear the macOS user-immutable flag so the daemon can rewrite a file it
17
+ * write-protected (the workspace's `bypassEnforcementTier: 'immutable'`).
18
+ * No-op on other platforms or if the file does not exist yet.
25
19
  */
26
- async function clearImmutable(filePath) {
20
+ export async function clearImmutable(filePath) {
27
21
  if (process.platform !== 'darwin')
28
22
  return;
29
23
  try {
@@ -32,12 +26,11 @@ async function clearImmutable(filePath) {
32
26
  catch { /* file may not exist yet */ }
33
27
  }
34
28
  /**
35
- * Set the macOS user-immutable flag after writing a file.
36
- * Prevents direct edits from succeeding — any attempt gets EPERM.
37
- * The flag is cleared before the next sync write.
38
- * No-op on non-macOS platforms. (WS-5 Q3)
29
+ * Set the macOS user-immutable flag (`chflags uchg`), so a hand edit of a
30
+ * managed file fails with EPERM. The flag needs no root to set or clear; it
31
+ * stops casual editing, not a determined user. No-op on other platforms.
39
32
  */
40
- async function setImmutable(filePath) {
33
+ export async function setImmutable(filePath) {
41
34
  if (process.platform !== 'darwin')
42
35
  return;
43
36
  try {
@@ -45,25 +38,16 @@ async function setImmutable(filePath) {
45
38
  }
46
39
  catch { /* non-fatal */ }
47
40
  }
48
- import { writeAntigravityHooks } from './harness/antigravityHooks.js';
49
- import { writeClaudeDesktopHooks } from './harness/claudeDesktopHooks.js';
50
- import { writeRooCodeHooks } from './harness/rooCodeHooks.js';
51
- import { writeContinueHooks } from './harness/continueHooks.js';
52
- import { writeOpenWebuiHooks } from './harness/openWebuiHooks.js';
53
- import { writeN8nHooks } from './harness/n8nHooks.js';
54
- import { writeHermesHooks } from './harness/hermesHooks.js';
55
- import { writeOpenclawHooks } from './harness/openclawHooks.js';
56
- import { writePiHooks } from './harness/piHooks.js';
57
- import { writeCodexHooks } from './harness/codexHooks.js';
58
- import { writeGithubCopilotHooks } from './harness/githubCopilotHooks.js';
59
- import { writeMuseHooks } from './harness/museHooks.js';
60
- import { writeOpenCodeHooks } from './harness/openCodeHooks.js';
61
- import { writeGrokHooks } from './harness/grokHooks.js';
62
41
  // ─── Harness config file mapping ─────────────────────────────────────
63
42
  /**
64
- * Maps each harness type to its expected config filename relative to
65
- * the workspace root. Empty string means the harness is deferred to
66
- * Phase 2 (e.g., n8n — TD-037).
43
+ * Each harness's rules file, relative to the workspace root: the file the
44
+ * drift watcher watches, config capture uploads, and SkillOpt edits and the
45
+ * decisions log write into. An empty string means the harness has no
46
+ * workspace rules file: its governance lives elsewhere (dsh under $DSH_HOME),
47
+ * or it writes no config of its own because it delegates to a wrapped
48
+ * harness's gate (Xirp, Agentic Orchestrator, AgentCore Runtime) or is gated
49
+ * by a service (TrueForge server). The SDK-gated frameworks share
50
+ * `.env.intutic`, which carries the proxy variables.
67
51
  */
68
52
  export const HARNESS_FILES = {
69
53
  cursor: '.cursorrules',
@@ -85,39 +69,13 @@ export const HARNESS_FILES = {
85
69
  goose: '.agents/plugins/intutic-governance/hooks/hooks.json',
86
70
  'open-webui': '.open-webui/intutic-governance-filter.py',
87
71
  langgraph: '.env.intutic',
88
- // Muse Code reads AGENTS.md (falling back to CLAUDE.md) — see muse.ts (CLI)
89
- // and museHooks.ts (the hook writer invoked below, same split codex uses).
72
+ // Muse Code, Grok Build and OpenCode all read AGENTS.md.
90
73
  'muse-code': 'AGENTS.md',
91
- // Grok Build's native rules file — same cross-tool convention Codex/Amp
92
- // read. Formatted by `formatMarkdown`, the same `---`-separated formatter
93
- // Cursor/Claude Code/Windsurf/GitHub Copilot already share below.
94
74
  grok: 'AGENTS.md',
95
- // OpenCode reads AGENTS.md (CLAUDE.md fallback) — the same markdown rules
96
- // file Muse/Grok get. The gate is the plugin `writeOpenCodeHooks` writes
97
- // below, not this file.
98
75
  opencode: 'AGENTS.md',
99
- // dsh has no workspace-relative rules file (governance lives entirely
100
- // under $DSH_HOME) — empty, same as goose/openhands below: this writer's
101
- // per-harness chain deliberately does not call writeDshHooks either (see
102
- // the "goose and openhands are deliberately absent here" comment above);
103
- // dshHooks.ts is invoked by tools/cli/src/harness/dsh.ts's own
104
- // writeConfig() and re-run on tamper by settingsGuard.ts, the same
105
- // two-path coverage goose/openhands rely on instead of this loop.
106
76
  dsh: '',
107
- // Xirp writes no config of its own (orchestrates other already-gated
108
- // harnesses — see gateRegistry.ts's NO_GATE row and tools/cli/src/harness/
109
- // xirp.ts). Empty filename => the loop below reports it `(deferred)`,
110
- // same as n8n before it gained a writer.
111
77
  xirp: '',
112
- // Agentic Orchestrator writes no config of its own either — same
113
- // "delegated" shape as Xirp (orchestrates already-gated Claude Code, Codex
114
- // and OpenCode — see gateRegistry.ts's NO_GATE row and
115
- // tools/cli/src/harness/agenticOrchestrator.ts).
116
78
  'agentic-orchestrator': '',
117
- // Wave 1 SDK-gated frameworks — same rationale as langgraph: no on-disk
118
- // hook/config file exists to gate tool calls, so each writes .env.intutic
119
- // (proxy base-URL vars + an SDK-gate pointer comment). See formatContent's
120
- // switch below and SDK_GATED_FRAMEWORKS.
121
79
  langchain: '.env.intutic',
122
80
  crewai: '.env.intutic',
123
81
  autogen: '.env.intutic',
@@ -126,57 +84,21 @@ export const HARNESS_FILES = {
126
84
  'openai-agents': '.env.intutic',
127
85
  'pydantic-ai': '.env.intutic',
128
86
  smolagents: '.env.intutic',
129
- // A4: AWS Strands Agents — same Python SDK-gated rationale as the Wave 1
130
- // family above (gate ships in intutic_clawde.gate.adapters.strands).
131
87
  strands: '.env.intutic',
132
- // TD-375: Microsoft Agent Framework — same Python SDK-gated rationale
133
- // (gate ships in intutic_clawde.gate.adapters.agent_framework).
134
88
  'agent-framework': '.env.intutic',
135
- // T2: JS/TS SDK-gated frameworks — same rationale as the Wave 1 Python
136
- // family above, but the blocking gate ships in @intutic/gate
137
- // (packages/gate-js) rather than intutic-clawde. See formatContent's
138
- // switch below and JS_SDK_GATED_FRAMEWORKS.
139
89
  mastra: '.env.intutic',
140
90
  'vercel-ai-sdk': '.env.intutic',
141
- // eve (Vercel, PREVIEW) — same JS/TS SDK-gated family: the gate is
142
- // @intutic/gate/eve's per-tool/per-connection approval policies, attached
143
- // in the developer's own agent/ directory; this file only carries the
144
- // proxy vars + pointer comment. See JS_SDK_GATED_FRAMEWORKS below.
145
91
  eve: '.env.intutic',
146
- // TrueForge (embedded-library mode only — see its HarnessType doc) — same
147
- // JS/TS SDK-gated family, gate ships in @intutic/gate/trueforge. See
148
- // formatContent's switch below and JS_SDK_GATED_FRAMEWORKS.
149
92
  trueforge: '.env.intutic',
150
- // A3: Vercel platform-agent runtimes — same @intutic/gate family as the T2
151
- // rows above. For ai-sdk-harness the env vars are weaker still: tool
152
- // execution is server-side in Vercel Sandbox microVMs the local proxy
153
- // never sees (the generated comment says so — see JS_SDK_GATED_FRAMEWORKS'
154
- // preamble override below and @intutic/gate/harness's module doc).
155
93
  'ai-sdk-harness': '.env.intutic',
156
94
  'ai-sdk-workflow': '.env.intutic',
157
- // B2: AWS Bedrock AgentCore Runtime — hosts the customer's own framework
158
- // code unchanged, so it writes no config of its own; the real tool-call
159
- // gate belongs to whichever already-supported framework adapter that code
160
- // uses (Strands, LangGraph, ...). Same 'delegated'/empty-filename shape as
161
- // xirp/agentic-orchestrator above — see tools/cli/src/harness/agentcore.ts
162
- // and gateKind.ts's DELEGATED_GATE_HARNESSES.
163
95
  'agentcore-runtime': '',
164
- // B3: TrueForge, standalone/hosted server (see its HarnessType doc) —
165
- // writes no config of its own: it is not detected by intutic init at all
166
- // (an operator-configured deployment, not a repo dependency this daemon's
167
- // scanner can find), and its gate is entirely out-of-process in
168
- // services/trueforge-bridge, not a file this daemon writes. Empty filename
169
- // => the loop below reports it `(deferred)`, same shape as
170
- // xirp/agentic-orchestrator/agentcore-runtime above, though for a
171
- // genuinely different reason — those are 'delegated' (governed by a
172
- // wrapped harness's own gate); this is 'bridge' (governed by a service
173
- // this repo ships and operates). See gateKind.ts's BRIDGE_GATED_HARNESSES.
174
96
  'trueforge-server': '',
175
97
  };
176
98
  /**
177
99
  * The workspace's local SOPs (`.intutic/sops/<dir>/*.md`, narrowed by
178
- * `session-context.json`'s `activeLocalSops` when present). Shared by the
179
- * config writer and by the gate-cache refresh, which compiles their
100
+ * `session-context.json`'s `activeLocalSops` when present). Read by the
101
+ * gate-cache refresh, which compiles their
180
102
  * `review_before:` tokens into hold rules (TD-474 item 4). A missing
181
103
  * directory is an empty list.
182
104
  */
@@ -221,215 +143,6 @@ export async function loadLocalSopEntries(workspaceRoot, harnesses) {
221
143
  }
222
144
  return localSopEntries;
223
145
  }
224
- /**
225
- * Write SOP content to all targeted harness config files.
226
- *
227
- * For each harness type, resolves the config file path, formats the
228
- * content according to the harness-specific format, and performs an
229
- * atomic write (tmp file → rename).
230
- *
231
- * @param workspaceRoot - Absolute path to the workspace root.
232
- * @param sops - SOPs to write, each specifying which harnesses to target.
233
- * @param proxyUrl - Intutic proxy URL for LLM API redirect.
234
- * @param harnesses - Harness types detected in the workspace.
235
- * @returns WriteResult with written and skipped file paths.
236
- */
237
- export async function writeConfigFiles(workspaceRoot, sops, proxyUrl, harnesses, workspaceId = '',
238
- /** WS-5 Q3: 'rewrite' (default) | 'immutable' | 'alert-only' */
239
- bypassEnforcementTier) {
240
- const filesWritten = [];
241
- const filesSkipped = [];
242
- // Bundled agent skills — write-if-missing, not drift-enforced
243
- try {
244
- const { writeBundledSkills } = await import('./skillWriter.js');
245
- await writeBundledSkills(workspaceRoot);
246
- }
247
- catch (e) {
248
- console.warn('[sync-daemon] writeBundledSkills failed (non-fatal):', e);
249
- }
250
- const localSopEntries = await loadLocalSopEntries(workspaceRoot, harnesses);
251
- const combinedSops = [...sops, ...localSopEntries];
252
- for (const harness of harnesses) {
253
- const filename = HARNESS_FILES[harness];
254
- // Phase 3 proprietary harnesses — no config file path needed (handled below)
255
- if (harness === 'hermes') {
256
- try {
257
- await writeHermesHooks(workspaceRoot, proxyUrl, workspaceId);
258
- }
259
- catch (e) {
260
- console.warn('[sync-daemon] writeHermesHooks failed (non-fatal):', e);
261
- }
262
- continue;
263
- }
264
- if (harness === 'openclaw') {
265
- try {
266
- await writeOpenclawHooks(workspaceRoot, proxyUrl, workspaceId);
267
- }
268
- catch (e) {
269
- console.warn('[sync-daemon] writeOpenclawHooks failed (non-fatal):', e);
270
- }
271
- continue;
272
- }
273
- if (harness === 'pi') {
274
- try {
275
- await writePiHooks(workspaceRoot, proxyUrl, workspaceId);
276
- }
277
- catch (e) {
278
- console.warn('[sync-daemon] writePiHooks failed (non-fatal):', e);
279
- }
280
- continue;
281
- }
282
- // cursor is deliberately absent here, for the same reason goose and
283
- // openhands are below.
284
- //
285
- // `cursorHooksJson` was a second writer of `.cursor/hooks.json`, and the two
286
- // disagreed about the file's schema: `cursorHooks` writes an object per
287
- // event carrying `failClosed: true`, while `cursorHooksJson.mergeHooks`
288
- // tested `Array.isArray(existing[event])`, found false, and REPLACED it with
289
- // a bare `{command}` array. So it silently dropped fail-closed and repointed
290
- // the user-level shell and MCP gates at `~/.intutic/hooks/cursor-check.js`,
291
- // a path no writer produces. `cursorHooks` already registers a superset of
292
- // its events at both levels, so it is deleted rather than repaired.
293
- // goose and openhands are deliberately absent here.
294
- //
295
- // They each used to get a *second* gate from this call site —
296
- // gooseHooksWriter.ts and openhandsHooksWriter.ts — installed alongside the
297
- // one their own writer produces. The two had contradictory models: the
298
- // survivors enforce locally and fail closed, these POSTed every tool call to
299
- // the control plane and failed open on any error or timeout. For openhands
300
- // both wrote `.openhands/hooks.json`, so whichever ran last silently won.
301
- //
302
- // Deleted rather than deprecated: two modules exporting the same symbol for
303
- // one harness *is* the defect. And they are not replaced by calls to the
304
- // survivors here — a second call site is how this started.
305
- // Phase 2 deferred or unknown harness
306
- if (!filename) {
307
- filesSkipped.push(`[${harness}] (deferred)`);
308
- continue;
309
- }
310
- const configPath = node_path.join(workspaceRoot, filename);
311
- // Filter SOPs that target this harness
312
- const targetedSops = combinedSops.filter((sop) => sop.harnessTargets.includes(harness));
313
- if (targetedSops.length === 0) {
314
- filesSkipped.push(configPath);
315
- continue;
316
- }
317
- const content = formatContent(harness, targetedSops, proxyUrl);
318
- try {
319
- await atomicWrite(configPath, content, bypassEnforcementTier);
320
- filesWritten.push(configPath);
321
- // For 'antigravity', also write the governance hook script and settings.json merge.
322
- // This is separate from the SOP content write above (which writes customInstructions).
323
- if (harness === 'antigravity') {
324
- try {
325
- await writeAntigravityHooks(workspaceRoot, proxyUrl, workspaceId);
326
- }
327
- catch (hookErr) {
328
- // Non-fatal — SOP content was written, only the hook script failed
329
- console.warn('[sync-daemon] writeAntigravityHooks failed (non-fatal):', hookErr);
330
- }
331
- }
332
- if (harness === 'claude-desktop') {
333
- try {
334
- await writeClaudeDesktopHooks(workspaceRoot, proxyUrl, workspaceId);
335
- }
336
- catch (e) {
337
- console.warn('[sync-daemon] writeClaudeDesktopHooks failed (non-fatal):', e);
338
- }
339
- }
340
- if (harness === 'roo-code') {
341
- try {
342
- await writeRooCodeHooks(workspaceRoot, proxyUrl, workspaceId);
343
- }
344
- catch (e) {
345
- console.warn('[sync-daemon] writeRooCodeHooks failed (non-fatal):', e);
346
- }
347
- }
348
- if (harness === 'continue') {
349
- try {
350
- await writeContinueHooks(workspaceRoot, proxyUrl, workspaceId);
351
- }
352
- catch (e) {
353
- console.warn('[sync-daemon] writeContinueHooks failed (non-fatal):', e);
354
- }
355
- }
356
- if (harness === 'open-webui') {
357
- try {
358
- await writeOpenWebuiHooks(workspaceRoot, proxyUrl, workspaceId);
359
- }
360
- catch (e) {
361
- console.warn('[sync-daemon] writeOpenWebuiHooks failed (non-fatal):', e);
362
- }
363
- }
364
- if (harness === 'n8n') {
365
- try {
366
- await writeN8nHooks(workspaceRoot, proxyUrl, workspaceId);
367
- }
368
- catch (e) {
369
- console.warn('[sync-daemon] writeN8nHooks failed (non-fatal):', e);
370
- }
371
- }
372
- // The .env.intutic proxy routing above governs LLM egress only; the gate
373
- // is what refuses tool calls. Written alongside, same as claude-desktop.
374
- if (harness === 'codex') {
375
- try {
376
- await writeCodexHooks(workspaceRoot, proxyUrl, workspaceId);
377
- }
378
- catch (e) {
379
- console.warn('[sync-daemon] writeCodexHooks failed (non-fatal):', e);
380
- }
381
- }
382
- // Preview mechanism (VS Code agent hooks) — the writer's header says so,
383
- // and the gate fails closed if the stdin shape shifts.
384
- if (harness === 'github-copilot') {
385
- try {
386
- await writeGithubCopilotHooks(workspaceRoot, proxyUrl, workspaceId);
387
- }
388
- catch (e) {
389
- console.warn('[sync-daemon] writeGithubCopilotHooks failed (non-fatal):', e);
390
- }
391
- }
392
- // Same split as codex/claude-desktop: AGENTS.md above carries the rules
393
- // text, this installs the PreToolUse/PermissionRequest gate (project +
394
- // managed tiers) and the managed_hooks_path merge into settings.json.
395
- if (harness === 'muse-code') {
396
- try {
397
- await writeMuseHooks(workspaceRoot, proxyUrl, workspaceId);
398
- }
399
- catch (e) {
400
- console.warn('[sync-daemon] writeMuseHooks failed (non-fatal):', e);
401
- }
402
- }
403
- // AGENTS.md above carries the rules text; this writes the plugin
404
- // OpenCode loads into its own process, which is the gate (TD-397).
405
- if (harness === 'opencode') {
406
- try {
407
- await writeOpenCodeHooks(workspaceRoot, proxyUrl, workspaceId);
408
- }
409
- catch (e) {
410
- console.warn('[sync-daemon] writeOpenCodeHooks failed (non-fatal):', e);
411
- }
412
- }
413
- // AGENTS.md above governs prompt-level rules only; the gate is what
414
- // refuses tool calls, and the config.toml model base_url merge is what
415
- // routes LLM egress. Written alongside, same as codex/claude-desktop.
416
- if (harness === 'grok') {
417
- try {
418
- await writeGrokHooks(workspaceRoot, proxyUrl, workspaceId);
419
- }
420
- catch (e) {
421
- console.warn('[sync-daemon] writeGrokHooks failed (non-fatal):', e);
422
- }
423
- }
424
- }
425
- catch (err) {
426
- console.warn(`[sync-daemon] writeConfigFiles failed for ${filename}:`, err);
427
- // Don't crash the loop — report as skipped
428
- filesSkipped.push(configPath);
429
- }
430
- }
431
- return { filesWritten, filesSkipped };
432
- }
433
146
  /**
434
147
  * Finds a match for a target block in content, tolerating line ending and whitespace variations.
435
148
  */
@@ -468,7 +181,7 @@ function findFuzzyMatch(content, target) {
468
181
  * of `void` — every operation's real fate (fuzzy-match miss on DELETE/
469
182
  * REPLACE, an unresolvable target file, or the final `atomicWrite` itself
470
183
  * failing) is recorded here rather than only `console.warn`'d, so the caller
471
- * (syncLoop.ts) can ack the daemon's actual outcome back to control-plane
184
+ * (`applySkillOptEdits`, syncCycle.ts) can ack the daemon's actual outcome back to control-plane
472
185
  * instead of the daemon-side write being invisible to it.
473
186
  */
474
187
  export async function applyConfigEdits(workspaceRoot, appliedEdits, bypassEnforcementTier) {
@@ -590,328 +303,6 @@ export async function applyConfigEdits(workspaceRoot, appliedEdits, bypassEnforc
590
303
  }
591
304
  return outcomes;
592
305
  }
593
- // ─── Formatters ──────────────────────────────────────────────────────
594
- /** Standard file header injected at the top of every auto-generated file. */
595
- function fileHeader() {
596
- return [
597
- '# Intutic Governance Rules (auto-generated)',
598
- '# DO NOT EDIT — managed by intutic sync daemon',
599
- `# Last sync: ${newIso()}`,
600
- '',
601
- '',
602
- ].join('\n');
603
- }
604
- /**
605
- * Format SOP content for a specific harness type.
606
- *
607
- * Each harness has a distinct format:
608
- * - Cursor / Claude Code / Windsurf → Markdown with `---` separators
609
- * - Antigravity → JSON with `customInstructions` field
610
- * - Aider → YAML with `extra-instructions` field
611
- * - OpenHands → TOML with `[intutic]` section
612
- * - Codex → `.env.intutic` with proxy URL vars
613
- */
614
- function formatContent(harness, sops, proxyUrl) {
615
- switch (harness) {
616
- case 'cursor':
617
- case 'claude-code':
618
- case 'windsurf':
619
- case 'github-copilot':
620
- case 'grok':
621
- return formatMarkdown(sops);
622
- case 'antigravity':
623
- return formatAntigravity(sops);
624
- case 'aider':
625
- return formatAider(sops);
626
- case 'openhands':
627
- return formatOpenHands(sops);
628
- case 'codex':
629
- return formatCodex(sops, proxyUrl);
630
- case 'langgraph':
631
- return formatLanggraph(sops, proxyUrl);
632
- case 'muse-code':
633
- case 'opencode':
634
- // AGENTS.md — same markdown shape as CLAUDE.md/.cursorrules/.windsurfrules.
635
- return formatMarkdown(sops);
636
- case 'langchain':
637
- case 'crewai':
638
- case 'autogen':
639
- case 'ag2':
640
- case 'google-adk':
641
- case 'openai-agents':
642
- case 'pydantic-ai':
643
- case 'smolagents':
644
- case 'strands':
645
- case 'agent-framework':
646
- return formatSdkGatedEnv(sops, proxyUrl, SDK_GATED_FRAMEWORKS[harness]);
647
- case 'mastra':
648
- case 'vercel-ai-sdk':
649
- case 'eve':
650
- case 'trueforge':
651
- case 'ai-sdk-harness':
652
- case 'ai-sdk-workflow':
653
- return formatJsSdkGatedEnv(sops, proxyUrl, JS_SDK_GATED_FRAMEWORKS[harness]);
654
- default:
655
- return formatMarkdown(sops);
656
- }
657
- }
658
- /** Cursor / Claude Code / Windsurf: Markdown with `---` separators. */
659
- function formatMarkdown(sops) {
660
- const header = fileHeader();
661
- const sections = sops.map((sop) => {
662
- // Hybrid approach: full SOP content + sop:// pointer comment for traceability
663
- const ref = sop.sopRef ? `\n${sop.sopRef}` : '';
664
- return [`## ${sop.title}`, '', sop.content + ref].join('\n');
665
- });
666
- return header + sections.join('\n\n---\n\n') + '\n';
667
- }
668
- /** Antigravity: JSON with `customInstructions` field. */
669
- function formatAntigravity(sops) {
670
- const combinedContent = sops
671
- .map((sop) => `## ${sop.title}\n\n${sop.content}`)
672
- .join('\n\n---\n\n');
673
- const payload = {
674
- _comment: 'Intutic Governance Rules (auto-generated) — DO NOT EDIT',
675
- _lastSync: newIso(),
676
- customInstructions: combinedContent,
677
- };
678
- return JSON.stringify(payload, null, 2) + '\n';
679
- }
680
- /** Aider: YAML with `extra-instructions` field. */
681
- function formatAider(sops) {
682
- const header = fileHeader();
683
- const combinedContent = sops
684
- .map((sop) => `## ${sop.title}\n\n${sop.content}`)
685
- .join('\n\n---\n\n');
686
- // YAML multiline block scalar using `|`
687
- const indented = combinedContent
688
- .split('\n')
689
- .map((line) => ` ${line}`)
690
- .join('\n');
691
- return header + `extra-instructions: |\n${indented}\n`;
692
- }
693
- /** OpenHands: TOML with `[intutic]` section. */
694
- function formatOpenHands(sops) {
695
- const header = fileHeader();
696
- const combinedContent = sops
697
- .map((sop) => `## ${sop.title}\n\n${sop.content}`)
698
- .join('\n\n---\n\n');
699
- // TOML multiline basic string uses triple quotes
700
- const escaped = combinedContent
701
- .replace(/\\/g, '\\\\')
702
- .replace(/"""/g, '\\"\\"\\"');
703
- return (header +
704
- `[intutic]\n` +
705
- `last_sync = "${newIso()}"\n` +
706
- `governance_rules = """\n${escaped}\n"""\n`);
707
- }
708
- /** Codex: `.env.intutic` with proxy URL vars. */
709
- function formatCodex(sops, proxyUrl) {
710
- const header = fileHeader();
711
- const sopIds = sops.map((sop) => sop.sopId).join(',');
712
- return (header +
713
- `INTUTIC_PROXY_URL=${proxyHost(proxyUrl)}\n` +
714
- `INTUTIC_SOP_IDS=${sopIds}\n` +
715
- `INTUTIC_LAST_SYNC=${newIso()}\n`);
716
- }
717
- /**
718
- * LangGraph: `.env.intutic` with proxy URL vars, plus a pointer at the
719
- * SDK-side tool gate. LangGraph tools are plain Python callables in the
720
- * agent's own process — there is no config or hook file this daemon could
721
- * write a tool-call gate into, so the env vars govern LLM egress only and
722
- * the blocking gate ships in `intutic-clawde` (`intutic_clawde.gate`).
723
- */
724
- function formatLanggraph(sops, proxyUrl) {
725
- return (formatCodex(sops, proxyUrl) +
726
- '\n' +
727
- '# These env vars govern LLM egress only. LangGraph tools run in your own\n' +
728
- '# Python process, where no config or hook file can gate them — the\n' +
729
- '# blocking tool gate ships SDK-side:\n' +
730
- '# pip install intutic-clawde\n' +
731
- '# from intutic_clawde.gate import guard_tools\n');
732
- }
733
- /**
734
- * Wave 1: seven more frameworks in LangGraph's family — tools are plain
735
- * Python callables/objects in the agent's own process, so the daemon has no
736
- * on-disk hook/config file to gate a call with, and every one of these
737
- * writes the same `.env.intutic` shape `formatLanggraph` does (proxy URL
738
- * vars + a comment pointing at the SDK-side gate). Declared as data here,
739
- * rather than as seven more hand-copied `formatXxx` functions, so the shape
740
- * cannot drift per-framework the way `gateBody.ts`'s module doc warns
741
- * hand-copied gate logic does.
742
- *
743
- * `pipExtra` is omitted for the three frameworks with no dedicated
744
- * `intutic_clawde.gate.adapters.*` module yet (autogen, ag2, pydantic-ai,
745
- * smolagents ship in a later wave — see `gateRegistry.ts`'s NO_GATE rows) —
746
- * their tools are governed today through the framework-agnostic
747
- * `@guard`/`guard_tools` helpers, which need no optional import.
748
- */
749
- const SDK_GATED_FRAMEWORKS = {
750
- langchain: {
751
- label: 'LangChain',
752
- pipExtra: 'langchain',
753
- importLine: 'from intutic_clawde.gate.adapters.langchain import IntuticMiddleware',
754
- docsSlug: 'langchain',
755
- },
756
- crewai: {
757
- label: 'CrewAI',
758
- pipExtra: 'crewai',
759
- importLine: 'from intutic_clawde.gate.adapters.crewai import install',
760
- docsSlug: 'crewai',
761
- },
762
- autogen: {
763
- label: 'AutoGen',
764
- importLine: 'from intutic_clawde.gate import guard, guard_tools',
765
- docsSlug: 'autogen',
766
- },
767
- ag2: {
768
- label: 'AG2',
769
- importLine: 'from intutic_clawde.gate import guard, guard_tools',
770
- docsSlug: 'ag2',
771
- },
772
- 'google-adk': {
773
- label: 'Google ADK',
774
- pipExtra: 'google-adk',
775
- importLine: 'from intutic_clawde.gate.adapters.google_adk import IntuticPlugin',
776
- docsSlug: 'google-adk',
777
- },
778
- 'openai-agents': {
779
- label: 'OpenAI Agents SDK',
780
- pipExtra: 'openai-agents',
781
- importLine: 'from intutic_clawde.gate.adapters.openai_agents import intutic_tool_guardrail',
782
- docsSlug: 'openai-agents',
783
- },
784
- 'pydantic-ai': {
785
- label: 'Pydantic AI',
786
- importLine: 'from intutic_clawde.gate import guard, guard_tools',
787
- docsSlug: 'pydantic-ai',
788
- },
789
- smolagents: {
790
- label: 'smolagents',
791
- importLine: 'from intutic_clawde.gate import guard, guard_tools',
792
- docsSlug: 'smolagents',
793
- },
794
- // A4: AWS Strands Agents — dedicated adapter module from day one
795
- // (intutic_clawde.gate.adapters.strands), unlike the four `pipExtra`-less
796
- // rows above that started on the framework-agnostic helpers.
797
- strands: {
798
- label: 'Strands Agents',
799
- pipExtra: 'strands',
800
- importLine: 'from intutic_clawde.gate.adapters.strands import IntuticHookProvider',
801
- docsSlug: 'strands',
802
- },
803
- // TD-375: Microsoft Agent Framework — dedicated adapter module from day one.
804
- 'agent-framework': {
805
- label: 'Microsoft Agent Framework',
806
- pipExtra: 'agent-framework',
807
- importLine: 'from intutic_clawde.gate.adapters.agent_framework import IntuticFunctionMiddleware',
808
- docsSlug: 'microsoft-agent-framework',
809
- },
810
- };
811
- /** Shared formatter for every Wave 1 SDK-gated framework — see SDK_GATED_FRAMEWORKS. */
812
- function formatSdkGatedEnv(sops, proxyUrl, info) {
813
- const pipInstall = info.pipExtra ? `intutic-clawde[${info.pipExtra}]` : 'intutic-clawde';
814
- return (formatCodex(sops, proxyUrl) +
815
- '\n' +
816
- `# These env vars govern LLM egress only. ${info.label} tools run in your own\n` +
817
- '# Python process, where no config or hook file can gate them — the\n' +
818
- '# blocking tool gate ships SDK-side:\n' +
819
- `# pip install ${pipInstall}\n` +
820
- `# ${info.importLine}\n` +
821
- `# See https://docs.intutic.ai/integrations/${info.docsSlug}\n`);
822
- }
823
- /**
824
- * T2: two more frameworks in LangGraph's family — tools are plain
825
- * objects/callables in the agent's own Node.js process, so the daemon has no
826
- * on-disk hook/config file to gate a call with, and both write the same
827
- * `.env.intutic` shape the Python family does. JS/TS-native, so the pointer
828
- * comment reads `npm install`/`import { ... } from '@intutic/gate/<subpath>'`
829
- * rather than `pip install`/`from intutic_clawde...` — see
830
- * `formatJsSdkGatedEnv`.
831
- */
832
- const JS_SDK_GATED_FRAMEWORKS = {
833
- mastra: {
834
- label: 'Mastra',
835
- importLine: "import { intuticHooks } from '@intutic/gate/mastra'",
836
- usageSummary: "new Agent({ ..., hooks: intuticHooks() }) — Mastra's beforeToolCall veto point. NOTE: " +
837
- 'per-call `hooks` on .generate()/.stream() OVERRIDE this, not merge with it.',
838
- docsSlug: 'mastra',
839
- },
840
- 'vercel-ai-sdk': {
841
- label: 'Vercel AI SDK',
842
- importLine: "import { intuticToolApproval, withIntuticProxy } from '@intutic/gate/vercel'",
843
- usageSummary: 'generateText({ ..., toolApproval: intuticToolApproval() }) — the toolApproval veto ' +
844
- 'point. NOTE: this framework has NO env-var LLM-egress routing; the vars above do not ' +
845
- 'route it — use withIntuticProxy(createOpenAI)(...) or equivalent in code.',
846
- docsSlug: 'vercel-ai-sdk',
847
- },
848
- eve: {
849
- label: 'eve',
850
- importLine: "import { intuticApproval, intuticAuditHooks } from '@intutic/gate/eve'",
851
- usageSummary: 'defineTool({ ..., approval: intuticApproval() }) per tool (and intuticConnectionApproval() ' +
852
- "per MCP/OpenAPI connection) — eve has no agent-level default approval field. NOTE: eve's " +
853
- 'default AI Gateway model routing is NOT proxy-governable; the vars above only reach a ' +
854
- 'direct-provider model built in code via withIntuticProxy(...). PREVIEW product.',
855
- docsSlug: 'eve',
856
- },
857
- trueforge: {
858
- label: 'TrueForge (embedded)',
859
- importLine: "import { intuticApprovalResponder } from '@intutic/gate/trueforge'",
860
- usageSummary: 'intuticApprovalResponder() answers tool.approval_required pauses with a real ' +
861
- 'Gate.guard() verdict, producing user.tool_approval items for your next ' +
862
- 'session.createTurn() call — TrueForge has no synchronous approval callback to hang a ' +
863
- "function off (confirmed against a real install); see that module's doc. Covers ONLY " +
864
- 'the embedded-library deployment mode — TrueForge run as its own server is governed ' +
865
- 'by the TrueForge bridge service instead (see the server-mode docs).',
866
- docsSlug: 'trueforge',
867
- },
868
- 'ai-sdk-harness': {
869
- label: 'AI SDK Harness',
870
- importLine: "import { intuticApprovalResponder, intuticStaticApprovals, recommendedHarnessSettings } from '@intutic/gate/harness'",
871
- usageSummary: 'toolApproval: intuticStaticApprovals(tools) routes every custom tool through the approval ' +
872
- 'flow; answer pauses with intuticApprovalResponder(). NOTE: built-in sandbox tools ignore ' +
873
- "toolApproval entirely — set permissionMode (defaults to 'allow-all') via " +
874
- 'recommendedHarnessSettings(); sandbox egress never crosses this proxy — set a sandbox ' +
875
- 'networkPolicy.',
876
- docsSlug: 'ai-sdk-harness',
877
- envPreamble: [
878
- 'These env vars govern LLM egress from THIS process only. AI SDK Harness',
879
- 'agents execute their tools server-side in Vercel Sandbox microVMs — that',
880
- 'traffic never crosses this proxy, and no config or hook file can gate the',
881
- 'sandbox from here. The blocking tool gate (custom host-executed tools',
882
- 'only) ships SDK-side:',
883
- ],
884
- },
885
- 'ai-sdk-workflow': {
886
- label: 'AI SDK Workflow',
887
- importLine: "import { intuticApprovalStep, withIntuticApproval } from '@intutic/gate/workflow'",
888
- usageSummary: 'new WorkflowAgent({ ..., tools: withIntuticApproval(tools, { step: intuticGate }) }), where ' +
889
- "intuticGate is your own \"use step\" function returning intuticApprovalStep(toolName, input, { gate }) " +
890
- '(needsApproval runs in the workflow sandbox, which has no Node.js). Attaches an async ' +
891
- 'needsApproval per tool (WorkflowAgent itself has no approval option). BLOCK throws a ' +
892
- 'FatalError-compatible refusal so the durable runtime aborts instead of retry-looping ' +
893
- "the denial; ALLOW resolves false (or true with { onAllow: 'human' }).",
894
- docsSlug: 'ai-sdk-workflow',
895
- },
896
- };
897
- /** Shared formatter for every T2 JS/TS SDK-gated framework — see
898
- * JS_SDK_GATED_FRAMEWORKS. Same env-var block `formatSdkGatedEnv` writes,
899
- * but "npm install"/an ESM import line/"Node.js process" in the pointer
900
- * comment, not "pip install"/"Python process". */
901
- function formatJsSdkGatedEnv(sops, proxyUrl, info) {
902
- const preamble = info.envPreamble ?? [
903
- `These env vars govern LLM egress only. ${info.label} tools run in your own`,
904
- 'Node.js process, where no config or hook file can gate them — the',
905
- 'blocking tool gate ships SDK-side:',
906
- ];
907
- return (formatCodex(sops, proxyUrl) +
908
- '\n' +
909
- preamble.map((line) => `# ${line}\n`).join('') +
910
- `# npm install @intutic/gate\n` +
911
- `# ${info.importLine}\n` +
912
- `# ${info.usageSummary}\n` +
913
- `# See https://docs.intutic.ai/integrations/${info.docsSlug}\n`);
914
- }
915
306
  // ─── Atomic file write ───────────────────────────────────────────────
916
307
  /**
917
308
  * Write content to a file atomically.
@@ -920,11 +311,9 @@ function formatJsSdkGatedEnv(sops, proxyUrl, info) {
920
311
  * This prevents partial/corrupt files if the process is interrupted mid-write.
921
312
  *
922
313
  * If bypassEnforcementTier === 'immutable', clears the macOS user-immutable
923
- * flag before writing and re-sets it after (WS-5 Q3).
314
+ * flag before writing and re-sets it after.
924
315
  *
925
- * Exported for reuse by other full-regenerate writers in this daemon (e.g.
926
- * `lib/decisionsDigest.ts`) that want the same write-tmp-then-rename
927
- * atomicity without duplicating it.
316
+ * Exported for `lib/decisionsDigest.ts`, which regenerates whole files too.
928
317
  */
929
318
  export async function atomicWrite(filePath, content, bypassEnforcementTier) {
930
319
  const dir = node_path.dirname(filePath);