codeloop-mcp-server 0.1.78 → 0.1.79
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,7 +1,14 @@
|
|
|
1
1
|
export type AgentMode = "fix" | "audit";
|
|
2
|
+
/**
|
|
3
|
+
* How long a PERSISTED audit mode stays in effect after it was last set.
|
|
4
|
+
* Each audit tool call rewrites the file (refreshing this window), so a
|
|
5
|
+
* continuous audit session never lapses; only an idle/abandoned audit does.
|
|
6
|
+
* Kept short enough that a later, unrelated request defaults back to fix.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AUDIT_TTL_MS: number;
|
|
2
9
|
/** Normalize a free-text mode value to the canonical enum. */
|
|
3
10
|
export declare function normalizeAgentMode(value?: string | null): AgentMode | undefined;
|
|
4
|
-
export declare function readPersistedAgentMode(cwd: string): AgentMode | undefined;
|
|
11
|
+
export declare function readPersistedAgentMode(cwd: string, now?: number): AgentMode | undefined;
|
|
5
12
|
export declare function persistAgentMode(cwd: string, mode: AgentMode): void;
|
|
6
13
|
/**
|
|
7
14
|
* Resolve the effective mode for a tool call and persist an explicit param so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent_mode.d.ts","sourceRoot":"","sources":["../../src/evidence/agent_mode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent_mode.d.ts","sourceRoot":"","sources":["../../src/evidence/agent_mode.ts"],"names":[],"mappings":"AAkCA,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,OAAO,CAAC;AAIxC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,QAAiB,CAAC;AAE3C,8DAA8D;AAC9D,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,CAc/E;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAmB,GAAG,SAAS,GAAG,SAAS,CAgBnG;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,CAQnE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,SAAS,CAWZ;AAED,gFAAgF;AAChF,eAAO,MAAM,sBAAsB,QAWiC,CAAC;AAErE;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,CAyBtF"}
|
|
@@ -17,10 +17,28 @@
|
|
|
17
17
|
* When a tool receives an explicit `mode`, it persists it so the rest of the
|
|
18
18
|
* session inherits the same mode without the agent having to repeat it on
|
|
19
19
|
* every call.
|
|
20
|
+
*
|
|
21
|
+
* READ-ONLY IS OPT-IN, NOT STICKY. audit must only apply when the user has
|
|
22
|
+
* actually asked for it ("don't modify my code, just list the problems").
|
|
23
|
+
* Persisted audit therefore EXPIRES: it is honored only for AUDIT_TTL_MS after
|
|
24
|
+
* it was last set, and every audit tool call refreshes that timestamp. The
|
|
25
|
+
* moment the agent stops passing `mode:"audit"` (because the user is no longer
|
|
26
|
+
* restricting edits), the persisted audit goes stale and CodeLoop reverts to
|
|
27
|
+
* the active fix default — verifying, checking the gate/confidence, and pushing
|
|
28
|
+
* the auto-fix loop. Persisted "fix" never expires (it IS the default). An
|
|
29
|
+
* explicit config.agent_mode:"audit" is a deliberate user opt-in and is honored
|
|
30
|
+
* with no TTL.
|
|
20
31
|
*/
|
|
21
32
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
22
33
|
import { join, dirname } from "path";
|
|
23
34
|
const MODE_FILE_REL = join(".codeloop", "agent_mode.json");
|
|
35
|
+
/**
|
|
36
|
+
* How long a PERSISTED audit mode stays in effect after it was last set.
|
|
37
|
+
* Each audit tool call rewrites the file (refreshing this window), so a
|
|
38
|
+
* continuous audit session never lapses; only an idle/abandoned audit does.
|
|
39
|
+
* Kept short enough that a later, unrelated request defaults back to fix.
|
|
40
|
+
*/
|
|
41
|
+
export const AUDIT_TTL_MS = 30 * 60 * 1000; // 30 minutes
|
|
24
42
|
/** Normalize a free-text mode value to the canonical enum. */
|
|
25
43
|
export function normalizeAgentMode(value) {
|
|
26
44
|
if (!value)
|
|
@@ -36,13 +54,21 @@ export function normalizeAgentMode(value) {
|
|
|
36
54
|
}
|
|
37
55
|
return undefined;
|
|
38
56
|
}
|
|
39
|
-
export function readPersistedAgentMode(cwd) {
|
|
57
|
+
export function readPersistedAgentMode(cwd, now = Date.now()) {
|
|
40
58
|
try {
|
|
41
59
|
const p = join(cwd, MODE_FILE_REL);
|
|
42
60
|
if (!existsSync(p))
|
|
43
61
|
return undefined;
|
|
44
62
|
const data = JSON.parse(readFileSync(p, "utf-8"));
|
|
45
|
-
|
|
63
|
+
const mode = normalizeAgentMode(data.mode);
|
|
64
|
+
// Persisted audit is OPT-IN and time-boxed: ignore it once stale so CodeLoop
|
|
65
|
+
// reverts to the active fix default unless the user keeps requesting audit.
|
|
66
|
+
if (mode === "audit") {
|
|
67
|
+
const setAt = data.set_at ? Date.parse(data.set_at) : NaN;
|
|
68
|
+
if (!Number.isFinite(setAt) || now - setAt > AUDIT_TTL_MS)
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
return mode;
|
|
46
72
|
}
|
|
47
73
|
catch {
|
|
48
74
|
return undefined;
|
|
@@ -73,13 +99,17 @@ export function resolveAgentMode(opts) {
|
|
|
73
99
|
"fix");
|
|
74
100
|
}
|
|
75
101
|
/** Shared schema description so every tool's `mode` param reads identically. */
|
|
76
|
-
export const MODE_PARAM_DESCRIPTION = "Agent workflow mode. 'fix' (default) =
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
102
|
+
export const MODE_PARAM_DESCRIPTION = "Agent workflow mode. LEAVE UNSET for the normal behavior: 'fix' (default) = " +
|
|
103
|
+
"the standard auto-fix loop where, after verify/gate, you actively diagnose " +
|
|
104
|
+
"and modify code, re-verify, and drive the gate/confidence up until it passes. " +
|
|
105
|
+
"ONLY set 'audit' when the user EXPLICITLY asked you to run the checks and " +
|
|
106
|
+
"LIST the problems WITHOUT modifying their code (e.g. 'don't change anything, " +
|
|
107
|
+
"just tell me what's wrong'). Do NOT infer audit on your own. In audit mode " +
|
|
108
|
+
"CodeLoop still runs every verification and returns the full findings, but its " +
|
|
109
|
+
"responses won't push you to edit files or loop — you present the report and " +
|
|
110
|
+
"stop. Audit is OPT-IN and time-boxed: it auto-expires so CodeLoop returns to " +
|
|
111
|
+
"the active fix default; when the user is ready to fix again, simply pass " +
|
|
112
|
+
"mode:'fix' (or omit it) to resume the auto-fix loop immediately.";
|
|
83
113
|
/**
|
|
84
114
|
* The read-only directive appended to verify / diagnose / gate_check responses
|
|
85
115
|
* when audit mode is active. Replaces the aggressive auto-fix prose.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent_mode.js","sourceRoot":"","sources":["../../src/evidence/agent_mode.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agent_mode.js","sourceRoot":"","sources":["../../src/evidence/agent_mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAIrC,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAA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