tickmarkr 1.85.0 → 1.87.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/README.md +4 -2
- package/dist/adapters/catalog-remote.d.ts +64 -0
- package/dist/adapters/catalog-remote.js +287 -0
- package/dist/adapters/catalog.d.ts +108 -0
- package/dist/adapters/catalog.js +189 -0
- package/dist/adapters/claude-code.js +5 -3
- package/dist/adapters/fake.js +33 -4
- package/dist/adapters/model-lints.d.ts +25 -5
- package/dist/adapters/model-lints.js +184 -50
- package/dist/adapters/model-windows.d.ts +31 -0
- package/dist/adapters/model-windows.js +69 -0
- package/dist/adapters/prompt.d.ts +5 -1
- package/dist/adapters/prompt.js +13 -4
- package/dist/adapters/registry.d.ts +34 -27
- package/dist/adapters/registry.js +215 -112
- package/dist/adapters/types.js +15 -3
- package/dist/brand.d.ts +5 -1
- package/dist/brand.js +18 -2
- package/dist/cli/commands/doctor.d.ts +3 -0
- package/dist/cli/commands/doctor.js +43 -21
- package/dist/cli/commands/fleet.d.ts +7 -0
- package/dist/cli/commands/fleet.js +94 -74
- package/dist/cli/commands/init.js +118 -5
- package/dist/cli/commands/plan.js +11 -1
- package/dist/cli/commands/resume.js +7 -1
- package/dist/cli/commands/status.js +44 -18
- package/dist/compile/gsd.d.ts +2 -1
- package/dist/compile/gsd.js +68 -2
- package/dist/compile/native.d.ts +14 -0
- package/dist/compile/native.js +168 -12
- package/dist/config/config.d.ts +20 -5
- package/dist/config/config.js +96 -64
- package/dist/config/fleet-overlay.d.ts +25 -20
- package/dist/config/fleet-overlay.js +195 -77
- package/dist/config/fleet-why.d.ts +23 -0
- package/dist/config/fleet-why.js +42 -0
- package/dist/drivers/herdr.d.ts +1 -0
- package/dist/drivers/herdr.js +70 -19
- package/dist/gates/acceptance.js +7 -2
- package/dist/gates/llm.d.ts +0 -1
- package/dist/gates/llm.js +5 -30
- package/dist/gates/review.d.ts +2 -1
- package/dist/gates/review.js +9 -7
- package/dist/gates/run-gates.d.ts +1 -0
- package/dist/gates/run-gates.js +21 -2
- package/dist/gates/verdict-cause.d.ts +4 -0
- package/dist/gates/verdict-cause.js +63 -0
- package/dist/graph/schema.d.ts +6 -0
- package/dist/graph/schema.js +8 -5
- package/dist/route/preference.d.ts +1 -1
- package/dist/route/preference.js +8 -1
- package/dist/route/router.d.ts +0 -5
- package/dist/route/router.js +16 -20
- package/dist/run/consult.d.ts +6 -0
- package/dist/run/consult.js +49 -26
- package/dist/run/daemon.js +81 -20
- package/dist/run/journal.js +87 -7
- package/dist/tui/cockpit/capture.d.ts +12 -0
- package/dist/tui/cockpit/capture.js +37 -1
- package/dist/tui/cockpit/components.js +8 -8
- package/dist/tui/cockpit/theme.d.ts +32 -26
- package/dist/tui/cockpit/theme.js +11 -5
- package/dist/tui/ink/components.d.ts +0 -15
- package/dist/tui/ink/components.js +0 -17
- package/dist/tui/ink/fleet-app.d.ts +4 -1
- package/dist/tui/ink/fleet-app.js +134 -13
- package/fixtures/gateway-models.json +1 -0
- package/fixtures/sample.native.md +1 -1
- package/package.json +1 -1
- package/skills/tickmarkr-overseer/SKILL.md +464 -34
- package/skills/tickmarkr-overseer/scripts/watch-artifacts.sh +86 -0
- package/skills/tickmarkr-overseer/scripts/watch-panes.sh +1 -1
- package/dist/tui/ink/studio-app.d.ts +0 -59
- package/dist/tui/ink/studio-app.js +0 -320
- package/dist/tui/save.d.ts +0 -38
- package/dist/tui/save.js +0 -96
- package/dist/tui/staging.d.ts +0 -29
- package/dist/tui/staging.js +0 -78
package/dist/adapters/prompt.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { renderAcceptanceItem } from "../graph/schema.js";
|
|
4
|
+
import { classifyVerdictCause } from "../gates/verdict-cause.js";
|
|
4
5
|
export function buildTaskPrompt(task, feedback = "", nonce = "") {
|
|
5
6
|
const list = (xs) => xs.map((x) => `- ${x}`).join("\n");
|
|
6
7
|
return `You are an autonomous coding worker dispatched by tickmarkr into an isolated git worktree.
|
|
@@ -41,15 +42,22 @@ function trailerTokenPositions(raw, nonce) {
|
|
|
41
42
|
positions.push(i);
|
|
42
43
|
return positions;
|
|
43
44
|
}
|
|
45
|
+
// The worker protocol binds participation in the nonce-bearing TICKMARKR_RESULT token outside its
|
|
46
|
+
// JSON object, while judge/review/consult bind it inside the object. Parsing has already rejected every
|
|
47
|
+
// candidate by the time this runs, so canonicalize that token with the `ok` key this boundary requests;
|
|
48
|
+
// the shared classifier still owns the resulting cause and callers cannot infer one from token count.
|
|
49
|
+
function workerVerdictWitness(raw, nonce, positions) {
|
|
50
|
+
if (positions.length === 0)
|
|
51
|
+
return raw;
|
|
52
|
+
return `{"nonce":${JSON.stringify(nonce)},"ok":false,`;
|
|
53
|
+
}
|
|
44
54
|
// v1.65 T1: the parse boundary's own no-trailer sentinel summaries. classifyDeadChannel keys on
|
|
45
55
|
// these — a result carrying any other summary is a PARSED trailer, i.e. the worker speaking.
|
|
46
56
|
export const NO_TRAILER_SUMMARY = "worker produced no TICKMARKR_RESULT trailer";
|
|
47
57
|
export const UNPARSEABLE_TRAILER_SUMMARY = "unparseable TICKMARKR_RESULT trailer";
|
|
48
58
|
export function parseWorkerResult(raw, nonce) {
|
|
49
|
-
const fail = (summary) => ({ ok: false, summary, deviations: [], raw });
|
|
59
|
+
const fail = (summary, cause) => ({ ok: false, summary, deviations: [], raw, cause });
|
|
50
60
|
const positions = trailerTokenPositions(raw, nonce);
|
|
51
|
-
if (positions.length === 0)
|
|
52
|
-
return fail(NO_TRAILER_SUMMARY);
|
|
53
61
|
// TUIs echo the prompt template, redraw lines, and HARD-wrap the JSON with per-line margins
|
|
54
62
|
// (cursor does; recent-unwrapped can't rejoin hard newlines). Scan occurrences backward — last
|
|
55
63
|
// parseable wins — joining wrapped lines, stripping margin/box chrome, and growing the candidate
|
|
@@ -79,7 +87,8 @@ export function parseWorkerResult(raw, nonce) {
|
|
|
79
87
|
}
|
|
80
88
|
}
|
|
81
89
|
}
|
|
82
|
-
|
|
90
|
+
const cause = classifyVerdictCause(workerVerdictWitness(raw, nonce, positions), nonce, "ok");
|
|
91
|
+
return fail(cause === "malformed-verdict" ? UNPARSEABLE_TRAILER_SUMMARY : NO_TRAILER_SUMMARY, cause);
|
|
83
92
|
}
|
|
84
93
|
// Signatures anchor distinctive CLI-error phrasing — never bare fragments or bare status-code
|
|
85
94
|
// numbers (the QUOTA_RE Pitfall-3 lesson): these run only over no-trailer output, but a stalled
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type TickmarkrConfig } from "../config/config.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type PreferenceRole } from "../route/preference.js";
|
|
3
|
+
import { type CatalogEntriesOptions, type CliEntry, type ModelIdField } from "./catalog.js";
|
|
3
4
|
import { type AuthHealth, type BillingChannel, type WorkerAdapter } from "./types.js";
|
|
4
|
-
export declare const CANDIDATE_CLI_CATALOG: readonly [
|
|
5
|
-
export declare
|
|
6
|
-
export declare function resolveShellBinary(bin: string, cwd?: string): {
|
|
5
|
+
export declare const CANDIDATE_CLI_CATALOG: readonly string[];
|
|
6
|
+
export declare function registeredAdapterBinaries(adapters?: WorkerAdapter[]): string[];
|
|
7
|
+
export declare function resolveShellBinary(bin: string, cwd?: string, pathEnv?: string): {
|
|
7
8
|
resolved?: string;
|
|
8
9
|
all: string[];
|
|
9
10
|
};
|
|
@@ -27,44 +28,50 @@ export declare function modelAliasLine(excluded: {
|
|
|
27
28
|
}[]): string;
|
|
28
29
|
export type CandidateCliDetection = {
|
|
29
30
|
binary: string;
|
|
30
|
-
|
|
31
|
+
path: string;
|
|
31
32
|
};
|
|
32
|
-
export declare function
|
|
33
|
-
export declare function
|
|
33
|
+
export declare function parseHerdrCliNames(help: string): string[];
|
|
34
|
+
export declare function herdrNominatedCliNames(cwd?: string, pathEnv?: string): string[];
|
|
35
|
+
export interface DetectCandidateCliOptions extends CatalogEntriesOptions {
|
|
36
|
+
cwd?: string;
|
|
34
37
|
pathEnv?: string;
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
entries?: readonly CliEntry[];
|
|
39
|
+
adapters?: WorkerAdapter[];
|
|
40
|
+
resolveBinary?: (binary: string) => {
|
|
41
|
+
resolved?: string;
|
|
42
|
+
all: string[];
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export declare function detectCandidateClis(opts?: DetectCandidateCliOptions): CandidateCliDetection[];
|
|
46
|
+
export declare function formatCandidateCliRow({ binary, path }: CandidateCliDetection): string;
|
|
37
47
|
export declare function probeHelpText(bin: string): string | undefined;
|
|
38
48
|
export declare function missingDeclaredFlags(helpText: string, flags: string[]): string[];
|
|
39
49
|
export declare function flagDriftWarnings(adapters: WorkerAdapter[], health: Record<string, AuthHealth>, helpOf?: (bin: string) => string | undefined): string[];
|
|
40
|
-
export
|
|
50
|
+
export interface DeclaredModels {
|
|
51
|
+
models: string[];
|
|
52
|
+
reason?: string;
|
|
53
|
+
}
|
|
54
|
+
export declare function parseDeclaredModels(raw: string, parser: "lines" | "pi-table" | "json", path?: string, field?: ModelIdField): DeclaredModels;
|
|
55
|
+
export declare function adaptersFromCliEntries(entries: readonly CliEntry[]): WorkerAdapter[];
|
|
56
|
+
export interface AllAdaptersOptions {
|
|
41
57
|
fakeScriptPath?: string;
|
|
42
|
-
|
|
58
|
+
cliEntries?: readonly CliEntry[];
|
|
59
|
+
operatorYaml?: string | null;
|
|
60
|
+
operatorPath?: string | false;
|
|
61
|
+
}
|
|
62
|
+
export declare function allAdapters(opts?: AllAdaptersOptions): WorkerAdapter[];
|
|
43
63
|
export declare function getAdapter(id: string, adapters: WorkerAdapter[]): WorkerAdapter;
|
|
44
64
|
export declare function probeAll(adapters: WorkerAdapter[], opts?: {
|
|
45
65
|
cwd?: string;
|
|
46
66
|
}): Promise<Record<string, AuthHealth>>;
|
|
47
67
|
export type ProbeModelStatus = "ok" | "timeout" | "failed";
|
|
48
68
|
export type ProbeModelProgress = (adapter: string, model: string, status: ProbeModelStatus, durationMs: number) => void;
|
|
49
|
-
export interface AutoPreferDoc {
|
|
50
|
-
derivedAt: string;
|
|
51
|
-
[shape: string]: string[] | string;
|
|
52
|
-
}
|
|
53
|
-
export declare const pendingAutoPreferKey: unique symbol;
|
|
54
|
-
export declare const DOCTOR_ROUTING_STALE_MS: number;
|
|
55
|
-
export declare function deriveAutoPrefer(cfg: TickmarkrConfig, adapters: WorkerAdapter[], health: Record<string, AuthHealth>, profile?: RoutingProfile): AutoPreferDoc;
|
|
56
|
-
export declare function readAutoPrefer(repoRoot: string): AutoPreferDoc | null;
|
|
57
|
-
export declare function routingPreferContext(repoRoot: string, cfg: TickmarkrConfig, opts?: {
|
|
58
|
-
globalDir?: string;
|
|
59
|
-
}): {
|
|
60
|
-
autoPrefer?: AutoPreferDoc;
|
|
61
|
-
doctorFresh: boolean;
|
|
62
|
-
overlayPreferShapes: ReadonlySet<string>;
|
|
63
|
-
};
|
|
64
69
|
export declare function probeModels(cfg: TickmarkrConfig, repoRoot: string, adapters: WorkerAdapter[], health: Record<string, AuthHealth>, onProgress?: ProbeModelProgress): Promise<void>;
|
|
65
70
|
export declare function writeDoctor(repoRoot: string, health: Record<string, AuthHealth>): void;
|
|
66
71
|
export declare function readDoctor(repoRoot: string): Record<string, AuthHealth> | null;
|
|
67
|
-
export declare function discoverChannels(cfg: TickmarkrConfig, adapters: WorkerAdapter[], health: Record<string, AuthHealth
|
|
72
|
+
export declare function discoverChannels(cfg: TickmarkrConfig, adapters: WorkerAdapter[], health: Record<string, AuthHealth>, role?: PreferenceRole): BillingChannel[];
|
|
73
|
+
export declare const PREFERENCE_ROLES: readonly ["worker", "judge", "review", "consult"];
|
|
74
|
+
export declare function rolePools(cfg: TickmarkrConfig, adapters: WorkerAdapter[], health: Record<string, AuthHealth>): Record<PreferenceRole, BillingChannel[]>;
|
|
68
75
|
export declare function servableExclusions(cfg: TickmarkrConfig, adapters: WorkerAdapter[], health: Record<string, AuthHealth>): {
|
|
69
76
|
key: string;
|
|
70
77
|
adapter: string;
|
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { existsSync, mkdtempSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, mkdtempSync, readFileSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
-
import { overlayPreferShapes, TIER_RANK } from "../config/config.js";
|
|
6
5
|
import { modelLints, suggestOverlay } from "./model-lints.js";
|
|
7
6
|
import { HerdrDriver } from "../drivers/herdr.js";
|
|
8
7
|
import { tickmarkrDir, stateDirName } from "../graph/graph.js";
|
|
9
8
|
import { disallowedBy, excludedChannels, exclusionLine, preferRanks } from "../route/preference.js";
|
|
10
|
-
import { learnedScore } from "../route/profile.js";
|
|
11
|
-
import { marginalCostRank } from "../route/router.js";
|
|
12
9
|
import { sh } from "../run/git.js";
|
|
13
|
-
import { claudeCode } from "./claude-code.js";
|
|
14
|
-
import { codex } from "./codex.js";
|
|
15
|
-
import { cursorAgent } from "./cursor-agent.js";
|
|
16
10
|
import { FakeAdapter } from "./fake.js";
|
|
17
|
-
import {
|
|
18
|
-
import { kimi } from "./kimi.js";
|
|
19
|
-
import { opencode } from "./opencode.js";
|
|
20
|
-
import { pi } from "./pi.js";
|
|
11
|
+
import { parseWorkerResult } from "./prompt.js";
|
|
21
12
|
import { sealHerdrEnv } from "../drivers/subprocess.js";
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
|
|
13
|
+
import { catalogEntries, isNativeCliDrive, projectCliEntries, SHIPPED_CLI_CATALOG, } from "./catalog.js";
|
|
14
|
+
import { channelKey, channelsFromConfig, modelAuthed, MODEL_ID_RE, QUOTA_RE, shq, } from "./types.js";
|
|
15
|
+
// Compatibility projection for callers/tests that only need shipped advisory names. The literal
|
|
16
|
+
// list is gone: both advisory and routable catalog views derive from SHIPPED_CLI_CATALOG. Native
|
|
17
|
+
// definitions (claudeCode, codex, cursorAgent, opencode, pi, grok, kimi) are owned by catalog.ts;
|
|
18
|
+
// this registry consumes their drive contracts instead of restating their registration order.
|
|
19
|
+
export const CANDIDATE_CLI_CATALOG = SHIPPED_CLI_CATALOG
|
|
20
|
+
.filter((entry) => entry.drive === undefined)
|
|
21
|
+
.map((entry) => entry.binary);
|
|
22
|
+
const SHIPPED_NATIVE_ADAPTERS = new Set(SHIPPED_CLI_CATALOG.flatMap((entry) => isNativeCliDrive(entry.drive) ? [entry.drive.adapter] : []));
|
|
23
|
+
const declarativeBinaries = new WeakMap();
|
|
24
|
+
// OBS-304: this was a hand-maintained mirror of the registered binaries, and the guard test that
|
|
25
|
+
// forbids catalog overlap checked against IT rather than against the adapters — so when kimi gained
|
|
26
|
+
// an adapter and nobody updated the copy, the guard kept passing on a collision it existed to catch.
|
|
27
|
+
// Derive it. A list that restates another list is the defect, not the entry that fell out of sync.
|
|
28
|
+
export function registeredAdapterBinaries(adapters = allAdapters()) {
|
|
29
|
+
return adapters.map((a) => a.hardcodedFlags?.binary ?? declarativeBinaries.get(a)).filter((b) => !!b);
|
|
30
|
+
}
|
|
27
31
|
// OBS-117: worker panes run commands through `bash -lc` (SubprocessDriver + sh()), not bare spawnSync(bin).
|
|
28
32
|
// Doctor must resolve adapter binaries the same way so a shadow install on PATH cannot disagree with dispatch.
|
|
29
33
|
function shellSpawnSync(cmd, cwd, timeoutMs = 10000) {
|
|
@@ -36,9 +40,24 @@ function shellSpawnSync(cmd, cwd, timeoutMs = 10000) {
|
|
|
36
40
|
});
|
|
37
41
|
return { code: r.status ?? 1, stdout: (r.stdout || "").trim(), stderr: (r.stderr || "").trim() };
|
|
38
42
|
}
|
|
39
|
-
export function resolveShellBinary(bin, cwd = process.cwd()) {
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
export function resolveShellBinary(bin, cwd = process.cwd(), pathEnv) {
|
|
44
|
+
// An explicit PATH is a deterministic fixture/operator boundary. The default remains the same
|
|
45
|
+
// login-shell environment used by dispatched workers (OBS-117).
|
|
46
|
+
const pathPrefix = pathEnv === undefined ? "" : `export PATH=${shq(pathEnv)}; `;
|
|
47
|
+
const r = shellSpawnSync(`${pathPrefix}type -a ${shq(bin)} 2>/dev/null | sed -n 's/^.* is \\(.*\\)$/\\1/p'`, cwd);
|
|
48
|
+
const hits = r.stdout.split("\n").map((s) => s.trim()).filter(Boolean);
|
|
49
|
+
// OBS-304: a duplicated PATH entry makes `type -a` emit the SAME path twice, which doctor then
|
|
50
|
+
// reported as "2 installs on PATH — …/claude, …/claude". Count distinct real files, so the real
|
|
51
|
+
// shadows (codex: homebrew + nvm) stop being buried in noise. realpath resolves symlinked twins.
|
|
52
|
+
const seen = new Set();
|
|
53
|
+
const all = hits.filter((p) => {
|
|
54
|
+
let key = p;
|
|
55
|
+
try {
|
|
56
|
+
key = realpathSync(p);
|
|
57
|
+
}
|
|
58
|
+
catch { /* unreadable or dangling — fall back to the literal path */ }
|
|
59
|
+
return seen.has(key) ? false : (seen.add(key), true);
|
|
60
|
+
});
|
|
42
61
|
return { resolved: all[0], all };
|
|
43
62
|
}
|
|
44
63
|
export function probeVersionShell(bin, cwd = process.cwd()) {
|
|
@@ -101,39 +120,47 @@ export function modelAliasLine(excluded) {
|
|
|
101
120
|
const parts = excluded.map(({ key, adapter }) => `${key} (not in ${adapter}'s reported model list)`);
|
|
102
121
|
return `model alias: ${excluded.length} channel(s) invalid — ${parts.join(", ")}`;
|
|
103
122
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
123
|
+
// Herdr's supported-kind help is nomination data only. Parse the closed token list and discard
|
|
124
|
+
// everything else before any name can reach a shell resolver.
|
|
125
|
+
export function parseHerdrCliNames(help) {
|
|
126
|
+
const body = /\[possible values:\s*([^\]]+)\]/m.exec(help)?.[1] ?? "";
|
|
127
|
+
return [...new Set(body.split(",").map((name) => name.trim()).filter((name) => /^[a-z0-9-]+$/.test(name)))];
|
|
107
128
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
return undefined;
|
|
118
|
-
}
|
|
129
|
+
export function herdrNominatedCliNames(cwd = process.cwd(), pathEnv) {
|
|
130
|
+
// This asks a known driver binary for static help. It is deliberately NOT gated on
|
|
131
|
+
// HerdrDriver.available(), which reports HERDR_ENV rather than binary presence.
|
|
132
|
+
const { resolved } = resolveShellBinary("herdr", cwd, pathEnv);
|
|
133
|
+
if (!resolved)
|
|
134
|
+
return [];
|
|
135
|
+
const r = shellSpawnSync(`${shq(resolved)} agent start --help`, cwd);
|
|
136
|
+
return r.code === 0 ? parseHerdrCliNames(`${r.stdout}\n${r.stderr}`) : [];
|
|
119
137
|
}
|
|
120
138
|
export function detectCandidateClis(opts = {}) {
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
139
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
140
|
+
const entries = opts.entries ?? catalogEntries({
|
|
141
|
+
shipped: opts.shipped,
|
|
142
|
+
operatorYaml: opts.operatorYaml,
|
|
143
|
+
operatorPath: opts.operatorPath,
|
|
144
|
+
herdrNames: opts.herdrNames ?? herdrNominatedCliNames(cwd, opts.pathEnv),
|
|
145
|
+
});
|
|
146
|
+
const registered = new Set(registeredAdapterBinaries(opts.adapters ?? allAdapters({ cliEntries: entries })));
|
|
147
|
+
const advisory = projectCliEntries(entries).advisory.filter((entry) => !registered.has(entry.binary));
|
|
148
|
+
const resolveBinary = opts.resolveBinary
|
|
149
|
+
?? ((binary) => resolveShellBinary(binary, cwd, opts.pathEnv));
|
|
150
|
+
const discovered = [];
|
|
151
|
+
for (const entry of advisory) {
|
|
152
|
+
const { resolved } = resolveBinary(entry.binary);
|
|
153
|
+
if (resolved)
|
|
154
|
+
discovered.push({ binary: entry.binary, path: resolved });
|
|
127
155
|
}
|
|
128
|
-
return
|
|
156
|
+
return discovered;
|
|
129
157
|
}
|
|
130
|
-
export function formatCandidateCliRow({ binary,
|
|
131
|
-
|
|
132
|
-
return ` ! ${binary.padEnd(14)} detected: ${ver} (no tickmarkr adapter — not routable)`;
|
|
158
|
+
export function formatCandidateCliRow({ binary, path }) {
|
|
159
|
+
return ` ! ${binary.padEnd(14)} detected at ${path} (no drive contract — not routable)`;
|
|
133
160
|
}
|
|
134
|
-
// v1.65 T3:
|
|
135
|
-
//
|
|
136
|
-
//
|
|
161
|
+
// v1.65 T3: bounded, error/status-checked and fail-open. Unlike candidate detection above, this
|
|
162
|
+
// executes only registered adapter binaries with drive contracts. undefined = unavailable/broken,
|
|
163
|
+
// so no drift verdict piles onto the existing auth report.
|
|
137
164
|
export function probeHelpText(bin) {
|
|
138
165
|
try {
|
|
139
166
|
const r = spawnSync(bin, ["--help"], { encoding: "utf8", timeout: 10000 });
|
|
@@ -169,11 +196,133 @@ export function flagDriftWarnings(adapters, health, helpOf = probeHelpText) {
|
|
|
169
196
|
}
|
|
170
197
|
return out;
|
|
171
198
|
}
|
|
199
|
+
function renderDriveTemplate(template, promptFile, model) {
|
|
200
|
+
return template.replaceAll("{promptFile}", shq(promptFile)).replaceAll("{model}", shq(model));
|
|
201
|
+
}
|
|
202
|
+
function valueAtPath(value, path) {
|
|
203
|
+
if (!path)
|
|
204
|
+
return value;
|
|
205
|
+
return path.split(".").reduce((cursor, part) => {
|
|
206
|
+
if (!cursor || typeof cursor !== "object")
|
|
207
|
+
return undefined;
|
|
208
|
+
return cursor[part];
|
|
209
|
+
}, value);
|
|
210
|
+
}
|
|
211
|
+
export function parseDeclaredModels(raw, parser, path, field) {
|
|
212
|
+
let values;
|
|
213
|
+
if (parser === "json") {
|
|
214
|
+
let root;
|
|
215
|
+
try {
|
|
216
|
+
root = JSON.parse(raw);
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
return { models: [], reason: "malformed JSON: the output did not parse" };
|
|
220
|
+
}
|
|
221
|
+
const selected = valueAtPath(root, path);
|
|
222
|
+
if (!Array.isArray(selected)) {
|
|
223
|
+
return { models: [], reason: `no array at ${path ? `path "${path}"` : "the JSON root"}` };
|
|
224
|
+
}
|
|
225
|
+
// One key per entry, and only the configured one — and `ModelIdField` is an id-key allowlist, so
|
|
226
|
+
// `cost` and `provider` are not spellable here: no price, no vendor, no whole object.
|
|
227
|
+
values = field === undefined
|
|
228
|
+
? selected
|
|
229
|
+
: selected.map((entry) => entry && typeof entry === "object" && !Array.isArray(entry)
|
|
230
|
+
? entry[field]
|
|
231
|
+
: undefined);
|
|
232
|
+
if (selected.length > 0 && !values.some((value) => typeof value === "string")) {
|
|
233
|
+
return {
|
|
234
|
+
models: [],
|
|
235
|
+
reason: field === undefined
|
|
236
|
+
? `${selected.length} entries are not id strings and no field is configured`
|
|
237
|
+
: `no string field "${field}" on any of the ${selected.length} entries`,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
else if (parser === "pi-table") {
|
|
242
|
+
const lines = raw.trim().split("\n");
|
|
243
|
+
const header = lines.findIndex((line) => /^provider\s+model\b/i.test(line.trim()));
|
|
244
|
+
values = header === -1 ? [] : lines.slice(header + 1).map((line) => {
|
|
245
|
+
const [provider, model] = line.trim().split(/\s+/);
|
|
246
|
+
return provider && model ? `${provider}/${model}` : "";
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
values = raw.split("\n").map((line) => line.trim());
|
|
251
|
+
}
|
|
252
|
+
// Blanks are structural padding in every parser (trailing newline, headerless table row), never a
|
|
253
|
+
// rejected id — counting them would make "all values rejected" fire on a healthy list.
|
|
254
|
+
const candidates = values.filter((value) => typeof value === "string" && value.length > 0);
|
|
255
|
+
const models = [...new Set(candidates.filter((value) => MODEL_ID_RE.test(value)))];
|
|
256
|
+
if (models.length === 0 && candidates.length > 0) {
|
|
257
|
+
return { models, reason: `all ${candidates.length} listed values were rejected by the model-id format` };
|
|
258
|
+
}
|
|
259
|
+
return { models };
|
|
260
|
+
}
|
|
261
|
+
function declarativeAdapter(entry) {
|
|
262
|
+
const drive = entry.drive;
|
|
263
|
+
const adapter = {
|
|
264
|
+
id: entry.id,
|
|
265
|
+
vendor: entry.vendor,
|
|
266
|
+
probe: async () => {
|
|
267
|
+
const health = probeVersionShell(entry.binary);
|
|
268
|
+
if (!health.installed)
|
|
269
|
+
return health;
|
|
270
|
+
const version = health.version ?? "";
|
|
271
|
+
if (!new RegExp(entry.identity).test(version)) {
|
|
272
|
+
return {
|
|
273
|
+
installed: true,
|
|
274
|
+
authed: false,
|
|
275
|
+
version,
|
|
276
|
+
models: [],
|
|
277
|
+
note: `identity mismatch for ${entry.binary}`,
|
|
278
|
+
binaryPaths: health.binaryPaths,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
return health;
|
|
282
|
+
},
|
|
283
|
+
channels: (cfg) => channelsFromConfig(entry.id, cfg),
|
|
284
|
+
headlessCommand: (promptFile, model) => renderDriveTemplate(drive.headless, promptFile, model),
|
|
285
|
+
interactiveCommand: (promptFile, model) => drive.interactive === null
|
|
286
|
+
? null
|
|
287
|
+
: renderDriveTemplate(drive.interactive, promptFile, model),
|
|
288
|
+
invoke(_task, _cwd, assignment, ctx) {
|
|
289
|
+
return { command: this.headlessCommand(ctx.promptFile, assignment.model) };
|
|
290
|
+
},
|
|
291
|
+
parse: parseWorkerResult,
|
|
292
|
+
...(drive.listModels ? {
|
|
293
|
+
listModels: async () => {
|
|
294
|
+
const { resolved } = resolveShellBinary(entry.binary);
|
|
295
|
+
if (!resolved)
|
|
296
|
+
return [];
|
|
297
|
+
const cmd = [shq(resolved), ...drive.listModels.argv.map(shq)].join(" ");
|
|
298
|
+
const result = shellSpawnSync(cmd, process.cwd(), 15000);
|
|
299
|
+
if (result.code !== 0)
|
|
300
|
+
return [];
|
|
301
|
+
const { models, reason } = parseDeclaredModels(result.stdout, drive.listModels.parser, drive.listModels.path, drive.listModels.field);
|
|
302
|
+
// Listing stays advisory (fail-open to []), but never silently: an empty projection names why.
|
|
303
|
+
if (models.length === 0 && reason)
|
|
304
|
+
console.warn(`tickmarkr: ${entry.id} listed no models — ${reason}`);
|
|
305
|
+
return models;
|
|
306
|
+
},
|
|
307
|
+
} : {}),
|
|
308
|
+
};
|
|
309
|
+
declarativeBinaries.set(adapter, entry.binary);
|
|
310
|
+
return adapter;
|
|
311
|
+
}
|
|
312
|
+
export function adaptersFromCliEntries(entries) {
|
|
313
|
+
return projectCliEntries(entries).routable.map((entry) => {
|
|
314
|
+
if (isNativeCliDrive(entry.drive))
|
|
315
|
+
return entry.drive.adapter;
|
|
316
|
+
return declarativeAdapter(entry);
|
|
317
|
+
});
|
|
318
|
+
}
|
|
172
319
|
export function allAdapters(opts = {}) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
320
|
+
const entries = opts.cliEntries ?? catalogEntries({
|
|
321
|
+
operatorYaml: opts.operatorYaml,
|
|
322
|
+
operatorPath: opts.operatorPath,
|
|
323
|
+
herdrNames: [],
|
|
324
|
+
});
|
|
325
|
+
const real = adaptersFromCliEntries(entries);
|
|
177
326
|
const fakePath = opts.fakeScriptPath ?? process.env.TICKMARKR_FAKE_SCRIPT;
|
|
178
327
|
return fakePath ? [new FakeAdapter(fakePath), ...real] : real;
|
|
179
328
|
}
|
|
@@ -233,58 +382,6 @@ function probeFailure(code, stdout, stderr, timedOut, timeoutMs = MODEL_PROBE_TI
|
|
|
233
382
|
? reasonTail(output) || `probe exited ${code}`
|
|
234
383
|
: undefined;
|
|
235
384
|
}
|
|
236
|
-
export const pendingAutoPreferKey = Symbol.for("tickmarkr.pendingAutoPrefer");
|
|
237
|
-
const median = (xs) => {
|
|
238
|
-
const s = [...xs].sort((a, b) => a - b);
|
|
239
|
-
const m = Math.floor(s.length / 2);
|
|
240
|
-
return s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2;
|
|
241
|
-
};
|
|
242
|
-
// ponytail: 24h TTL matches plan.ts staleness — promote to config when an operator asks.
|
|
243
|
-
export const DOCTOR_ROUTING_STALE_MS = 24 * 60 * 60 * 1000;
|
|
244
|
-
export function deriveAutoPrefer(cfg, adapters, health, profile) {
|
|
245
|
-
const derivedAt = new Date().toISOString();
|
|
246
|
-
const out = { derivedAt };
|
|
247
|
-
// v1.52 T5: routing.floors is the only band authority — a map entry can no longer carry a tier.
|
|
248
|
-
for (const shape of Object.keys(cfg.routing.map)) {
|
|
249
|
-
const minTier = cfg.routing.floors[shape] ?? "cheap";
|
|
250
|
-
const ranked = [];
|
|
251
|
-
for (const a of adapters) {
|
|
252
|
-
const h = health[a.id];
|
|
253
|
-
if (!h?.installed || !h?.authed || typeof a.channels !== "function")
|
|
254
|
-
continue;
|
|
255
|
-
const qualifying = a.channels(cfg).filter((c) => TIER_RANK[c.tier] >= TIER_RANK[minTier] && h.modelAuth?.[c.model]?.authed === true);
|
|
256
|
-
if (!qualifying.length)
|
|
257
|
-
continue;
|
|
258
|
-
const durations = qualifying
|
|
259
|
-
.map((c) => h.modelAuth?.[c.model]?.durationMs)
|
|
260
|
-
.filter((d) => typeof d === "number");
|
|
261
|
-
ranked.push({
|
|
262
|
-
adapter: a.id,
|
|
263
|
-
mc: Math.min(...qualifying.map(marginalCostRank)),
|
|
264
|
-
dur: durations.length ? median(durations) : Number.POSITIVE_INFINITY,
|
|
265
|
-
learned: profile ? Math.max(...qualifying.map((c) => learnedScore(profile, shape, channelKey(c), c.channel))) : 0,
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
ranked.sort((a, b) => a.mc - b.mc || a.dur - b.dur || b.learned - a.learned);
|
|
269
|
-
out[shape] = ranked.map((r) => r.adapter);
|
|
270
|
-
}
|
|
271
|
-
return out;
|
|
272
|
-
}
|
|
273
|
-
export function readAutoPrefer(repoRoot) {
|
|
274
|
-
const raw = readDoctorFile(repoRoot);
|
|
275
|
-
if (!raw || typeof raw.autoPrefer !== "object" || raw.autoPrefer === null)
|
|
276
|
-
return null;
|
|
277
|
-
return raw.autoPrefer;
|
|
278
|
-
}
|
|
279
|
-
export function routingPreferContext(repoRoot, cfg, opts = {}) {
|
|
280
|
-
const age = doctorAgeMs(repoRoot);
|
|
281
|
-
const doctorFresh = age !== null && age <= DOCTOR_ROUTING_STALE_MS;
|
|
282
|
-
return {
|
|
283
|
-
autoPrefer: doctorFresh ? readAutoPrefer(repoRoot) ?? undefined : undefined,
|
|
284
|
-
doctorFresh,
|
|
285
|
-
overlayPreferShapes: overlayPreferShapes(repoRoot, opts),
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
385
|
const probeModelStatus = (v) => v.authed ? "ok" : v.reason?.includes("timed out") ? "timeout" : "failed";
|
|
289
386
|
// v1.21: one bounded, headless call per configured model; detected-but-unclassified models never enter this loop.
|
|
290
387
|
export async function probeModels(cfg, repoRoot, adapters, health, onProgress) {
|
|
@@ -296,7 +393,7 @@ export async function probeModels(cfg, repoRoot, adapters, health, onProgress) {
|
|
|
296
393
|
if (!h?.installed)
|
|
297
394
|
return;
|
|
298
395
|
// Tests inject FakeAdapter; never let an incidental default adapter spend a real token in the suite.
|
|
299
|
-
if (process.env.VITEST &&
|
|
396
|
+
if (process.env.VITEST && SHIPPED_NATIVE_ADAPTERS.has(a))
|
|
300
397
|
return;
|
|
301
398
|
const verdicts = {};
|
|
302
399
|
const priorModelAuth = priorHealth?.[a.id]?.modelAuth;
|
|
@@ -360,7 +457,6 @@ export async function probeModels(cfg, repoRoot, adapters, health, onProgress) {
|
|
|
360
457
|
}
|
|
361
458
|
h.modelAuth = verdicts;
|
|
362
459
|
}));
|
|
363
|
-
health[pendingAutoPreferKey] = deriveAutoPrefer(cfg, adapters, health);
|
|
364
460
|
}
|
|
365
461
|
// T2: caps concurrent probes per adapter at 2 — v1.33.5 regression, 4 concurrent codex exec in one
|
|
366
462
|
// repo made ALL 4 time out where sequential passed 2/4 (suspected CLI self-contention).
|
|
@@ -388,24 +484,25 @@ function readDoctorFile(repoRoot) {
|
|
|
388
484
|
}
|
|
389
485
|
export function writeDoctor(repoRoot, health) {
|
|
390
486
|
tickmarkrDir(repoRoot);
|
|
391
|
-
const pending = health[pendingAutoPreferKey];
|
|
392
|
-
const payload = { ...health };
|
|
393
|
-
delete payload[pendingAutoPreferKey];
|
|
394
|
-
if (pending)
|
|
395
|
-
payload.autoPrefer = pending;
|
|
396
487
|
const path = doctorPath(repoRoot);
|
|
397
488
|
const tmp = `${path}.tmp`;
|
|
398
|
-
writeFileSync(tmp, JSON.stringify(
|
|
489
|
+
writeFileSync(tmp, JSON.stringify(health, null, 2) + "\n");
|
|
399
490
|
renameSync(tmp, path);
|
|
400
491
|
}
|
|
401
492
|
export function readDoctor(repoRoot) {
|
|
402
493
|
const raw = readDoctorFile(repoRoot);
|
|
403
494
|
if (!raw)
|
|
404
495
|
return null;
|
|
496
|
+
// pre-v1.86 caches may still carry an `autoPrefer` key — strip it; the mechanism is deleted and
|
|
497
|
+
// the key is never read back into health.
|
|
405
498
|
const { autoPrefer: _, ...health } = raw;
|
|
406
499
|
return health;
|
|
407
500
|
}
|
|
408
|
-
|
|
501
|
+
// v1.87 T2: `role` is optional and defaults to "worker", so every pre-existing two/three-argument
|
|
502
|
+
// call keeps its exact present behaviour — the worker pool. A non-worker role reads the SAME fleet
|
|
503
|
+
// through its own deny scope: a worker-only deny (routing.deny.workers) benches a channel for
|
|
504
|
+
// dispatch while leaving it eligible to judge, review or consult the work.
|
|
505
|
+
export function discoverChannels(cfg, adapters, health, role = "worker") {
|
|
409
506
|
const base = adapters
|
|
410
507
|
.filter((a) => health[a.id]?.installed && health[a.id]?.authed)
|
|
411
508
|
.flatMap((a) => {
|
|
@@ -420,7 +517,13 @@ export function discoverChannels(cfg, adapters, health) {
|
|
|
420
517
|
});
|
|
421
518
|
if (!cfg.routing.allow && !cfg.routing.deny)
|
|
422
519
|
return base;
|
|
423
|
-
return base.filter((c) => disallowedBy(c, cfg.routing) === null);
|
|
520
|
+
return base.filter((c) => disallowedBy(c, cfg.routing, role) === null);
|
|
521
|
+
}
|
|
522
|
+
// v1.87 T2: the role-scoped pool builder. One doctor probe, one discovery pass per role — so the
|
|
523
|
+
// daemon hands each seat the pool its own policy allows instead of handing everyone the worker list.
|
|
524
|
+
export const PREFERENCE_ROLES = ["worker", "judge", "review", "consult"];
|
|
525
|
+
export function rolePools(cfg, adapters, health) {
|
|
526
|
+
return Object.fromEntries(PREFERENCE_ROLES.map((role) => [role, discoverChannels(cfg, adapters, health, role)]));
|
|
424
527
|
}
|
|
425
528
|
// HYG-07(a): the channels discoverChannels silently dropped because their model isn't in the adapter's
|
|
426
529
|
// served list (the HYG-05 filter above). Computed from the SAME inputs as the drop (a.channels(cfg), not
|
package/dist/adapters/types.js
CHANGED
|
@@ -70,9 +70,21 @@ export function channelsFromConfig(adapterId, cfg) {
|
|
|
70
70
|
const e = cfg.tiers[adapterId];
|
|
71
71
|
if (!e)
|
|
72
72
|
return [];
|
|
73
|
-
return Object.entries(e.models).
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
return Object.entries(e.models).flatMap(([model, tier]) => {
|
|
74
|
+
const override = e.modelOverrides?.[model];
|
|
75
|
+
const vendor = override?.vendor ?? e.vendor;
|
|
76
|
+
// Parsed configs guarantee this only occurs for invalid data, but direct callers must fail closed
|
|
77
|
+
// too: an undeclared vendor is not review diversity and provider prefixes are never provenance.
|
|
78
|
+
if (!vendor?.trim())
|
|
79
|
+
return [];
|
|
80
|
+
return [{
|
|
81
|
+
adapter: adapterId,
|
|
82
|
+
vendor,
|
|
83
|
+
model,
|
|
84
|
+
channel: override?.channel ?? e.channel,
|
|
85
|
+
tier,
|
|
86
|
+
}];
|
|
87
|
+
});
|
|
76
88
|
}
|
|
77
89
|
export function channelKey(c) {
|
|
78
90
|
return `${c.adapter}:${c.model}`;
|
package/dist/brand.d.ts
CHANGED
|
@@ -16,7 +16,11 @@ export declare function bannerShell(): string;
|
|
|
16
16
|
export declare const TICKMARKR_EXIT_TRAILER = "printf '\\nTICKMARKR_''EXIT:%s\\n' $?";
|
|
17
17
|
/** OBS-50: visible-pane bootstrap script — banner + agent command + byte-identical exit trailer. */
|
|
18
18
|
export declare function paneDispatchScript(body: string[]): string;
|
|
19
|
-
/**
|
|
19
|
+
/** Record that the command being passed directly to ExecutorDriver.run is a daemon-built launch. */
|
|
20
|
+
export declare function paneLaunchCommand(command: string): string;
|
|
21
|
+
/** Driver-side half of paneLaunchCommand's one-shot handoff. */
|
|
22
|
+
export declare function consumePaneLaunchIntent(): boolean;
|
|
23
|
+
/** OBS-50/342: one short, intent-bearing pane-run line; bootstrap lives beside the prompt. */
|
|
20
24
|
export declare function paneDispatchCommand(scriptPath: string): string;
|
|
21
25
|
/** The settled brand green ramp (256-color), bright → deep. */
|
|
22
26
|
export declare const BRAND_RAMP: readonly [84, 78, 41, 35];
|
package/dist/brand.js
CHANGED
|
@@ -78,9 +78,25 @@ export const TICKMARKR_EXIT_TRAILER = `printf '\\nTICKMARKR_''EXIT:%s\\n' $?`;
|
|
|
78
78
|
export function paneDispatchScript(body) {
|
|
79
79
|
return ["export BASH_SILENCE_DEPRECATION_WARNING=1", ...body, TICKMARKR_EXIT_TRAILER].join("\n");
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
const pendingPaneLaunchIntents = [];
|
|
82
|
+
/** Record that the command being passed directly to ExecutorDriver.run is a daemon-built launch. */
|
|
83
|
+
export function paneLaunchCommand(command) {
|
|
84
|
+
const intent = { kind: "launch" };
|
|
85
|
+
pendingPaneLaunchIntents.push(intent);
|
|
86
|
+
queueMicrotask(() => {
|
|
87
|
+
const index = pendingPaneLaunchIntents.indexOf(intent);
|
|
88
|
+
if (index >= 0)
|
|
89
|
+
pendingPaneLaunchIntents.splice(index, 1);
|
|
90
|
+
});
|
|
91
|
+
return command;
|
|
92
|
+
}
|
|
93
|
+
/** Driver-side half of paneLaunchCommand's one-shot handoff. */
|
|
94
|
+
export function consumePaneLaunchIntent() {
|
|
95
|
+
return pendingPaneLaunchIntents.shift()?.kind === "launch";
|
|
96
|
+
}
|
|
97
|
+
/** OBS-50/342: one short, intent-bearing pane-run line; bootstrap lives beside the prompt. */
|
|
82
98
|
export function paneDispatchCommand(scriptPath) {
|
|
83
|
-
return `bash ${shq(scriptPath)}
|
|
99
|
+
return paneLaunchCommand(`bash ${shq(scriptPath)}`);
|
|
84
100
|
}
|
|
85
101
|
// ── design system (v1.50) ── contract: docs/codebase/CLI-DESIGN.md ──────────
|
|
86
102
|
// Every cockpit surface styles through these tokens/glyphs/helpers. Styled only
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { type ClaudeAlias } from "../../adapters/claude-code.js";
|
|
2
2
|
import type { WorkerAdapter } from "../../adapters/types.js";
|
|
3
3
|
import { type KimiDoctorTurnResult } from "../../adapters/kimi.js";
|
|
4
|
+
import { type CatalogReadResult } from "../../adapters/catalog-remote.js";
|
|
4
5
|
export type DoctorOpts = {
|
|
5
6
|
banner?: boolean;
|
|
6
7
|
kimiTurnProbe?: (cwd: string) => Promise<KimiDoctorTurnResult>;
|
|
7
8
|
resolveClaudeAliasIdentity?: (cwd: string, alias: ClaudeAlias) => string | undefined;
|
|
9
|
+
catalog?: CatalogReadResult;
|
|
10
|
+
catalogNow?: () => Date;
|
|
8
11
|
};
|
|
9
12
|
export declare function doctor(_argv: string[], cwd?: string, adapters?: WorkerAdapter[], opts?: DoctorOpts): Promise<string>;
|