Skip to content

Commit 5d430c2

Browse files
chore: remove genuine dead code surfaced by aft_inspect dogfooding
Deletes verified-unreachable code (each checked: zero non-test callers, and the replacing path confirmed): - cli/lib/opencode-helpers + pi-helpers: buildModelSelection, groupModelsByProvider, getProviders, filterModels, getStaticModels (+ STATIC_MODELS) — orphaned by the setup-wizard overhaul that replaced the recommendation trees with model-picker.ts. - cli/adapters/index: getAllAdapters, getAdaptersWithPluginRegistered, getAdaptersPreferInstalled — unused (getAdapter/getInstalledAdapters are the live API). - cli/lib/paths: getMagicContextTempDir wrapper (+ its core import) — never called. - cli/lib/pi-package-entry: defaultPiPackageEntry — never called. - cli/lib/logs-opencode: dead re-export of issue-body helpers (consumers import the source module directly). - dreamer/task-registry: isAgenticTask + AGENTIC_SET — vestigial after Dreamer V2 made verify/classify/map first-class non-agentic runners; only its own test used it. - dreamer/task-executor: dangling isAgenticTask re-export. - dreamer/retrospective-raw-provider: sameResolvedPath (+ node:path resolve import). Left intact (NOT dead, AFT resolver/scope artifacts): the 67 Tauri commands (macro-dispatch blind spot), barrel re-exports, and test-only-usage helpers (getDreamRuns, getTaskScheduleStatesForProject) — captured in the AFT dogfood report. Gate: plugin tsc + 177 dreamer tests, CLI 207 tests, biome clean. Co-authored-by: Alfonso [Magic Context] <288211368+alfonso-magic-context@users.noreply.github.com>
1 parent 0307849 commit 5d430c2

11 files changed

Lines changed: 4 additions & 254 deletions

File tree

packages/cli/src/adapters/index.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ export { OpenCodeAdapter, PiAdapter };
77

88
const ALL: HarnessAdapter[] = [new OpenCodeAdapter(), new PiAdapter()];
99

