@cchistory/lite 0.9.0 → 0.9.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.
Files changed (175) hide show
  1. package/INSTALL.md +1 -1
  2. package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
  3. package/apps/lite-cli/dist/agent-contract.js +41 -2
  4. package/apps/lite-cli/dist/agent-contract.js.map +1 -1
  5. package/apps/lite-cli/dist/help.js +5 -5
  6. package/apps/lite-cli/dist/index.d.ts.map +1 -1
  7. package/apps/lite-cli/dist/index.js +148 -17
  8. package/apps/lite-cli/dist/index.js.map +1 -1
  9. package/apps/lite-cli/dist/index.test.js +114 -95
  10. package/apps/lite-cli/dist/index.test.js.map +1 -1
  11. package/apps/lite-cli/dist/inventory-and-git.test.d.ts +7 -0
  12. package/apps/lite-cli/dist/inventory-and-git.test.d.ts.map +1 -0
  13. package/apps/lite-cli/dist/inventory-and-git.test.js +776 -0
  14. package/apps/lite-cli/dist/inventory-and-git.test.js.map +1 -0
  15. package/apps/lite-cli/dist/inventory-command.d.ts +30 -0
  16. package/apps/lite-cli/dist/inventory-command.d.ts.map +1 -0
  17. package/apps/lite-cli/dist/inventory-command.js +265 -0
  18. package/apps/lite-cli/dist/inventory-command.js.map +1 -0
  19. package/apps/lite-cli/dist/json-v2.d.ts +2 -2
  20. package/apps/lite-cli/dist/json-v2.d.ts.map +1 -1
  21. package/apps/lite-cli/dist/json-v2.js +9 -3
  22. package/apps/lite-cli/dist/json-v2.js.map +1 -1
  23. package/apps/lite-cli/dist/project-git-command.d.ts +28 -0
  24. package/apps/lite-cli/dist/project-git-command.d.ts.map +1 -0
  25. package/apps/lite-cli/dist/project-git-command.js +288 -0
  26. package/apps/lite-cli/dist/project-git-command.js.map +1 -0
  27. package/apps/lite-cli/dist/startup-render.d.ts +10 -0
  28. package/apps/lite-cli/dist/startup-render.d.ts.map +1 -0
  29. package/apps/lite-cli/dist/startup-render.js +335 -0
  30. package/apps/lite-cli/dist/startup-render.js.map +1 -0
  31. package/apps/lite-cli/dist/version.d.ts +1 -1
  32. package/apps/lite-cli/dist/version.js +1 -1
  33. package/apps/lite-tui/dist/render.d.ts +1 -1
  34. package/apps/lite-tui/dist/version.d.ts +1 -1
  35. package/apps/lite-tui/dist/version.js +1 -1
  36. package/docs/guide/for-agents.md +14 -0
  37. package/docs/guide/lite.md +53 -2
  38. package/node_modules/@cchistory/canonical/dist/agent-inventory.d.ts +25 -0
  39. package/node_modules/@cchistory/canonical/dist/agent-inventory.d.ts.map +1 -0
  40. package/node_modules/@cchistory/canonical/dist/agent-inventory.js +345 -0
  41. package/node_modules/@cchistory/canonical/dist/agent-inventory.js.map +1 -0
  42. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.d.ts +7 -0
  43. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.d.ts.map +1 -0
  44. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.js +231 -0
  45. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.js.map +1 -0
  46. package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts.map +1 -1
  47. package/node_modules/@cchistory/canonical/dist/directory-scope.js +4 -1
  48. package/node_modules/@cchistory/canonical/dist/directory-scope.js.map +1 -1
  49. package/node_modules/@cchistory/canonical/dist/index.d.ts +2 -0
  50. package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
  51. package/node_modules/@cchistory/canonical/dist/index.js +2 -0
  52. package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
  53. package/node_modules/@cchistory/canonical/dist/project-merge.d.ts +42 -0
  54. package/node_modules/@cchistory/canonical/dist/project-merge.d.ts.map +1 -0
  55. package/node_modules/@cchistory/canonical/dist/project-merge.js +396 -0
  56. package/node_modules/@cchistory/canonical/dist/project-merge.js.map +1 -0
  57. package/node_modules/@cchistory/canonical/dist/project-merge.test.d.ts +7 -0
  58. package/node_modules/@cchistory/canonical/dist/project-merge.test.d.ts.map +1 -0
  59. package/node_modules/@cchistory/canonical/dist/project-merge.test.js +319 -0
  60. package/node_modules/@cchistory/canonical/dist/project-merge.test.js.map +1 -0
  61. package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -1
  62. package/node_modules/@cchistory/canonical/dist/session-interpreter.js +38 -0
  63. package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -1
  64. package/node_modules/@cchistory/canonical/dist/tool-call-summary.d.ts.map +1 -1
  65. package/node_modules/@cchistory/canonical/dist/tool-call-summary.js +8 -0
  66. package/node_modules/@cchistory/canonical/dist/tool-call-summary.js.map +1 -1
  67. package/node_modules/@cchistory/canonical/package.json +1 -1
  68. package/node_modules/@cchistory/domain/dist/agent-inventory.d.ts +146 -0
  69. package/node_modules/@cchistory/domain/dist/agent-inventory.d.ts.map +1 -0
  70. package/node_modules/@cchistory/domain/dist/agent-inventory.js +9 -0
  71. package/node_modules/@cchistory/domain/dist/agent-inventory.js.map +1 -0
  72. package/node_modules/@cchistory/domain/dist/agent-startup.d.ts +362 -0
  73. package/node_modules/@cchistory/domain/dist/agent-startup.d.ts.map +1 -0
  74. package/node_modules/@cchistory/domain/dist/agent-startup.js +8 -0
  75. package/node_modules/@cchistory/domain/dist/agent-startup.js.map +1 -0
  76. package/node_modules/@cchistory/domain/dist/index.d.ts +5 -0
  77. package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
  78. package/node_modules/@cchistory/domain/dist/index.js +3 -0
  79. package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
  80. package/node_modules/@cchistory/domain/dist/index.test.js +18 -1
  81. package/node_modules/@cchistory/domain/dist/index.test.js.map +1 -1
  82. package/node_modules/@cchistory/domain/dist/project-git.d.ts +121 -0
  83. package/node_modules/@cchistory/domain/dist/project-git.d.ts.map +1 -0
  84. package/node_modules/@cchistory/domain/dist/project-git.js +93 -0
  85. package/node_modules/@cchistory/domain/dist/project-git.js.map +1 -0
  86. package/node_modules/@cchistory/domain/package.json +1 -1
  87. package/node_modules/@cchistory/live-runtime/dist/index.d.ts +2 -1
  88. package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
  89. package/node_modules/@cchistory/live-runtime/dist/index.js +2 -1
  90. package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
  91. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.d.ts +35 -0
  92. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.d.ts.map +1 -0
  93. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.js +68 -0
  94. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.js.map +1 -0
  95. package/node_modules/@cchistory/live-runtime/package.json +1 -1
  96. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts +9 -0
  97. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts.map +1 -1
  98. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js +130 -7
  99. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js.map +1 -1
  100. package/node_modules/@cchistory/source-adapters/dist/index.d.ts +5 -0
  101. package/node_modules/@cchistory/source-adapters/dist/index.d.ts.map +1 -1
  102. package/node_modules/@cchistory/source-adapters/dist/index.js +5 -0
  103. package/node_modules/@cchistory/source-adapters/dist/index.js.map +1 -1
  104. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +2 -0
  105. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
  106. package/node_modules/@cchistory/source-adapters/dist/index.test.js +2 -0
  107. package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
  108. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.d.ts +14 -0
  109. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.d.ts.map +1 -0
  110. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.js +397 -0
  111. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.js.map +1 -0
  112. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.d.ts +6 -0
  113. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.d.ts.map +1 -0
  114. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.js +106 -0
  115. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.js.map +1 -0
  116. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.d.ts +42 -0
  117. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.d.ts.map +1 -0
  118. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.js +368 -0
  119. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.js.map +1 -0
  120. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.d.ts +22 -0
  121. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.d.ts.map +1 -0
  122. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.js +195 -0
  123. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.js.map +1 -0
  124. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.d.ts +23 -0
  125. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.d.ts.map +1 -0
  126. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.js +147 -0
  127. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.js.map +1 -0
  128. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.d.ts +11 -0
  129. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.d.ts.map +1 -0
  130. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.js +339 -0
  131. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.js.map +1 -0
  132. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.d.ts +70 -0
  133. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.d.ts.map +1 -0
  134. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.js +257 -0
  135. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.js.map +1 -0
  136. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.d.ts +11 -0
  137. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.d.ts.map +1 -0
  138. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.js +321 -0
  139. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.js.map +1 -0
  140. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.d.ts +12 -0
  141. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.d.ts.map +1 -0
  142. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.js +363 -0
  143. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.js.map +1 -0
  144. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.d.ts +20 -0
  145. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.d.ts.map +1 -0
  146. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.js +408 -0
  147. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.js.map +1 -0
  148. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.d.ts +24 -0
  149. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.d.ts.map +1 -0
  150. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.js +225 -0
  151. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.js.map +1 -0
  152. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.d.ts +12 -0
  153. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.d.ts.map +1 -0
  154. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.js +372 -0
  155. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.js.map +1 -0
  156. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.d.ts +62 -0
  157. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.d.ts.map +1 -0
  158. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.js +428 -0
  159. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.js.map +1 -0
  160. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.d.ts +7 -0
  161. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.d.ts.map +1 -0
  162. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.js +399 -0
  163. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.js.map +1 -0
  164. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.d.ts +16 -0
  165. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.d.ts.map +1 -0
  166. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.js +478 -0
  167. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.js.map +1 -0
  168. package/node_modules/@cchistory/source-adapters/package.json +1 -1
  169. package/package.json +5 -5
  170. package/schemas/cchistory-lite-agent-v1.schema.json +3 -1
  171. package/schemas/cchistory-lite-envelope-v1.schema.json +33 -0
  172. package/schemas/cchistory-lite-inventory-v1.schema.json +94 -0
  173. package/schemas/cchistory-lite-merged-projects-v1.schema.json +44 -0
  174. package/schemas/cchistory-lite-v2.schema.json +22 -1
  175. package/skills/using-cchistory-lite/SKILL.md +17 -0
