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.
Files changed (163) hide show
  1. package/README.md +36 -192
  2. package/dist/application/use-cases/check-claimed-tests.js +81 -0
  3. package/dist/application/use-cases/detect-test-weakening.js +237 -0
  4. package/dist/application/use-cases/rerun-tests.js +110 -7
  5. package/dist/index.js +38 -1212
  6. package/dist/infrastructure/orchestration/artifacts-extractor.js +2 -323
  7. package/dist/presentation/cli/commands/check-command.js +178 -23
  8. package/dist/presentation/cli/commands/help-command.js +21 -285
  9. package/dist/ui.js +5 -236
  10. package/dist/utils/version.js +0 -6
  11. package/package.json +9 -38
  12. package/dist/application/services/verdict-service.js +0 -154
  13. package/dist/application/use-cases/assess-cross-vendor.js +0 -126
  14. package/dist/application/use-cases/build-cross-vendor-verdict.js +0 -118
  15. package/dist/application/use-cases/domain-trust.js +0 -110
  16. package/dist/application/use-cases/export-aat.js +0 -107
  17. package/dist/application/use-cases/generate-acceptance-criteria.js +0 -223
  18. package/dist/application/use-cases/generate-final-report.js +0 -259
  19. package/dist/application/use-cases/generate-narration.js +0 -130
  20. package/dist/application/use-cases/generate-thread-title.js +0 -181
  21. package/dist/application/use-cases/narrator-prompt-template.js +0 -158
  22. package/dist/application/use-cases/plan-auto-review.js +0 -57
  23. package/dist/application/use-cases/reconcile-audit.js +0 -100
  24. package/dist/application/use-cases/search-sessions.js +0 -70
  25. package/dist/application/use-cases/should-auto-review.js +0 -71
  26. package/dist/application/use-cases/thread-export.js +0 -245
  27. package/dist/application/use-cases/verify-claim.js +0 -456
  28. package/dist/application/use-cases/write-pass.js +0 -277
  29. package/dist/domain/audit.js +0 -11
  30. package/dist/domain/services/codebase-detector.js +0 -85
  31. package/dist/domain/task.js +0 -91
  32. package/dist/error-handler.js +0 -139
  33. package/dist/infrastructure/completion/bash-completion.js +0 -29
  34. package/dist/infrastructure/completion/fish-completion.js +0 -17
  35. package/dist/infrastructure/completion/zsh-completion.js +0 -25
  36. package/dist/infrastructure/config/config-manager.js +0 -174
  37. package/dist/infrastructure/config/product-context.js +0 -49
  38. package/dist/infrastructure/context/adapters/drawio-source.js +0 -157
  39. package/dist/infrastructure/context/adapters/figma-source.js +0 -198
  40. package/dist/infrastructure/context/adapters/github-issue-source.js +0 -160
  41. package/dist/infrastructure/context/adapters/linear-source.js +0 -190
  42. package/dist/infrastructure/context/context-resolver.js +0 -144
  43. package/dist/infrastructure/context/context-source.js +0 -114
  44. package/dist/infrastructure/context/github-api.js +0 -110
  45. package/dist/infrastructure/context/github-device-flow.js +0 -65
  46. package/dist/infrastructure/context/oauth-flow.js +0 -207
  47. package/dist/infrastructure/context/oauth-store.js +0 -122
  48. package/dist/infrastructure/context/registry-bootstrap.js +0 -95
  49. package/dist/infrastructure/context/write-pass-resolver.js +0 -106
  50. package/dist/infrastructure/cost/budget-config.js +0 -114
  51. package/dist/infrastructure/cost/cost-router.js +0 -97
  52. package/dist/infrastructure/cost/spend-aggregator.js +0 -222
  53. package/dist/infrastructure/cost/team-ledger.js +0 -355
  54. package/dist/infrastructure/discovery/discovery-log.js +0 -85
  55. package/dist/infrastructure/hooks/audit-tip-signature.js +0 -336
  56. package/dist/infrastructure/hooks/claude-sdk-hook.js +0 -1018
  57. package/dist/infrastructure/hooks/hook-mode.js +0 -87
  58. package/dist/infrastructure/hooks/mirror-tool-call-to-audit.js +0 -49
  59. package/dist/infrastructure/hooks/pre-prompt-scan.js +0 -122
  60. package/dist/infrastructure/hooks/session-analyzer.js +0 -177
  61. package/dist/infrastructure/observability/execution-tracer.js +0 -227
  62. package/dist/infrastructure/orchestration/agent-adapter.js +0 -13
  63. package/dist/infrastructure/orchestration/agent-installer.js +0 -101
  64. package/dist/infrastructure/orchestration/agents-config-seed.js +0 -68
  65. package/dist/infrastructure/orchestration/aider-adapter.js +0 -611
  66. package/dist/infrastructure/orchestration/cassette-recorder.js +0 -120
  67. package/dist/infrastructure/orchestration/claude-code-adapter.js +0 -592
  68. package/dist/infrastructure/orchestration/codex-adapter.js +0 -574
  69. package/dist/infrastructure/orchestration/conductor-adapter.js +0 -416
  70. package/dist/infrastructure/orchestration/context-handoff.js +0 -162
  71. package/dist/infrastructure/orchestration/control/codex-control-surface.js +0 -99
  72. package/dist/infrastructure/orchestration/control/control-surface.js +0 -15
  73. package/dist/infrastructure/orchestration/detect-ollama.js +0 -75
  74. package/dist/infrastructure/orchestration/failover-classifier.js +0 -151
  75. package/dist/infrastructure/orchestration/failover-config.js +0 -67
  76. package/dist/infrastructure/orchestration/failover-policy.js +0 -106
  77. package/dist/infrastructure/orchestration/gemini-adapter.js +0 -663
  78. package/dist/infrastructure/orchestration/generic-cli-adapter.js +0 -689
  79. package/dist/infrastructure/orchestration/graphify-context.js +0 -209
  80. package/dist/infrastructure/orchestration/memory-injector.js +0 -380
  81. package/dist/infrastructure/orchestration/mocks/mock-agent-repl.js +0 -388
  82. package/dist/infrastructure/orchestration/mocks/mock-codex-app-server.js +0 -73
  83. package/dist/infrastructure/orchestration/mocks/mock-synthesis.js +0 -83
  84. package/dist/infrastructure/orchestration/mocks/resolve-agent-spawn.js +0 -37
  85. package/dist/infrastructure/orchestration/opencode-adapter.js +0 -580
  86. package/dist/infrastructure/orchestration/progress-aggregator.js +0 -906
  87. package/dist/infrastructure/orchestration/readiness.js +0 -103
  88. package/dist/infrastructure/orchestration/session-manager.js +0 -1590
  89. package/dist/infrastructure/orchestration/session-persistence.js +0 -394
  90. package/dist/infrastructure/orchestration/thread-key-store.js +0 -127
  91. package/dist/infrastructure/orchestration/write-pass-store.js +0 -38
  92. package/dist/infrastructure/protocols/cloud-sync.js +0 -207
  93. package/dist/infrastructure/protocols/mcp-helpers.js +0 -25
  94. package/dist/infrastructure/protocols/mcp-server-impl.js +0 -3935
  95. package/dist/infrastructure/protocols/mcp-tools.js +0 -401
  96. package/dist/infrastructure/protocols/probe-port.js +0 -36
  97. package/dist/infrastructure/protocols/thread-phase.js +0 -105
  98. package/dist/infrastructure/protocols/ui/app-script-artifacts.js +0 -121
  99. package/dist/infrastructure/protocols/ui/app-script-audit-footer.js +0 -44
  100. package/dist/infrastructure/protocols/ui/app-script-audit-verify.js +0 -56
  101. package/dist/infrastructure/protocols/ui/app-script-composer-cost.js +0 -588
  102. package/dist/infrastructure/protocols/ui/app-script-context-sources.js +0 -168
  103. package/dist/infrastructure/protocols/ui/app-script-conversation.js +0 -67
  104. package/dist/infrastructure/protocols/ui/app-script-drawer.js +0 -115
  105. package/dist/infrastructure/protocols/ui/app-script-failover.js +0 -133
  106. package/dist/infrastructure/protocols/ui/app-script-github.js +0 -113
  107. package/dist/infrastructure/protocols/ui/app-script-observer.js +0 -104
  108. package/dist/infrastructure/protocols/ui/app-script-onboarding.js +0 -80
  109. package/dist/infrastructure/protocols/ui/app-script-overlay.js +0 -203
  110. package/dist/infrastructure/protocols/ui/app-script-recovery.js +0 -136
  111. package/dist/infrastructure/protocols/ui/app-script-render.js +0 -166
  112. package/dist/infrastructure/protocols/ui/app-script-share.js +0 -78
  113. package/dist/infrastructure/protocols/ui/app-script-sidebar.js +0 -194
  114. package/dist/infrastructure/protocols/ui/app-script-tour.js +0 -78
  115. package/dist/infrastructure/protocols/ui/app-script-wpass.js +0 -312
  116. package/dist/infrastructure/protocols/ui/app-script.js +0 -2998
  117. package/dist/infrastructure/protocols/ui/font-faces.js +0 -7
  118. package/dist/infrastructure/protocols/ui/styles.js +0 -2147
  119. package/dist/infrastructure/protocols/ui/tokens.js +0 -96
  120. package/dist/infrastructure/protocols/ui-page-v2.js +0 -320
  121. package/dist/infrastructure/protocols/verify-page.js +0 -1677
  122. package/dist/infrastructure/security/file-collection.js +0 -118
  123. package/dist/infrastructure/security/fix-code.js +0 -144
  124. package/dist/infrastructure/security/fix-secret.js +0 -89
  125. package/dist/infrastructure/security/permissions-config.js +0 -235
  126. package/dist/infrastructure/security/scan-types.js +0 -10
  127. package/dist/infrastructure/security/ship-scan.js +0 -195
  128. package/dist/infrastructure/security/trust-scorer.js +0 -724
  129. package/dist/infrastructure/security/vibe-checks.js +0 -99
  130. package/dist/infrastructure/storage/atomic-write.js +0 -86
  131. package/dist/infrastructure/storage/cross-tool-agents.js +0 -268
  132. package/dist/infrastructure/storage/project-thread-migration.js +0 -237
  133. package/dist/infrastructure/storage/project-thread-mirror.js +0 -671
  134. package/dist/infrastructure/storage/project-thread-reader.js +0 -409
  135. package/dist/infrastructure/storage/project-thread-title-backfill.js +0 -214
  136. package/dist/monitoring.js +0 -212
  137. package/dist/presentation/cli/commands/audit-command.js +0 -201
  138. package/dist/presentation/cli/commands/budget-command.js +0 -79
  139. package/dist/presentation/cli/commands/config-command.js +0 -125
  140. package/dist/presentation/cli/commands/context-source-command.js +0 -217
  141. package/dist/presentation/cli/commands/hook-command.js +0 -265
  142. package/dist/presentation/cli/commands/init-command.js +0 -590
  143. package/dist/presentation/cli/commands/memory-command.js +0 -1031
  144. package/dist/presentation/cli/commands/narrator-command.js +0 -101
  145. package/dist/presentation/cli/commands/permission-command.js +0 -105
  146. package/dist/presentation/cli/commands/protocols-builder.js +0 -254
  147. package/dist/presentation/cli/commands/protocols-command.js +0 -84
  148. package/dist/presentation/cli/commands/repo-map-builder.js +0 -247
  149. package/dist/presentation/cli/commands/report-command.js +0 -403
  150. package/dist/presentation/cli/commands/scan-command.js +0 -52
  151. package/dist/presentation/cli/commands/scan-tool-command.js +0 -110
  152. package/dist/presentation/cli/commands/search-command.js +0 -51
  153. package/dist/presentation/cli/commands/setup-command.js +0 -330
  154. package/dist/presentation/cli/commands/status-command.js +0 -614
  155. package/dist/presentation/cli/commands/team-command.js +0 -256
  156. package/dist/presentation/cli/commands/thread-command.js +0 -370
  157. package/dist/presentation/cli/commands/trust-command.js +0 -328
  158. package/dist/presentation/cli/commands/verify-command.js +0 -298
  159. package/dist/presentation/cli/error-display.js +0 -328
  160. package/dist/presentation/cli/repl.js +0 -805
  161. package/dist/presentation/cli/task-deliverable.js +0 -153
  162. package/dist/testing/cassette.js +0 -125
  163. 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