overarch-linux-arm64 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +214 -0
- package/dist/bin/overarch.d.ts +2 -0
- package/dist/bin/overarch.js +178 -0
- package/dist/src/agent/context.d.ts +14 -0
- package/dist/src/agent/context.js +200 -0
- package/dist/src/agent/context_compressor.d.ts +21 -0
- package/dist/src/agent/context_compressor.js +90 -0
- package/dist/src/agent/manifest.d.ts +22 -0
- package/dist/src/agent/manifest.js +131 -0
- package/dist/src/agent/planner.d.ts +38 -0
- package/dist/src/agent/planner.js +118 -0
- package/dist/src/agent/runtime.d.ts +59 -0
- package/dist/src/agent/runtime.js +400 -0
- package/dist/src/cli/approval.d.ts +13 -0
- package/dist/src/cli/approval.js +71 -0
- package/dist/src/cli/args.d.ts +15 -0
- package/dist/src/cli/args.js +47 -0
- package/dist/src/cli/commands/audit.d.ts +10 -0
- package/dist/src/cli/commands/audit.js +79 -0
- package/dist/src/cli/commands/companion.d.ts +1 -0
- package/dist/src/cli/commands/companion.js +143 -0
- package/dist/src/cli/commands/config.d.ts +1 -0
- package/dist/src/cli/commands/config.js +135 -0
- package/dist/src/cli/commands/doctor.d.ts +1 -0
- package/dist/src/cli/commands/doctor.js +217 -0
- package/dist/src/cli/commands/init.d.ts +1 -0
- package/dist/src/cli/commands/init.js +134 -0
- package/dist/src/cli/commands/memory.d.ts +2 -0
- package/dist/src/cli/commands/memory.js +98 -0
- package/dist/src/cli/commands/onboarding.d.ts +3 -0
- package/dist/src/cli/commands/onboarding.js +223 -0
- package/dist/src/cli/commands/sessions.d.ts +1 -0
- package/dist/src/cli/commands/sessions.js +22 -0
- package/dist/src/cli/commands/status.d.ts +1 -0
- package/dist/src/cli/commands/status.js +37 -0
- package/dist/src/cli/commands/update.d.ts +9 -0
- package/dist/src/cli/commands/update.js +105 -0
- package/dist/src/cli/repl.d.ts +3 -0
- package/dist/src/cli/repl.js +821 -0
- package/dist/src/cli/ui.d.ts +53 -0
- package/dist/src/cli/ui.js +215 -0
- package/dist/src/companion/petdex_adapter.d.ts +31 -0
- package/dist/src/companion/petdex_adapter.js +171 -0
- package/dist/src/companion/petdex_bridge.d.ts +65 -0
- package/dist/src/companion/petdex_bridge.js +356 -0
- package/dist/src/companion/types.d.ts +57 -0
- package/dist/src/companion/types.js +11 -0
- package/dist/src/config/index.d.ts +24 -0
- package/dist/src/config/index.js +237 -0
- package/dist/src/config/types.d.ts +58 -0
- package/dist/src/config/types.js +7 -0
- package/dist/src/core/diagnostics.d.ts +48 -0
- package/dist/src/core/diagnostics.js +115 -0
- package/dist/src/core/index.d.ts +23 -0
- package/dist/src/core/index.js +23 -0
- package/dist/src/core/mission.d.ts +55 -0
- package/dist/src/core/mission.js +173 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/learning/memory_manager.d.ts +26 -0
- package/dist/src/learning/memory_manager.js +211 -0
- package/dist/src/learning/types.d.ts +54 -0
- package/dist/src/learning/types.js +1 -0
- package/dist/src/mcp/registry.d.ts +17 -0
- package/dist/src/mcp/registry.js +97 -0
- package/dist/src/mcp/types.d.ts +13 -0
- package/dist/src/mcp/types.js +1 -0
- package/dist/src/providers/anthropic.d.ts +10 -0
- package/dist/src/providers/anthropic.js +95 -0
- package/dist/src/providers/base.d.ts +15 -0
- package/dist/src/providers/base.js +108 -0
- package/dist/src/providers/factory.d.ts +28 -0
- package/dist/src/providers/factory.js +142 -0
- package/dist/src/providers/gemini.d.ts +10 -0
- package/dist/src/providers/gemini.js +97 -0
- package/dist/src/providers/openai.d.ts +9 -0
- package/dist/src/providers/openai.js +85 -0
- package/dist/src/providers/openrouter.d.ts +5 -0
- package/dist/src/providers/openrouter.js +14 -0
- package/dist/src/providers/registry.d.ts +19 -0
- package/dist/src/providers/registry.js +209 -0
- package/dist/src/providers/types.d.ts +59 -0
- package/dist/src/providers/types.js +1 -0
- package/dist/src/providers/validator.d.ts +24 -0
- package/dist/src/providers/validator.js +161 -0
- package/dist/src/security/audit.d.ts +56 -0
- package/dist/src/security/audit.js +154 -0
- package/dist/src/security/guardrails.d.ts +9 -0
- package/dist/src/security/guardrails.js +32 -0
- package/dist/src/security/permissions.d.ts +12 -0
- package/dist/src/security/permissions.js +68 -0
- package/dist/src/security/policy.d.ts +220 -0
- package/dist/src/security/policy.js +720 -0
- package/dist/src/session/manager.d.ts +22 -0
- package/dist/src/session/manager.js +172 -0
- package/dist/src/session/types.d.ts +36 -0
- package/dist/src/session/types.js +1 -0
- package/dist/src/tools/checkpoint.d.ts +26 -0
- package/dist/src/tools/checkpoint.js +160 -0
- package/dist/src/tools/diagnostics.d.ts +2 -0
- package/dist/src/tools/diagnostics.js +125 -0
- package/dist/src/tools/diff.d.ts +14 -0
- package/dist/src/tools/diff.js +124 -0
- package/dist/src/tools/filesystem.d.ts +2 -0
- package/dist/src/tools/filesystem.js +224 -0
- package/dist/src/tools/git.d.ts +2 -0
- package/dist/src/tools/git.js +138 -0
- package/dist/src/tools/markdown.d.ts +33 -0
- package/dist/src/tools/markdown.js +190 -0
- package/dist/src/tools/project.d.ts +2 -0
- package/dist/src/tools/project.js +63 -0
- package/dist/src/tools/registry.d.ts +14 -0
- package/dist/src/tools/registry.js +230 -0
- package/dist/src/tools/search.d.ts +2 -0
- package/dist/src/tools/search.js +136 -0
- package/dist/src/tools/shell.d.ts +2 -0
- package/dist/src/tools/shell.js +74 -0
- package/dist/src/tools/symbols.d.ts +30 -0
- package/dist/src/tools/symbols.js +155 -0
- package/dist/src/tools/types.d.ts +28 -0
- package/dist/src/tools/types.js +1 -0
- package/dist/src/tools/web_search.d.ts +14 -0
- package/dist/src/tools/web_search.js +154 -0
- package/install.sh +29 -0
- package/overarch +15 -0
- package/package.json +28 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Estimates token count from text using standard ~4 characters per token heuristic
|
|
3
|
+
*/
|
|
4
|
+
export function estimateTokens(text) {
|
|
5
|
+
if (!text)
|
|
6
|
+
return 0;
|
|
7
|
+
return Math.ceil(text.length / 4);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Estimates token count for an array of messages
|
|
11
|
+
*/
|
|
12
|
+
export function estimateMessagesTokens(messages) {
|
|
13
|
+
let count = 0;
|
|
14
|
+
for (const m of messages) {
|
|
15
|
+
count += estimateTokens(m.content);
|
|
16
|
+
if (m.toolCalls) {
|
|
17
|
+
count += estimateTokens(JSON.stringify(m.toolCalls));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return count;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Compresses conversation history to stay within a configured token budget,
|
|
24
|
+
* preserving critical goals, plans, recent file diffs, and verification evidence
|
|
25
|
+
* while summarizing verbose intermediate tool executions.
|
|
26
|
+
*/
|
|
27
|
+
export function compressContext(messages, maxTokens = 60000) {
|
|
28
|
+
const originalTokens = estimateMessagesTokens(messages);
|
|
29
|
+
if (originalTokens <= maxTokens || messages.length <= 6) {
|
|
30
|
+
return {
|
|
31
|
+
messages,
|
|
32
|
+
originalTokens,
|
|
33
|
+
compressedTokens: originalTokens,
|
|
34
|
+
didCompress: false
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const result = [];
|
|
38
|
+
// Keep first message (often user's main objective)
|
|
39
|
+
result.push(messages[0]);
|
|
40
|
+
// Intermediate messages (slice between 1 and length - 4) are candidates for compression
|
|
41
|
+
const intermediate = messages.slice(1, messages.length - 4);
|
|
42
|
+
const recent = messages.slice(messages.length - 4);
|
|
43
|
+
for (const m of intermediate) {
|
|
44
|
+
if (m.role === 'tool') {
|
|
45
|
+
// Compress verbose tool output if it exceeds 300 characters
|
|
46
|
+
if (m.content.length > 300) {
|
|
47
|
+
try {
|
|
48
|
+
const parsed = JSON.parse(m.content);
|
|
49
|
+
const success = parsed.success !== false ? 'success' : 'failed';
|
|
50
|
+
const summary = parsed.error ? `Error: ${parsed.error}` : `Output: ${String(parsed.output || '').slice(0, 100)}...`;
|
|
51
|
+
result.push({
|
|
52
|
+
role: 'tool',
|
|
53
|
+
toolCallId: m.toolCallId,
|
|
54
|
+
content: JSON.stringify({ success: parsed.success, summary, compressed: true })
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
result.push({
|
|
59
|
+
role: 'tool',
|
|
60
|
+
toolCallId: m.toolCallId,
|
|
61
|
+
content: m.content.slice(0, 150) + '... [output compressed]'
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
result.push(m);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else if (m.role === 'assistant' && m.content.length > 500) {
|
|
70
|
+
// Retain assistant toolCalls intact, but truncate verbose discursive text
|
|
71
|
+
result.push({
|
|
72
|
+
role: 'assistant',
|
|
73
|
+
content: m.content.slice(0, 250) + '... [reasoning compressed for brevity]',
|
|
74
|
+
toolCalls: m.toolCalls
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
result.push(m);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Always append the latest messages intact
|
|
82
|
+
result.push(...recent);
|
|
83
|
+
const compressedTokens = estimateMessagesTokens(result);
|
|
84
|
+
return {
|
|
85
|
+
messages: result,
|
|
86
|
+
originalTokens,
|
|
87
|
+
compressedTokens,
|
|
88
|
+
didCompress: true
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface RepoManifest {
|
|
2
|
+
name: string;
|
|
3
|
+
cwd: string;
|
|
4
|
+
projectTypes: string[];
|
|
5
|
+
entryPoints: string[];
|
|
6
|
+
buildSystems: string[];
|
|
7
|
+
keyDirectories: string[];
|
|
8
|
+
testDirectories: string[];
|
|
9
|
+
testToSourceMap: Record<string, string>;
|
|
10
|
+
git: {
|
|
11
|
+
branch: string;
|
|
12
|
+
isClean: boolean;
|
|
13
|
+
modifiedFiles: string[];
|
|
14
|
+
};
|
|
15
|
+
configFiles: string[];
|
|
16
|
+
documentationFiles: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Builds a structured manifest and architecture map of the repository.
|
|
20
|
+
* Discovers entry points, build configs, documentation, git status, and test-to-source relationships.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildRepoManifest(cwd?: string): Promise<RepoManifest>;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { exec } from 'node:child_process';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
const execAsync = promisify(exec);
|
|
6
|
+
/**
|
|
7
|
+
* Builds a structured manifest and architecture map of the repository.
|
|
8
|
+
* Discovers entry points, build configs, documentation, git status, and test-to-source relationships.
|
|
9
|
+
*/
|
|
10
|
+
export async function buildRepoManifest(cwd = process.cwd()) {
|
|
11
|
+
const manifest = {
|
|
12
|
+
name: path.basename(cwd),
|
|
13
|
+
cwd,
|
|
14
|
+
projectTypes: [],
|
|
15
|
+
entryPoints: [],
|
|
16
|
+
buildSystems: [],
|
|
17
|
+
keyDirectories: [],
|
|
18
|
+
testDirectories: [],
|
|
19
|
+
testToSourceMap: {},
|
|
20
|
+
git: {
|
|
21
|
+
branch: 'unknown',
|
|
22
|
+
isClean: true,
|
|
23
|
+
modifiedFiles: []
|
|
24
|
+
},
|
|
25
|
+
configFiles: [],
|
|
26
|
+
documentationFiles: []
|
|
27
|
+
};
|
|
28
|
+
// 1. Git Awareness
|
|
29
|
+
try {
|
|
30
|
+
const { stdout: branch } = await execAsync('git branch --show-current', { cwd });
|
|
31
|
+
manifest.git.branch = branch.trim() || 'HEAD';
|
|
32
|
+
const { stdout: status } = await execAsync('git status --porcelain', { cwd });
|
|
33
|
+
const lines = status.trim().split('\n').map(l => l.trim()).filter(Boolean);
|
|
34
|
+
manifest.git.isClean = lines.length === 0;
|
|
35
|
+
manifest.git.modifiedFiles = lines.map(l => l.slice(3).trim());
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
manifest.git.branch = 'non-git';
|
|
39
|
+
}
|
|
40
|
+
// 2. Package Managers & Build Systems
|
|
41
|
+
const buildFiles = [
|
|
42
|
+
{ file: 'package.json', type: 'Node.js', build: 'npm / pnpm / yarn' },
|
|
43
|
+
{ file: 'tsconfig.json', type: 'TypeScript', build: 'tsc' },
|
|
44
|
+
{ file: 'Cargo.toml', type: 'Rust', build: 'cargo' },
|
|
45
|
+
{ file: 'pyproject.toml', type: 'Python', build: 'pip / poetry' },
|
|
46
|
+
{ file: 'requirements.txt', type: 'Python', build: 'pip' },
|
|
47
|
+
{ file: 'go.mod', type: 'Go', build: 'go' },
|
|
48
|
+
{ file: 'Makefile', type: 'Make', build: 'make' },
|
|
49
|
+
{ file: 'docker-compose.yml', type: 'Docker', build: 'docker-compose' },
|
|
50
|
+
{ file: 'Dockerfile', type: 'Docker', build: 'docker' }
|
|
51
|
+
];
|
|
52
|
+
for (const b of buildFiles) {
|
|
53
|
+
try {
|
|
54
|
+
await fs.access(path.join(cwd, b.file));
|
|
55
|
+
if (!manifest.projectTypes.includes(b.type))
|
|
56
|
+
manifest.projectTypes.push(b.type);
|
|
57
|
+
if (!manifest.buildSystems.includes(b.build))
|
|
58
|
+
manifest.buildSystems.push(b.build);
|
|
59
|
+
manifest.configFiles.push(b.file);
|
|
60
|
+
}
|
|
61
|
+
catch { }
|
|
62
|
+
}
|
|
63
|
+
// Node.js specific entry points from package.json
|
|
64
|
+
try {
|
|
65
|
+
const pkgContent = await fs.readFile(path.join(cwd, 'package.json'), 'utf8');
|
|
66
|
+
const pkg = JSON.parse(pkgContent);
|
|
67
|
+
if (pkg.name)
|
|
68
|
+
manifest.name = pkg.name;
|
|
69
|
+
if (pkg.main)
|
|
70
|
+
manifest.entryPoints.push(pkg.main);
|
|
71
|
+
if (pkg.module)
|
|
72
|
+
manifest.entryPoints.push(pkg.module);
|
|
73
|
+
if (pkg.bin) {
|
|
74
|
+
if (typeof pkg.bin === 'string')
|
|
75
|
+
manifest.entryPoints.push(pkg.bin);
|
|
76
|
+
else if (typeof pkg.bin === 'object')
|
|
77
|
+
manifest.entryPoints.push(...Object.values(pkg.bin));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch { }
|
|
81
|
+
// 3. Scan directory structure (shallow + key subdirs)
|
|
82
|
+
const ignoredDirs = new Set(['node_modules', '.git', 'dist', 'build', '.next', '.turbo', '.cache', 'coverage']);
|
|
83
|
+
try {
|
|
84
|
+
const entries = await fs.readdir(cwd, { withFileTypes: true });
|
|
85
|
+
for (const entry of entries) {
|
|
86
|
+
if (entry.isDirectory()) {
|
|
87
|
+
if (ignoredDirs.has(entry.name))
|
|
88
|
+
continue;
|
|
89
|
+
const dirName = entry.name.toLowerCase();
|
|
90
|
+
if (dirName.includes('test') || dirName === '__tests__' || dirName === 'spec') {
|
|
91
|
+
manifest.testDirectories.push(entry.name);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
manifest.keyDirectories.push(entry.name);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (entry.isFile()) {
|
|
98
|
+
const lower = entry.name.toLowerCase();
|
|
99
|
+
if (lower.endsWith('.md') || lower.endsWith('.txt') || lower === 'license') {
|
|
100
|
+
manifest.documentationFiles.push(entry.name);
|
|
101
|
+
}
|
|
102
|
+
if (lower === 'main.py' || lower === 'app.py' || lower === 'main.go' || lower === 'index.js' || lower === 'index.ts') {
|
|
103
|
+
manifest.entryPoints.push(entry.name);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch { }
|
|
109
|
+
// 4. Map test files to source files
|
|
110
|
+
for (const testDir of manifest.testDirectories) {
|
|
111
|
+
try {
|
|
112
|
+
const testFiles = await fs.readdir(path.join(cwd, testDir));
|
|
113
|
+
for (const tf of testFiles) {
|
|
114
|
+
if (!tf.endsWith('.js') && !tf.endsWith('.ts') && !tf.endsWith('.py') && !tf.endsWith('.go'))
|
|
115
|
+
continue;
|
|
116
|
+
const baseName = tf.replace(/(\.test|\.spec|_test)\.(ts|js|py|go)$/, '');
|
|
117
|
+
// Search in src/ or cwd for matching source
|
|
118
|
+
const potentialSources = [
|
|
119
|
+
path.join('src', `${baseName}.ts`),
|
|
120
|
+
path.join('src', `${baseName}.js`),
|
|
121
|
+
`${baseName}.ts`,
|
|
122
|
+
`${baseName}.py`,
|
|
123
|
+
`${baseName}.go`
|
|
124
|
+
];
|
|
125
|
+
manifest.testToSourceMap[path.join(testDir, tf)] = potentialSources[0];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch { }
|
|
129
|
+
}
|
|
130
|
+
return manifest;
|
|
131
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CcssMode } from '../config/types.js';
|
|
2
|
+
export interface Plan {
|
|
3
|
+
goal: string;
|
|
4
|
+
steps: PlanStep[];
|
|
5
|
+
}
|
|
6
|
+
export interface PlanStep {
|
|
7
|
+
id: number;
|
|
8
|
+
description: string;
|
|
9
|
+
status: 'pending' | 'running' | 'done' | 'failed' | 'skipped';
|
|
10
|
+
toolName?: string;
|
|
11
|
+
result?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CcssModeConfig {
|
|
14
|
+
mode: CcssMode;
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
planningDepth: 'concise' | 'standard' | 'deep';
|
|
18
|
+
requireCheckpoint: boolean;
|
|
19
|
+
verificationIntensity: 'none' | 'relevant' | 'strict';
|
|
20
|
+
parallelInspection: boolean;
|
|
21
|
+
approvalGate: 'auto' | 'standard' | 'strict';
|
|
22
|
+
}
|
|
23
|
+
export declare const CCSS_MODE_CONFIGS: Record<CcssMode, CcssModeConfig>;
|
|
24
|
+
/**
|
|
25
|
+
* Parses `/ccss [mode] [prompt]` commands, supporting:
|
|
26
|
+
* - `/ccss` (shows status)
|
|
27
|
+
* - `/ccss god` (switches mode to god)
|
|
28
|
+
* - `/ccss god refactor auth system` (switches mode and runs prompt)
|
|
29
|
+
* - `/ccss status`
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseCcssCommand(input: string): {
|
|
32
|
+
mode?: CcssMode;
|
|
33
|
+
prompt?: string;
|
|
34
|
+
isStatus?: boolean;
|
|
35
|
+
};
|
|
36
|
+
export declare function parsePlan(text: string): Plan | null;
|
|
37
|
+
export declare function formatPlan(plan: Plan): string;
|
|
38
|
+
export declare function updateStep(plan: Plan, stepId: number, status: PlanStep['status'], result?: string): void;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export const CCSS_MODE_CONFIGS = {
|
|
2
|
+
auto: {
|
|
3
|
+
mode: 'auto',
|
|
4
|
+
name: 'Auto Mode',
|
|
5
|
+
description: 'Pragmatic autonomy: execute safe work, verify changes, deliver concisely.',
|
|
6
|
+
planningDepth: 'concise',
|
|
7
|
+
requireCheckpoint: false,
|
|
8
|
+
verificationIntensity: 'relevant',
|
|
9
|
+
parallelInspection: true,
|
|
10
|
+
approvalGate: 'auto'
|
|
11
|
+
},
|
|
12
|
+
master: {
|
|
13
|
+
mode: 'master',
|
|
14
|
+
name: 'Master Mission',
|
|
15
|
+
description: 'Architectural orchestration: structured milestones, risk analysis, pre-mutation checkpoints.',
|
|
16
|
+
planningDepth: 'standard',
|
|
17
|
+
requireCheckpoint: true,
|
|
18
|
+
verificationIntensity: 'relevant',
|
|
19
|
+
parallelInspection: true,
|
|
20
|
+
approvalGate: 'standard'
|
|
21
|
+
},
|
|
22
|
+
god: {
|
|
23
|
+
mode: 'god',
|
|
24
|
+
name: 'God Mode',
|
|
25
|
+
description: 'Maximum orchestration depth: deep decomposition, alternative paths, strict verification.',
|
|
26
|
+
planningDepth: 'deep',
|
|
27
|
+
requireCheckpoint: true,
|
|
28
|
+
verificationIntensity: 'strict',
|
|
29
|
+
parallelInspection: true,
|
|
30
|
+
approvalGate: 'standard'
|
|
31
|
+
},
|
|
32
|
+
control: {
|
|
33
|
+
mode: 'control',
|
|
34
|
+
name: 'Control Mode',
|
|
35
|
+
description: 'Human-in-the-loop: explicit gates before every state mutation, step-by-step rollback.',
|
|
36
|
+
planningDepth: 'standard',
|
|
37
|
+
requireCheckpoint: true,
|
|
38
|
+
verificationIntensity: 'strict',
|
|
39
|
+
parallelInspection: false,
|
|
40
|
+
approvalGate: 'strict'
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Parses `/ccss [mode] [prompt]` commands, supporting:
|
|
45
|
+
* - `/ccss` (shows status)
|
|
46
|
+
* - `/ccss god` (switches mode to god)
|
|
47
|
+
* - `/ccss god refactor auth system` (switches mode and runs prompt)
|
|
48
|
+
* - `/ccss status`
|
|
49
|
+
*/
|
|
50
|
+
export function parseCcssCommand(input) {
|
|
51
|
+
const trimmed = input.trim();
|
|
52
|
+
const match = trimmed.match(/^\/ccss(?:\s+([a-zA-Z0-9_-]+))?(?:\s+(.*))?$/i);
|
|
53
|
+
if (!match) {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
const rawArg = (match[1] || '').toLowerCase();
|
|
57
|
+
const restPrompt = (match[2] || '').trim();
|
|
58
|
+
if (!rawArg || rawArg === 'status') {
|
|
59
|
+
return { isStatus: true };
|
|
60
|
+
}
|
|
61
|
+
const validModes = ['auto', 'master', 'god', 'control'];
|
|
62
|
+
if (validModes.includes(rawArg)) {
|
|
63
|
+
return {
|
|
64
|
+
mode: rawArg,
|
|
65
|
+
prompt: restPrompt || undefined
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// If user typed `/ccss do this thing`, treat rawArg as start of prompt
|
|
69
|
+
return {
|
|
70
|
+
prompt: `${rawArg} ${restPrompt}`.trim()
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export function parsePlan(text) {
|
|
74
|
+
const lines = text.split('\n');
|
|
75
|
+
const steps = [];
|
|
76
|
+
for (const line of lines) {
|
|
77
|
+
const match = line.match(/^(\d+)\.\s+(.*)/);
|
|
78
|
+
if (match) {
|
|
79
|
+
steps.push({
|
|
80
|
+
id: parseInt(match[1], 10),
|
|
81
|
+
description: match[2].trim(),
|
|
82
|
+
status: 'pending'
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (steps.length > 0) {
|
|
87
|
+
return {
|
|
88
|
+
goal: 'Generated Plan',
|
|
89
|
+
steps
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
export function formatPlan(plan) {
|
|
95
|
+
let output = `Plan: ${plan.goal}\n`;
|
|
96
|
+
for (const step of plan.steps) {
|
|
97
|
+
let icon = '○';
|
|
98
|
+
if (step.status === 'running')
|
|
99
|
+
icon = '●';
|
|
100
|
+
if (step.status === 'done')
|
|
101
|
+
icon = '✓';
|
|
102
|
+
if (step.status === 'failed')
|
|
103
|
+
icon = '✗';
|
|
104
|
+
if (step.status === 'skipped')
|
|
105
|
+
icon = '⊘';
|
|
106
|
+
output += `${icon} ${step.id}. ${step.description}\n`;
|
|
107
|
+
}
|
|
108
|
+
return output;
|
|
109
|
+
}
|
|
110
|
+
export function updateStep(plan, stepId, status, result) {
|
|
111
|
+
const step = plan.steps.find(s => s.id === stepId);
|
|
112
|
+
if (step) {
|
|
113
|
+
step.status = status;
|
|
114
|
+
if (result) {
|
|
115
|
+
step.result = result;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as readline from 'node:readline/promises';
|
|
2
|
+
import { ToolRegistry } from '../tools/registry.js';
|
|
3
|
+
import { ToolResult } from '../tools/types.js';
|
|
4
|
+
import { OverarchConfig, CcssMode } from '../config/types.js';
|
|
5
|
+
import { Plan } from './planner.js';
|
|
6
|
+
import { LLMProvider, Message } from '../providers/types.js';
|
|
7
|
+
import { AgentState } from '../companion/types.js';
|
|
8
|
+
import { MemoryManager } from '../learning/memory_manager.js';
|
|
9
|
+
export interface EpistemicReport {
|
|
10
|
+
goal: string;
|
|
11
|
+
ccssMode: CcssMode;
|
|
12
|
+
iterations: number;
|
|
13
|
+
filesModified: string[];
|
|
14
|
+
toolsExecuted: number;
|
|
15
|
+
verificationStatus: 'verified' | 'skipped' | 'unverified';
|
|
16
|
+
}
|
|
17
|
+
export interface AgentCallbacks {
|
|
18
|
+
onText: (chunk: string) => void;
|
|
19
|
+
onToolStart: (name: string, params: Record<string, unknown>) => void;
|
|
20
|
+
onToolEnd: (name: string, result: ToolResult) => void;
|
|
21
|
+
onPlan: (plan: Plan) => void;
|
|
22
|
+
onError: (error: Error) => void;
|
|
23
|
+
onStateChange?: (state: AgentState, message?: string) => void;
|
|
24
|
+
onReport?: (report: EpistemicReport) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare class AgentRuntime {
|
|
27
|
+
private provider;
|
|
28
|
+
private toolRegistry;
|
|
29
|
+
private config;
|
|
30
|
+
private options;
|
|
31
|
+
private messages;
|
|
32
|
+
private checkpointManager;
|
|
33
|
+
private memoryManager;
|
|
34
|
+
constructor(provider: LLMProvider, toolRegistry: ToolRegistry, config: OverarchConfig, options?: {
|
|
35
|
+
autoApprove?: boolean;
|
|
36
|
+
verbose?: boolean;
|
|
37
|
+
rl?: readline.Interface;
|
|
38
|
+
cwd?: string;
|
|
39
|
+
});
|
|
40
|
+
setConfig(newConfig: OverarchConfig): void;
|
|
41
|
+
setProvider(newProvider: LLMProvider): void;
|
|
42
|
+
/**
|
|
43
|
+
* Production 7-Stage Agent Pipeline:
|
|
44
|
+
* 1. Understand: Parse goal, establish epistemic tracking
|
|
45
|
+
* 2. Inspect: Discover repository state, parallel read-only tool inspection
|
|
46
|
+
* 3. Plan: Structure roadmap and milestones
|
|
47
|
+
* 4. Approve: CCHCFAI authority gating, pre-mutation checkpointing
|
|
48
|
+
* 5. Execute: Sequential deterministic tool mutations with loop prevention
|
|
49
|
+
* 6. Verify: Auto-verification of modifications
|
|
50
|
+
* 7. Report: Synthesize evidence-based completion summary
|
|
51
|
+
*/
|
|
52
|
+
run(userMessage: string, systemContext: string, callbacks: AgentCallbacks): Promise<string>;
|
|
53
|
+
private executeSingleToolCall;
|
|
54
|
+
private mapToolToState;
|
|
55
|
+
getMemoryManager(): MemoryManager;
|
|
56
|
+
abort(): void;
|
|
57
|
+
getMessages(): Message[];
|
|
58
|
+
setMessages(messages: Message[]): void;
|
|
59
|
+
}
|