@meetless/mla 0.1.4

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 (202) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +81 -0
  3. package/dist/build-info.json +9 -0
  4. package/dist/bundles/ask-core.js +396 -0
  5. package/dist/bundles/mcp.js +16592 -0
  6. package/dist/bundles/trace-core.js +263 -0
  7. package/dist/cli.js +828 -0
  8. package/dist/commands/activate.js +781 -0
  9. package/dist/commands/adoption.js +130 -0
  10. package/dist/commands/ask.js +290 -0
  11. package/dist/commands/context.js +114 -0
  12. package/dist/commands/debug.js +313 -0
  13. package/dist/commands/doctor.js +1021 -0
  14. package/dist/commands/enrich.js +427 -0
  15. package/dist/commands/evidence.js +229 -0
  16. package/dist/commands/flush.js +184 -0
  17. package/dist/commands/graph.js +104 -0
  18. package/dist/commands/init.js +272 -0
  19. package/dist/commands/internal-active-review.js +322 -0
  20. package/dist/commands/internal-auto-index.js +188 -0
  21. package/dist/commands/internal-capture-decisions.js +320 -0
  22. package/dist/commands/internal-evidence-correlate.js +239 -0
  23. package/dist/commands/internal-evidence-hooks.js +240 -0
  24. package/dist/commands/internal-evidence-inject.js +231 -0
  25. package/dist/commands/internal-finalize.js +221 -0
  26. package/dist/commands/internal-pretool-observe.js +225 -0
  27. package/dist/commands/internal-refresh.js +136 -0
  28. package/dist/commands/internal-session-nudge.js +120 -0
  29. package/dist/commands/internal-steer-sync.js +117 -0
  30. package/dist/commands/internal-turn-recap.js +140 -0
  31. package/dist/commands/kb.js +375 -0
  32. package/dist/commands/kb_add.js +681 -0
  33. package/dist/commands/kb_forget.js +283 -0
  34. package/dist/commands/kb_move.js +45 -0
  35. package/dist/commands/kb_pending.js +410 -0
  36. package/dist/commands/kb_personal.js +149 -0
  37. package/dist/commands/kb_promote.js +188 -0
  38. package/dist/commands/kb_purge.js +168 -0
  39. package/dist/commands/kb_reingest.js +335 -0
  40. package/dist/commands/kb_retime.js +170 -0
  41. package/dist/commands/kb_review.js +391 -0
  42. package/dist/commands/kb_revision.js +179 -0
  43. package/dist/commands/kb_show.js +385 -0
  44. package/dist/commands/label.js +226 -0
  45. package/dist/commands/login.js +295 -0
  46. package/dist/commands/logout.js +108 -0
  47. package/dist/commands/mcp-supervisor.js +93 -0
  48. package/dist/commands/mcp.js +227 -0
  49. package/dist/commands/queue-prune.js +98 -0
  50. package/dist/commands/review.js +358 -0
  51. package/dist/commands/rewire.js +124 -0
  52. package/dist/commands/rules.js +728 -0
  53. package/dist/commands/scan-context.js +67 -0
  54. package/dist/commands/session.js +347 -0
  55. package/dist/commands/stats.js +479 -0
  56. package/dist/commands/status.js +61 -0
  57. package/dist/commands/summary.js +250 -0
  58. package/dist/commands/turn.js +114 -0
  59. package/dist/commands/uninstall.js +222 -0
  60. package/dist/commands/whoami.js +102 -0
  61. package/dist/commands/workspace.js +130 -0
  62. package/dist/hooks-template/ce0-post-tool-use.sh +34 -0
  63. package/dist/hooks-template/ce0-session-start.sh +49 -0
  64. package/dist/hooks-template/ce0-stop.sh +29 -0
  65. package/dist/hooks-template/ce0-user-prompt-submit.sh +38 -0
  66. package/dist/hooks-template/common.sh +934 -0
  67. package/dist/hooks-template/event-batch-filter.jq +67 -0
  68. package/dist/hooks-template/flush.sh +503 -0
  69. package/dist/hooks-template/post-tool-use.sh +423 -0
  70. package/dist/hooks-template/pre-tool-use.sh +69 -0
  71. package/dist/hooks-template/session-start.sh +140 -0
  72. package/dist/hooks-template/stop.sh +308 -0
  73. package/dist/hooks-template/user-prompt-submit.sh +1162 -0
  74. package/dist/lib/activation.js +79 -0
  75. package/dist/lib/active-conflict-cache.js +141 -0
  76. package/dist/lib/active-memory.js +59 -0
  77. package/dist/lib/active-review-runner.js +26 -0
  78. package/dist/lib/agent-decision/index.js +25 -0
  79. package/dist/lib/agent-decision/keys.js +49 -0
  80. package/dist/lib/agent-decision/normalize-claude.js +183 -0
  81. package/dist/lib/agent-decision/types.js +21 -0
  82. package/dist/lib/agent-decision/validate.js +216 -0
  83. package/dist/lib/analytics/capture.js +96 -0
  84. package/dist/lib/analytics/command-event.js +267 -0
  85. package/dist/lib/analytics/consent.js +58 -0
  86. package/dist/lib/analytics/coverage-gap.js +96 -0
  87. package/dist/lib/analytics/envelope.js +236 -0
  88. package/dist/lib/analytics/event-id.js +86 -0
  89. package/dist/lib/analytics/evidence.js +150 -0
  90. package/dist/lib/analytics/followthrough.js +194 -0
  91. package/dist/lib/analytics/forwarder.js +109 -0
  92. package/dist/lib/analytics/logs.js +78 -0
  93. package/dist/lib/analytics/metrics.js +78 -0
  94. package/dist/lib/analytics/recorder.js +92 -0
  95. package/dist/lib/analytics/review-analytics.js +75 -0
  96. package/dist/lib/analytics/sequence.js +77 -0
  97. package/dist/lib/analytics/store.js +131 -0
  98. package/dist/lib/analytics/turn-recap.js +279 -0
  99. package/dist/lib/artifact_id.js +108 -0
  100. package/dist/lib/auth-breaker.js +161 -0
  101. package/dist/lib/auto-index.js +112 -0
  102. package/dist/lib/classifier.js +88 -0
  103. package/dist/lib/config.js +298 -0
  104. package/dist/lib/conflict-advisory.js +64 -0
  105. package/dist/lib/debug-bundle.js +520 -0
  106. package/dist/lib/enrichment/ingest.js +301 -0
  107. package/dist/lib/enrichment/plan.js +253 -0
  108. package/dist/lib/enrichment/protocol.js +359 -0
  109. package/dist/lib/enrichment/scout-brief.js +176 -0
  110. package/dist/lib/failure-telemetry.js +444 -0
  111. package/dist/lib/git.js +200 -0
  112. package/dist/lib/governance-cache.js +77 -0
  113. package/dist/lib/governed-path-cache.js +76 -0
  114. package/dist/lib/http.js +677 -0
  115. package/dist/lib/identity-envelope.js +23 -0
  116. package/dist/lib/kb-candidate.js +65 -0
  117. package/dist/lib/kb_acl.js +98 -0
  118. package/dist/lib/login.js +353 -0
  119. package/dist/lib/mcp-fetchers.js +130 -0
  120. package/dist/lib/mcp-restart.js +47 -0
  121. package/dist/lib/observability.js +805 -0
  122. package/dist/lib/open-url.js +33 -0
  123. package/dist/lib/orphan-guard.js +70 -0
  124. package/dist/lib/packaged.js +21 -0
  125. package/dist/lib/reconcile-sessions.js +171 -0
  126. package/dist/lib/redactor.js +89 -0
  127. package/dist/lib/relationship-candidate-query.js +27 -0
  128. package/dist/lib/render.js +611 -0
  129. package/dist/lib/rules/applicability.js +64 -0
  130. package/dist/lib/rules/attest-code-rule-version.js +47 -0
  131. package/dist/lib/rules/attest-notes-location.js +217 -0
  132. package/dist/lib/rules/attest-rule-version.js +69 -0
  133. package/dist/lib/rules/canonical-json.js +97 -0
  134. package/dist/lib/rules/ce0-emit.js +64 -0
  135. package/dist/lib/rules/ce0-evidence.js +281 -0
  136. package/dist/lib/rules/ce0-recall-sample.js +82 -0
  137. package/dist/lib/rules/ce0-rule.js +55 -0
  138. package/dist/lib/rules/ce0-sampling-bucket.js +15 -0
  139. package/dist/lib/rules/ce0-store.js +683 -0
  140. package/dist/lib/rules/ce0-telemetry-project.js +93 -0
  141. package/dist/lib/rules/ce0-telemetry.js +158 -0
  142. package/dist/lib/rules/code-rule-registry.js +17 -0
  143. package/dist/lib/rules/command-match.js +185 -0
  144. package/dist/lib/rules/consult-evidence-binding.js +27 -0
  145. package/dist/lib/rules/consultation-capture-adapter.js +193 -0
  146. package/dist/lib/rules/content-match.js +56 -0
  147. package/dist/lib/rules/deny-admission.js +99 -0
  148. package/dist/lib/rules/durable-observation.js +190 -0
  149. package/dist/lib/rules/enforce-notes-version.js +421 -0
  150. package/dist/lib/rules/evaluation-input-hash.js +126 -0
  151. package/dist/lib/rules/evaluator.js +108 -0
  152. package/dist/lib/rules/inert-rule-families.js +51 -0
  153. package/dist/lib/rules/input-authority-resolver.js +241 -0
  154. package/dist/lib/rules/interception-schema.js +170 -0
  155. package/dist/lib/rules/interception-store.js +267 -0
  156. package/dist/lib/rules/live-input-authority.js +66 -0
  157. package/dist/lib/rules/local-matcher.js +108 -0
  158. package/dist/lib/rules/local-observe.js +79 -0
  159. package/dist/lib/rules/local-rule-version-repo.js +214 -0
  160. package/dist/lib/rules/memory-requirement.js +109 -0
  161. package/dist/lib/rules/notes-observe.js +39 -0
  162. package/dist/lib/rules/notes-path.js +261 -0
  163. package/dist/lib/rules/notes-rule.js +75 -0
  164. package/dist/lib/rules/observe-adapter.js +114 -0
  165. package/dist/lib/rules/observed-rule-hash.js +119 -0
  166. package/dist/lib/rules/prompt-submit-adapter.js +132 -0
  167. package/dist/lib/rules/requirement-subject.js +240 -0
  168. package/dist/lib/rules/rule-activity.js +67 -0
  169. package/dist/lib/rules/rule-version-hash.js +151 -0
  170. package/dist/lib/rules/runtime-scope.js +55 -0
  171. package/dist/lib/rules/stop-adapter.js +116 -0
  172. package/dist/lib/rules/stop-response-snapshot.js +174 -0
  173. package/dist/lib/rules/types.js +10 -0
  174. package/dist/lib/rules/ulid.js +46 -0
  175. package/dist/lib/rules/version-evaluation.js +156 -0
  176. package/dist/lib/scanner/agent-memory.js +99 -0
  177. package/dist/lib/scanner/bootstrap-summary.js +87 -0
  178. package/dist/lib/scanner/cache.js +59 -0
  179. package/dist/lib/scanner/frontmatter.js +42 -0
  180. package/dist/lib/scanner/parse-directives.js +69 -0
  181. package/dist/lib/scanner/parse-structured.js +72 -0
  182. package/dist/lib/scanner/render.js +73 -0
  183. package/dist/lib/scanner/scan.js +132 -0
  184. package/dist/lib/scanner/score.js +38 -0
  185. package/dist/lib/scanner/scout-mission.js +126 -0
  186. package/dist/lib/scanner/types.js +7 -0
  187. package/dist/lib/session-scope.js +195 -0
  188. package/dist/lib/spool.js +355 -0
  189. package/dist/lib/staleness.js +100 -0
  190. package/dist/lib/steer-cache.js +87 -0
  191. package/dist/lib/tagged-reference.js +20 -0
  192. package/dist/lib/temporal.js +109 -0
  193. package/dist/lib/turn-recap-emit.js +67 -0
  194. package/dist/lib/unwire.js +253 -0
  195. package/dist/lib/update-check.js +469 -0
  196. package/dist/lib/update-notifier.js +217 -0
  197. package/dist/lib/upgrade-apply.js +643 -0
  198. package/dist/lib/wire.js +1087 -0
  199. package/dist/lib/workspace.js +96 -0
  200. package/dist/lib/zip.js +154 -0
  201. package/dist/pretool-entry.js +37 -0
  202. package/package.json +75 -0