10-
/** Every registered adapter. */
11-
export function getAllAdapters(): HarnessAdapter[] {
12-
return ALL;
13-
}
14-
1510
/** Look up an adapter by kind. Throws on unknown kind. */
1611
export function getAdapter(kind: HarnessKind): HarnessAdapter {
1712
const found = ALL.find((a) => a.kind === kind);
@@ -23,17 +18,3 @@ export function getAdapter(kind: HarnessKind): HarnessAdapter {
2318
export function getInstalledAdapters(): HarnessAdapter[] {
2419
return ALL.filter((a) => a.isInstalled());
2520
}
26-
27-
/** Adapters whose plugin entry is registered in the harness's config. */
28-
export function getAdaptersWithPluginRegistered(): HarnessAdapter[] {
29-
return ALL.filter((a) => a.hasPluginEntry());
30-
}
31-
32-
/** Sorted: installed adapters first, then the rest. Stable for ties. */
33-
export function getAdaptersPreferInstalled(): HarnessAdapter[] {
34-
return [...ALL].sort((a, b) => {
35-
const aa = a.isInstalled() ? 0 : 1;
36-
const bb = b.isInstalled() ? 0 : 1;
37-
return aa - bb;
38-
});
39-
}

packages/cli/src/commands/setup-pi.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ describe("runSetup", () => {
285285
const env: SetupEnvironment = {
286286
detectPiBinary: () => ({ path: join(root, "bin", "pi"), source: "path" }),
287287
getPiVersion: () => "0.74.0",
288-
// Only github-copilot model so buildModelSelection always picks it first
288+
// Only one model so the model picker has a single deterministic choice.
289289
getAvailableModels: () => ["github-copilot/gpt-5.4"],
290290
paths: {
291291
getPiAgentConfigDir: () => agentDir,

packages/cli/src/lib/logs-opencode.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ import { readFileSync, writeFileSync } from "node:fs";
22
import { homedir } from "node:os";
33
import { join } from "node:path";
44
import { type DiagnosticReport, renderDiagnosticsMarkdown } from "./diagnostics-opencode";
5-
import { capBodyToGithubLimit, extractRecentErrors, MAX_GITHUB_BODY_BYTES } from "./issue-body";
5+
import { capBodyToGithubLimit, extractRecentErrors } from "./issue-body";
66
import { sanitizeConfigValue, sanitizeDiagnosticText } from "./redaction";
77

8-
// Re-export the shared body helpers so downstream callers (and tests) can
9-
// import them from the same module they get `bundleIssueReport` from.
10-
export { capBodyToGithubLimit, extractRecentErrors, MAX_GITHUB_BODY_BYTES };
11-
128
/**
139
* Replace absolute home paths, usernames, and known secret-token shapes in
1410
* captured log lines so users can share reports publicly without leaking

packages/cli/src/lib/opencode-helpers.ts

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -25,99 +25,4 @@ export function getAvailableModels(): string[] {
2525
}
2626
}
2727

28-
/** Group models by provider for display */
29-
export function groupModelsByProvider(models: string[]): Map<string, string[]> {
30-
const groups = new Map<string, string[]>();
31-
for (const model of models) {
32-
const slashIdx = model.indexOf("/");
33-
const provider = slashIdx >= 0 ? model.substring(0, slashIdx) : "other";
34-
const list = groups.get(provider) ?? [];
35-
list.push(model);
36-
groups.set(provider, list);
37-
}
38-
return groups;
39-
}
40-
41-
/** Get unique providers from model list */
42-
export function getProviders(models: string[]): string[] {
43-
const providers = new Set<string>();
44-
for (const model of models) {
45-
const slashIdx = model.indexOf("/");
46-
if (slashIdx >= 0) {
47-
providers.add(model.substring(0, slashIdx));
48-
}
49-
}
50-
return [...providers].sort();
51-
}
52-
53-
/** Filter models matching any of the given patterns */
54-
export function filterModels(models: string[], patterns: string[]): string[] {
55-
return models.filter((m) => patterns.some((p) => m.includes(p)));
56-
}
5728

58-
/**
59-
* Build a curated model selection list for a given role.
60-
* Returns models ordered by recommendation priority.
61-
*/
62-
export function buildModelSelection(
63-
allModels: string[],
64-
role: "historian" | "dreamer" | "sidekick",
65-
): { label: string; value: string; recommended?: boolean }[] {
66-
const result: { label: string; value: string; recommended?: boolean }[] = [];
67-
const added = new Set<string>();
68-
69-
const addIfAvailable = (pattern: string, hint?: string) => {
70-
const matches = allModels.filter((m) => m === pattern || m.endsWith(`/${pattern}`));
71-
for (const m of matches) {
72-
if (!added.has(m)) {
73-
added.add(m);
74-
result.push({
75-
label: hint ? `${m}${hint}` : m,
76-
value: m,
77-
recommended: result.length === 0,
78-
});
79-
}
80-
}
81-
};
82-
83-
if (role === "historian") {
84-
// Follow the actual fallback chain order.
85-
// Per-request providers first (github-copilot) — better for historian's
86-
// single long prompt/request pattern vs token-based billing.
87-
addIfAvailable("github-copilot/claude-sonnet-4.6", "per-request billing");
88-
addIfAvailable("anthropic/claude-sonnet-4-6");
89-
addIfAvailable("github-copilot/gpt-5.4", "per-request billing");
90-
addIfAvailable("openai/gpt-5.4");
91-
addIfAvailable("github-copilot/gemini-3.1-pro-preview", "per-request billing");
92-
addIfAvailable("opencode-go/minimax-m2.7");
93-
addIfAvailable("opencode-go/glm-5");
94-
} else if (role === "dreamer") {
95-
// Local/cheap models first — dreamer runs overnight
96-
for (const m of allModels.filter((m) => m.startsWith("ollama/"))) {
97-
if (!added.has(m)) {
98-
added.add(m);
99-
result.push({ label: `${m} — local`, value: m, recommended: result.length === 0 });
100-
}
101-
}
102-
103-
addIfAvailable("github-copilot/claude-sonnet-4.6", "per-request billing");
104-
addIfAvailable("anthropic/claude-sonnet-4-6");
105-
addIfAvailable("github-copilot/gemini-3-flash-preview", "per-request billing");
106-
addIfAvailable("opencode-go/glm-5");
107-
addIfAvailable("opencode-go/minimax-m2.7");
108-
} else if (role === "sidekick") {
109-
// Fast models first
110-
for (const m of allModels.filter((m) => m.startsWith("cerebras/"))) {
111-
if (!added.has(m)) {
112-
added.add(m);
113-
result.push({ label: m, value: m, recommended: result.length === 0 });
114-
}
115-
}
116-
117-
addIfAvailable("opencode/gpt-5-nano");
118-
addIfAvailable("github-copilot/gemini-3-flash-preview");
119-
addIfAvailable("github-copilot/gpt-5-mini");
120-
}
121-
122-
return result;
123-
}

packages/cli/src/lib/paths.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { resolveCortexKitUserConfigPath } from "@magic-context/core/config/migra
55
import {
66
getMagicContextHistorianDir as getMagicContextHistorianDirCore,
77
getMagicContextLogPath as getMagicContextLogPathCore,
8-
getMagicContextTempDir as getMagicContextTempDirCore,
98
} from "@magic-context/core/shared/data-path";
109
import type { HarnessId } from "@magic-context/core/shared/harness";
1110

@@ -133,23 +132,6 @@ export function getPiUserExtensionsPath(): string {
133132
// Plugin / shared paths
134133
// ============================================================================
135134

136-
/**
137-
* Per-harness temp directory the plugin writes to.
138-
*
139-
* Re-exported from the plugin so the CLI and the running plugin always agree
140-
* on the path. The CLI uses this with an explicit harness when running
141-
* `magic-context doctor --harness opencode` or `--harness pi`, because the
142-
* unified CLI never loads the plugin (so `setHarness()` was never called) and
143-
* we still need to surface the correct per-harness diagnostics.
144-
*
145-
* Layout:
146-
* - `getMagicContextTempDir("opencode")` → `${tmpdir}/opencode/magic-context/`
147-
* - `getMagicContextTempDir("pi")` → `${tmpdir}/pi/magic-context/`
148-
*/
149-
export function getMagicContextTempDir(harness: HarnessId): string {
150-
return getMagicContextTempDirCore(harness);
151-
}
152-
153135
/** Plugin log file path under the harness-scoped temp dir. */
154136
export function getMagicContextLogPath(harness: HarnessId): string {
155137
return getMagicContextLogPathCore(harness);

packages/cli/src/lib/pi-helpers.ts

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,6 @@ export interface PiBinaryInfo {
1111

1212
export const PI_PACKAGE_SOURCE = "npm:@cortexkit/pi-magic-context";
1313

14-
const STATIC_MODELS = [
15-
"anthropic/claude-haiku-4-5",
16-
"anthropic/claude-sonnet-4-6",
17-
"github-copilot/claude-sonnet-4.6",
18-
"github-copilot/gpt-5.4",
19-
"github-copilot/gpt-5-mini",
20-
"github-copilot/gemini-3-flash-preview",
21-
"openai/gpt-5.4",
22-
"openai/gpt-5.4-mini",
23-
"opencode-go/glm-5",
24-
"opencode-go/minimax-m2.7",
25-
"ollama/qwen2.5-coder:7b",
26-
"cerebras/llama3.1-8b",
27-
];
28-
29-
export function getStaticModels(): string[] {
30-
return [...STATIC_MODELS];
31-
}
32-
3314
export function detectPiBinary(): PiBinaryInfo | null {
3415
// Node-only PATH walker, not which/where: shelling out fails in
3516
// Alpine/slim/Nix/bunx sandboxes that lack those binaries (same reason the
@@ -148,76 +129,3 @@ export function getAvailableModels(piPath: string): string[] {
148129
// which offers free-text provider/model entry instead.
149130
return [];
150131
}
151-
152-
export function buildModelSelection(
153-
allModels: string[],
154-
role: "historian" | "dreamer" | "sidekick",
155-
): { label: string; value: string; recommended?: boolean }[] {
156-
const result: { label: string; value: string; recommended?: boolean }[] = [];
157-
const added = new Set<string>();
158-
159-
const addIfAvailable = (pattern: string, hint?: string) => {
160-
const matches = allModels.filter((m) => m === pattern || m.endsWith(`/${pattern}`));
161-
for (const model of matches) {
162-
if (added.has(model)) continue;
163-
added.add(model);
164-
result.push({
165-
label: hint ? `${model}${hint}` : model,
166-
value: model,
167-
recommended: result.length === 0,
168-
});
169-
}
170-
};
171-
172-
if (role === "historian") {
173-
addIfAvailable("anthropic/claude-haiku-4-5", "fast/cheap default");
174-
addIfAvailable("github-copilot/claude-sonnet-4.6", "per-request billing");
175-
addIfAvailable("anthropic/claude-sonnet-4-6");
176-
addIfAvailable("github-copilot/gpt-5.4", "per-request billing");
177-
addIfAvailable("openai/gpt-5.4");
178-
addIfAvailable("opencode-go/minimax-m2.7");
179-
addIfAvailable("opencode-go/glm-5");
180-
} else if (role === "dreamer") {
181-
for (const model of allModels.filter((m) => m.startsWith("ollama/"))) {
182-
if (added.has(model)) continue;
183-
added.add(model);
184-
result.push({
185-
label: `${model} — local`,
186-
value: model,
187-
recommended: result.length === 0,
188-
});
189-
}
190-
addIfAvailable("anthropic/claude-sonnet-4-6", "recommended quality default");
191-
addIfAvailable("github-copilot/claude-sonnet-4.6", "per-request billing");
192-
addIfAvailable("github-copilot/gemini-3-flash-preview", "fast/cheap");
193-
addIfAvailable("opencode-go/glm-5");
194-
addIfAvailable("opencode-go/minimax-m2.7");
195-
} else {
196-
for (const model of allModels.filter((m) => m.startsWith("cerebras/"))) {
197-
if (added.has(model)) continue;
198-
added.add(model);
199-
result.push({
200-
label: `${model} — fast`,
201-
value: model,
202-
recommended: result.length === 0,
203-
});
204-
}
205-
addIfAvailable("github-copilot/gemini-3-flash-preview", "fast");
206-
addIfAvailable("github-copilot/gpt-5-mini", "fast");
207-
addIfAvailable("openai/gpt-5.4-mini", "fast");
208-
addIfAvailable("anthropic/claude-haiku-4-5", "fast");
209-
}
210-
211-
for (const model of allModels) {
212-
if (result.length >= 30) break;
213-
if (added.has(model)) continue;
214-
added.add(model);
215-
result.push({
216-
label: model,
217-
value: model,
218-
recommended: result.length === 0,
219-
});
220-
}
221-
222-
return result;
223-
}

packages/cli/src/lib/pi-package-entry.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { PI_PACKAGE_SOURCE } from "./pi-helpers";
2-
31
export const PI_MAGIC_CONTEXT_PACKAGE_NAME = "@cortexkit/pi-magic-context";
42

53
function stripNpmPrefix(value: string): string {
@@ -47,6 +45,3 @@ export function describePiPackageEntry(entry: unknown): string {
4745
}
4846
}
4947

50-
export function defaultPiPackageEntry(): string {
51-
return PI_PACKAGE_SOURCE;
52-
}

packages/plugin/src/features/magic-context/dreamer/retrospective-raw-provider.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { resolve } from "node:path";
21

32
import { cleanUserText } from "../../../hooks/magic-context/read-session-chunk";
43
import { hasMeaningfulUserText } from "../../../hooks/magic-context/read-session-formatting";
@@ -526,6 +525,3 @@ function parseJsonRecord(value: string): Record<string, unknown> | null {
526525
return parsed as Record<string, unknown>;
527526
}
528527

529-
export function sameResolvedPath(a: string, b: string): boolean {
530-
return resolve(a) === resolve(b);
531-
}

packages/plugin/src/features/magic-context/dreamer/task-executor.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import {
6262
RETROSPECTIVE_SYSTEM_PROMPT,
6363
type RetrospectivePromptEvent,
6464
} from "./task-prompts";
65-
import { isAgenticTask } from "./task-registry";
65+
6666
import type { DreamTaskRuntimeConfig, TaskExecOutcome, TaskExecutor } from "./task-scheduler";
6767
import { runVerify } from "./verify";
6868

@@ -974,5 +974,3 @@ async function runAgenticTask(
974974
}
975975
}
976976

977-
/** Re-export for the dream-timer's executor wiring. */
978-
export { isAgenticTask };

packages/plugin/src/features/magic-context/dreamer/task-registry.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { describe, expect, test } from "bun:test";
44
import {
55
CANONICAL_DREAM_TASKS,
6-
isAgenticTask,
76
isCanonicalDreamTask,
87
MEMORY_DOMAIN_TASKS,
98
} from "./task-registry";
@@ -22,11 +21,7 @@ describe("dreamer task registry", () => {
2221
"promote-primers",
2322
"refresh-primers",
2423
]);
25-
expect(isAgenticTask("promote-primers")).toBe(false);
26-
expect(isAgenticTask("refresh-primers")).toBe(false);
27-
// map-memories has its own runner — NOT the agentic prompt-builder path.
28-
expect(isAgenticTask("map-memories")).toBe(false);
29-
// It leads the canonical order (records the mappings verify gates on).
24+
// map-memories leads the canonical order (records the mappings verify gates on).
3025
expect(CANONICAL_DREAM_TASKS.indexOf("map-memories")).toBe(0);
3126
expect(CANONICAL_DREAM_TASKS.indexOf("classify-memories")).toBe(
3227
CANONICAL_DREAM_TASKS.indexOf("curate") + 1,

0 commit comments

Comments
 (0)