contextos-mcp 0.4.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/LICENSE +21 -0
- package/README.md +260 -0
- package/bin/mcp.mjs +61 -0
- package/bin/swarm.mjs +45 -0
- package/dist/agents/aider.d.ts +12 -0
- package/dist/agents/aider.js +192 -0
- package/dist/agents/aider.js.map +1 -0
- package/dist/agents/claude-code.d.ts +9 -0
- package/dist/agents/claude-code.js +236 -0
- package/dist/agents/claude-code.js.map +1 -0
- package/dist/agents/codex.d.ts +14 -0
- package/dist/agents/codex.js +203 -0
- package/dist/agents/codex.js.map +1 -0
- package/dist/agents/direct-llm.d.ts +22 -0
- package/dist/agents/direct-llm.js +254 -0
- package/dist/agents/direct-llm.js.map +1 -0
- package/dist/agents/mock.d.ts +10 -0
- package/dist/agents/mock.js +170 -0
- package/dist/agents/mock.js.map +1 -0
- package/dist/agents/opencode.d.ts +23 -0
- package/dist/agents/opencode.js +631 -0
- package/dist/agents/opencode.js.map +1 -0
- package/dist/agents/provider.d.ts +11 -0
- package/dist/agents/provider.js +31 -0
- package/dist/agents/provider.js.map +1 -0
- package/dist/compression/compressor.d.ts +28 -0
- package/dist/compression/compressor.js +268 -0
- package/dist/compression/compressor.js.map +1 -0
- package/dist/config.d.ts +43 -0
- package/dist/config.js +172 -0
- package/dist/config.js.map +1 -0
- package/dist/contextos/loader.d.ts +46 -0
- package/dist/contextos/loader.js +120 -0
- package/dist/contextos/loader.js.map +1 -0
- package/dist/contextos/selector.d.ts +46 -0
- package/dist/contextos/selector.js +80 -0
- package/dist/contextos/selector.js.map +1 -0
- package/dist/core/action-dispatcher.d.ts +15 -0
- package/dist/core/action-dispatcher.js +28 -0
- package/dist/core/action-dispatcher.js.map +1 -0
- package/dist/core/action-schema.d.ts +72 -0
- package/dist/core/action-schema.js +86 -0
- package/dist/core/action-schema.js.map +1 -0
- package/dist/core/repl-interface.d.ts +48 -0
- package/dist/core/repl-interface.js +5 -0
- package/dist/core/repl-interface.js.map +1 -0
- package/dist/core/repl.d.ts +59 -0
- package/dist/core/repl.js +353 -0
- package/dist/core/repl.js.map +1 -0
- package/dist/core/rlm.d.ts +65 -0
- package/dist/core/rlm.js +564 -0
- package/dist/core/rlm.js.map +1 -0
- package/dist/core/runtime.py +470 -0
- package/dist/core/types.d.ts +265 -0
- package/dist/core/types.js +19 -0
- package/dist/core/types.js.map +1 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.js +75 -0
- package/dist/env.js.map +1 -0
- package/dist/hooks/runner.d.ts +43 -0
- package/dist/hooks/runner.js +173 -0
- package/dist/hooks/runner.js.map +1 -0
- package/dist/labs/cli.d.ts +15 -0
- package/dist/labs/cli.js +295 -0
- package/dist/labs/cli.js.map +1 -0
- package/dist/labs/episodic-memory.d.ts +132 -0
- package/dist/labs/episodic-memory.js +391 -0
- package/dist/labs/episodic-memory.js.map +1 -0
- package/dist/labs/interactive-swarm.d.ts +20 -0
- package/dist/labs/interactive-swarm.js +1173 -0
- package/dist/labs/interactive-swarm.js.map +1 -0
- package/dist/labs/interactive.d.ts +10 -0
- package/dist/labs/interactive.js +2099 -0
- package/dist/labs/interactive.js.map +1 -0
- package/dist/labs/ts-analyzer.d.ts +74 -0
- package/dist/labs/ts-analyzer.js +379 -0
- package/dist/labs/ts-analyzer.js.map +1 -0
- package/dist/labs/viewer.d.ts +12 -0
- package/dist/labs/viewer.js +1284 -0
- package/dist/labs/viewer.js.map +1 -0
- package/dist/main.d.ts +15 -0
- package/dist/main.js +247 -0
- package/dist/main.js.map +1 -0
- package/dist/mcp/server.d.ts +16 -0
- package/dist/mcp/server.js +192775 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/session.d.ts +117 -0
- package/dist/mcp/session.js +450 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/state.d.ts +42 -0
- package/dist/mcp/state.js +537 -0
- package/dist/mcp/state.js.map +1 -0
- package/dist/mcp/tools/contextos.d.ts +17 -0
- package/dist/mcp/tools/contextos.js +583 -0
- package/dist/mcp/tools/contextos.js.map +1 -0
- package/dist/mcp/tools.d.ts +15 -0
- package/dist/mcp/tools.js +393 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/orchestration/reviewer-gate.d.ts +43 -0
- package/dist/orchestration/reviewer-gate.js +280 -0
- package/dist/orchestration/reviewer-gate.js.map +1 -0
- package/dist/orchestration/reviewer-prompt.d.ts +18 -0
- package/dist/orchestration/reviewer-prompt.js +67 -0
- package/dist/orchestration/reviewer-prompt.js.map +1 -0
- package/dist/orchestration/verification-runner.d.ts +53 -0
- package/dist/orchestration/verification-runner.js +352 -0
- package/dist/orchestration/verification-runner.js.map +1 -0
- package/dist/plugins/adapter.d.ts +11 -0
- package/dist/plugins/adapter.js +11 -0
- package/dist/plugins/adapter.js.map +1 -0
- package/dist/plugins/core/archive.d.ts +9 -0
- package/dist/plugins/core/archive.js +128 -0
- package/dist/plugins/core/archive.js.map +1 -0
- package/dist/plugins/core/digest.d.ts +11 -0
- package/dist/plugins/core/digest.js +70 -0
- package/dist/plugins/core/digest.js.map +1 -0
- package/dist/plugins/core/grants.d.ts +22 -0
- package/dist/plugins/core/grants.js +90 -0
- package/dist/plugins/core/grants.js.map +1 -0
- package/dist/plugins/core/index.d.ts +10 -0
- package/dist/plugins/core/index.js +11 -0
- package/dist/plugins/core/index.js.map +1 -0
- package/dist/plugins/core/pinning.d.ts +15 -0
- package/dist/plugins/core/pinning.js +86 -0
- package/dist/plugins/core/pinning.js.map +1 -0
- package/dist/plugins/core/types.d.ts +105 -0
- package/dist/plugins/core/types.js +22 -0
- package/dist/plugins/core/types.js.map +1 -0
- package/dist/plugins/core/updater.d.ts +16 -0
- package/dist/plugins/core/updater.js +64 -0
- package/dist/plugins/core/updater.js.map +1 -0
- package/dist/plugins/loader.d.ts +65 -0
- package/dist/plugins/loader.js +110 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/prompts/orchestrator.d.ts +6 -0
- package/dist/prompts/orchestrator.js +114 -0
- package/dist/prompts/orchestrator.js.map +1 -0
- package/dist/routing/model-resolver.d.ts +27 -0
- package/dist/routing/model-resolver.js +265 -0
- package/dist/routing/model-resolver.js.map +1 -0
- package/dist/routing/model-router.d.ts +130 -0
- package/dist/routing/model-router.js +515 -0
- package/dist/routing/model-router.js.map +1 -0
- package/dist/runtime/attestations.cjs +260 -0
- package/dist/runtime/reviewer-pipeline.cjs +319 -0
- package/dist/runtime/sandbox.cjs +468 -0
- package/dist/runtime/state-machine.cjs +885 -0
- package/dist/runtime/thread-store.cjs +175 -0
- package/dist/runtime/transactional-git.cjs +315 -0
- package/dist/runtime/verification-pipeline.cjs +435 -0
- package/dist/sandbox/execution.d.ts +165 -0
- package/dist/sandbox/execution.js +497 -0
- package/dist/sandbox/execution.js.map +1 -0
- package/dist/security/file-policy.d.ts +22 -0
- package/dist/security/file-policy.js +53 -0
- package/dist/security/file-policy.js.map +1 -0
- package/dist/security/repository-boundary.d.ts +21 -0
- package/dist/security/repository-boundary.js +119 -0
- package/dist/security/repository-boundary.js.map +1 -0
- package/dist/security/secret-filter.d.ts +36 -0
- package/dist/security/secret-filter.js +149 -0
- package/dist/security/secret-filter.js.map +1 -0
- package/dist/swarm.d.ts +14 -0
- package/dist/swarm.js +624 -0
- package/dist/swarm.js.map +1 -0
- package/dist/threads/cache.d.ts +64 -0
- package/dist/threads/cache.js +241 -0
- package/dist/threads/cache.js.map +1 -0
- package/dist/threads/manager.d.ts +94 -0
- package/dist/threads/manager.js +914 -0
- package/dist/threads/manager.js.map +1 -0
- package/dist/ui/banner.d.ts +14 -0
- package/dist/ui/banner.js +42 -0
- package/dist/ui/banner.js.map +1 -0
- package/dist/ui/dashboard.d.ts +33 -0
- package/dist/ui/dashboard.js +135 -0
- package/dist/ui/dashboard.js.map +1 -0
- package/dist/ui/index.d.ts +11 -0
- package/dist/ui/index.js +12 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/log.d.ts +39 -0
- package/dist/ui/log.js +126 -0
- package/dist/ui/log.js.map +1 -0
- package/dist/ui/onboarding.d.ts +14 -0
- package/dist/ui/onboarding.js +755 -0
- package/dist/ui/onboarding.js.map +1 -0
- package/dist/ui/run-log.d.ts +50 -0
- package/dist/ui/run-log.js +60 -0
- package/dist/ui/run-log.js.map +1 -0
- package/dist/ui/spinner.d.ts +41 -0
- package/dist/ui/spinner.js +172 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/ui/streaming-feed.d.ts +72 -0
- package/dist/ui/streaming-feed.js +386 -0
- package/dist/ui/streaming-feed.js.map +1 -0
- package/dist/ui/summary.d.ts +18 -0
- package/dist/ui/summary.js +113 -0
- package/dist/ui/summary.js.map +1 -0
- package/dist/ui/text-input.d.ts +19 -0
- package/dist/ui/text-input.js +266 -0
- package/dist/ui/text-input.js.map +1 -0
- package/dist/ui/theme.d.ts +63 -0
- package/dist/ui/theme.js +97 -0
- package/dist/ui/theme.js.map +1 -0
- package/dist/utils/command-exists.d.ts +11 -0
- package/dist/utils/command-exists.js +41 -0
- package/dist/utils/command-exists.js.map +1 -0
- package/dist/utils/process-security.d.ts +19 -0
- package/dist/utils/process-security.js +90 -0
- package/dist/utils/process-security.js.map +1 -0
- package/dist/utils/rolling-buffer.d.ts +16 -0
- package/dist/utils/rolling-buffer.js +30 -0
- package/dist/utils/rolling-buffer.js.map +1 -0
- package/dist/utils/safe-spawn.d.ts +13 -0
- package/dist/utils/safe-spawn.js +49 -0
- package/dist/utils/safe-spawn.js.map +1 -0
- package/dist/worktree/manager.d.ts +69 -0
- package/dist/worktree/manager.js +593 -0
- package/dist/worktree/manager.js.map +1 -0
- package/dist/worktree/merge.d.ts +58 -0
- package/dist/worktree/merge.js +389 -0
- package/dist/worktree/merge.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rolling string buffer with a maximum byte limit.
|
|
3
|
+
*
|
|
4
|
+
* Drops oldest chunks when the total accumulated length exceeds `maxBytes`.
|
|
5
|
+
* Used by agent backends to prevent OOM when a runaway child process
|
|
6
|
+
* produces unbounded stdout/stderr output.
|
|
7
|
+
*/
|
|
8
|
+
export class RollingBuffer {
|
|
9
|
+
maxBytes;
|
|
10
|
+
chunks = [];
|
|
11
|
+
totalLength = 0;
|
|
12
|
+
constructor(maxBytes = 2 * 1024 * 1024) {
|
|
13
|
+
this.maxBytes = maxBytes;
|
|
14
|
+
} // 2MB default
|
|
15
|
+
append(text) {
|
|
16
|
+
this.chunks.push(text);
|
|
17
|
+
this.totalLength += text.length;
|
|
18
|
+
while (this.totalLength > this.maxBytes && this.chunks.length > 1) {
|
|
19
|
+
const dropped = this.chunks.shift();
|
|
20
|
+
this.totalLength -= dropped.length;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
toString() {
|
|
24
|
+
return this.chunks.join("");
|
|
25
|
+
}
|
|
26
|
+
get length() {
|
|
27
|
+
return this.totalLength;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=rolling-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rolling-buffer.js","sourceRoot":"","sources":["../../src/utils/rolling-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,OAAO,aAAa;IAII;IAHrB,MAAM,GAAa,EAAE,CAAC;IACtB,WAAW,GAAG,CAAC,CAAC;IAExB,YAA6B,WAAmB,CAAC,GAAG,IAAI,GAAG,IAAI;QAAlC,aAAQ,GAAR,QAAQ,CAA0B;IAAG,CAAC,CAAC,cAAc;IAElF,MAAM,CAAC,IAAY;QAClB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC;QAChC,OAAO,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnE,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAG,CAAC;YACrC,IAAI,CAAC,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;QACpC,CAAC;IACF,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;CACD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ChildProcess, type SpawnOptions } from "node:child_process";
|
|
2
|
+
/**
|
|
3
|
+
* Escapes an argument for Windows cmd.exe /s /c invocation to prevent
|
|
4
|
+
* command chaining (&, |, &&, ||), variable expansion (%VAR%), and redirections (<, >).
|
|
5
|
+
*/
|
|
6
|
+
export declare function escapeWindowsArg(arg: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Safely spawns a child process in a cross-platform manner.
|
|
9
|
+
* On Unix or Windows with native .exe, uses direct execution with shell: false.
|
|
10
|
+
* On Windows with .cmd/.bat scripts, invokes cmd.exe /d /s /c with strictly escaped arguments
|
|
11
|
+
* and windowsVerbatimArguments: true, preventing shell injection.
|
|
12
|
+
*/
|
|
13
|
+
export declare function safeSpawn(command: string, args?: string[], options?: SpawnOptions): Promise<ChildProcess>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { resolveExecutablePath } from "./command-exists.js";
|
|
3
|
+
/**
|
|
4
|
+
* Escapes an argument for Windows cmd.exe /s /c invocation to prevent
|
|
5
|
+
* command chaining (&, |, &&, ||), variable expansion (%VAR%), and redirections (<, >).
|
|
6
|
+
*/
|
|
7
|
+
export function escapeWindowsArg(arg) {
|
|
8
|
+
if (!arg)
|
|
9
|
+
return '""';
|
|
10
|
+
// Double all percent signs to prevent %VAR% expansion in cmd.exe
|
|
11
|
+
let escaped = arg.replace(/%/g, "%%");
|
|
12
|
+
// Escape backslashes before quotes and escape quotes
|
|
13
|
+
escaped = escaped.replace(/(\\*)"/g, '$1$1\\"');
|
|
14
|
+
// If it contains spaces or metacharacters, wrap in double quotes
|
|
15
|
+
if (/[ \t\n\v"&|<>^]/.test(escaped)) {
|
|
16
|
+
return `"${escaped}"`;
|
|
17
|
+
}
|
|
18
|
+
return escaped;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Safely spawns a child process in a cross-platform manner.
|
|
22
|
+
* On Unix or Windows with native .exe, uses direct execution with shell: false.
|
|
23
|
+
* On Windows with .cmd/.bat scripts, invokes cmd.exe /d /s /c with strictly escaped arguments
|
|
24
|
+
* and windowsVerbatimArguments: true, preventing shell injection.
|
|
25
|
+
*/
|
|
26
|
+
export async function safeSpawn(command, args = [], options = {}) {
|
|
27
|
+
const isWindows = process.platform === "win32";
|
|
28
|
+
// If already a resolved path or command, find executable
|
|
29
|
+
const resolved = (await resolveExecutablePath(command)) || command;
|
|
30
|
+
if (!isWindows) {
|
|
31
|
+
return spawn(resolved, args, { ...options, shell: false });
|
|
32
|
+
}
|
|
33
|
+
const isBatchOrCmd = /\.(cmd|bat)$/i.test(resolved);
|
|
34
|
+
if (!isBatchOrCmd) {
|
|
35
|
+
// Native Windows .exe — execute directly without shell
|
|
36
|
+
return spawn(resolved, args, { ...options, shell: false });
|
|
37
|
+
}
|
|
38
|
+
// Windows .cmd or .bat script: Node CVE-2024-27980 throws EINVAL on shell: false.
|
|
39
|
+
// Safely invoke cmd.exe with strict escaping and windowsVerbatimArguments.
|
|
40
|
+
const comSpec = process.env.COMSPEC || "cmd.exe";
|
|
41
|
+
const escapedArgs = args.map(escapeWindowsArg);
|
|
42
|
+
const fullCommandLine = `"${resolved}" ${escapedArgs.join(" ")}`;
|
|
43
|
+
return spawn(comSpec, ["/d", "/s", "/c", fullCommandLine], {
|
|
44
|
+
...options,
|
|
45
|
+
windowsVerbatimArguments: true,
|
|
46
|
+
shell: false,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=safe-spawn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-spawn.js","sourceRoot":"","sources":["../../src/utils/safe-spawn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC3C,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,iEAAiE;IACjE,IAAI,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,qDAAqD;IACrD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAChD,iEAAiE;IACjE,IAAI,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACrC,OAAO,IAAI,OAAO,GAAG,CAAC;IACvB,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC9B,OAAe,EACf,OAAiB,EAAE,EACnB,UAAwB,EAAE;IAE1B,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;IAE/C,yDAAyD;IACzD,MAAM,QAAQ,GAAG,CAAC,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC;IAEnE,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,YAAY,GAAG,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEpD,IAAI,CAAC,YAAY,EAAE,CAAC;QACnB,uDAAuD;QACvD,OAAO,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,kFAAkF;IAClF,2EAA2E;IAC3E,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,SAAS,CAAC;IACjD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC/C,MAAM,eAAe,GAAG,IAAI,QAAQ,KAAK,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IAEjE,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,CAAC,EAAE;QAC1D,GAAG,OAAO;QACV,wBAAwB,EAAE,IAAI;QAC9B,KAAK,EAAE,KAAK;KACZ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git worktree manager — creates isolated worktrees for thread execution.
|
|
3
|
+
*
|
|
4
|
+
* Phase 2 enhancements:
|
|
5
|
+
* - Mutex on create() to prevent branch name races under concurrency
|
|
6
|
+
* - Retry logic for git worktree add (transient lock file contention)
|
|
7
|
+
*
|
|
8
|
+
* Lifecycle:
|
|
9
|
+
* 1. create() — git worktree add -b swarm/<id> <path> HEAD
|
|
10
|
+
* 2. Agent runs in worktree directory
|
|
11
|
+
* 3. getDiff() — capture changes
|
|
12
|
+
* 4. commit() — commit changes in worktree
|
|
13
|
+
* 5. destroy() — git worktree remove + branch cleanup
|
|
14
|
+
*/
|
|
15
|
+
import type { WorktreeInfo } from "../core/types.js";
|
|
16
|
+
/** Read a worktree without initializing a runtime or changing its real index. */
|
|
17
|
+
export declare function readWorktreeDiff(worktreePath: string, repoRoot: string): Promise<string>;
|
|
18
|
+
export declare class ScopeViolationError extends Error {
|
|
19
|
+
readonly files: readonly string[];
|
|
20
|
+
constructor(files: readonly string[]);
|
|
21
|
+
}
|
|
22
|
+
export declare function normalizeGitPath(file: string): string;
|
|
23
|
+
export declare function isWithinWriteScope(file: string, writeScope: readonly string[]): boolean;
|
|
24
|
+
export declare function isDeniedByWriteScope(file: string, denyScope: readonly string[]): boolean;
|
|
25
|
+
export declare function createRepositoryFingerprint(repoRoot: string): string;
|
|
26
|
+
export declare class WorktreeManager {
|
|
27
|
+
private repoRoot;
|
|
28
|
+
private baseDir;
|
|
29
|
+
private sessionId;
|
|
30
|
+
private repoFingerprint;
|
|
31
|
+
private worktrees;
|
|
32
|
+
private createMutex;
|
|
33
|
+
constructor(repoRoot: string, baseDir?: string, sessionId?: string);
|
|
34
|
+
getSessionId(): string;
|
|
35
|
+
getRepositoryFingerprint(): string;
|
|
36
|
+
isContextosWorktree(wtPath: string): boolean;
|
|
37
|
+
/** Ensure we're in a git repo and the base directory exists. */
|
|
38
|
+
init(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Create a new worktree for a thread.
|
|
41
|
+
* Serialized via mutex to prevent branch name races.
|
|
42
|
+
* Retries on transient lock-file contention.
|
|
43
|
+
*/
|
|
44
|
+
create(threadId: string): Promise<WorktreeInfo>;
|
|
45
|
+
private createWorktreeWithRetry;
|
|
46
|
+
/** Get HEAD commit SHA of a worktree. */
|
|
47
|
+
getHeadSha(threadId: string): Promise<string>;
|
|
48
|
+
/** Get diff of candidate worktree commits against baseSha. */
|
|
49
|
+
getCandidateDiff(threadId: string, baseSha: string): Promise<string>;
|
|
50
|
+
/** Get the git diff of uncommitted changes in a worktree. */
|
|
51
|
+
getDiff(threadId: string): Promise<string>;
|
|
52
|
+
/** Get diff stats (short summary). */
|
|
53
|
+
getDiffStats(threadId: string): Promise<string>;
|
|
54
|
+
/** Get list of changed files without mutating Git index. */
|
|
55
|
+
getChangedFiles(threadId: string): Promise<string[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Detect every worktree change, including untracked, staged, unstaged,
|
|
58
|
+
* committed, and both sides of renames, then enforce the immutable scope.
|
|
59
|
+
*/
|
|
60
|
+
assertWriteScope(threadId: string, baseSha: string, writeScope: readonly string[], denyScope?: readonly string[]): Promise<string[]>;
|
|
61
|
+
/** Commit all changes in a worktree. */
|
|
62
|
+
commit(threadId: string, message: string, writeScope?: readonly string[], denyScope?: readonly string[]): Promise<boolean>;
|
|
63
|
+
/** Destroy a worktree and optionally its branch. */
|
|
64
|
+
destroy(threadId: string, deleteBranch?: boolean): Promise<void>;
|
|
65
|
+
/** Get info for a thread's worktree. */
|
|
66
|
+
getWorktreeInfo(threadId: string): WorktreeInfo | undefined;
|
|
67
|
+
/** Cleanup all worktrees. Resilient — continues past individual failures. */
|
|
68
|
+
destroyAll(): Promise<void>;
|
|
69
|
+
}
|