@@ -0,0 +1,288 @@
1
+ /**
2
+ * Role: CLI handlers for Slice B — formatting opt-in `ls projects --with-git` lines
3
+ * and executing `merge-projects <file1.json> <file2.json> [...]` pure multi-host
4
+ * project reconciliation over exported JSON snapshots.
5
+ * Excludes local Git execution (source-adapters) and merge semantics (canonical).
6
+ */
7
+ import { readFile } from "node:fs/promises";
8
+ import os from "node:os";
9
+ import path from "node:path";
10
+ import { formatRelativeTime, } from "@cchistory/domain";
11
+ import { buildMergedProjectsEnvelope, mergeHostProjectSnapshots, } from "@cchistory/live-runtime";
12
+ export function formatProjectGitLine(git) {
13
+ if (!git)
14
+ return undefined;
15
+ if (git.status === "missing_path")
16
+ return "git: local path missing";
17
+ if (git.status === "not_git")
18
+ return "git: not a git repository";
19
+ if (git.status === "timeout")
20
+ return "git: inspection timed out";
21
+ if (git.status === "error")
22
+ return `git: error (${git.error ?? "unknown"})`;
23
+ const branchLabel = git.branch ? (git.detached ? `${git.branch} (detached)` : git.branch) : "unborn";
24
+ const shaShort = git.head_sha ? git.head_sha.slice(0, 7) : "-";
25
+ const dirtyPart = git.dirty_files === null
26
+ ? "dirty ?"
27
+ : git.dirty_files === 0
28
+ ? "clean"
29
+ : `${git.dirty_files} dirty`;
30
+ const parts = [`${branchLabel} @ ${shaShort}`, dirtyPart];
31
+ if (git.ahead !== null || git.behind !== null) {
32
+ parts.push(`↑${git.ahead ?? 0}/↓${git.behind ?? 0}`);
33
+ }
34
+ else if (!git.upstream && git.branch && !git.detached) {
35
+ parts.push("no upstream");
36
+ }
37
+ if (git.repo_remote) {
38
+ parts.push(git.repo_remote);
39
+ }
40
+ return `git: ${parts.join(" · ")}`;
41
+ }
42
+ export async function runMergeProjectsCommand(parsed, io, jsonMode, deps) {
43
+ if (parsed.positionals.length === 0) {
44
+ throw new deps.UsageError("merge-projects requires at least one project snapshot JSON file (for example: cchistory-lite merge-projects host-a.json host-b.json --json).");
45
+ }
46
+ const nowMs = io.now?.() ?? Date.now();
47
+ const useEnvelope = parsed.booleans.has("envelope");
48
+ const hostIdEntries = parsed.values.get("host-id") ?? [];
49
+ if (hostIdEntries.length > 1) {
50
+ throw new deps.UsageError("--host-id may only be specified once.");
51
+ }
52
+ const envelopeHostId = hostIdEntries.at(-1) ?? io.hostname ?? os.hostname();
53
+ const snapshots = [];
54
+ const seenHosts = new Map();
55
+ for (const rawFilePath of parsed.positionals) {
56
+ const resolvedPath = path.resolve(io.cwd, rawFilePath);
57
+ let rawText;
58
+ try {
59
+ rawText = await readFile(resolvedPath, "utf8");
60
+ }
61
+ catch (error) {
62
+ throw new deps.UsageError(`Could not read snapshot file ${rawFilePath}: ${error instanceof Error ? error.message : String(error)}`);
63
+ }
64
+ let parsedJson;
65
+ try {
66
+ parsedJson = JSON.parse(rawText);
67
+ }
68
+ catch (error) {
69
+ throw new deps.UsageError(`Invalid JSON in ${rawFilePath}: ${error instanceof Error ? error.message : String(error)}`);
70
+ }
71
+ const snapshot = parseHostProjectSnapshot(parsedJson, resolvedPath, deps.UsageError);
72
+ const hostKey = snapshot.host_id.trim().toLowerCase();
73
+ const existingFile = seenHosts.get(hostKey);
74
+ if (existingFile) {
75
+ throw new deps.UsageError(`Duplicate host_id ${JSON.stringify(snapshot.host_id)} in ${rawFilePath} and ${existingFile}. ` +
76
+ `Re-export each host snapshot with a distinct --host-id <name> (for example: cchistory-lite ls projects --no-dir --all --with-git --host-id <name> --json).`);
77
+ }
78
+ seenHosts.set(hostKey, rawFilePath);
79
+ snapshots.push(snapshot);
80
+ }
81
+ const report = mergeHostProjectSnapshots(snapshots, {
82
+ nowIso: new Date(nowMs).toISOString(),
83
+ });
84
+ if (useEnvelope) {
85
+ const envelope = buildMergedProjectsEnvelope(report, { hostId: envelopeHostId });
86
+ io.stdout(`${JSON.stringify(envelope, null, 2)}\n`);
87
+ return;
88
+ }
89
+ if (jsonMode !== "none") {
90
+ io.stdout(`${JSON.stringify(report, null, 2)}\n`);
91
+ return;
92
+ }
93
+ io.stdout(renderMergedProjectsReport(report, nowMs));
94
+ }
95
+ export function parseHostProjectSnapshot(raw, filePath, UsageError) {
96
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
97
+ throw new UsageError(`Snapshot ${filePath} must be a JSON object.`);
98
+ }
99
+ const obj = raw;
100
+ const fallbackHostId = path.basename(filePath, path.extname(filePath)) || "host";
101
+ // 1. ReadOnlyEnvelopeV1 (`schema_version: 1, domain: "projects", items: [...]`)
102
+ if (obj.schema_version === 1 && obj.domain === "projects" && Array.isArray(obj.items)) {
103
+ const explicitHost = asNonEmptyString(obj.host_id);
104
+ const summaryObj = obj.summary && typeof obj.summary === "object" && !Array.isArray(obj.summary)
105
+ ? obj.summary
106
+ : undefined;
107
+ const totalProjects = typeof summaryObj?.total_project_count === "number" ? summaryObj.total_project_count : null;
108
+ const truncated = summaryObj?.truncated === true || (totalProjects !== null && totalProjects > obj.items.length);
109
+ return {
110
+ host_id: explicitHost ?? fallbackHostId,
111
+ ...(explicitHost ? {} : { host_id_inferred_from_filename: true }),
112
+ generated_at: asNonEmptyString(obj.generated_at) ?? null,
113
+ source_file: filePath,
114
+ ...(totalProjects !== null ? { total_projects: totalProjects } : {}),
115
+ ...(truncated ? { truncated: true } : {}),
116
+ projects: obj.items.map((item, idx) => normalizeProjectEntry(item, filePath, idx, UsageError)),
117
+ };
118
+ }
119
+ // 2. Standard `ls projects --json` (`cchistory-lite/v2`), canonical JSON, or raw `{ host_id, projects }`
120
+ if (Array.isArray(obj.projects)) {
121
+ const projects = obj.projects.map((item, idx) => normalizeProjectEntry(item, filePath, idx, UsageError));
122
+ const explicitHost = asNonEmptyString(obj.host_id);
123
+ const inferredHost = explicitHost ?? inferHostIdFromRawProjects(obj.projects);
124
+ const totalProjects = typeof obj.total === "number" ? obj.total : null;
125
+ const truncated = totalProjects !== null && totalProjects > projects.length;
126
+ return {
127
+ host_id: inferredHost ?? fallbackHostId,
128
+ ...(inferredHost ? {} : { host_id_inferred_from_filename: true }),
129
+ generated_at: asNonEmptyString(obj.generated_at) ??
130
+ asNonEmptyString(obj.read?.prepared_at) ??
131
+ null,
132
+ source_file: filePath,
133
+ ...(totalProjects !== null ? { total_projects: totalProjects } : {}),
134
+ ...(truncated ? { truncated: true } : {}),
135
+ projects,
136
+ };
137
+ }
138
+ throw new UsageError(`Snapshot ${filePath} does not look like a projects list (expected a top-level "projects" array or a v1 "projects" envelope).`);
139
+ }
140
+ function normalizeProjectEntry(raw, filePath, index, UsageError) {
141
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
142
+ throw new UsageError(`Snapshot ${filePath} project entry #${index} must be an object.`);
143
+ }
144
+ const rec = raw;
145
+ const displayName = asNonEmptyString(rec.display_name) ??
146
+ asNonEmptyString(rec.repo_remote) ??
147
+ asNonEmptyString(rec.primary_workspace_path) ??
148
+ asNonEmptyString(rec.repo_root) ??
149
+ `project-${index}`;
150
+ const committedTurns = typeof rec.committed_turn_count === "number" ? rec.committed_turn_count : 0;
151
+ const candidateTurns = typeof rec.candidate_turn_count === "number" ? rec.candidate_turn_count : 0;
152
+ const turnCount = typeof rec.turn_count === "number" ? rec.turn_count : committedTurns + candidateTurns;
153
+ const gitRaw = rec.git && typeof rec.git === "object" && !Array.isArray(rec.git)
154
+ ? rec.git
155
+ : null;
156
+ return {
157
+ project_id: asNonEmptyString(rec.project_id),
158
+ display_name: displayName,
159
+ slug: asNonEmptyString(rec.slug),
160
+ primary_workspace_path: asNonEmptyString(rec.primary_workspace_path) ?? null,
161
+ repo_root: asNonEmptyString(rec.repo_root) ?? null,
162
+ repo_remote: asNonEmptyString(rec.repo_remote) ?? null,
163
+ source_platforms: Array.isArray(rec.source_platforms)
164
+ ? rec.source_platforms.filter((item) => typeof item === "string")
165
+ : [],
166
+ session_count: typeof rec.session_count === "number" ? rec.session_count : 0,
167
+ turn_count: turnCount,
168
+ last_activity_at: asNonEmptyString(rec.last_activity_at) ??
169
+ asNonEmptyString(rec.project_last_activity_at) ??
170
+ null,
171
+ git: gitRaw,
172
+ };
173
+ }
174
+ function inferHostIdFromRawProjects(rawProjects) {
175
+ for (const item of rawProjects) {
176
+ if (!item || typeof item !== "object" || Array.isArray(item))
177
+ continue;
178
+ const rec = item;
179
+ if (Array.isArray(rec.host_ids)) {
180
+ const first = rec.host_ids.find((v) => typeof v === "string" && v.trim().length > 0);
181
+ if (first)
182
+ return first.trim();
183
+ }
184
+ }
185
+ return undefined;
186
+ }
187
+ export function renderMergedProjectsReport(report, nowMs = Date.now()) {
188
+ const { summary } = report;
189
+ const allWithoutGit = report.projects.length > 0 && report.projects.every((project) => project.sync_state === "git_not_collected");
190
+ const gitSummaryTail = allWithoutGit
191
+ ? " · git: unavailable (re-export with --with-git)"
192
+ : ` · ${summary.diverged_project_count} diverged` +
193
+ ` · ${summary.dirty_project_count} dirty` +
194
+ ` · ${summary.unpushed_project_count} unpushed` +
195
+ ` · ${summary.behind_project_count} behind`;
196
+ const lines = [
197
+ `Merged Projects · ${summary.project_count} projects across ${summary.host_count} hosts` +
198
+ ` · ${summary.multi_host_project_count} multi-host` +
199
+ gitSummaryTail,
200
+ `Hosts: ${report.hosts.join(", ") || "-"}`,
201
+ ];
202
+ if (report.warnings && report.warnings.length > 0) {
203
+ lines.push("", `Warnings (${report.warnings.length})`);
204
+ for (const warning of report.warnings) {
205
+ lines.push(` [warning] ${warning}`);
206
+ }
207
+ }
208
+ lines.push("");
209
+ if (report.projects.length === 0) {
210
+ lines.push(" (no projects in input snapshots)");
211
+ return `${lines.join("\n")}\n`;
212
+ }
213
+ for (const project of report.projects) {
214
+ const matchTag = project.repo_remote ? project.repo_remote : "directory_fallback";
215
+ lines.push(`● ${project.display_name} [${project.sync_state}] · ${matchTag}`);
216
+ const alerts = [];
217
+ const latestHosts = project.latest_commit_hosts?.length
218
+ ? project.latest_commit_hosts
219
+ : project.latest_commit_host
220
+ ? [project.latest_commit_host]
221
+ : [];
222
+ if (latestHosts.length > 0) {
223
+ const commitRel = project.latest_commit_at ? ` (${formatRelativeTime(project.latest_commit_at, nowMs)})` : "";
224
+ const sharedSha = !project.commit_diverged ? project.hosts.find((h) => h.head_sha)?.head_sha?.slice(0, 7) : undefined;
225
+ if (latestHosts.length > 1 && sharedSha) {
226
+ alerts.push(`aligned @ ${sharedSha}${commitRel}`);
227
+ }
228
+ else {
229
+ alerts.push(`latest commit: ${latestHosts.join(", ")}${commitRel}`);
230
+ }
231
+ }
232
+ if (project.branch_diverged)
233
+ alerts.push("branch diverged");
234
+ else if (project.commit_diverged)
235
+ alerts.push("commit diverged");
236
+ if (project.dirty_hosts.length > 0)
237
+ alerts.push(`dirty: ${project.dirty_hosts.join(",")}`);
238
+ if (project.unpushed_hosts.length > 0)
239
+ alerts.push(`unpushed: ${project.unpushed_hosts.join(",")}`);
240
+ if (project.behind_hosts.length > 0)
241
+ alerts.push(`behind: ${project.behind_hosts.join(",")}`);
242
+ if (project.no_upstream_hosts && project.no_upstream_hosts.length > 0) {
243
+ alerts.push(`no upstream: ${project.no_upstream_hosts.join(",")}`);
244
+ }
245
+ if (alerts.length > 0) {
246
+ lines.push(` ${alerts.join(" · ")}`);
247
+ }
248
+ for (const host of project.hosts) {
249
+ const gitParts = [];
250
+ if (host.git_status === "ok") {
251
+ gitParts.push(`${host.branch ?? "unborn"}@${host.head_sha ? host.head_sha.slice(0, 7) : "-"}`);
252
+ gitParts.push(host.dirty_files && host.dirty_files > 0 ? `dirty:${host.dirty_files}` : "clean");
253
+ if (host.ahead !== null || host.behind !== null) {
254
+ gitParts.push(`↑${host.ahead ?? 0}/↓${host.behind ?? 0}`);
255
+ }
256
+ else if (!host.upstream && host.branch && !host.detached) {
257
+ gitParts.push("no upstream");
258
+ }
259
+ }
260
+ else {
261
+ gitParts.push(`git:${host.git_status}`);
262
+ }
263
+ const commitPart = host.git_status === "ok" && host.head_committed_at
264
+ ? `commit ${formatRelativeTime(host.head_committed_at, nowMs)}`
265
+ : null;
266
+ const activityPart = host.last_activity_at
267
+ ? `active ${formatRelativeTime(host.last_activity_at, nowMs)}`
268
+ : "no activity";
269
+ const pathPart = project.match_kind === "directory_fallback"
270
+ ? host.workspace_path ?? host.repo_root ?? "(path unknown)"
271
+ : null;
272
+ const tail = [
273
+ commitPart,
274
+ activityPart,
275
+ `${host.session_count} sessions / ${host.turn_count} turns`,
276
+ pathPart,
277
+ ]
278
+ .filter(Boolean)
279
+ .join(" · ");
280
+ lines.push(` ${host.host_id}: ${gitParts.join(" ")} · ${tail}`);
281
+ }
282
+ }
283
+ return `${lines.join("\n")}\n`;
284
+ }
285
+ function asNonEmptyString(value) {
286
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
287
+ }
288
+ //# sourceMappingURL=project-git-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-git-command.js","sourceRoot":"","sources":["../src/project-git-command.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,kBAAkB,GAKnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AAqBjC,MAAM,UAAU,oBAAoB,CAAC,GAAmC;IACtE,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,IAAI,GAAG,CAAC,MAAM,KAAK,cAAc;QAAE,OAAO,yBAAyB,CAAC;IACpE,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,2BAA2B,CAAC;IACjE,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,2BAA2B,CAAC;IACjE,IAAI,GAAG,CAAC,MAAM,KAAK,OAAO;QAAE,OAAO,eAAe,GAAG,CAAC,KAAK,IAAI,SAAS,GAAG,CAAC;IAE5E,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACrG,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC/D,MAAM,SAAS,GACb,GAAG,CAAC,WAAW,KAAK,IAAI;QACtB,CAAC,CAAC,SAAS;QACX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,KAAK,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Role: Native human-readable CLI renderer for per-tool pre-launch startup contexts.
3
+ * Renders each supported tool (Claude Code, Codex, Google Antigravity, OpenCode,
4
+ * DeepSeek Harness) using its own native concepts, precedence layers, and budget metrics
5
+ * rather than flattening them into a lowest-common-denominator table.
6
+ * Excludes JSON serialization, filesystem reads, and command argument parsing.
7
+ */
8
+ import type { AgentStartupResolution } from "@cchistory/domain";
9
+ export declare function renderStartupContexts(resolutions: readonly AgentStartupResolution[], explicitAgentFilter: boolean, scopeNote?: string): string[];
10
+ //# sourceMappingURL=startup-render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startup-render.d.ts","sourceRoot":"","sources":["../src/startup-render.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,sBAAsB,EAQvB,MAAM,mBAAmB,CAAC;AAE3B,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,SAAS,sBAAsB,EAAE,EAC9C,mBAAmB,EAAE,OAAO,EAC5B,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,EAAE,CA8CV"}
@@ -0,0 +1,335 @@
1
+ /**
2
+ * Role: Native human-readable CLI renderer for per-tool pre-launch startup contexts.
3
+ * Renders each supported tool (Claude Code, Codex, Google Antigravity, OpenCode,
4
+ * DeepSeek Harness) using its own native concepts, precedence layers, and budget metrics
5
+ * rather than flattening them into a lowest-common-denominator table.
6
+ * Excludes JSON serialization, filesystem reads, and command argument parsing.
7
+ */
8
+ export function renderStartupContexts(resolutions, explicitAgentFilter, scopeNote) {
9
+ if (resolutions.length === 0)
10
+ return [];
11
+ const first = resolutions[0];
12
+ const scopeParts = [];
13
+ if (first.project_dir)
14
+ scopeParts.push(`dir=${first.project_dir}`);
15
+ if (first.git_root)
16
+ scopeParts.push(`git_root=${first.git_root}`);
17
+ if (scopeNote)
18
+ scopeParts.push(scopeNote);
19
+ const headerSuffix = scopeParts.length > 0 ? ` · ${scopeParts.join(" · ")}` : " · global scope";
20
+ const lines = [`Pre-Launch Startup Contexts${headerSuffix}`];
21
+ for (const res of resolutions) {
22
+ if (res.resolution_tier !== "native" || "supported" in res.native) {
23
+ lines.push(`● ${res.display_name} [${res.client}] · tier=${res.resolution_tier}`);
24
+ if ("supported" in res.native && res.native.supported === false) {
25
+ lines.push(` ${res.native.reason}`);
26
+ }
27
+ continue;
28
+ }
29
+ if (!explicitAgentFilter && res.files_read.length === 0 && !hasNonFileStartupSignal(res)) {
30
+ lines.push(`○ ${res.display_name} [${res.client}] · no startup config/context files found`);
31
+ continue;
32
+ }
33
+ const nativeCtx = res.native;
34
+ switch (nativeCtx.client) {
35
+ case "claude_code":
36
+ lines.push(...renderClaudeCode(res, nativeCtx));
37
+ break;
38
+ case "codex":
39
+ lines.push(...renderCodex(res, nativeCtx));
40
+ break;
41
+ case "antigravity":
42
+ lines.push(...renderAntigravity(res, nativeCtx));
43
+ break;
44
+ case "opencode":
45
+ lines.push(...renderOpenCode(res, nativeCtx));
46
+ break;
47
+ case "deepseek_harness":
48
+ lines.push(...renderDeepSeekHarness(res, nativeCtx));
49
+ break;
50
+ }
51
+ lines.push("");
52
+ }
53
+ return lines;
54
+ }
55
+ function renderClaudeCode(res, ctx) {
56
+ const fp = ctx.startup_footprint;
57
+ const lines = [
58
+ `● Claude Code [claude_code] · always-loaded ${formatBytes(fp.always_loaded_bytes)} (~${fp.always_loaded_estimated_tokens} tok) · ${res.files_read.length} files`,
59
+ ];
60
+ const s = ctx.settings_cascade;
61
+ const settingBits = [];
62
+ if (s.effective_model)
63
+ settingBits.push(`model=${s.effective_model}`);
64
+ if (s.permission_mode)
65
+ settingBits.push(`permission_mode=${s.permission_mode}`);
66
+ if (s.permissions) {
67
+ settingBits.push(`perms(allow=${s.permissions.allow_count}, ask=${s.permissions.ask_count}, deny=${s.permissions.deny_count})`);
68
+ }
69
+ if (s.disabled_mcpjson_servers.length > 0) {
70
+ settingBits.push(`disabledMcpjson=[${s.disabled_mcpjson_servers.join(", ")}]`);
71
+ }
72
+ if (settingBits.length > 0 || s.files.length > 0) {
73
+ lines.push(` settings (${s.files.length}): ${settingBits.join(" · ") || s.files.map((f) => f.layer).join(" -> ")}`);
74
+ }
75
+ if (ctx.claude_md_chain.length > 0) {
76
+ lines.push(` CLAUDE.md chain (${ctx.claude_md_chain.length}, ${fp.resolved_import_count} @imports${fp.missing_import_count > 0 ? `, ${fp.missing_import_count} missing` : ""}):`);
77
+ for (const entry of ctx.claude_md_chain) {
78
+ lines.push(` [${entry.layer}] ${entry.path} (${formatBytes(entry.size_bytes)}, ~${entry.estimated_tokens} tok)`);
79
+ for (const imp of entry.imports) {
80
+ const tag = imp.cycle
81
+ ? "[cycle]"
82
+ : !imp.exists
83
+ ? "[missing]"
84
+ : `${formatBytes(imp.size_bytes ?? 0)}`;
85
+ lines.push(` ${" ".repeat(Math.max(0, imp.depth - 1))}↳ @${imp.raw_ref} -> ${imp.resolved_path} (${tag})`);
86
+ }
87
+ }
88
+ }
89
+ if (ctx.rules.length > 0) {
90
+ lines.push(` .claude/rules (${ctx.rules.length}: ${fp.always_rule_count} always, ${fp.path_scoped_rule_count} path-scoped):`);
91
+ for (const rule of ctx.rules) {
92
+ const modeText = rule.mode === "path_scoped" && rule.paths?.length
93
+ ? `paths=[${rule.paths.join(", ")}]`
94
+ : "always";
95
+ lines.push(` [${rule.scope}] ${rule.name} · ${modeText} (${formatBytes(rule.size_bytes)})`);
96
+ }
97
+ }
98
+ appendResolvedMcpLines(lines, ctx.mcp_servers);
99
+ if (ctx.plugins.length > 0) {
100
+ lines.push(` plugins (${ctx.plugins.length}):`);
101
+ for (const p of ctx.plugins) {
102
+ const bundle = [
103
+ p.bundled_skills.length ? `${p.bundled_skills.length} skills` : "",
104
+ p.bundled_commands.length ? `${p.bundled_commands.length} cmds` : "",
105
+ p.bundled_agents.length ? `${p.bundled_agents.length} agents` : "",
106
+ p.bundled_mcp_servers.length ? `${p.bundled_mcp_servers.length} mcp` : "",
107
+ p.bundled_hooks.length ? `${p.bundled_hooks.length} hooks` : "",
108
+ ].filter(Boolean);
109
+ const bundleStr = bundle.length > 0 ? ` · bundle: ${bundle.join(", ")}` : "";
110
+ lines.push(` ${p.name} [${p.enabled ? "enabled" : "disabled"}]${bundleStr}`);
111
+ }
112
+ }
113
+ appendCompactNamedList(lines, "skills", ctx.skills);
114
+ appendCompactNamedList(lines, "commands", ctx.commands);
115
+ appendCompactNamedList(lines, "subagents", ctx.subagents);
116
+ appendHookLines(lines, ctx.hooks);
117
+ return lines;
118
+ }
119
+ function renderCodex(res, ctx) {
120
+ const fp = ctx.startup_footprint;
121
+ const pct = Math.round(fp.budget_used_ratio * 100);
122
+ const lines = [
123
+ `● Codex [codex] · doc budget ${formatBytes(fp.loaded_bytes)} / ${formatBytes(fp.budget_bytes)} (${pct}%, ~${fp.estimated_tokens} tok) · ${res.files_read.length} files`,
124
+ ];
125
+ const c = ctx.config_cascade;
126
+ const bits = [`codex_home=${ctx.codex_home}`];
127
+ if (c.effective_model)
128
+ bits.push(`model=${c.effective_model}`);
129
+ if (c.model_reasoning_effort)
130
+ bits.push(`effort=${c.model_reasoning_effort}`);
131
+ if (c.approval_policy)
132
+ bits.push(`approval=${c.approval_policy}`);
133
+ if (c.sandbox_mode)
134
+ bits.push(`sandbox=${c.sandbox_mode}`);
135
+ if (c.active_profile)
136
+ bits.push(`profile=${c.active_profile}`);
137
+ if (c.profiles.length > 0)
138
+ bits.push(`profiles=[${c.profiles.join(", ")}]`);
139
+ lines.push(` config: ${bits.join(" · ")}`);
140
+ if (c.project_config_path) {
141
+ const gateLabel = c.project_config_trusted
142
+ ? c.project_trust_level && c.project_trust_level !== "trusted"
143
+ ? `trusted (${c.project_trust_level})`
144
+ : "trusted"
145
+ : `TRUST-GATED (trust_level=${c.project_trust_level ?? "unset"}; project .codex/config.toml skipped)`;
146
+ lines.push(` project config: ${c.project_config_path} · ${gateLabel}`);
147
+ }
148
+ if (ctx.instruction_chain.length > 0) {
149
+ lines.push(` instruction chain (${ctx.instruction_chain.length}):`);
150
+ for (const item of ctx.instruction_chain) {
151
+ const extra = item.status === "shadowed"
152
+ ? `shadowed by ${item.shadowed_by ?? "override"}`
153
+ : item.status === "truncated"
154
+ ? `truncated ${formatBytes(item.included_bytes)}/${formatBytes(item.size_bytes)}`
155
+ : item.status === "budget_exhausted"
156
+ ? `budget_exhausted (0/${formatBytes(item.size_bytes)})`
157
+ : `${formatBytes(item.included_bytes)}`;
158
+ lines.push(` [${item.layer}] ${item.kind} · ${item.status} · ${item.path} (${extra})`);
159
+ }
160
+ }
161
+ appendResolvedMcpLines(lines, ctx.mcp_servers);
162
+ if (ctx.agents.length > 0) {
163
+ lines.push(` agents (${ctx.agents.length}): ${ctx.agents.map((a) => `${a.name} [${a.scope}/${a.source}]`).join(", ")}`);
164
+ }
165
+ appendCompactNamedList(lines, "skills", ctx.skills);
166
+ appendHookLines(lines, ctx.hooks);
167
+ return lines;
168
+ }
169
+ function renderAntigravity(res, ctx) {
170
+ const fp = ctx.startup_footprint;
171
+ const lines = [
172
+ `● Google Antigravity [antigravity] · inlined rules ${formatBytes(fp.inlined_rules_bytes)} (~${fp.inlined_rules_estimated_tokens}/${fp.aggregate_rules_budget_tokens} tok budget, ${fp.demoted_rule_count} demoted, ${fp.truncated_rule_count} capped@24,000B) · ${res.files_read.length} files`,
173
+ ];
174
+ if (ctx.discovery_roots.length > 0) {
175
+ lines.push(` roots (${ctx.discovery_roots.length}): ${ctx.discovery_roots.map((r) => `${r.kind}:${r.path}`).join(" · ")}`);
176
+ }
177
+ if (ctx.rules.length > 0) {
178
+ lines.push(` rules (${ctx.rules.length}):`);
179
+ for (const r of ctx.rules) {
180
+ const sizeText = r.truncated_by_file_cap
181
+ ? `truncated ${r.capped_bytes.toLocaleString("en-US")}/${r.size_bytes.toLocaleString("en-US")} B`
182
+ : formatBytes(r.size_bytes);
183
+ const flags = [
184
+ `trigger=${r.trigger}`,
185
+ r.budget_status,
186
+ r.globs?.length ? `globs=[${r.globs.join(", ")}]` : "",
187
+ ].filter(Boolean);
188
+ const origin = r.plugin_name ? `${r.source}:${r.plugin_name}` : r.source;
189
+ lines.push(` [${origin}] ${r.path} · ${flags.join(" · ")} (${sizeText})`);
190
+ for (const inc of r.includes) {
191
+ lines.push(` ↳ @[${inc.label}](${inc.raw_ref}) ${inc.exists ? "ok" : "[missing]"}`);
192
+ }
193
+ }
194
+ }
195
+ if (ctx.plugins.length > 0) {
196
+ lines.push(` plugins (${ctx.plugins.length}):`);
197
+ for (const p of ctx.plugins) {
198
+ const bundle = [
199
+ p.bundled_rules.length ? `${p.bundled_rules.length} rules` : "",
200
+ p.bundled_skills.length ? `${p.bundled_skills.length} skills` : "",
201
+ p.bundled_mcp_servers.length ? `${p.bundled_mcp_servers.length} mcp` : "",
202
+ p.bundled_hooks.length ? `${p.bundled_hooks.length} hooks` : "",
203
+ ].filter(Boolean);
204
+ lines.push(` ${p.display_name} [${p.enabled ? "enabled" : "disabled"} via ${p.enabled_source}]` +
205
+ (bundle.length > 0 ? ` · bundle: ${bundle.join(", ")}` : ""));
206
+ }
207
+ }
208
+ appendCompactNamedList(lines, "skills", ctx.skills);
209
+ if (ctx.workflows.length > 0) {
210
+ lines.push(` workflows (${ctx.workflows.length}): ${ctx.workflows.map((w) => `${w.name} [${w.scope}]`).join(", ")}`);
211
+ }
212
+ appendResolvedMcpLines(lines, ctx.mcp_servers);
213
+ appendHookLines(lines, ctx.hooks);
214
+ return lines;
215
+ }
216
+ function renderOpenCode(res, ctx) {
217
+ const fp = ctx.startup_footprint;
218
+ const lines = [
219
+ `● OpenCode [opencode] · instructions ${formatBytes(fp.instruction_bytes)} (~${fp.instruction_estimated_tokens} tok, ${fp.instruction_file_count} files) · ${res.files_read.length} files`,
220
+ ];
221
+ const c = ctx.config_cascade;
222
+ const bits = [];
223
+ if (c.effective_model)
224
+ bits.push(`model=${c.effective_model}`);
225
+ if (c.small_model)
226
+ bits.push(`small_model=${c.small_model}`);
227
+ if (c.default_agent)
228
+ bits.push(`default_agent=${c.default_agent}`);
229
+ if (c.provider_names.length > 0)
230
+ bits.push(`providers=[${c.provider_names.join(", ")}]`);
231
+ bits.push(`claude_md_fallback=${c.claude_md_fallback_disabled ? "disabled" : "enabled"}`);
232
+ lines.push(` config (${c.files.length}): ${bits.join(" · ")}`);
233
+ if (ctx.instructions.length > 0) {
234
+ lines.push(` instructions (${ctx.instructions.length}):`);
235
+ for (const inst of ctx.instructions) {
236
+ const sizeLabel = inst.exists === false ? "[missing]" : `${formatBytes(inst.size_bytes)}, ~${inst.estimated_tokens} tok`;
237
+ lines.push(` [${inst.source}] ${inst.path} (${sizeLabel})`);
238
+ }
239
+ }
240
+ appendResolvedMcpLines(lines, ctx.mcp_servers);
241
+ appendCompactNamedList(lines, "agents", ctx.agents);
242
+ appendCompactNamedList(lines, "skills", ctx.skills);
243
+ if (ctx.commands.length > 0) {
244
+ lines.push(` commands (${ctx.commands.length}): ${ctx.commands.map((cmd) => `${cmd.name} [${cmd.scope}]`).join(", ")}`);
245
+ }
246
+ if (ctx.plugins.length > 0) {
247
+ lines.push(` plugins (${ctx.plugins.length}): ${ctx.plugins.map((p) => `${p.name} [${p.scope}/${p.source}]`).join(", ")}`);
248
+ }
249
+ return lines;
250
+ }
251
+ function renderDeepSeekHarness(res, ctx) {
252
+ const fp = ctx.startup_footprint;
253
+ const lines = [
254
+ `● DeepSeek Harness [deepseek_harness] · dsh_home=${ctx.dsh_home} · instructions ${formatBytes(fp.instruction_bytes)} (~${fp.instruction_estimated_tokens} tok) · ${res.files_read.length} files`,
255
+ ];
256
+ if (ctx.credentials_file_present) {
257
+ lines.push(` credentials: .credentials.yaml present (never read)`);
258
+ }
259
+ if (ctx.profiles.length > 0) {
260
+ lines.push(` profiles (${ctx.profiles.length}): ${ctx.profiles.map((p) => `${p.name} (${p.files.join(", ") || "empty"})`).join(" · ")}`);
261
+ }
262
+ if (ctx.cordis_layers.length > 0) {
263
+ lines.push(` cordis layers (${ctx.cordis_layers.length}):`);
264
+ for (const layer of ctx.cordis_layers) {
265
+ const label = layer.profile_name ? `${layer.layer}:${layer.profile_name}` : layer.layer;
266
+ lines.push(` [${label}] ${layer.path} (${formatBytes(layer.size_bytes)})`);
267
+ }
268
+ }
269
+ if (ctx.instructions.length > 0) {
270
+ lines.push(` instructions (${ctx.instructions.length}):`);
271
+ for (const inst of ctx.instructions) {
272
+ lines.push(` [${inst.layer}] ${inst.path} (${formatBytes(inst.size_bytes)}, ~${inst.estimated_tokens} tok)`);
273
+ }
274
+ }
275
+ appendResolvedMcpLines(lines, ctx.mcp_servers);
276
+ appendCompactNamedList(lines, "skills", ctx.skills);
277
+ if (ctx.subagents.length > 0) {
278
+ lines.push(` subagents (${ctx.subagents.length}): ${ctx.subagents.map((a) => `${a.name} [${a.scope}]`).join(", ")}`);
279
+ }
280
+ if (ctx.plugins.length > 0) {
281
+ lines.push(` plugins (${ctx.plugins.length}): ${ctx.plugins.map((p) => `${p.name} [${p.scope}]`).join(", ")}`);
282
+ }
283
+ return lines;
284
+ }
285
+ function appendResolvedMcpLines(lines, servers) {
286
+ if (servers.length === 0)
287
+ return;
288
+ lines.push(` MCP servers (${servers.length}):`);
289
+ for (const s of servers) {
290
+ const tags = [s.status, s.precedence_layer, s.transport];
291
+ if (s.from_plugin)
292
+ tags.push(`plugin=${s.from_plugin}`);
293
+ if (s.disabled_reason)
294
+ tags.push(s.disabled_reason);
295
+ if (s.shadowed_by)
296
+ tags.push(`shadowed_by=${s.shadowed_by}`);
297
+ const target = s.url ?? s.command ?? "-";
298
+ lines.push(` ${s.server_id} [${tags.join(" · ")}] -> ${target}`);
299
+ }
300
+ }
301
+ function appendCompactNamedList(lines, label, items) {
302
+ if (items.length === 0)
303
+ return;
304
+ const formatted = items.map((item) => {
305
+ const loc = item.scope ?? item.source ?? "";
306
+ const tag = item.status === "shadowed" ? `${loc}/shadowed` : loc;
307
+ return tag ? `${item.name} [${tag}]` : item.name;
308
+ });
309
+ lines.push(` ${label} (${items.length}): ${formatted.join(", ")}`);
310
+ }
311
+ function appendHookLines(lines, hooks) {
312
+ if (hooks.length === 0)
313
+ return;
314
+ lines.push(` hooks (${hooks.length}):`);
315
+ for (const h of hooks) {
316
+ const head = h.name ? `${h.name}:${h.event}` : h.event;
317
+ const matcher = h.matcher ? ` matcher=${h.matcher}` : "";
318
+ const state = h.enabled ? "" : " [disabled]";
319
+ const cmd = h.command ? ` -> ${h.command}` : "";
320
+ lines.push(` ${head}${matcher}${state}${cmd}`);
321
+ }
322
+ }
323
+ function hasNonFileStartupSignal(res) {
324
+ if (!("supported" in res.native) && res.native.client === "deepseek_harness") {
325
+ return res.native.credentials_file_present || res.native.profiles.length > 0;
326
+ }
327
+ return false;
328
+ }
329
+ function formatBytes(bytes) {
330
+ if (bytes < 1024)
331
+ return `${bytes} B`;
332
+ const kb = bytes / 1024;
333
+ return `${kb >= 10 ? kb.toFixed(0) : kb.toFixed(1)} KiB`;
334
+ }
335
+ //# sourceMappingURL=startup-render.js.map