@intutic/sync-daemon 2.1.0 → 2.3.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/README.md +1 -1
- package/dist/agentReporter.d.ts +24 -11
- package/dist/agentReporter.d.ts.map +1 -1
- package/dist/agentReporter.js +20 -13
- package/dist/agentReporter.js.map +1 -1
- package/dist/configReader.d.ts +45 -25
- package/dist/configReader.d.ts.map +1 -1
- package/dist/configReader.js +70 -46
- package/dist/configReader.js.map +1 -1
- package/dist/configWriter.d.ts +32 -45
- package/dist/configWriter.d.ts.map +1 -1
- package/dist/configWriter.js +52 -686
- package/dist/configWriter.js.map +1 -1
- package/dist/disconnect/harnesses.d.ts +29 -0
- package/dist/disconnect/harnesses.d.ts.map +1 -0
- package/dist/disconnect/harnesses.js +805 -0
- package/dist/disconnect/harnesses.js.map +1 -0
- package/dist/disconnect/index.d.ts +25 -0
- package/dist/disconnect/index.d.ts.map +1 -0
- package/dist/disconnect/index.js +92 -0
- package/dist/disconnect/index.js.map +1 -0
- package/dist/disconnect/mcp.d.ts +81 -0
- package/dist/disconnect/mcp.d.ts.map +1 -0
- package/dist/disconnect/mcp.js +354 -0
- package/dist/disconnect/mcp.js.map +1 -0
- package/dist/disconnect/originals.d.ts +88 -0
- package/dist/disconnect/originals.d.ts.map +1 -0
- package/dist/disconnect/originals.js +257 -0
- package/dist/disconnect/originals.js.map +1 -0
- package/dist/disconnect/plan.d.ts +175 -0
- package/dist/disconnect/plan.d.ts.map +1 -0
- package/dist/disconnect/plan.js +580 -0
- package/dist/disconnect/plan.js.map +1 -0
- package/dist/disconnect/recognise.d.ts +43 -0
- package/dist/disconnect/recognise.d.ts.map +1 -0
- package/dist/disconnect/recognise.js +108 -0
- package/dist/disconnect/recognise.js.map +1 -0
- package/dist/disconnect/tomlLines.d.ts +39 -0
- package/dist/disconnect/tomlLines.d.ts.map +1 -0
- package/dist/disconnect/tomlLines.js +105 -0
- package/dist/disconnect/tomlLines.js.map +1 -0
- package/dist/harness/aiderConfigMerger.d.ts +29 -8
- package/dist/harness/aiderConfigMerger.d.ts.map +1 -1
- package/dist/harness/aiderConfigMerger.js +63 -12
- package/dist/harness/aiderConfigMerger.js.map +1 -1
- package/dist/harness/antigravityCliHooks.d.ts +61 -0
- package/dist/harness/antigravityCliHooks.d.ts.map +1 -0
- package/dist/harness/antigravityCliHooks.js +207 -0
- package/dist/harness/antigravityCliHooks.js.map +1 -0
- package/dist/harness/antigravityHooks.d.ts +12 -2
- package/dist/harness/antigravityHooks.d.ts.map +1 -1
- package/dist/harness/antigravityHooks.js +38 -16
- package/dist/harness/antigravityHooks.js.map +1 -1
- package/dist/harness/antigravityProducts.d.ts +40 -0
- package/dist/harness/antigravityProducts.d.ts.map +1 -0
- package/dist/harness/antigravityProducts.js +109 -0
- package/dist/harness/antigravityProducts.js.map +1 -0
- package/dist/harness/claudeAgentsMd.d.ts +29 -0
- package/dist/harness/claudeAgentsMd.d.ts.map +1 -0
- package/dist/harness/claudeAgentsMd.js +80 -0
- package/dist/harness/claudeAgentsMd.js.map +1 -0
- package/dist/harness/claudeCodeHooks.d.ts +6 -6
- package/dist/harness/claudeCodeHooks.d.ts.map +1 -1
- package/dist/harness/claudeCodeHooks.js +115 -28
- package/dist/harness/claudeCodeHooks.js.map +1 -1
- package/dist/harness/claudeProjectApproval.d.ts +53 -0
- package/dist/harness/claudeProjectApproval.d.ts.map +1 -0
- package/dist/harness/claudeProjectApproval.js +159 -0
- package/dist/harness/claudeProjectApproval.js.map +1 -0
- package/dist/harness/clineHooks.d.ts +0 -1
- package/dist/harness/clineHooks.d.ts.map +1 -1
- package/dist/harness/clineHooks.js +13 -4
- package/dist/harness/clineHooks.js.map +1 -1
- package/dist/harness/codexConfigMerger.d.ts.map +1 -1
- package/dist/harness/codexConfigMerger.js +4 -0
- package/dist/harness/codexConfigMerger.js.map +1 -1
- package/dist/harness/codexHooks.d.ts +2 -0
- package/dist/harness/codexHooks.d.ts.map +1 -1
- package/dist/harness/codexHooks.js +15 -4
- package/dist/harness/codexHooks.js.map +1 -1
- package/dist/harness/continueConfigMerger.d.ts.map +1 -1
- package/dist/harness/continueConfigMerger.js +4 -0
- package/dist/harness/continueConfigMerger.js.map +1 -1
- package/dist/harness/cursorHooks.d.ts +5 -2
- package/dist/harness/cursorHooks.d.ts.map +1 -1
- package/dist/harness/cursorHooks.js +12 -3
- package/dist/harness/cursorHooks.js.map +1 -1
- package/dist/harness/dshHooks.d.ts +5 -5
- package/dist/harness/dshHooks.d.ts.map +1 -1
- package/dist/harness/dshHooks.js +12 -5
- package/dist/harness/dshHooks.js.map +1 -1
- package/dist/harness/gateArtifacts.d.ts +35 -0
- package/dist/harness/gateArtifacts.d.ts.map +1 -0
- package/dist/harness/gateArtifacts.js +88 -0
- package/dist/harness/gateArtifacts.js.map +1 -0
- package/dist/harness/gateBody.d.ts +195 -69
- package/dist/harness/gateBody.d.ts.map +1 -1
- package/dist/harness/gateBody.js +847 -182
- package/dist/harness/gateBody.js.map +1 -1
- package/dist/harness/gateSightings.d.ts +47 -0
- package/dist/harness/gateSightings.d.ts.map +1 -0
- package/dist/harness/gateSightings.js +159 -0
- package/dist/harness/gateSightings.js.map +1 -0
- package/dist/harness/githubCopilotHooks.d.ts.map +1 -1
- package/dist/harness/githubCopilotHooks.js +11 -10
- package/dist/harness/githubCopilotHooks.js.map +1 -1
- package/dist/harness/gooseHardener.d.ts +0 -1
- package/dist/harness/gooseHardener.d.ts.map +1 -1
- package/dist/harness/gooseHardener.js +1 -1
- package/dist/harness/gooseHardener.js.map +1 -1
- package/dist/harness/gooseHooks.d.ts +29 -1
- package/dist/harness/gooseHooks.d.ts.map +1 -1
- package/dist/harness/gooseHooks.js +107 -69
- package/dist/harness/gooseHooks.js.map +1 -1
- package/dist/harness/grokHooks.d.ts +2 -2
- package/dist/harness/grokHooks.d.ts.map +1 -1
- package/dist/harness/grokHooks.js +20 -18
- package/dist/harness/grokHooks.js.map +1 -1
- package/dist/harness/hermesHooks.d.ts +18 -8
- package/dist/harness/hermesHooks.d.ts.map +1 -1
- package/dist/harness/hermesHooks.js +55 -19
- package/dist/harness/hermesHooks.js.map +1 -1
- package/dist/harness/holdRedaction.d.ts +4 -1
- package/dist/harness/holdRedaction.d.ts.map +1 -1
- package/dist/harness/holdRedaction.js +32 -8
- package/dist/harness/holdRedaction.js.map +1 -1
- package/dist/harness/jetbrainsXmlConfig.d.ts +20 -0
- package/dist/harness/jetbrainsXmlConfig.d.ts.map +1 -1
- package/dist/harness/jetbrainsXmlConfig.js +39 -18
- package/dist/harness/jetbrainsXmlConfig.js.map +1 -1
- package/dist/harness/mcpAutoWrite.d.ts +62 -25
- package/dist/harness/mcpAutoWrite.d.ts.map +1 -1
- package/dist/harness/mcpAutoWrite.js +406 -95
- package/dist/harness/mcpAutoWrite.js.map +1 -1
- package/dist/harness/museHooks.d.ts +3 -3
- package/dist/harness/museHooks.d.ts.map +1 -1
- package/dist/harness/museHooks.js +15 -7
- package/dist/harness/museHooks.js.map +1 -1
- package/dist/harness/n8nHooks.d.ts +0 -1
- package/dist/harness/n8nHooks.d.ts.map +1 -1
- package/dist/harness/n8nHooks.js +4 -1
- package/dist/harness/n8nHooks.js.map +1 -1
- package/dist/harness/openCodeHooks.d.ts +2 -2
- package/dist/harness/openCodeHooks.d.ts.map +1 -1
- package/dist/harness/openCodeHooks.js +9 -8
- package/dist/harness/openCodeHooks.js.map +1 -1
- package/dist/harness/openWebuiHooks.d.ts +0 -1
- package/dist/harness/openWebuiHooks.d.ts.map +1 -1
- package/dist/harness/openWebuiHooks.js +11 -3
- package/dist/harness/openWebuiHooks.js.map +1 -1
- package/dist/harness/openclawHooks.d.ts +75 -18
- package/dist/harness/openclawHooks.d.ts.map +1 -1
- package/dist/harness/openclawHooks.js +214 -160
- package/dist/harness/openclawHooks.js.map +1 -1
- package/dist/harness/openhandsHooks.d.ts +37 -11
- package/dist/harness/openhandsHooks.d.ts.map +1 -1
- package/dist/harness/openhandsHooks.js +148 -97
- package/dist/harness/openhandsHooks.js.map +1 -1
- package/dist/harness/piHooks.d.ts +52 -17
- package/dist/harness/piHooks.d.ts.map +1 -1
- package/dist/harness/piHooks.js +177 -163
- package/dist/harness/piHooks.js.map +1 -1
- package/dist/harness/protectedPaths.d.ts +107 -25
- package/dist/harness/protectedPaths.d.ts.map +1 -1
- package/dist/harness/protectedPaths.js +342 -48
- package/dist/harness/protectedPaths.js.map +1 -1
- package/dist/harness/rulesSection.d.ts +62 -0
- package/dist/harness/rulesSection.d.ts.map +1 -0
- package/dist/harness/rulesSection.js +145 -0
- package/dist/harness/rulesSection.js.map +1 -0
- package/dist/harness/windsurfHooks.d.ts +18 -3
- package/dist/harness/windsurfHooks.d.ts.map +1 -1
- package/dist/harness/windsurfHooks.js +41 -8
- package/dist/harness/windsurfHooks.js.map +1 -1
- package/dist/harness/windsurfJetBrainsProxy.d.ts +1 -1
- package/dist/harness/windsurfJetBrainsProxy.d.ts.map +1 -1
- package/dist/harness/windsurfJetBrainsProxy.js +5 -1
- package/dist/harness/windsurfJetBrainsProxy.js.map +1 -1
- package/dist/index.d.ts +21 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -19
- package/dist/index.js.map +1 -1
- package/dist/inventory.d.ts +53 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +133 -0
- package/dist/inventory.js.map +1 -0
- package/dist/lib/complianceProbes.d.ts +2 -1
- package/dist/lib/complianceProbes.d.ts.map +1 -1
- package/dist/lib/complianceProbes.js +1 -1
- package/dist/lib/complianceProbes.js.map +1 -1
- package/dist/lib/decisionsDigest.d.ts +35 -17
- package/dist/lib/decisionsDigest.d.ts.map +1 -1
- package/dist/lib/decisionsDigest.js +106 -47
- package/dist/lib/decisionsDigest.js.map +1 -1
- package/dist/lib/egressPolicy.d.ts +2 -2
- package/dist/lib/egressPolicy.js +2 -2
- package/dist/lib/mcpRegistryPy.d.ts +11 -0
- package/dist/lib/mcpRegistryPy.d.ts.map +1 -0
- package/dist/lib/mcpRegistryPy.js +173 -0
- package/dist/lib/mcpRegistryPy.js.map +1 -0
- package/dist/lib/phrasesPy.d.ts +11 -0
- package/dist/lib/phrasesPy.d.ts.map +1 -0
- package/dist/lib/phrasesPy.js +351 -0
- package/dist/lib/phrasesPy.js.map +1 -0
- package/dist/lib/policySnapshot.d.ts +63 -9
- package/dist/lib/policySnapshot.d.ts.map +1 -1
- package/dist/lib/policySnapshot.js +269 -45
- package/dist/lib/policySnapshot.js.map +1 -1
- package/dist/lib/processPoller.d.ts.map +1 -1
- package/dist/lib/processPoller.js +9 -2
- package/dist/lib/processPoller.js.map +1 -1
- package/dist/lib/regexLinearity.d.ts +43 -0
- package/dist/lib/regexLinearity.d.ts.map +1 -0
- package/dist/lib/regexLinearity.js +275 -0
- package/dist/lib/regexLinearity.js.map +1 -0
- package/dist/lib/runtimeEnv.d.ts +1 -3
- package/dist/lib/runtimeEnv.d.ts.map +1 -1
- package/dist/lib/runtimeEnv.js +0 -2
- package/dist/lib/runtimeEnv.js.map +1 -1
- package/dist/lib/sequencePy.d.ts +10 -0
- package/dist/lib/sequencePy.d.ts.map +1 -0
- package/dist/lib/sequencePy.js +102 -0
- package/dist/lib/sequencePy.js.map +1 -0
- package/dist/sessionReporter.d.ts +18 -12
- package/dist/sessionReporter.d.ts.map +1 -1
- package/dist/sessionReporter.js +37 -24
- package/dist/sessionReporter.js.map +1 -1
- package/dist/skillWriter.d.ts +23 -5
- package/dist/skillWriter.d.ts.map +1 -1
- package/dist/skillWriter.js +159 -16
- package/dist/skillWriter.js.map +1 -1
- package/dist/syncCycle.d.ts +142 -0
- package/dist/syncCycle.d.ts.map +1 -0
- package/dist/syncCycle.js +327 -0
- package/dist/syncCycle.js.map +1 -0
- package/dist/trajectoryMonitor.d.ts +2 -4
- package/dist/trajectoryMonitor.d.ts.map +1 -1
- package/dist/trajectoryMonitor.js +2 -5
- package/dist/trajectoryMonitor.js.map +1 -1
- package/dist/watcher/driftWatcher.d.ts +0 -1
- package/dist/watcher/driftWatcher.d.ts.map +1 -1
- package/dist/watcher/driftWatcher.js +1 -2
- package/dist/watcher/driftWatcher.js.map +1 -1
- package/dist/watcher/settingsGuard.d.ts +36 -7
- package/dist/watcher/settingsGuard.d.ts.map +1 -1
- package/dist/watcher/settingsGuard.js +397 -60
- package/dist/watcher/settingsGuard.js.map +1 -1
- package/dist/watcher/vscodeHookSettings.d.ts +30 -0
- package/dist/watcher/vscodeHookSettings.d.ts.map +1 -0
- package/dist/watcher/vscodeHookSettings.js +170 -0
- package/dist/watcher/vscodeHookSettings.js.map +1 -0
- package/dist/wsClient.d.ts +0 -1
- package/dist/wsClient.d.ts.map +1 -1
- package/dist/wsClient.js +0 -1
- package/dist/wsClient.js.map +1 -1
- package/package.json +5 -5
- package/dist/harness/claudeDesktopHooks.d.ts +0 -30
- package/dist/harness/claudeDesktopHooks.d.ts.map +0 -1
- package/dist/harness/claudeDesktopHooks.js +0 -254
- package/dist/harness/claudeDesktopHooks.js.map +0 -1
- package/dist/harness/continueHooks.d.ts +0 -63
- package/dist/harness/continueHooks.d.ts.map +0 -1
- package/dist/harness/continueHooks.js +0 -247
- package/dist/harness/continueHooks.js.map +0 -1
- package/dist/harness/gateKind.d.ts +0 -164
- package/dist/harness/gateKind.d.ts.map +0 -1
- package/dist/harness/gateKind.js +0 -144
- package/dist/harness/gateKind.js.map +0 -1
- package/dist/harness/rooCodeHooks.d.ts +0 -31
- package/dist/harness/rooCodeHooks.d.ts.map +0 -1
- package/dist/harness/rooCodeHooks.js +0 -286
- package/dist/harness/rooCodeHooks.js.map +0 -1
- package/dist/hashReporter.d.ts +0 -33
- package/dist/hashReporter.d.ts.map +0 -1
- package/dist/hashReporter.js +0 -69
- package/dist/hashReporter.js.map +0 -1
- package/dist/integrityStore.d.ts +0 -35
- package/dist/integrityStore.d.ts.map +0 -1
- package/dist/integrityStore.js +0 -71
- package/dist/integrityStore.js.map +0 -1
- package/dist/lib/gitWorktrees.d.ts +0 -140
- package/dist/lib/gitWorktrees.d.ts.map +0 -1
- package/dist/lib/gitWorktrees.js +0 -191
- package/dist/lib/gitWorktrees.js.map +0 -1
- package/dist/syncLoop.d.ts +0 -172
- package/dist/syncLoop.d.ts.map +0 -1
- package/dist/syncLoop.js +0 -878
- package/dist/syncLoop.js.map +0 -1
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* Opt-in via `WorkspaceSettings.decisionsLogEnabled` (default off). The
|
|
18
18
|
* CALLER is responsible for that gate — `refreshDecisionsDigest` always
|
|
19
|
-
* fetches and writes when invoked, so `
|
|
19
|
+
* fetches and writes when invoked, so `intutic connect` only calls it when the
|
|
20
20
|
* workspace has opted in. When disabled, the caller simply stops calling
|
|
21
21
|
* this module; existing files are left as they were last written rather than
|
|
22
22
|
* being force-deleted (a developer's editor may have that file open) or
|
|
@@ -29,13 +29,22 @@
|
|
|
29
29
|
* pattern (i): a DO-NOT-EDIT header + `atomicWrite`. Gitignored — runtime
|
|
30
30
|
* artifacts stay untracked, the same rule this repo's own CLAUDE.md doc
|
|
31
31
|
* comment states for daemon-generated governance files.
|
|
32
|
-
* 2.
|
|
33
|
-
*
|
|
34
|
-
* (`
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
32
|
+
* 2. The newest ~10 entries, delivered to every active harness that reads
|
|
33
|
+
* an instructions file, where `HARNESS_RULES_FILES` says it reads them
|
|
34
|
+
* (`decisionsTargetOf`) — this is what makes the digest something the
|
|
35
|
+
* agent actually reads without needing to know `.intutic/DECISIONS.md`
|
|
36
|
+
* exists. In a file the user also writes (`AGENTS.md`, `GEMINI.md`,
|
|
37
|
+
* ...) it is a marked section of its own (`INTUTIC:DECISIONS_LOG`),
|
|
38
|
+
* apart from the rules section; next to a rules file of Intutic's own it
|
|
39
|
+
* is a second file (`.claude/rules/intutic-decisions.md`, ...). Claude
|
|
40
|
+
* Code gets it from `.claude/rules/`, which it loads with or without a
|
|
41
|
+
* `CLAUDE.md`; `CLAUDE.md` itself is never written. When Claude Code
|
|
42
|
+
* also reads the workspace's `AGENTS.md` and that file carries the
|
|
43
|
+
* section for another harness, Claude Code's own file is left out, so it
|
|
44
|
+
* does not read the log twice (see `claudeAgentsMd.ts`).
|
|
45
|
+
*
|
|
46
|
+
* Earlier versions put the section in `CLAUDE.md`; {@link
|
|
47
|
+
* retireClaudeMdDigest} takes it out again on every sync.
|
|
39
48
|
*
|
|
40
49
|
* Deliberately does NOT reuse `configWriter.ts`'s own `fileHeader()` for the
|
|
41
50
|
* DECISIONS.md header — that helper stamps `newIso()` (wall-clock "Last
|
|
@@ -49,13 +58,18 @@
|
|
|
49
58
|
import * as fs from 'node:fs/promises';
|
|
50
59
|
import * as path from 'node:path';
|
|
51
60
|
import { createLogger } from '@intutic/logger';
|
|
52
|
-
import { HarnessType } from '@intutic/shared-types';
|
|
53
|
-
import {
|
|
61
|
+
import { HarnessType, decisionsTargetOf, rulesFileOf } from '@intutic/shared-types';
|
|
62
|
+
import { atomicWrite } from '../configWriter.js';
|
|
63
|
+
import { DECISIONS_MARKERS, removeRulesSection, retireRulesFile, writeRulesSection } from '../harness/rulesSection.js';
|
|
64
|
+
import { claudeCodeReadsAgentsMd } from '../harness/claudeAgentsMd.js';
|
|
65
|
+
import { openclawAgentWorkspace } from '../harness/openclawHooks.js';
|
|
66
|
+
import { ensureAiderReadEntry } from '../harness/aiderConfigMerger.js';
|
|
67
|
+
import { forgetOriginal, readOriginal, writeOwnedFile } from '../disconnect/originals.js';
|
|
54
68
|
const log = createLogger('sync-decisions-digest');
|
|
55
69
|
/** Relative to the workspace root. */
|
|
56
70
|
export const DECISIONS_LOG_RELATIVE_PATH = path.join('.intutic', 'DECISIONS.md');
|
|
57
|
-
|
|
58
|
-
const
|
|
71
|
+
/** First line of the decisions log's own files, which `intutic disconnect` recognises. */
|
|
72
|
+
export const DECISIONS_FILE_HEADER = '# Intutic Governed Decisions Log (auto-generated)';
|
|
59
73
|
/**
|
|
60
74
|
* Trims trailing `/` without a regex — see the identical helper in
|
|
61
75
|
* `egressPolicy.ts`/`approvedBypasses.ts`: `/\/+$/` is flagged by CodeQL as a
|
|
@@ -131,29 +145,93 @@ export function renderDecisionsMarkdown(entries) {
|
|
|
131
145
|
const lines = entries.map((e) => `- ${e.timestamp} — ${e.summary}`);
|
|
132
146
|
return header + lines.join('\n') + '\n';
|
|
133
147
|
}
|
|
134
|
-
/**
|
|
135
|
-
export function
|
|
148
|
+
/** The newest `limit` entries, as the body of the section or file each harness reads. */
|
|
149
|
+
export function renderDecisionsSectionBody(entries, limit = 10) {
|
|
136
150
|
const bounded = entries.slice(0, limit);
|
|
137
151
|
const lines = bounded.length > 0
|
|
138
152
|
? bounded.map((e) => `- ${e.timestamp} — ${e.summary}`)
|
|
139
153
|
: ['_No governance decisions recorded yet._'];
|
|
140
|
-
return [
|
|
154
|
+
return ['## Recent Governed Decisions', '', ...lines].join('\n');
|
|
155
|
+
}
|
|
156
|
+
/** A harness's decisions file: the product's front matter, the header, the entries. */
|
|
157
|
+
function renderDecisionsFile(body, frontMatter) {
|
|
158
|
+
const head = frontMatter ? `---\n${frontMatter}\n---\n\n` : '';
|
|
159
|
+
return `${head}${DECISIONS_FILE_HEADER}\n# DO NOT EDIT — managed by intutic sync daemon\n\n${body}\n`;
|
|
160
|
+
}
|
|
161
|
+
async function readText(file) {
|
|
162
|
+
try {
|
|
163
|
+
return await fs.readFile(file, 'utf-8');
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
141
168
|
}
|
|
142
169
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* absent, the section is appended once, with a separating blank line.
|
|
170
|
+
* Writes `body` wherever each of `harnesses` reads its instructions, once per
|
|
171
|
+
* file. Claude Code's own file is left out (and removed) when Claude Code
|
|
172
|
+
* reads the workspace's `AGENTS.md` and that file gets the section for
|
|
173
|
+
* another harness.
|
|
148
174
|
*/
|
|
149
|
-
export function
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
175
|
+
export async function writeDecisionsTargets(workspaceRoot, harnesses, body) {
|
|
176
|
+
const claudeFromAgentsMd = harnesses.includes(HarnessType.CLAUDE_CODE) &&
|
|
177
|
+
harnesses.some((h) => rulesFileOf(h) === 'AGENTS.md') &&
|
|
178
|
+
(await claudeCodeReadsAgentsMd(workspaceRoot));
|
|
179
|
+
const written = new Set();
|
|
180
|
+
for (const harness of harnesses) {
|
|
181
|
+
const target = decisionsTargetOf(harness);
|
|
182
|
+
if (!target)
|
|
183
|
+
continue;
|
|
184
|
+
const file = target.kind === 'section' && target.scope === 'user'
|
|
185
|
+
? path.join(await openclawAgentWorkspace(), 'AGENTS.md')
|
|
186
|
+
: path.join(workspaceRoot, target.path);
|
|
187
|
+
if (harness === HarnessType.CLAUDE_CODE && claudeFromAgentsMd) {
|
|
188
|
+
await retireRulesFile(file, workspaceRoot);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (written.has(file))
|
|
192
|
+
continue;
|
|
193
|
+
written.add(file);
|
|
194
|
+
if (target.kind === 'section') {
|
|
195
|
+
await writeRulesSection(file, workspaceRoot, body, DECISIONS_MARKERS);
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const content = renderDecisionsFile(body, target.frontMatter?.('Intutic governed decisions log') ?? '');
|
|
199
|
+
if ((await readText(file)) !== content)
|
|
200
|
+
await writeOwnedFile(file, workspaceRoot, content);
|
|
201
|
+
// Aider loads no file it is not told about.
|
|
202
|
+
if (harness === HarnessType.AIDER)
|
|
203
|
+
await ensureAiderReadEntry(path.join(workspaceRoot, '.aider.conf.yml'), file);
|
|
154
204
|
}
|
|
155
|
-
|
|
156
|
-
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Takes out the decisions-log section earlier versions wrote into the
|
|
208
|
+
* workspace's `CLAUDE.md`, leaving the user's text as it was. A `CLAUDE.md`
|
|
209
|
+
* Intutic created that holds nothing else goes, with its record; one an
|
|
210
|
+
* earlier version wrote whole is given back (`retireRulesFile`). Runs on
|
|
211
|
+
* every sync, whether or not the decisions log is on.
|
|
212
|
+
*/
|
|
213
|
+
export async function retireClaudeMdDigest(workspaceRoot) {
|
|
214
|
+
const file = path.join(workspaceRoot, 'CLAUDE.md');
|
|
215
|
+
const text = await readText(file);
|
|
216
|
+
if (text === null)
|
|
217
|
+
return;
|
|
218
|
+
const next = removeRulesSection(text, DECISIONS_MARKERS);
|
|
219
|
+
if (next !== null) {
|
|
220
|
+
const record = await readOriginal(file, workspaceRoot);
|
|
221
|
+
if (next.trim() === '' && record && !record.existed) {
|
|
222
|
+
await fs.rm(file, { force: true });
|
|
223
|
+
await forgetOriginal(file, workspaceRoot);
|
|
224
|
+
log.info({ action: 'decisions_claude_md_removed', path: file }, 'Removed the CLAUDE.md an earlier version created for the decisions log');
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const mode = (await fs.stat(file)).mode & 0o7777;
|
|
228
|
+
const tmp = `${file}.intutic-tmp`;
|
|
229
|
+
await fs.writeFile(tmp, next, 'utf-8');
|
|
230
|
+
await fs.chmod(tmp, mode);
|
|
231
|
+
await fs.rename(tmp, file);
|
|
232
|
+
log.info({ action: 'decisions_claude_md_section_removed', path: file }, 'Took the decisions-log section out of CLAUDE.md');
|
|
233
|
+
}
|
|
234
|
+
await retireRulesFile(file, workspaceRoot);
|
|
157
235
|
}
|
|
158
236
|
/**
|
|
159
237
|
* Fetch and write both files in one call, mirroring `refreshEgressPolicy`.
|
|
@@ -169,26 +247,7 @@ export async function refreshDecisionsDigest(opts) {
|
|
|
169
247
|
try {
|
|
170
248
|
const fullPath = path.join(opts.workspaceRoot, DECISIONS_LOG_RELATIVE_PATH);
|
|
171
249
|
await atomicWrite(fullPath, renderDecisionsMarkdown(digest.entries));
|
|
172
|
-
|
|
173
|
-
const claudeMdPath = path.join(opts.workspaceRoot, HARNESS_FILES[HarnessType.CLAUDE_CODE]);
|
|
174
|
-
let existing = null;
|
|
175
|
-
try {
|
|
176
|
-
existing = await fs.readFile(claudeMdPath, 'utf-8');
|
|
177
|
-
}
|
|
178
|
-
catch {
|
|
179
|
-
existing = null;
|
|
180
|
-
}
|
|
181
|
-
if (existing !== null) {
|
|
182
|
-
const section = renderBoundedSection(digest.entries, 10);
|
|
183
|
-
const updated = injectBoundedSection(existing, section);
|
|
184
|
-
if (updated !== existing) {
|
|
185
|
-
await atomicWrite(claudeMdPath, updated);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
log.debug({ action: 'decisions_digest_skip_inject' }, 'claude-code config file not written yet this run — skipping bounded-section injection this cycle');
|
|
190
|
-
}
|
|
191
|
-
}
|
|
250
|
+
await writeDecisionsTargets(opts.workspaceRoot, opts.harnesses, renderDecisionsSectionBody(digest.entries, 10));
|
|
192
251
|
return { entriesWritten: digest.entries.length };
|
|
193
252
|
}
|
|
194
253
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decisionsDigest.js","sourceRoot":"","sources":["../../src/lib/decisionsDigest.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"decisionsDigest.js","sourceRoot":"","sources":["../../src/lib/decisionsDigest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,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AM,GAAG,MAAM,oBAAoB,CAAC,IAAI,CAAC,CAAA;IAC/C,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAA;IAEhC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,2BAA2B,CAAC,CAAA;QAC3E,MAAM,WAAW,CAAC,QAAQ,EAAE,uBAAuB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;QAEpE,MAAM,qBAAqB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,EAAE,0BAA0B,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;QAE/G,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAA;IAClD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,+BAA+B,EAAE,GAAG,EAAE,EAAE,qCAAqC,CAAC,CAAA;QACjG,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* egressPolicy.ts — ships the workspace's central egress policy *to* the
|
|
3
3
|
* machine, so an admin sets `enforce`/`monitor` + an allow list once in the
|
|
4
|
-
* control plane rather than in every developer's local proxy config
|
|
5
|
-
*
|
|
4
|
+
* control plane rather than in every developer's local proxy config.
|
|
5
|
+
* Mirrors `policySnapshot.ts` / `approvedBypasses.ts`: fetch from
|
|
6
6
|
* the control plane, write a local artifact under `.intutic/hooks` with
|
|
7
7
|
* integrity headers, and let the consumer (here the Rust proxy) read it.
|
|
8
8
|
*
|
package/dist/lib/egressPolicy.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* egressPolicy.ts — ships the workspace's central egress policy *to* the
|
|
3
3
|
* machine, so an admin sets `enforce`/`monitor` + an allow list once in the
|
|
4
|
-
* control plane rather than in every developer's local proxy config
|
|
5
|
-
*
|
|
4
|
+
* control plane rather than in every developer's local proxy config.
|
|
5
|
+
* Mirrors `policySnapshot.ts` / `approvedBypasses.ts`: fetch from
|
|
6
6
|
* the control plane, write a local artifact under `.intutic/hooks` with
|
|
7
7
|
* integrity headers, and let the consumer (here the Rust proxy) read it.
|
|
8
8
|
*
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP server registry and allowlist decisions in Python, for the bash
|
|
3
|
+
* gates (their extractor already requires python3).
|
|
4
|
+
*
|
|
5
|
+
* Byte-identical to `packages/intutic-clawde/intutic_clawde/gate/mcp_registry.py`,
|
|
6
|
+
* which a test compares; edit that file and copy it here. It is the
|
|
7
|
+
* transliteration of `@intutic/shared-types`'s mcpRegistryRecord.ts, and both
|
|
8
|
+
* run the shared vectors.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MCP_REGISTRY_PY_SOURCE: string;
|
|
11
|
+
//# sourceMappingURL=mcpRegistryPy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpRegistryPy.d.ts","sourceRoot":"","sources":["../../src/lib/mcpRegistryPy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,QAkKlC,CAAA"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP server registry and allowlist decisions in Python, for the bash
|
|
3
|
+
* gates (their extractor already requires python3).
|
|
4
|
+
*
|
|
5
|
+
* Byte-identical to `packages/intutic-clawde/intutic_clawde/gate/mcp_registry.py`,
|
|
6
|
+
* which a test compares; edit that file and copy it here. It is the
|
|
7
|
+
* transliteration of `@intutic/shared-types`'s mcpRegistryRecord.ts, and both
|
|
8
|
+
* run the shared vectors.
|
|
9
|
+
*/
|
|
10
|
+
export const MCP_REGISTRY_PY_SOURCE = String.raw `"""The MCP server registry and allowlist decisions, read from the policy snapshot.
|
|
11
|
+
|
|
12
|
+
A transliteration of packages/shared-types/src/mcpRegistryRecord.ts: the
|
|
13
|
+
registry decision (evaluateMcpRegistry), the allowlist decision
|
|
14
|
+
(evaluateMcpAllowlist), and the snapshot's @mcp_registry and @mcp_allowlist
|
|
15
|
+
records. The control plane's hook gate, the MCP proxy and the JavaScript hook
|
|
16
|
+
gates run the TypeScript; the bash hook gates and this package run this file,
|
|
17
|
+
and every one of them runs packages/shared-types/fixtures/mcp-registry-vectors.json,
|
|
18
|
+
so all of them refuse a call with the same code, rule id and reason.
|
|
19
|
+
|
|
20
|
+
The bash gates emit this file verbatim (services/sync-daemon/src/lib/mcpRegistryPy.ts
|
|
21
|
+
holds a byte-identical copy, which a test compares). It must stay
|
|
22
|
+
self-contained: the standard library only, no module state beyond the
|
|
23
|
+
constants below, and no backtick or dollar-brace, which the TypeScript copy
|
|
24
|
+
cannot hold.
|
|
25
|
+
|
|
26
|
+
Both records sit inside the snapshot's digest. A gate that finds the snapshot
|
|
27
|
+
unverified (its digest broken or missing, or another workspace's) trusts
|
|
28
|
+
neither: it refuses every MCP call with unverified_refusal, at block, in an
|
|
29
|
+
observe-only workspace too.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
import base64
|
|
33
|
+
import json
|
|
34
|
+
|
|
35
|
+
MCP_REGISTRY_RECORD_TAG = "@mcp_registry"
|
|
36
|
+
MCP_ALLOWLIST_RECORD_TAG = "@mcp_allowlist"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def split_mcp_tool_name(tool):
|
|
40
|
+
"""(server, tool) for a harness name mcp__<server>__<tool>, else None.
|
|
41
|
+
|
|
42
|
+
The server is the part before the first double underscore; the tool, the
|
|
43
|
+
rest, may hold more of them.
|
|
44
|
+
"""
|
|
45
|
+
if not isinstance(tool, str) or not tool.startswith("mcp__"):
|
|
46
|
+
return None
|
|
47
|
+
rest = tool[len("mcp__"):]
|
|
48
|
+
sep = rest.find("__")
|
|
49
|
+
if sep <= 0:
|
|
50
|
+
return None
|
|
51
|
+
return rest[:sep], rest[sep + 2:]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _strings(value):
|
|
55
|
+
return [v for v in value if isinstance(v, str)] if isinstance(value, list) else []
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def parse_registry(value):
|
|
59
|
+
"""The registry as the control plane sends it, or None for a non-object.
|
|
60
|
+
|
|
61
|
+
Wrong-typed lists read as empty, and any default but deny as allow.
|
|
62
|
+
"""
|
|
63
|
+
if not isinstance(value, dict):
|
|
64
|
+
return None
|
|
65
|
+
disabled = {}
|
|
66
|
+
if isinstance(value.get("disabledTools"), dict):
|
|
67
|
+
for server, tools in value["disabledTools"].items():
|
|
68
|
+
names = _strings(tools)
|
|
69
|
+
if names:
|
|
70
|
+
disabled[server] = names
|
|
71
|
+
return {
|
|
72
|
+
"defaultPolicy": "deny" if value.get("defaultPolicy") == "deny" else "allow",
|
|
73
|
+
"approvedServers": _strings(value.get("approvedServers")),
|
|
74
|
+
"blockedServers": _strings(value.get("blockedServers")),
|
|
75
|
+
"heldServers": _strings(value.get("heldServers")),
|
|
76
|
+
"disabledTools": disabled,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def decode_registry_record(line):
|
|
81
|
+
"""The @mcp_registry line's registry; None for another line or a damaged one."""
|
|
82
|
+
parts = line.split("\t")
|
|
83
|
+
if len(parts) != 2 or parts[0] != MCP_REGISTRY_RECORD_TAG or not parts[1]:
|
|
84
|
+
return None
|
|
85
|
+
try:
|
|
86
|
+
return parse_registry(json.loads(base64.b64decode(parts[1], validate=True).decode("utf-8")))
|
|
87
|
+
except Exception:
|
|
88
|
+
return None
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def evaluate_registry(registry, server, tool):
|
|
92
|
+
"""(code, rule_id, reason) refusing one MCP call, or None to let it continue.
|
|
93
|
+
|
|
94
|
+
A blocked server, then a held one, then (under deny) one not approved,
|
|
95
|
+
then a disabled tool.
|
|
96
|
+
"""
|
|
97
|
+
if server in registry["blockedServers"]:
|
|
98
|
+
return (
|
|
99
|
+
"SERVER_BLOCKED",
|
|
100
|
+
"mcp_registry." + server,
|
|
101
|
+
"MCP server \"" + server + "\" is blocked in this workspace's MCP server registry. "
|
|
102
|
+
"An owner or admin can change that on the MCP Servers page.",
|
|
103
|
+
)
|
|
104
|
+
if server in registry["heldServers"]:
|
|
105
|
+
return (
|
|
106
|
+
"SERVER_HELD",
|
|
107
|
+
"mcp_registry." + server,
|
|
108
|
+
"MCP server \"" + server + "\" changed its tools in a way scored high risk, and this workspace "
|
|
109
|
+
"holds such a server until it is approved again. It is waiting in the approval queue on the MCP "
|
|
110
|
+
"Servers page for an owner or admin.",
|
|
111
|
+
)
|
|
112
|
+
if registry["defaultPolicy"] == "deny" and server not in registry["approvedServers"]:
|
|
113
|
+
return (
|
|
114
|
+
"SERVER_NOT_APPROVED",
|
|
115
|
+
"mcpDefaultPolicy",
|
|
116
|
+
"MCP server \"" + server + "\" is not approved in this workspace's MCP server registry, "
|
|
117
|
+
"and the workspace refuses unapproved servers (mcpDefaultPolicy: deny). It is waiting in "
|
|
118
|
+
"the approval queue on the MCP Servers page for an owner or admin.",
|
|
119
|
+
)
|
|
120
|
+
if tool in registry["disabledTools"].get(server, []):
|
|
121
|
+
return (
|
|
122
|
+
"TOOL_DISABLED",
|
|
123
|
+
"mcp_registry." + server + "." + tool,
|
|
124
|
+
"Tool \"" + tool + "\" is disabled on MCP server \"" + server + "\" in this workspace's "
|
|
125
|
+
"MCP server registry. An owner or admin can re-enable it on the MCP Servers page.",
|
|
126
|
+
)
|
|
127
|
+
return None
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def decode_allowlist_record(line):
|
|
131
|
+
"""The @mcp_allowlist line as {"severity", "servers"}; None for another line.
|
|
132
|
+
|
|
133
|
+
A severity other than shadow reads as block, so a damaged one refuses.
|
|
134
|
+
"""
|
|
135
|
+
parts = line.split("\t")
|
|
136
|
+
if len(parts) != 3 or parts[0] != MCP_ALLOWLIST_RECORD_TAG:
|
|
137
|
+
return None
|
|
138
|
+
return {
|
|
139
|
+
"severity": "shadow" if parts[1] == "shadow" else "block",
|
|
140
|
+
"servers": [s for s in parts[2].split(",") if s],
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def evaluate_allowlist(allowlist, server):
|
|
145
|
+
"""(code, rule_id, reason) for a server the allowlist does not name, else None.
|
|
146
|
+
|
|
147
|
+
Under shadow the caller records the refusal instead of enforcing it.
|
|
148
|
+
"""
|
|
149
|
+
if server in allowlist["servers"]:
|
|
150
|
+
return None
|
|
151
|
+
return (
|
|
152
|
+
"SERVER_NOT_ALLOWED",
|
|
153
|
+
"mcp_allowlist",
|
|
154
|
+
"MCP server \"" + server + "\" is not on the MCP server allowlist for this workspace",
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def unverified_refusal(server):
|
|
159
|
+
"""(code, rule_id, reason) refusing an MCP call on an unverified snapshot.
|
|
160
|
+
|
|
161
|
+
Neither the registry's approvals nor the allowlist's servers can be
|
|
162
|
+
vouched for, and a deleted record looks like one never set, so the
|
|
163
|
+
snapshot admits no MCP server at all.
|
|
164
|
+
"""
|
|
165
|
+
return (
|
|
166
|
+
"POLICY_SNAPSHOT_UNVERIFIED",
|
|
167
|
+
"policy_snapshot",
|
|
168
|
+
"MCP server \"" + server + "\" is refused because the policy snapshot on this machine failed its "
|
|
169
|
+
"integrity check, so its MCP server registry and allowlist admit no server until the sync daemon "
|
|
170
|
+
"restores a verified snapshot",
|
|
171
|
+
)
|
|
172
|
+
`;
|
|
173
|
+
//# sourceMappingURL=mcpRegistryPy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpRegistryPy.js","sourceRoot":"","sources":["../../src/lib/mcpRegistryPy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkK/C,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The phrase matcher in Python, for the gates that run Python: the bash gates
|
|
3
|
+
* (their extractor already requires python3) and the Open WebUI filter.
|
|
4
|
+
*
|
|
5
|
+
* Byte-identical to `packages/intutic-clawde/intutic_clawde/gate/phrases.py`,
|
|
6
|
+
* which a test compares; edit that file and copy it here. It is the
|
|
7
|
+
* transliteration of `@intutic/shared-types`'s phrases.ts, and both run the
|
|
8
|
+
* shared vectors.
|
|
9
|
+
*/
|
|
10
|
+
export declare const PHRASES_PY_SOURCE: string;
|
|
11
|
+
//# sourceMappingURL=phrasesPy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phrasesPy.d.ts","sourceRoot":"","sources":["../../src/lib/phrasesPy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,QAoV7B,CAAA"}
|