codehere 1.0.1 → 1.0.2
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 +36 -192
- package/dist/application/use-cases/check-claimed-tests.js +81 -0
- package/dist/application/use-cases/detect-test-weakening.js +237 -0
- package/dist/application/use-cases/rerun-tests.js +110 -7
- package/dist/index.js +38 -1212
- package/dist/infrastructure/orchestration/artifacts-extractor.js +2 -323
- package/dist/presentation/cli/commands/check-command.js +178 -23
- package/dist/presentation/cli/commands/help-command.js +21 -285
- package/dist/ui.js +5 -236
- package/dist/utils/version.js +0 -6
- package/package.json +9 -38
- package/dist/application/services/verdict-service.js +0 -154
- package/dist/application/use-cases/assess-cross-vendor.js +0 -126
- package/dist/application/use-cases/build-cross-vendor-verdict.js +0 -118
- package/dist/application/use-cases/domain-trust.js +0 -110
- package/dist/application/use-cases/export-aat.js +0 -107
- package/dist/application/use-cases/generate-acceptance-criteria.js +0 -223
- package/dist/application/use-cases/generate-final-report.js +0 -259
- package/dist/application/use-cases/generate-narration.js +0 -130
- package/dist/application/use-cases/generate-thread-title.js +0 -181
- package/dist/application/use-cases/narrator-prompt-template.js +0 -158
- package/dist/application/use-cases/plan-auto-review.js +0 -57
- package/dist/application/use-cases/reconcile-audit.js +0 -100
- package/dist/application/use-cases/search-sessions.js +0 -70
- package/dist/application/use-cases/should-auto-review.js +0 -71
- package/dist/application/use-cases/thread-export.js +0 -245
- package/dist/application/use-cases/verify-claim.js +0 -456
- package/dist/application/use-cases/write-pass.js +0 -277
- package/dist/domain/audit.js +0 -11
- package/dist/domain/services/codebase-detector.js +0 -85
- package/dist/domain/task.js +0 -91
- package/dist/error-handler.js +0 -139
- package/dist/infrastructure/completion/bash-completion.js +0 -29
- package/dist/infrastructure/completion/fish-completion.js +0 -17
- package/dist/infrastructure/completion/zsh-completion.js +0 -25
- package/dist/infrastructure/config/config-manager.js +0 -174
- package/dist/infrastructure/config/product-context.js +0 -49
- package/dist/infrastructure/context/adapters/drawio-source.js +0 -157
- package/dist/infrastructure/context/adapters/figma-source.js +0 -198
- package/dist/infrastructure/context/adapters/github-issue-source.js +0 -160
- package/dist/infrastructure/context/adapters/linear-source.js +0 -190
- package/dist/infrastructure/context/context-resolver.js +0 -144
- package/dist/infrastructure/context/context-source.js +0 -114
- package/dist/infrastructure/context/github-api.js +0 -110
- package/dist/infrastructure/context/github-device-flow.js +0 -65
- package/dist/infrastructure/context/oauth-flow.js +0 -207
- package/dist/infrastructure/context/oauth-store.js +0 -122
- package/dist/infrastructure/context/registry-bootstrap.js +0 -95
- package/dist/infrastructure/context/write-pass-resolver.js +0 -106
- package/dist/infrastructure/cost/budget-config.js +0 -114
- package/dist/infrastructure/cost/cost-router.js +0 -97
- package/dist/infrastructure/cost/spend-aggregator.js +0 -222
- package/dist/infrastructure/cost/team-ledger.js +0 -355
- package/dist/infrastructure/discovery/discovery-log.js +0 -85
- package/dist/infrastructure/hooks/audit-tip-signature.js +0 -336
- package/dist/infrastructure/hooks/claude-sdk-hook.js +0 -1018
- package/dist/infrastructure/hooks/hook-mode.js +0 -87
- package/dist/infrastructure/hooks/mirror-tool-call-to-audit.js +0 -49
- package/dist/infrastructure/hooks/pre-prompt-scan.js +0 -122
- package/dist/infrastructure/hooks/session-analyzer.js +0 -177
- package/dist/infrastructure/observability/execution-tracer.js +0 -227
- package/dist/infrastructure/orchestration/agent-adapter.js +0 -13
- package/dist/infrastructure/orchestration/agent-installer.js +0 -101
- package/dist/infrastructure/orchestration/agents-config-seed.js +0 -68
- package/dist/infrastructure/orchestration/aider-adapter.js +0 -611
- package/dist/infrastructure/orchestration/cassette-recorder.js +0 -120
- package/dist/infrastructure/orchestration/claude-code-adapter.js +0 -592
- package/dist/infrastructure/orchestration/codex-adapter.js +0 -574
- package/dist/infrastructure/orchestration/conductor-adapter.js +0 -416
- package/dist/infrastructure/orchestration/context-handoff.js +0 -162
- package/dist/infrastructure/orchestration/control/codex-control-surface.js +0 -99
- package/dist/infrastructure/orchestration/control/control-surface.js +0 -15
- package/dist/infrastructure/orchestration/detect-ollama.js +0 -75
- package/dist/infrastructure/orchestration/failover-classifier.js +0 -151
- package/dist/infrastructure/orchestration/failover-config.js +0 -67
- package/dist/infrastructure/orchestration/failover-policy.js +0 -106
- package/dist/infrastructure/orchestration/gemini-adapter.js +0 -663
- package/dist/infrastructure/orchestration/generic-cli-adapter.js +0 -689
- package/dist/infrastructure/orchestration/graphify-context.js +0 -209
- package/dist/infrastructure/orchestration/memory-injector.js +0 -380
- package/dist/infrastructure/orchestration/mocks/mock-agent-repl.js +0 -388
- package/dist/infrastructure/orchestration/mocks/mock-codex-app-server.js +0 -73
- package/dist/infrastructure/orchestration/mocks/mock-synthesis.js +0 -83
- package/dist/infrastructure/orchestration/mocks/resolve-agent-spawn.js +0 -37
- package/dist/infrastructure/orchestration/opencode-adapter.js +0 -580
- package/dist/infrastructure/orchestration/progress-aggregator.js +0 -906
- package/dist/infrastructure/orchestration/readiness.js +0 -103
- package/dist/infrastructure/orchestration/session-manager.js +0 -1590
- package/dist/infrastructure/orchestration/session-persistence.js +0 -394
- package/dist/infrastructure/orchestration/thread-key-store.js +0 -127
- package/dist/infrastructure/orchestration/write-pass-store.js +0 -38
- package/dist/infrastructure/protocols/cloud-sync.js +0 -207
- package/dist/infrastructure/protocols/mcp-helpers.js +0 -25
- package/dist/infrastructure/protocols/mcp-server-impl.js +0 -3935
- package/dist/infrastructure/protocols/mcp-tools.js +0 -401
- package/dist/infrastructure/protocols/probe-port.js +0 -36
- package/dist/infrastructure/protocols/thread-phase.js +0 -105
- package/dist/infrastructure/protocols/ui/app-script-artifacts.js +0 -121
- package/dist/infrastructure/protocols/ui/app-script-audit-footer.js +0 -44
- package/dist/infrastructure/protocols/ui/app-script-audit-verify.js +0 -56
- package/dist/infrastructure/protocols/ui/app-script-composer-cost.js +0 -588
- package/dist/infrastructure/protocols/ui/app-script-context-sources.js +0 -168
- package/dist/infrastructure/protocols/ui/app-script-conversation.js +0 -67
- package/dist/infrastructure/protocols/ui/app-script-drawer.js +0 -115
- package/dist/infrastructure/protocols/ui/app-script-failover.js +0 -133
- package/dist/infrastructure/protocols/ui/app-script-github.js +0 -113
- package/dist/infrastructure/protocols/ui/app-script-observer.js +0 -104
- package/dist/infrastructure/protocols/ui/app-script-onboarding.js +0 -80
- package/dist/infrastructure/protocols/ui/app-script-overlay.js +0 -203
- package/dist/infrastructure/protocols/ui/app-script-recovery.js +0 -136
- package/dist/infrastructure/protocols/ui/app-script-render.js +0 -166
- package/dist/infrastructure/protocols/ui/app-script-share.js +0 -78
- package/dist/infrastructure/protocols/ui/app-script-sidebar.js +0 -194
- package/dist/infrastructure/protocols/ui/app-script-tour.js +0 -78
- package/dist/infrastructure/protocols/ui/app-script-wpass.js +0 -312
- package/dist/infrastructure/protocols/ui/app-script.js +0 -2998
- package/dist/infrastructure/protocols/ui/font-faces.js +0 -7
- package/dist/infrastructure/protocols/ui/styles.js +0 -2147
- package/dist/infrastructure/protocols/ui/tokens.js +0 -96
- package/dist/infrastructure/protocols/ui-page-v2.js +0 -320
- package/dist/infrastructure/protocols/verify-page.js +0 -1677
- package/dist/infrastructure/security/file-collection.js +0 -118
- package/dist/infrastructure/security/fix-code.js +0 -144
- package/dist/infrastructure/security/fix-secret.js +0 -89
- package/dist/infrastructure/security/permissions-config.js +0 -235
- package/dist/infrastructure/security/scan-types.js +0 -10
- package/dist/infrastructure/security/ship-scan.js +0 -195
- package/dist/infrastructure/security/trust-scorer.js +0 -724
- package/dist/infrastructure/security/vibe-checks.js +0 -99
- package/dist/infrastructure/storage/atomic-write.js +0 -86
- package/dist/infrastructure/storage/cross-tool-agents.js +0 -268
- package/dist/infrastructure/storage/project-thread-migration.js +0 -237
- package/dist/infrastructure/storage/project-thread-mirror.js +0 -671
- package/dist/infrastructure/storage/project-thread-reader.js +0 -409
- package/dist/infrastructure/storage/project-thread-title-backfill.js +0 -214
- package/dist/monitoring.js +0 -212
- package/dist/presentation/cli/commands/audit-command.js +0 -201
- package/dist/presentation/cli/commands/budget-command.js +0 -79
- package/dist/presentation/cli/commands/config-command.js +0 -125
- package/dist/presentation/cli/commands/context-source-command.js +0 -217
- package/dist/presentation/cli/commands/hook-command.js +0 -265
- package/dist/presentation/cli/commands/init-command.js +0 -590
- package/dist/presentation/cli/commands/memory-command.js +0 -1031
- package/dist/presentation/cli/commands/narrator-command.js +0 -101
- package/dist/presentation/cli/commands/permission-command.js +0 -105
- package/dist/presentation/cli/commands/protocols-builder.js +0 -254
- package/dist/presentation/cli/commands/protocols-command.js +0 -84
- package/dist/presentation/cli/commands/repo-map-builder.js +0 -247
- package/dist/presentation/cli/commands/report-command.js +0 -403
- package/dist/presentation/cli/commands/scan-command.js +0 -52
- package/dist/presentation/cli/commands/scan-tool-command.js +0 -110
- package/dist/presentation/cli/commands/search-command.js +0 -51
- package/dist/presentation/cli/commands/setup-command.js +0 -330
- package/dist/presentation/cli/commands/status-command.js +0 -614
- package/dist/presentation/cli/commands/team-command.js +0 -256
- package/dist/presentation/cli/commands/thread-command.js +0 -370
- package/dist/presentation/cli/commands/trust-command.js +0 -328
- package/dist/presentation/cli/commands/verify-command.js +0 -298
- package/dist/presentation/cli/error-display.js +0 -328
- package/dist/presentation/cli/repl.js +0 -805
- package/dist/presentation/cli/task-deliverable.js +0 -153
- package/dist/testing/cassette.js +0 -125
- package/dist/testing/replay-adapter.js +0 -147
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cloud sync bridge for codehere remote dashboard.
|
|
3
|
-
*
|
|
4
|
-
* Pushes session state to codehere.uk/api/sync every 30s.
|
|
5
|
-
* Pulls task assignments from cloud.
|
|
6
|
-
*
|
|
7
|
-
* What leaves the machine:
|
|
8
|
-
* - Session metadata (id, title, status, agent, project, tags, duration, tools, files, trustScore)
|
|
9
|
-
* - Machine identity (name, token hash)
|
|
10
|
-
*
|
|
11
|
-
* What stays local:
|
|
12
|
-
* - Code, file contents, API keys, git repos, full conversation threads
|
|
13
|
-
*/
|
|
14
|
-
import { randomUUID } from 'crypto';
|
|
15
|
-
import { readFileSync, existsSync, writeFileSync, mkdirSync } from 'fs';
|
|
16
|
-
import { join, dirname } from 'path';
|
|
17
|
-
import { homedir, hostname } from 'os';
|
|
18
|
-
const CLOUD_URL = 'https://codehere.uk/api/sync';
|
|
19
|
-
const TOKEN_PATH = join(process.env.CODEHERE_HOME || homedir(), '.codehere', 'cloud-token');
|
|
20
|
-
const SESSIONS_FILE = join(process.env.CODEHERE_HOME || homedir(), '.codehere', 'sessions.jsonl');
|
|
21
|
-
// Lazy-loaded session manager — imported once to avoid circular deps
|
|
22
|
-
let _sessionManager = null;
|
|
23
|
-
async function getSessionManager() {
|
|
24
|
-
if (!_sessionManager) {
|
|
25
|
-
const { SessionManager } = await import('../orchestration/session-manager.js');
|
|
26
|
-
_sessionManager = SessionManager.getInstance();
|
|
27
|
-
}
|
|
28
|
-
return _sessionManager;
|
|
29
|
-
}
|
|
30
|
-
// ── Token management ─────────────────────────────────────────────────────────
|
|
31
|
-
export function getOrCreateToken() {
|
|
32
|
-
if (existsSync(TOKEN_PATH)) {
|
|
33
|
-
return readFileSync(TOKEN_PATH, 'utf-8').trim();
|
|
34
|
-
}
|
|
35
|
-
const token = randomUUID();
|
|
36
|
-
const dir = dirname(TOKEN_PATH);
|
|
37
|
-
if (!existsSync(dir)) {
|
|
38
|
-
mkdirSync(dir, { recursive: true });
|
|
39
|
-
}
|
|
40
|
-
writeFileSync(TOKEN_PATH, token);
|
|
41
|
-
return token;
|
|
42
|
-
}
|
|
43
|
-
function formatDuration(ms) {
|
|
44
|
-
const seconds = Math.floor(ms / 1000);
|
|
45
|
-
if (seconds < 60)
|
|
46
|
-
return `${seconds}s`;
|
|
47
|
-
const minutes = Math.floor(seconds / 60);
|
|
48
|
-
const remainingSeconds = seconds % 60;
|
|
49
|
-
return `${minutes}m ${remainingSeconds}s`;
|
|
50
|
-
}
|
|
51
|
-
function extractProjectFromCwd(cwd) {
|
|
52
|
-
// Extract project name from cwd path (last directory component)
|
|
53
|
-
const parts = cwd.split('/').filter(Boolean);
|
|
54
|
-
return parts[parts.length - 1] || 'unknown';
|
|
55
|
-
}
|
|
56
|
-
function extractTrustScore(artifacts) {
|
|
57
|
-
return artifacts?.trustScore;
|
|
58
|
-
}
|
|
59
|
-
export function collectSessionMetadata() {
|
|
60
|
-
if (!existsSync(SESSIONS_FILE)) {
|
|
61
|
-
return [];
|
|
62
|
-
}
|
|
63
|
-
try {
|
|
64
|
-
const content = readFileSync(SESSIONS_FILE, 'utf-8');
|
|
65
|
-
const lines = content.split('\n').filter((l) => l.trim().length > 0);
|
|
66
|
-
// Parse records and pair spawned + completed
|
|
67
|
-
const spawnedMap = new Map();
|
|
68
|
-
const completedMap = new Map();
|
|
69
|
-
for (const line of lines) {
|
|
70
|
-
try {
|
|
71
|
-
const record = JSON.parse(line);
|
|
72
|
-
if (record.t === 'spawned') {
|
|
73
|
-
spawnedMap.set(record.id, record);
|
|
74
|
-
}
|
|
75
|
-
else if (record.t === 'completed') {
|
|
76
|
-
completedMap.set(record.id, record);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
// Skip malformed lines
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const sessions = [];
|
|
84
|
-
for (const [id, spawned] of spawnedMap.entries()) {
|
|
85
|
-
const completed = completedMap.get(id);
|
|
86
|
-
const status = completed
|
|
87
|
-
? completed.status === 'completed'
|
|
88
|
-
? 'done'
|
|
89
|
-
: completed.status === 'failed'
|
|
90
|
-
? 'failed'
|
|
91
|
-
: 'done'
|
|
92
|
-
: 'running';
|
|
93
|
-
const durationMs = completed?.durationMs ?? Date.now() - spawned.startedAt;
|
|
94
|
-
const tools = completed?.steps?.length ?? 0;
|
|
95
|
-
const files = completed?.artifacts?.filesChanged?.length ?? 0;
|
|
96
|
-
const trustScore = extractTrustScore(completed?.artifacts);
|
|
97
|
-
// Extract title from prompt (first line or first 80 chars)
|
|
98
|
-
const title = spawned.prompt.split('\n')[0].slice(0, 80) || 'Untitled task';
|
|
99
|
-
sessions.push({
|
|
100
|
-
id,
|
|
101
|
-
title,
|
|
102
|
-
status,
|
|
103
|
-
agent: spawned.agent || 'Unknown',
|
|
104
|
-
project: extractProjectFromCwd(spawned.cwd || ''),
|
|
105
|
-
tags: [], // Tags not yet implemented in session schema
|
|
106
|
-
duration: formatDuration(durationMs),
|
|
107
|
-
tools,
|
|
108
|
-
files,
|
|
109
|
-
...(trustScore !== undefined ? { trustScore } : {}),
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return sessions.sort((a, b) => {
|
|
113
|
-
// Running first, then by duration descending
|
|
114
|
-
if (a.status === 'running' && b.status !== 'running')
|
|
115
|
-
return -1;
|
|
116
|
-
if (a.status !== 'running' && b.status === 'running')
|
|
117
|
-
return 1;
|
|
118
|
-
return 0;
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
catch {
|
|
122
|
-
return [];
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// ── Sync loop ────────────────────────────────────────────────────────────────
|
|
126
|
-
let syncInterval = null;
|
|
127
|
-
export function startCloudSync(machineName) {
|
|
128
|
-
const token = getOrCreateToken();
|
|
129
|
-
// Use hostname + first 8 chars of token as machine ID — unique per machine
|
|
130
|
-
const machineId = machineName || `${hostname()}-${token.slice(0, 8)}`;
|
|
131
|
-
console.log(` Cloud sync enabled — pushing to codehere.uk/app`);
|
|
132
|
-
console.log(` Machine: ${machineId}`);
|
|
133
|
-
console.log(` Token: ${TOKEN_PATH}`);
|
|
134
|
-
const push = async () => {
|
|
135
|
-
try {
|
|
136
|
-
const sessions = collectSessionMetadata();
|
|
137
|
-
const res = await fetch(CLOUD_URL, {
|
|
138
|
-
method: 'POST',
|
|
139
|
-
headers: { 'Content-Type': 'application/json' },
|
|
140
|
-
body: JSON.stringify({
|
|
141
|
-
machineId,
|
|
142
|
-
name: machineId,
|
|
143
|
-
token,
|
|
144
|
-
sessions,
|
|
145
|
-
timestamp: Date.now(),
|
|
146
|
-
}),
|
|
147
|
-
});
|
|
148
|
-
if (!res.ok) {
|
|
149
|
-
const body = await res.text();
|
|
150
|
-
console.error(` Cloud sync failed: ${res.status} ${body}`);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
const data = (await res.json());
|
|
154
|
-
if (data.sessionsPushed && data.sessionsPushed > 0) {
|
|
155
|
-
console.log(` Cloud sync: ${data.sessionsPushed} session(s) pushed`);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
catch (err) {
|
|
160
|
-
console.error(` Cloud sync error: ${err instanceof Error ? err.message : String(err)}`);
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
const pullTasks = async () => {
|
|
164
|
-
try {
|
|
165
|
-
const res = await fetch(`${CLOUD_URL}?action=pull-tasks&machineId=${machineId}`);
|
|
166
|
-
if (!res.ok)
|
|
167
|
-
return;
|
|
168
|
-
const data = (await res.json());
|
|
169
|
-
const tasks = data.tasks || [];
|
|
170
|
-
for (const task of tasks) {
|
|
171
|
-
if (task.prompt) {
|
|
172
|
-
console.log(` Cloud task received: ${task.prompt.slice(0, 60)}...`);
|
|
173
|
-
try {
|
|
174
|
-
const manager = await getSessionManager();
|
|
175
|
-
manager.spawn(task.prompt, task.agent || 'claude-code');
|
|
176
|
-
// Mark task as claimed
|
|
177
|
-
await fetch(`${CLOUD_URL}?action=claim-task&machineId=${machineId}&taskId=${task.id}`, {
|
|
178
|
-
method: 'POST',
|
|
179
|
-
headers: { 'Content-Type': 'application/json' },
|
|
180
|
-
body: JSON.stringify({ machineId, token, taskId: task.id }),
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
catch (err) {
|
|
184
|
-
console.error(` Failed to spawn cloud task: ${err instanceof Error ? err.message : String(err)}`);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
catch {
|
|
190
|
-
// Silent fail for task pull — not critical
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
// Push immediately, then every 30s
|
|
194
|
-
push();
|
|
195
|
-
pullTasks();
|
|
196
|
-
syncInterval = setInterval(() => {
|
|
197
|
-
push();
|
|
198
|
-
pullTasks();
|
|
199
|
-
}, 30000);
|
|
200
|
-
}
|
|
201
|
-
export function stopCloudSync() {
|
|
202
|
-
if (syncInterval) {
|
|
203
|
-
clearInterval(syncInterval);
|
|
204
|
-
syncInterval = null;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
//# sourceMappingURL=cloud-sync.js.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP helper functions — shared between MCP server and trust command.
|
|
3
|
-
* Extracted to avoid circular imports.
|
|
4
|
-
*/
|
|
5
|
-
import { readFileSync } from 'fs';
|
|
6
|
-
import { collectCodeFiles } from '../security/file-collection.js';
|
|
7
|
-
// ── File collection ──────────────────────────────────────────────────────────
|
|
8
|
-
// Uses the shared walker — same exclusion rules as trust and report.
|
|
9
|
-
export function collectFilesForMCP(target) {
|
|
10
|
-
const paths = collectCodeFiles(target);
|
|
11
|
-
const result = [];
|
|
12
|
-
for (const filepath of paths) {
|
|
13
|
-
try {
|
|
14
|
-
result.push({ filepath, code: readFileSync(filepath, 'utf-8') });
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
// skip unreadable files (iCloud-evicted, permissions, too large)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
// ── Scoring ──────────────────────────────────────────────────────────────────
|
|
23
|
-
// Re-export score function using the shared scorer
|
|
24
|
-
export { scoreFile as scoreFileForMCP, aggregateTrust } from '../security/trust-scorer.js';
|
|
25
|
-
//# sourceMappingURL=mcp-helpers.js.map
|