@gajae-code/coding-agent 0.16.7 → 0.17.1
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/CHANGELOG.md +180 -1
- package/dist/types/capability/fs.d.ts +37 -4
- package/dist/types/capability/index.d.ts +19 -0
- package/dist/types/capability/types.d.ts +9 -0
- package/dist/types/cli/doctor/args.d.ts +36 -0
- package/dist/types/cli/doctor/checks.d.ts +18 -0
- package/dist/types/cli/doctor/config-repairs.d.ts +38 -0
- package/dist/types/cli/doctor/context.d.ts +89 -0
- package/dist/types/cli/doctor/files.d.ts +27 -0
- package/dist/types/cli/doctor/ids.d.ts +20 -0
- package/dist/types/cli/doctor/install-repairs.d.ts +94 -0
- package/dist/types/cli/doctor/journal.d.ts +43 -0
- package/dist/types/cli/doctor/managed-link.d.ts +39 -0
- package/dist/types/cli/doctor/native-probe.d.ts +2 -0
- package/dist/types/cli/doctor/permission-repairs.d.ts +25 -0
- package/dist/types/cli/doctor/plugin-quarantine.d.ts +77 -0
- package/dist/types/cli/doctor/plugin-restore.d.ts +40 -0
- package/dist/types/cli/doctor/plugin-targets.d.ts +11 -0
- package/dist/types/cli/doctor/probe-client.d.ts +9 -0
- package/dist/types/cli/doctor/probe-types.d.ts +18 -0
- package/dist/types/cli/doctor/probe.d.ts +3 -0
- package/dist/types/cli/doctor/projection-probe.d.ts +2 -0
- package/dist/types/cli/doctor/repairs.d.ts +28 -0
- package/dist/types/cli/doctor/report.d.ts +27 -0
- package/dist/types/cli/doctor/runner.d.ts +4 -0
- package/dist/types/cli/doctor/safety.d.ts +10 -0
- package/dist/types/cli/doctor/service-repairs.d.ts +8 -0
- package/dist/types/cli/doctor/service-targets.d.ts +41 -0
- package/dist/types/cli/doctor/types.d.ts +145 -0
- package/dist/types/cli/doctor-cli.d.ts +7 -0
- package/dist/types/cli/doctor-supervisor.d.ts +121 -0
- package/dist/types/cli/doctor-worker.d.ts +29 -0
- package/dist/types/cli/install-activation.d.ts +158 -0
- package/dist/types/cli/macos-community-app.d.ts +41 -0
- package/dist/types/cli/mcp-cli.d.ts +0 -11
- package/dist/types/cli/update-cli.d.ts +41 -4
- package/dist/types/cli-main.d.ts +174 -0
- package/dist/types/cli.d.ts +1 -171
- package/dist/types/commands/doctor.d.ts +7 -0
- package/dist/types/commands/sdk.d.ts +17 -8
- package/dist/types/config/autorouting-tier-map.d.ts +19 -0
- package/dist/types/config/file-lock.d.ts +27 -3
- package/dist/types/config/model-preset-registry.d.ts +1 -0
- package/dist/types/config/model-registry.d.ts +12 -5
- package/dist/types/config/model-resolver.d.ts +16 -3
- package/dist/types/config/models-config-schema.d.ts +2 -0
- package/dist/types/config/settings-schema.d.ts +1 -1
- package/dist/types/coordinator-mcp/question-gate-codec.d.ts +1 -1
- package/dist/types/coordinator-mcp/session-reaper.d.ts +15 -5
- package/dist/types/cursor.d.ts +9 -9
- package/dist/types/discovery/agents-md.d.ts +6 -1
- package/dist/types/discovery/helpers.d.ts +36 -7
- package/dist/types/discovery/index.d.ts +1 -1
- package/dist/types/discovery/mcp-json.d.ts +2 -0
- package/dist/types/extensibility/extensions/loader.d.ts +22 -1
- package/dist/types/extensibility/gjc-plugins/lifecycle.d.ts +14 -1
- package/dist/types/extensibility/gjc-plugins/paths.d.ts +2 -1
- package/dist/types/extensibility/gjc-plugins/types.d.ts +25 -0
- package/dist/types/extensibility/plugins/manager.d.ts +33 -4
- package/dist/types/extensibility/plugins/marketplace/cache.d.ts +6 -0
- package/dist/types/extensibility/plugins/marketplace/manager.d.ts +186 -0
- package/dist/types/extensibility/plugins/marketplace/registry.d.ts +27 -0
- package/dist/types/extensibility/plugins/marketplace/source-resolver.d.ts +16 -1
- package/dist/types/extensibility/runtime-skill-discovery.d.ts +16 -3
- package/dist/types/gjc-runtime/autoresearch-runtime.d.ts +6 -0
- package/dist/types/gjc-runtime/launch-worktree.d.ts +53 -0
- package/dist/types/gjc-runtime/session-layout.d.ts +8 -0
- package/dist/types/gjc-runtime/session-state-lock.d.ts +15 -0
- package/dist/types/gjc-runtime/session-state-sidecar.d.ts +13 -0
- package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +6 -0
- package/dist/types/main.d.ts +19 -1
- package/dist/types/modes/acp/acp-agent.d.ts +40 -0
- package/dist/types/modes/components/agent-dashboard.d.ts +1 -0
- package/dist/types/modes/components/model-selector.d.ts +2 -0
- package/dist/types/modes/interactive-mode.d.ts +1 -1
- package/dist/types/runtime-mcp/config-writer.d.ts +47 -0
- package/dist/types/runtime-mcp/policy-json-edit.d.ts +60 -0
- package/dist/types/runtime-mcp/startup-policy.d.ts +4 -0
- package/dist/types/runtime-mcp/types.d.ts +2 -2
- package/dist/types/sdk/acp/adapter.d.ts +5 -1
- package/dist/types/sdk/broker/broker.d.ts +51 -0
- package/dist/types/sdk/broker/daemon-entry.d.ts +39 -0
- package/dist/types/sdk/broker/discovery.d.ts +38 -0
- package/dist/types/sdk/broker/doctor-restart.d.ts +79 -0
- package/dist/types/sdk/broker/endpoint-authority.d.ts +7 -0
- package/dist/types/sdk/broker/ensure.d.ts +14 -0
- package/dist/types/sdk/broker/lifecycle.d.ts +2 -0
- package/dist/types/sdk/broker/process-incarnation.d.ts +50 -0
- package/dist/types/sdk/broker/runtime.d.ts +26 -0
- package/dist/types/sdk/broker/session-index.d.ts +13 -4
- package/dist/types/sdk/broker/worktree-occupancy.d.ts +14 -0
- package/dist/types/sdk/bus/chat-daemon-cli.d.ts +16 -0
- package/dist/types/sdk/bus/chat-daemon-control.d.ts +101 -6
- package/dist/types/sdk/bus/chat-daemon-runtime.d.ts +16 -0
- package/dist/types/sdk/bus/daemon-startup-exclusion.d.ts +43 -0
- package/dist/types/sdk/bus/doctor-daemon-restart-client.d.ts +51 -0
- package/dist/types/sdk/bus/doctor-daemon-restart.d.ts +39 -0
- package/dist/types/sdk/bus/index.d.ts +2 -0
- package/dist/types/sdk/bus/notification-service.d.ts +3 -0
- package/dist/types/sdk/bus/telegram-daemon-cli.d.ts +11 -0
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +1 -1
- package/dist/types/sdk/bus/telegram-daemon-control.d.ts +5 -0
- package/dist/types/sdk/bus/telegram-daemon-owner-registry.d.ts +1 -0
- package/dist/types/sdk/bus/telegram-daemon.d.ts +36 -5
- package/dist/types/sdk/cli/session-cli.d.ts +1 -0
- package/dist/types/sdk/host/session-runtime.d.ts +4 -0
- package/dist/types/sdk/host/surface-policy.d.ts +3 -1
- package/dist/types/sdk/lifecycle/service.d.ts +44 -10
- package/dist/types/sdk/prompt-deadline-lease.d.ts +6 -3
- package/dist/types/sdk/prompt-deadline-manager.d.ts +2 -2
- package/dist/types/sdk/prompt-failure.d.ts +47 -0
- package/dist/types/sdk/prompt-status.d.ts +19 -0
- package/dist/types/sdk/router/session-router.d.ts +3 -4
- package/dist/types/sdk/service-artifact-paths.d.ts +16 -0
- package/dist/types/sdk/session-authority.d.ts +9 -0
- package/dist/types/sdk/session.d.ts +3 -1
- package/dist/types/session/agent-session.d.ts +1 -1
- package/dist/types/session/blob-store.d.ts +1 -1
- package/dist/types/session/fallback-chain-controller.d.ts +3 -6
- package/dist/types/session/internal/managed-session-scope.d.ts +44 -0
- package/dist/types/session/primary-control-surface.d.ts +4 -0
- package/dist/types/session/session-manager.d.ts +6 -0
- package/dist/types/system-prompt.d.ts +6 -0
- package/dist/types/tools/ask.d.ts +25 -0
- package/dist/types/tools/image-gen.d.ts +0 -4
- package/dist/types/tools/skill-discovery.d.ts +7 -5
- package/dist/types/tools/ultragoal-ask-guard.d.ts +7 -4
- package/dist/types/utils/changelog.d.ts +0 -9
- package/dist/types/utils/mupdf-wasm.d.ts +1 -0
- package/package.json +9 -8
- package/scripts/compile-args.ts +8 -4
- package/src/capability/fs.ts +395 -17
- package/src/capability/index.ts +273 -10
- package/src/capability/types.ts +9 -0
- package/src/cli/customize-doctor.ts +18 -12
- package/src/cli/doctor/args.ts +236 -0
- package/src/cli/doctor/checks.ts +431 -0
- package/src/cli/doctor/config-repairs.ts +517 -0
- package/src/cli/doctor/context.ts +149 -0
- package/src/cli/doctor/files.ts +149 -0
- package/src/cli/doctor/ids.ts +115 -0
- package/src/cli/doctor/install-repairs.ts +335 -0
- package/src/cli/doctor/journal.ts +423 -0
- package/src/cli/doctor/managed-link.ts +514 -0
- package/src/cli/doctor/native-probe.ts +13 -0
- package/src/cli/doctor/permission-repairs.ts +242 -0
- package/src/cli/doctor/plugin-quarantine.ts +377 -0
- package/src/cli/doctor/plugin-restore.ts +59 -0
- package/src/cli/doctor/plugin-targets.ts +373 -0
- package/src/cli/doctor/probe-client.ts +195 -0
- package/src/cli/doctor/probe-types.ts +21 -0
- package/src/cli/doctor/probe.ts +42 -0
- package/src/cli/doctor/projection-probe.ts +249 -0
- package/src/cli/doctor/repairs.ts +1157 -0
- package/src/cli/doctor/report.ts +176 -0
- package/src/cli/doctor/runner.ts +342 -0
- package/src/cli/doctor/safety.ts +40 -0
- package/src/cli/doctor/service-repairs.ts +452 -0
- package/src/cli/doctor/service-targets.ts +274 -0
- package/src/cli/doctor/types.ts +164 -0
- package/src/cli/doctor-cli.ts +62 -0
- package/src/cli/doctor-supervisor.ts +571 -0
- package/src/cli/doctor-worker.ts +181 -0
- package/src/cli/install-activation.ts +666 -0
- package/src/cli/macos-community-app.ts +1449 -0
- package/src/cli/mcp-cli.ts +11 -21
- package/src/cli/nofile-limit.ts +5 -1
- package/src/cli/plugin-cli.ts +6 -1
- package/src/cli/update-cli.ts +362 -264
- package/src/cli-main.ts +517 -0
- package/src/cli.ts +64 -433
- package/src/commands/autoresearch.ts +11 -5
- package/src/commands/completion.ts +1 -1
- package/src/commands/doctor.ts +13 -0
- package/src/commands/sdk.ts +58 -10
- package/src/commands/ultragoal.ts +11 -5
- package/src/config/autorouting-tier-map.ts +7 -0
- package/src/config/file-lock.ts +736 -71
- package/src/config/mcp-schema.json +3 -3
- package/src/config/model-preset-registry.ts +1 -0
- package/src/config/model-registry.ts +80 -27
- package/src/config/model-resolver.ts +33 -4
- package/src/config/models-config-schema.ts +2 -0
- package/src/config/settings-schema.ts +6 -2
- package/src/coordinator-mcp/question-gate-codec.ts +1 -0
- package/src/coordinator-mcp/server.ts +534 -51
- package/src/coordinator-mcp/session-reaper.ts +64 -8
- package/src/cursor.ts +223 -53
- package/src/discovery/agents-md.ts +74 -8
- package/src/discovery/agents.ts +32 -7
- package/src/discovery/builtin.ts +184 -75
- package/src/discovery/claude-plugins.ts +85 -17
- package/src/discovery/cline.ts +38 -10
- package/src/discovery/cursor.ts +19 -6
- package/src/discovery/gemini.ts +62 -22
- package/src/discovery/github.ts +13 -3
- package/src/discovery/helpers.ts +483 -89
- package/src/discovery/index.ts +1 -0
- package/src/discovery/mcp-json.ts +36 -10
- package/src/discovery/opencode.ts +36 -19
- package/src/discovery/ssh.ts +11 -8
- package/src/discovery/windsurf.ts +12 -3
- package/src/exec/bash-executor.ts +10 -3
- package/src/exec/isolated-shell.ts +15 -2
- package/src/extensibility/extensions/loader.ts +88 -26
- package/src/extensibility/gjc-plugins/lifecycle.ts +189 -0
- package/src/extensibility/gjc-plugins/paths.ts +4 -1
- package/src/extensibility/gjc-plugins/types.ts +27 -0
- package/src/extensibility/plugins/manager.ts +200 -22
- package/src/extensibility/plugins/marketplace/cache.ts +55 -2
- package/src/extensibility/plugins/marketplace/manager.ts +1262 -162
- package/src/extensibility/plugins/marketplace/registry.ts +153 -0
- package/src/extensibility/plugins/marketplace/source-resolver.ts +116 -10
- package/src/extensibility/runtime-skill-discovery.ts +61 -9
- package/src/extensibility/skill-management.ts +7 -1
- package/src/gjc-runtime/autoresearch-runtime.ts +10 -1
- package/src/gjc-runtime/launch-worktree.test.ts +248 -0
- package/src/gjc-runtime/launch-worktree.ts +275 -38
- package/src/gjc-runtime/repository-binding.ts +26 -1
- package/src/gjc-runtime/session-layout.ts +10 -0
- package/src/gjc-runtime/session-state-lock.ts +330 -23
- package/src/gjc-runtime/session-state-sidecar.ts +328 -80
- package/src/gjc-runtime/ultragoal-runtime.ts +10 -1
- package/src/harness-control-plane/session-lease.ts +2 -2
- package/src/internal-urls/docs-index.generated.ts +28 -26
- package/src/main.ts +150 -29
- package/src/memories/index.ts +24 -2
- package/src/modes/acp/acp-agent.ts +522 -68
- package/src/modes/components/agent-dashboard.ts +3 -1
- package/src/modes/components/model-selector.ts +28 -19
- package/src/modes/components/plugin-settings.ts +2 -1
- package/src/modes/controllers/selector-controller.ts +15 -9
- package/src/modes/interactive-mode.ts +21 -3
- package/src/prompts/system/system-prompt.md +5 -1
- package/src/prompts/tools/browser.md +1 -1
- package/src/prompts/tools/move-session.md +4 -0
- package/src/prompts/tools/read.md +2 -1
- package/src/prompts/tools/skill-discovery.md +6 -5
- package/src/prompts/tools/task.md +1 -0
- package/src/runtime-mcp/config-writer.ts +228 -0
- package/src/runtime-mcp/oauth-discovery.ts +114 -14
- package/src/runtime-mcp/policy-json-edit.ts +129 -0
- package/src/runtime-mcp/startup-policy.ts +14 -0
- package/src/runtime-mcp/types.ts +2 -2
- package/src/sdk/acp/adapter.ts +27 -12
- package/src/sdk/broker/broker.ts +273 -44
- package/src/sdk/broker/daemon-entry.ts +119 -0
- package/src/sdk/broker/discovery.ts +173 -20
- package/src/sdk/broker/doctor-restart.ts +206 -0
- package/src/sdk/broker/endpoint-authority.ts +36 -0
- package/src/sdk/broker/ensure.ts +49 -14
- package/src/sdk/broker/lifecycle.ts +174 -42
- package/src/sdk/broker/process-incarnation.ts +86 -2
- package/src/sdk/broker/runtime.ts +145 -21
- package/src/sdk/broker/session-index.ts +136 -22
- package/src/sdk/broker/spawn-substrate.ts +4 -1
- package/src/sdk/broker/transport.ts +5 -0
- package/src/sdk/broker/worktree-occupancy.ts +21 -1
- package/src/sdk/bus/chat-daemon-cli.ts +63 -0
- package/src/sdk/bus/chat-daemon-control.ts +260 -64
- package/src/sdk/bus/chat-daemon-runtime.ts +141 -25
- package/src/sdk/bus/daemon-startup-exclusion.ts +119 -0
- package/src/sdk/bus/doctor-daemon-restart-client.ts +291 -0
- package/src/sdk/bus/doctor-daemon-restart.ts +92 -0
- package/src/sdk/bus/index.ts +252 -51
- package/src/sdk/bus/kind-aware-reconciliation.ts +76 -41
- package/src/sdk/bus/notification-service.ts +21 -3
- package/src/sdk/bus/reconciliation-store.ts +17 -11
- package/src/sdk/bus/telegram-daemon-cli.ts +91 -5
- package/src/sdk/bus/telegram-daemon-contract.ts +1 -1
- package/src/sdk/bus/telegram-daemon-control.ts +47 -0
- package/src/sdk/bus/telegram-daemon-owner-registry.ts +1 -1
- package/src/sdk/bus/telegram-daemon.ts +178 -13
- package/src/sdk/cli/session-cli.ts +100 -12
- package/src/sdk/host/host.ts +2 -7
- package/src/sdk/host/session-runtime.test.ts +329 -8
- package/src/sdk/host/session-runtime.ts +202 -50
- package/src/sdk/host/surface-policy.ts +8 -1
- package/src/sdk/lifecycle/service.ts +199 -22
- package/src/sdk/mcp/server.ts +1 -1
- package/src/sdk/prompt-deadline-lease.ts +12 -4
- package/src/sdk/prompt-deadline-manager.ts +5 -7
- package/src/sdk/prompt-failure.ts +148 -0
- package/src/sdk/prompt-status.ts +30 -1
- package/src/sdk/prompt-watchdog.ts +11 -3
- package/src/sdk/protocol/operation-inventory.generated.json +18 -0
- package/src/sdk/protocol/operation-registry.ts +20 -8
- package/src/sdk/router/session-router.ts +8 -3
- package/src/sdk/service-artifact-paths.ts +26 -0
- package/src/sdk/session-authority.ts +10 -0
- package/src/sdk/session.ts +361 -194
- package/src/session/agent-session.ts +398 -93
- package/src/session/blob-store.ts +9 -9
- package/src/session/fallback-chain-controller.ts +3 -7
- package/src/session/internal/managed-session-scope.ts +445 -29
- package/src/session/internal/managed-session-storage.ts +38 -6
- package/src/session/primary-control-surface.ts +12 -0
- package/src/session/session-manager.ts +11 -3
- package/src/session/session-storage.ts +1 -1
- package/src/session-import/codex.ts +6 -1
- package/src/session-import/redact.ts +7 -0
- package/src/skill-state/workflow-mutation-guard.ts +645 -39
- package/src/slash-commands/builtin-registry.ts +7 -3
- package/src/system-prompt.ts +8 -0
- package/src/task/executor.ts +36 -3
- package/src/task/types.ts +27 -5
- package/src/tools/ask.ts +114 -34
- package/src/tools/browser/actions.ts +2 -2
- package/src/tools/browser/tab-worker.ts +11 -8
- package/src/tools/descriptors.ts +6 -1
- package/src/tools/fetch.ts +7 -2
- package/src/tools/image-gen.ts +33 -34
- package/src/tools/read.ts +78 -32
- package/src/tools/skill-discovery.ts +17 -7
- package/src/tools/tool-catalog.generated.ts +8 -8
- package/src/tools/ultragoal-ask-guard.ts +16 -26
- package/src/utils/changelog.ts +7 -1
- package/src/utils/git.ts +3 -1
- package/src/utils/markit.ts +24 -2
- package/src/utils/mupdf-wasm.ts +26 -0
- package/src/web/search/providers/openai-compatible.ts +191 -14
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { getAgentDbPath, VERSION } from "@gajae-code/utils/dirs";
|
|
4
|
+
import { JSONC, YAML } from "bun";
|
|
5
|
+
import { computeAutoloadStatus } from "../../runtime-mcp/startup-policy";
|
|
6
|
+
import type { DoctorConfigSource, DoctorContext } from "./context";
|
|
7
|
+
import { type DoctorFileObservation, doctorErrno, doctorMapping, readDoctorFile } from "./files";
|
|
8
|
+
import { binaryTargetId, configTargetId, mcpTargetId, permissionTargetId, resolveDoctorRoot } from "./ids";
|
|
9
|
+
import { describeInstallRestore, type InstallRestoreDescriptorV1 } from "./install-repairs";
|
|
10
|
+
import { describeManagedLink } from "./managed-link";
|
|
11
|
+
import type { CheckEvidence, DoctorCheck } from "./types";
|
|
12
|
+
|
|
13
|
+
export interface DoctorCollector {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly dependsOn: readonly string[];
|
|
16
|
+
readonly timeoutMs: number;
|
|
17
|
+
collect(context: DoctorContext): Promise<DoctorCheck[]>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function doctorCheck(
|
|
21
|
+
id: string,
|
|
22
|
+
targetId: string,
|
|
23
|
+
result: Pick<DoctorCheck, "execution" | "health" | "evidenceLevel"> & Partial<DoctorCheck>,
|
|
24
|
+
): DoctorCheck {
|
|
25
|
+
return {
|
|
26
|
+
id,
|
|
27
|
+
targetId,
|
|
28
|
+
dependsOn: [],
|
|
29
|
+
remediationIds: [],
|
|
30
|
+
evidence: {},
|
|
31
|
+
observedAt: new Date().toISOString(),
|
|
32
|
+
...result,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function fileCheck(
|
|
37
|
+
id: string,
|
|
38
|
+
targetId: string,
|
|
39
|
+
observation: DoctorFileObservation,
|
|
40
|
+
source: DoctorConfigSource,
|
|
41
|
+
): DoctorCheck | undefined {
|
|
42
|
+
if (source.root.resolution !== "resolved")
|
|
43
|
+
return doctorCheck(id, targetId, {
|
|
44
|
+
scope: source.scope,
|
|
45
|
+
execution: "blocked",
|
|
46
|
+
health: "unknown",
|
|
47
|
+
evidenceLevel: "observed",
|
|
48
|
+
reasonCode: "root_resolution_unknown",
|
|
49
|
+
});
|
|
50
|
+
if (observation.status === "read") return undefined;
|
|
51
|
+
return doctorCheck(id, targetId, {
|
|
52
|
+
scope: source.scope,
|
|
53
|
+
execution: observation.status === "missing" ? "completed" : "blocked",
|
|
54
|
+
health: observation.status === "missing" ? "not_applicable" : "unknown",
|
|
55
|
+
evidenceLevel: "observed",
|
|
56
|
+
reasonCode: `file_${observation.status}`,
|
|
57
|
+
evidence: observation.errno ? { errno: observation.errno } : {},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function parseConfig(
|
|
62
|
+
observation: DoctorFileObservation,
|
|
63
|
+
format: "yaml" | "json",
|
|
64
|
+
): { document?: Record<string, unknown>; reasonCode?: string } {
|
|
65
|
+
if (observation.status !== "read") return {};
|
|
66
|
+
try {
|
|
67
|
+
const parsed: unknown = format === "yaml" ? YAML.parse(observation.text) : JSONC.parse(observation.text);
|
|
68
|
+
const document = doctorMapping(parsed);
|
|
69
|
+
return document ? { document } : { reasonCode: "config_root_not_mapping" };
|
|
70
|
+
} catch {
|
|
71
|
+
// Parser errors may include source snippets containing credentials.
|
|
72
|
+
return { reasonCode: "config_parse_error" };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function collectRuntime(context: DoctorContext): Promise<DoctorCheck[]> {
|
|
77
|
+
return [
|
|
78
|
+
doctorCheck("runtime.identity", `t1:runtime:${context.installRoot.rootId}`, {
|
|
79
|
+
execution: "completed",
|
|
80
|
+
health: "ok",
|
|
81
|
+
evidenceLevel: "observed",
|
|
82
|
+
reasonCode: "runtime_available",
|
|
83
|
+
evidence: {
|
|
84
|
+
version: VERSION,
|
|
85
|
+
runtimeVersion: Bun.version,
|
|
86
|
+
platform: process.platform,
|
|
87
|
+
arch: process.arch,
|
|
88
|
+
channel: context.compiled ? "standalone" : "source",
|
|
89
|
+
},
|
|
90
|
+
}),
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export async function collectConfig(context: DoctorContext): Promise<DoctorCheck[]> {
|
|
95
|
+
const checks: DoctorCheck[] = [];
|
|
96
|
+
for (const source of context.sources) {
|
|
97
|
+
const observation = await readDoctorFile(source.configPath);
|
|
98
|
+
const parsed = parseConfig(observation, "yaml");
|
|
99
|
+
const skills = doctorMapping(parsed.document?.skills);
|
|
100
|
+
for (const schemaKey of ["skills.enabled", "skills.enableSkillCommands"] as const) {
|
|
101
|
+
const field = schemaKey.slice("skills.".length);
|
|
102
|
+
const beforeValue = skills?.[field];
|
|
103
|
+
const targetId = configTargetId(source.root.rootId, source.scope, schemaKey);
|
|
104
|
+
context.targets.set(targetId, { kind: "config", targetId, source, schemaKey, observation, beforeValue });
|
|
105
|
+
const id = `config.${source.scope}.${schemaKey}`;
|
|
106
|
+
const failure = fileCheck(id, targetId, observation, source);
|
|
107
|
+
if (failure) {
|
|
108
|
+
checks.push(failure);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const reasonCode =
|
|
112
|
+
parsed.reasonCode ??
|
|
113
|
+
(parsed.document?.skills !== undefined && !skills
|
|
114
|
+
? "config_skills_not_mapping"
|
|
115
|
+
: beforeValue !== undefined && typeof beforeValue !== "boolean"
|
|
116
|
+
? "config_invalid_boolean"
|
|
117
|
+
: "config_field_valid");
|
|
118
|
+
checks.push(
|
|
119
|
+
doctorCheck(id, targetId, {
|
|
120
|
+
scope: source.scope,
|
|
121
|
+
execution: "completed",
|
|
122
|
+
health: reasonCode === "config_field_valid" ? "ok" : "error",
|
|
123
|
+
evidenceLevel: "observed",
|
|
124
|
+
reasonCode,
|
|
125
|
+
evidence: {
|
|
126
|
+
schemaLocation: schemaKey,
|
|
127
|
+
present: beforeValue !== undefined,
|
|
128
|
+
...(typeof beforeValue === "boolean" ? { enabled: beforeValue } : {}),
|
|
129
|
+
schemaCoverage: "selected_fields",
|
|
130
|
+
},
|
|
131
|
+
remediationIds: ["config.set-validated"],
|
|
132
|
+
}),
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return checks;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export async function collectPermissions(context: DoctorContext): Promise<DoctorCheck[]> {
|
|
140
|
+
const source = context.sources.find(candidate => candidate.scope === "user");
|
|
141
|
+
if (!source) return [];
|
|
142
|
+
const observation = await readDoctorFile(source.configPath);
|
|
143
|
+
const targetId = permissionTargetId(source.root.rootId);
|
|
144
|
+
context.targets.set(targetId, { kind: "permission", targetId, source, observation });
|
|
145
|
+
const failure = fileCheck("permissions.user.config", targetId, observation, source);
|
|
146
|
+
if (failure) return [failure];
|
|
147
|
+
if (observation.status !== "read") return [];
|
|
148
|
+
const exposed = (observation.identity.mode & 0o077) !== 0;
|
|
149
|
+
return [
|
|
150
|
+
doctorCheck("permissions.user.config", targetId, {
|
|
151
|
+
scope: "user",
|
|
152
|
+
execution: "completed",
|
|
153
|
+
health: process.platform === "win32" ? "unknown" : exposed ? "warning" : "ok",
|
|
154
|
+
evidenceLevel: "observed",
|
|
155
|
+
reasonCode: process.platform === "win32" ? "acl_not_probed" : exposed ? "mode_exposes_config" : "mode_private",
|
|
156
|
+
evidence: {
|
|
157
|
+
mode: observation.identity.mode & 0o777,
|
|
158
|
+
ownerMatches: process.getuid ? observation.identity.owner === process.getuid() : false,
|
|
159
|
+
aclCoverage: "not_probed",
|
|
160
|
+
},
|
|
161
|
+
remediationIds: ["permissions.restrict-owned-config"],
|
|
162
|
+
}),
|
|
163
|
+
];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export async function collectMcp(context: DoctorContext): Promise<DoctorCheck[]> {
|
|
167
|
+
const checks: DoctorCheck[] = [];
|
|
168
|
+
for (const source of context.sources) {
|
|
169
|
+
const observation = await readDoctorFile(source.mcpPath);
|
|
170
|
+
const id = `mcp.${source.scope}.configuration`;
|
|
171
|
+
const rootTarget = `t1:mcp-config:${source.root.rootId}:${source.scope}`;
|
|
172
|
+
const failure = fileCheck(id, rootTarget, observation, source);
|
|
173
|
+
if (failure) {
|
|
174
|
+
checks.push(failure);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const parsed = parseConfig(observation, source.mcpPath.endsWith(".json") ? "json" : "yaml");
|
|
178
|
+
const servers = doctorMapping(parsed.document?.mcpServers);
|
|
179
|
+
if (parsed.reasonCode || (parsed.document?.mcpServers !== undefined && !servers)) {
|
|
180
|
+
checks.push(
|
|
181
|
+
doctorCheck(id, rootTarget, {
|
|
182
|
+
scope: source.scope,
|
|
183
|
+
execution: "completed",
|
|
184
|
+
health: "error",
|
|
185
|
+
evidenceLevel: "observed",
|
|
186
|
+
reasonCode: parsed.reasonCode ?? "mcp_servers_not_mapping",
|
|
187
|
+
}),
|
|
188
|
+
);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const names = Object.keys(servers ?? {}).sort();
|
|
192
|
+
const disabled = parsed.document?.disabledServers;
|
|
193
|
+
const disabledNames = new Set<string>(
|
|
194
|
+
Array.isArray(disabled) ? disabled.filter((name): name is string => typeof name === "string") : [],
|
|
195
|
+
);
|
|
196
|
+
if (names.length > 1000) {
|
|
197
|
+
checks.push(
|
|
198
|
+
doctorCheck(id, rootTarget, {
|
|
199
|
+
scope: source.scope,
|
|
200
|
+
execution: "blocked",
|
|
201
|
+
health: "unknown",
|
|
202
|
+
evidenceLevel: "observed",
|
|
203
|
+
reasonCode: "limit_exceeded",
|
|
204
|
+
}),
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
for (const name of names.slice(0, 1000)) {
|
|
208
|
+
const server = doctorMapping(servers?.[name]);
|
|
209
|
+
for (const field of ["autoload", "enabled"] as const) {
|
|
210
|
+
const targetId = mcpTargetId(source.root.rootId, source.scope, name, field);
|
|
211
|
+
context.targets.set(targetId, {
|
|
212
|
+
kind: "mcp",
|
|
213
|
+
targetId,
|
|
214
|
+
source,
|
|
215
|
+
serverName: name,
|
|
216
|
+
field,
|
|
217
|
+
definitionIsMapping: server !== undefined,
|
|
218
|
+
observation,
|
|
219
|
+
beforeValue: server?.[field],
|
|
220
|
+
});
|
|
221
|
+
const valid =
|
|
222
|
+
server !== undefined &&
|
|
223
|
+
(server.enabled === undefined || typeof server.enabled === "boolean") &&
|
|
224
|
+
(server.autoload === undefined || typeof server.autoload === "boolean");
|
|
225
|
+
const evidence: CheckEvidence = {
|
|
226
|
+
present: server?.[field] !== undefined,
|
|
227
|
+
runtimeProbed: false,
|
|
228
|
+
...(typeof server?.enabled === "boolean" ? { enabled: server.enabled } : {}),
|
|
229
|
+
...(typeof server?.autoload === "boolean" ? { autoload: server.autoload } : {}),
|
|
230
|
+
...(valid
|
|
231
|
+
? {
|
|
232
|
+
startupStatus: computeAutoloadStatus(
|
|
233
|
+
name,
|
|
234
|
+
{
|
|
235
|
+
enabled: typeof server.enabled === "boolean" ? server.enabled : undefined,
|
|
236
|
+
autoload: typeof server.autoload === "boolean" ? server.autoload : undefined,
|
|
237
|
+
},
|
|
238
|
+
disabledNames,
|
|
239
|
+
),
|
|
240
|
+
}
|
|
241
|
+
: {}),
|
|
242
|
+
};
|
|
243
|
+
checks.push(
|
|
244
|
+
doctorCheck(`mcp.${source.scope}.${targetId.split(":").at(-2)}.${field}`, targetId, {
|
|
245
|
+
scope: source.scope,
|
|
246
|
+
execution: "completed",
|
|
247
|
+
health: valid ? "ok" : "error",
|
|
248
|
+
evidenceLevel: "observed",
|
|
249
|
+
reasonCode: valid ? "mcp_static_policy_valid" : "mcp_invalid_policy",
|
|
250
|
+
evidence,
|
|
251
|
+
remediationIds: ["mcp.set-startup-policy"],
|
|
252
|
+
}),
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (names.length === 0) {
|
|
257
|
+
checks.push(
|
|
258
|
+
doctorCheck(id, rootTarget, {
|
|
259
|
+
scope: source.scope,
|
|
260
|
+
execution: "completed",
|
|
261
|
+
health: "not_applicable",
|
|
262
|
+
evidenceLevel: "observed",
|
|
263
|
+
reasonCode: "mcp_no_servers",
|
|
264
|
+
}),
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return checks;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export async function collectCredentials(context: DoctorContext): Promise<DoctorCheck[]> {
|
|
272
|
+
const targetId = `t1:credentials:${context.agentRoot.rootId}`;
|
|
273
|
+
try {
|
|
274
|
+
const stat = await fs.lstat(getAgentDbPath(context.agentRoot.locator));
|
|
275
|
+
return [
|
|
276
|
+
doctorCheck("credentials.storage", targetId, {
|
|
277
|
+
execution: "completed",
|
|
278
|
+
health: stat.isSymbolicLink() || !stat.isFile() ? "warning" : "ok",
|
|
279
|
+
evidenceLevel: "observed",
|
|
280
|
+
reasonCode:
|
|
281
|
+
stat.isSymbolicLink() || !stat.isFile()
|
|
282
|
+
? "credential_storage_not_regular"
|
|
283
|
+
: "credential_storage_present",
|
|
284
|
+
evidence: { present: true, contentsRead: false, authenticationProbed: false },
|
|
285
|
+
}),
|
|
286
|
+
];
|
|
287
|
+
} catch (error) {
|
|
288
|
+
const errno = doctorErrno(error);
|
|
289
|
+
return [
|
|
290
|
+
doctorCheck("credentials.storage", targetId, {
|
|
291
|
+
execution: errno === "ENOENT" ? "completed" : "blocked",
|
|
292
|
+
health: errno === "ENOENT" ? "not_applicable" : "unknown",
|
|
293
|
+
evidenceLevel: "observed",
|
|
294
|
+
reasonCode: errno === "ENOENT" ? "credential_storage_absent" : "credential_storage_unreadable",
|
|
295
|
+
evidence: { errno, contentsRead: false, authenticationProbed: false },
|
|
296
|
+
}),
|
|
297
|
+
];
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export async function collectInstallation(context: DoctorContext): Promise<DoctorCheck[]> {
|
|
302
|
+
const targetId = context.compiled
|
|
303
|
+
? binaryTargetId(context.installRoot.rootId, path.basename(context.executable))
|
|
304
|
+
: `t1:installation:${context.installRoot.rootId}:source`;
|
|
305
|
+
if (context.compiled)
|
|
306
|
+
context.targets.set(targetId, {
|
|
307
|
+
kind: "binary",
|
|
308
|
+
targetId,
|
|
309
|
+
filePath: context.executable,
|
|
310
|
+
root: context.installRoot,
|
|
311
|
+
});
|
|
312
|
+
try {
|
|
313
|
+
const stat = await fs.lstat(context.executable);
|
|
314
|
+
let descriptor: InstallRestoreDescriptorV1 | undefined;
|
|
315
|
+
if (
|
|
316
|
+
context.compiled &&
|
|
317
|
+
context.options.repair === "install.restore-binary" &&
|
|
318
|
+
context.options.targetId === targetId
|
|
319
|
+
) {
|
|
320
|
+
const channel = VERSION.includes("nightly")
|
|
321
|
+
? "nightly"
|
|
322
|
+
: /^\d+\.\d+\.\d+$/.test(VERSION)
|
|
323
|
+
? "stable"
|
|
324
|
+
: "unknown";
|
|
325
|
+
descriptor = await describeInstallRestore(context.executable, undefined, channel, `v${VERSION}`);
|
|
326
|
+
context.targets.set(targetId, {
|
|
327
|
+
kind: "binary",
|
|
328
|
+
targetId,
|
|
329
|
+
filePath: context.executable,
|
|
330
|
+
root: context.installRoot,
|
|
331
|
+
installDescriptor: descriptor,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
return [
|
|
335
|
+
doctorCheck("installation.current", targetId, {
|
|
336
|
+
execution: "completed",
|
|
337
|
+
health: stat.isFile() ? "ok" : "error",
|
|
338
|
+
evidenceLevel: "observed",
|
|
339
|
+
reasonCode: stat.isFile() ? "installation_entry_present" : "installation_entry_not_regular",
|
|
340
|
+
evidence: {
|
|
341
|
+
channel: context.compiled ? "standalone" : "source",
|
|
342
|
+
version: VERSION,
|
|
343
|
+
present: true,
|
|
344
|
+
...(descriptor && context.options.sha256
|
|
345
|
+
? { integrityResult: descriptor.targetDigest === context.options.sha256 ? "matches_pin" : "mismatch" }
|
|
346
|
+
: {}),
|
|
347
|
+
},
|
|
348
|
+
remediationIds: context.compiled ? ["install.restore-binary"] : [],
|
|
349
|
+
}),
|
|
350
|
+
];
|
|
351
|
+
} catch (error) {
|
|
352
|
+
return [
|
|
353
|
+
doctorCheck("installation.current", targetId, {
|
|
354
|
+
execution: "blocked",
|
|
355
|
+
health: "unknown",
|
|
356
|
+
evidenceLevel: "observed",
|
|
357
|
+
reasonCode: "installation_entry_unreadable",
|
|
358
|
+
evidence: { errno: doctorErrno(error) },
|
|
359
|
+
}),
|
|
360
|
+
];
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** Managed alias observation only: nothing on PATH is executed or resolved through the shell. */
|
|
365
|
+
export async function collectManagedLinks(context: DoctorContext): Promise<DoctorCheck[]> {
|
|
366
|
+
// The group must always answer. Returning nothing makes the check vanish from
|
|
367
|
+
// the report entirely, which reads as "nothing to say" rather than the truth,
|
|
368
|
+
// and the plan requires an inapplicable scope be stated, not hidden.
|
|
369
|
+
// `completed` + `not_applicable`, never `unsupported`: this is a fully
|
|
370
|
+
// determined answer, so it must not inflate the incomplete coverage that
|
|
371
|
+
// drives exit 3.
|
|
372
|
+
const inapplicable = (reasonCode: string): DoctorCheck[] => [
|
|
373
|
+
doctorCheck("link.managed", `t1:link:${context.installRoot.rootId}:not-applicable`, {
|
|
374
|
+
execution: "completed",
|
|
375
|
+
health: "not_applicable",
|
|
376
|
+
evidenceLevel: "not_probed",
|
|
377
|
+
reasonCode,
|
|
378
|
+
evidence: { present: false },
|
|
379
|
+
}),
|
|
380
|
+
];
|
|
381
|
+
// `cliPath` is set exactly for a source checkout; a standalone binary has no
|
|
382
|
+
// managed alias to inspect.
|
|
383
|
+
if (!context.cliPath) return inapplicable("managed_link_standalone_install");
|
|
384
|
+
const workspace = path.resolve(path.dirname(context.cliPath), "..", "..", "..");
|
|
385
|
+
const checks: DoctorCheck[] = [];
|
|
386
|
+
for (const entry of (process.env.PATH ?? "").split(path.delimiter)) {
|
|
387
|
+
if (!entry || !path.isAbsolute(entry)) continue;
|
|
388
|
+
for (const alias of ["gjc", "가재씨"]) {
|
|
389
|
+
const targetPath = path.join(entry, alias);
|
|
390
|
+
const stat = await fs.lstat(targetPath).catch(() => undefined);
|
|
391
|
+
if (!stat) continue;
|
|
392
|
+
const descriptor = await describeManagedLink(targetPath, workspace, alias);
|
|
393
|
+
if (context.targets.has(descriptor.targetId)) continue;
|
|
394
|
+
context.targets.set(descriptor.targetId, {
|
|
395
|
+
kind: "link",
|
|
396
|
+
targetId: descriptor.targetId,
|
|
397
|
+
filePath: targetPath,
|
|
398
|
+
root: resolveDoctorRoot("install", descriptor.parentPath),
|
|
399
|
+
linkDescriptor: descriptor,
|
|
400
|
+
});
|
|
401
|
+
checks.push(
|
|
402
|
+
doctorCheck(`installation.link.${descriptor.targetId.split(":").at(-1)}`, descriptor.targetId, {
|
|
403
|
+
execution: "completed",
|
|
404
|
+
health: descriptor.status === "healthy" ? "ok" : descriptor.status === "broken" ? "error" : "warning",
|
|
405
|
+
evidenceLevel: "observed",
|
|
406
|
+
reasonCode: descriptor.reasonCode ?? `managed_link_${descriptor.status}`,
|
|
407
|
+
evidence: {
|
|
408
|
+
present: true,
|
|
409
|
+
status: descriptor.status,
|
|
410
|
+
runtimeProbed: false,
|
|
411
|
+
candidateCount: descriptor.candidates.length,
|
|
412
|
+
},
|
|
413
|
+
remediationIds: descriptor.receiptTrusted ? ["install.repair-managed-link"] : [],
|
|
414
|
+
}),
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
// A source checkout with no alias installed anywhere on PATH is a real,
|
|
419
|
+
// observed answer — not an empty group.
|
|
420
|
+
return checks.length > 0 ? checks : inapplicable("managed_link_absent");
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export const BASIC_DOCTOR_COLLECTORS: readonly DoctorCollector[] = [
|
|
424
|
+
{ id: "runtime", dependsOn: [], timeoutMs: 2_000, collect: collectRuntime },
|
|
425
|
+
{ id: "config", dependsOn: [], timeoutMs: 2_000, collect: collectConfig },
|
|
426
|
+
{ id: "permissions", dependsOn: [], timeoutMs: 2_000, collect: collectPermissions },
|
|
427
|
+
{ id: "installation", dependsOn: [], timeoutMs: 2_000, collect: collectInstallation },
|
|
428
|
+
{ id: "link", dependsOn: [], timeoutMs: 3_000, collect: collectManagedLinks },
|
|
429
|
+
{ id: "credentials", dependsOn: [], timeoutMs: 2_000, collect: collectCredentials },
|
|
430
|
+
{ id: "mcp", dependsOn: [], timeoutMs: 2_000, collect: collectMcp },
|
|
431
|
+
];
|