@@ -0,0 +1,313 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.parseArgs = parseArgs;
37
+ exports.runDebug = runDebug;
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const readline = __importStar(require("readline"));
41
+ const config_1 = require("../lib/config");
42
+ const observability_1 = require("../lib/observability");
43
+ const workspace_1 = require("../lib/workspace");
44
+ const http_1 = require("../lib/http");
45
+ const debug_bundle_1 = require("../lib/debug-bundle");
46
+ const KNOWN_FLAGS = new Set([
47
+ "--trace-id",
48
+ "--out",
49
+ "--include-prompts",
50
+ "--include-diffs",
51
+ "--yes",
52
+ "-y",
53
+ "--no-backend",
54
+ "--command",
55
+ "--run-id",
56
+ "--session-id",
57
+ "--quiet",
58
+ "-q",
59
+ ]);
60
+ const FLAGS_WITH_VALUES = new Set([
61
+ "--trace-id",
62
+ "--out",
63
+ "--command",
64
+ "--run-id",
65
+ "--session-id",
66
+ ]);
67
+ // A value-bearing flag must be followed by a real value, never the next flag,
68
+ // or an operator's "drop the value" typo silently changes intent.
69
+ function takeValue(argv, i, flag) {
70
+ const v = argv[i + 1];
71
+ if (v === undefined) {
72
+ throw new Error(`Missing value for ${flag}`);
73
+ }
74
+ if (v.startsWith("-")) {
75
+ throw new Error(`Missing value for ${flag} (got the next flag ${v} instead)`);
76
+ }
77
+ return v;
78
+ }
79
+ function parseArgs(argv) {
80
+ const out = {
81
+ includePrompts: false,
82
+ includeDiffs: false,
83
+ yes: false,
84
+ noBackend: false,
85
+ quiet: false,
86
+ };
87
+ for (let i = 0; i < argv.length; i++) {
88
+ const a = argv[i];
89
+ switch (a) {
90
+ case "--trace-id":
91
+ out.traceId = takeValue(argv, i, a);
92
+ i += 1;
93
+ break;
94
+ case "--out":
95
+ out.out = takeValue(argv, i, a);
96
+ i += 1;
97
+ break;
98
+ case "--command":
99
+ out.command = takeValue(argv, i, a);
100
+ i += 1;
101
+ break;
102
+ case "--run-id":
103
+ out.runId = takeValue(argv, i, a);
104
+ i += 1;
105
+ break;
106
+ case "--session-id":
107
+ out.sessionId = takeValue(argv, i, a);
108
+ i += 1;
109
+ break;
110
+ case "--include-prompts":
111
+ out.includePrompts = true;
112
+ break;
113
+ case "--include-diffs":
114
+ out.includeDiffs = true;
115
+ break;
116
+ case "--yes":
117
+ case "-y":
118
+ out.yes = true;
119
+ break;
120
+ case "--no-backend":
121
+ out.noBackend = true;
122
+ break;
123
+ case "--quiet":
124
+ case "-q":
125
+ out.quiet = true;
126
+ break;
127
+ default:
128
+ if (a.startsWith("-") && !KNOWN_FLAGS.has(a)) {
129
+ throw new Error(`Unknown flag: ${a}. Supported: ${[...KNOWN_FLAGS].join(", ")}`);
130
+ }
131
+ throw new Error(`Unexpected argument: ${a}`);
132
+ }
133
+ }
134
+ if (!out.traceId) {
135
+ throw new Error("`mla debug bundle` requires --trace-id <id>");
136
+ }
137
+ return out;
138
+ }
139
+ // Default fetcher: ask control for an observability summary of the trace. There
140
+ // is no such endpoint today, so this will normally fail; that is fine and
141
+ // expected. The point of the seam is that it is fail-soft (any error becomes a
142
+ // warning + a partial bundle) and that it lights up automatically the day
143
+ // control grows the endpoint. A bundle never requires backend access (spec 6.7).
144
+ const defaultBackendFetcher = async (traceId, opts, counts) => {
145
+ let cfg;
146
+ try {
147
+ cfg = (0, config_1.readConfig)();
148
+ }
149
+ catch (e) {
150
+ return {
151
+ summary: null,
152
+ langfuseProjectId: null,
153
+ warning: `backend summary skipped: no usable config (${errText(e)})`,
154
+ };
155
+ }
156
+ try {
157
+ const raw = await (0, http_1.get)(cfg, `/internal/v1/observability/trace/${traceId}`, 8000);
158
+ const summary = raw && typeof raw === "object" && "summary" in raw
159
+ ? (0, debug_bundle_1.redactValue)(raw.summary, opts, counts)
160
+ : (0, debug_bundle_1.redactValue)(raw, opts, counts);
161
+ const lf = raw && typeof raw === "object" && typeof raw.langfuseProjectId === "string"
162
+ ? raw.langfuseProjectId
163
+ : null;
164
+ return { summary, langfuseProjectId: lf, warning: null };
165
+ }
166
+ catch (e) {
167
+ return {
168
+ summary: null,
169
+ langfuseProjectId: null,
170
+ warning: `backend trace summary unavailable (${errText(e)}); bundle is partial ` +
171
+ `(local logs only). This is expected offline or against a backend ` +
172
+ `without the observability summary endpoint.`,
173
+ };
174
+ }
175
+ };
176
+ function errText(e) {
177
+ if (e instanceof Error)
178
+ return e.message;
179
+ return String(e);
180
+ }
181
+ // Interactive confirmation for the raw-payload opt-ins. Default reads from the
182
+ // TTY. Non-interactive callers (no TTY) MUST pass --yes to include raw payloads;
183
+ // otherwise we refuse rather than silently bundling sensitive content.
184
+ async function confirmInteractive(prompt) {
185
+ const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
186
+ try {
187
+ const answer = await new Promise((resolve) => rl.question(prompt, resolve));
188
+ const norm = answer.trim().toLowerCase();
189
+ return norm === "y" || norm === "yes";
190
+ }
191
+ finally {
192
+ rl.close();
193
+ }
194
+ }
195
+ async function runDebug(argv, deps = {}) {
196
+ const [sub, ...rest] = argv;
197
+ if (sub !== "bundle") {
198
+ console.error(`Unknown debug subcommand: ${sub ?? "(none)"}. Usage: mla debug bundle --trace-id <id>`);
199
+ return 2;
200
+ }
201
+ let flags;
202
+ try {
203
+ flags = parseArgs(rest);
204
+ }
205
+ catch (e) {
206
+ console.error(errText(e));
207
+ return 2;
208
+ }
209
+ // OBS-1 shape guard up front: a malformed id never seeds a bundle path.
210
+ if (!(0, observability_1.isCanonicalTraceId)(flags.traceId)) {
211
+ console.error(`Invalid --trace-id "${flags.traceId}": expected 32 lowercase hex chars ` +
212
+ `(OBS-1). The id is the last path segment of the Langfuse deep-link mla ` +
213
+ `prints on a run.`);
214
+ return 2;
215
+ }
216
+ const home = deps.home ?? config_1.HOME;
217
+ const now = deps.now ?? (() => new Date().toISOString());
218
+ const isTTY = deps.isTTY ?? Boolean(process.stdin.isTTY);
219
+ const confirm = deps.confirm ?? confirmInteractive;
220
+ const backendFetcher = deps.backendFetcher ?? defaultBackendFetcher;
221
+ const opts = {
222
+ includePrompts: flags.includePrompts,
223
+ includeDiffs: flags.includeDiffs,
224
+ };
225
+ // Gate the raw-payload opt-ins. Interactive: ask once, naming exactly what
226
+ // would be included. Non-interactive without --yes: refuse (never silently
227
+ // bundle sensitive content for an automated caller).
228
+ if (opts.includePrompts || opts.includeDiffs) {
229
+ const categories = [
230
+ opts.includePrompts ? "prompts, document bodies, tool payloads, raw requests" : null,
231
+ opts.includeDiffs ? "source diffs" : null,
232
+ ]
233
+ .filter(Boolean)
234
+ .join("; ");
235
+ if (!flags.yes) {
236
+ if (!isTTY) {
237
+ console.error(`Refusing to include raw payloads (${categories}) non-interactively. ` +
238
+ `Re-run with --yes to confirm in a non-interactive context.`);
239
+ return 2;
240
+ }
241
+ const ok = await confirm(`This bundle will include RAW payloads (${categories}). These can contain ` +
242
+ `sensitive content. Include them? [y/N] `);
243
+ if (!ok) {
244
+ console.error("Aborted: raw payloads not included. Re-run without the include flags for a redacted bundle.");
245
+ return 1;
246
+ }
247
+ }
248
+ }
249
+ const counts = { diffs: 0, prompts: 0, secrets: 0 };
250
+ const warnings = [];
251
+ // Local logs: always, offline-capable. Trace-scoped + redacted in the core.
252
+ const logsDir = path.join(home, "logs");
253
+ const localLogs = (0, debug_bundle_1.collectLocalLogs)(logsDir, flags.traceId, opts, counts);
254
+ // Best-effort backend summary (skippable with --no-backend).
255
+ let backendSummary = null;
256
+ let langfuseProjectId = null;
257
+ if (flags.noBackend) {
258
+ warnings.push("backend summary skipped (--no-backend); bundle is local-only.");
259
+ }
260
+ else {
261
+ const r = await backendFetcher(flags.traceId, opts, counts);
262
+ backendSummary = r.summary;
263
+ langfuseProjectId = r.langfuseProjectId;
264
+ if (r.warning)
265
+ warnings.push(r.warning);
266
+ }
267
+ const workspaceId = (() => {
268
+ try {
269
+ return (0, workspace_1.tryResolveWorkspaceId)(deps.cwd ?? process.cwd());
270
+ }
271
+ catch {
272
+ return null;
273
+ }
274
+ })();
275
+ const build = (0, observability_1.loadBuildInfo)();
276
+ const inputs = {
277
+ traceId: flags.traceId,
278
+ createdAt: now(),
279
+ mlaVersion: build.version,
280
+ releaseSha: build.sha,
281
+ workspaceId,
282
+ command: flags.command ?? "unknown",
283
+ runId: flags.runId ?? null,
284
+ sessionId: flags.sessionId ?? null,
285
+ telemetryEnabled: !(0, observability_1.telemetryDisabled)(),
286
+ langfuseProjectId,
287
+ sentryUrl: null,
288
+ opts,
289
+ localLogs,
290
+ backendSummary,
291
+ warnings,
292
+ redactionCounts: counts,
293
+ };
294
+ const built = (0, debug_bundle_1.buildBundle)(inputs);
295
+ const outPath = flags.out
296
+ ? path.resolve(flags.out)
297
+ : path.join(home, "debug", `${flags.traceId}.zip`);
298
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
299
+ fs.writeFileSync(outPath, built.zip, { mode: 0o600 });
300
+ if (!flags.quiet) {
301
+ console.log(`Wrote debug bundle: ${outPath}`);
302
+ console.log(` trace_id: ${flags.traceId}`);
303
+ console.log(` files: ${built.fileList.length + 1} (incl. manifest.json)`);
304
+ console.log(` redacted: ${counts.prompts} prompt-field(s), ${counts.diffs} diff-field(s), ` +
305
+ `${counts.secrets} secret(s)` +
306
+ (opts.includePrompts || opts.includeDiffs ? " (raw payloads INCLUDED per flags)" : ""));
307
+ if (warnings.length > 0) {
308
+ console.log(` warnings: ${warnings.length} (see manifest.json / redaction-report.json)`);
309
+ }
310
+ console.log("Review manifest.json + redaction-report.json before sharing. Nothing was uploaded.");
311
+ }
312
+ return 0;
313
+ }