@outerlayer/cli 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +16 -7
  3. package/dist/{agent-setup-YEFN74Y4.js → agent-setup-QE6PSCEZ.js} +8 -8
  4. package/dist/build-info.json +1 -1
  5. package/dist/{builder-PP436VGZ.js → builder-UUS4ORDH.js} +3 -3
  6. package/dist/{check-YDXOLVJ5.js → check-63IDCEEV.js} +31 -30
  7. package/dist/{chunk-XR3BJN33.js → chunk-22RMZBGW.js} +20 -1
  8. package/dist/{chunk-TB7EP24C.js → chunk-2M63GG56.js} +1 -1
  9. package/dist/{chunk-Y6P5XX2B.js → chunk-3D4OYFCD.js} +4 -4
  10. package/dist/{chunk-2GBCTEN4.js → chunk-3KTA5UU2.js} +1 -1
  11. package/dist/{chunk-USO2DKBD.js → chunk-4KSQKQXE.js} +8 -2
  12. package/dist/{chunk-UES67HLJ.js → chunk-4QVZCVWT.js} +5 -5
  13. package/dist/{chunk-I263FZ3A.js → chunk-6S3H3J6H.js} +3 -3
  14. package/dist/{chunk-BHOBM3IZ.js → chunk-C6IV5BV7.js} +10 -10
  15. package/dist/{chunk-VDI5POCC.js → chunk-CNFVHDHG.js} +1 -1
  16. package/dist/{chunk-EOWWTFUU.js → chunk-DPKX26LT.js} +92 -16
  17. package/dist/{chunk-SUMWRA7K.js → chunk-DXQ5MHCO.js} +1 -1
  18. package/dist/{chunk-ZQ5JGHUO.js → chunk-EFZLAYPE.js} +2 -2
  19. package/dist/{chunk-RWQWPZB4.js → chunk-GI4XXD4I.js} +3 -3
  20. package/dist/{chunk-YU5GL7QS.js → chunk-HDTVTA6I.js} +2 -2
  21. package/dist/{chunk-BFESLKPP.js → chunk-IP7BIBXJ.js} +19 -1
  22. package/dist/{chunk-YT35WGIP.js → chunk-J5M7BSJQ.js} +99 -7
  23. package/dist/{chunk-IU4NZROR.js → chunk-JXYVA45C.js} +1 -1
  24. package/dist/{chunk-BMX3L7CR.js → chunk-LCEXHCHD.js} +1 -1
  25. package/dist/{chunk-7C4T5BGN.js → chunk-MJXXRX4M.js} +54 -12
  26. package/dist/{chunk-E5DC4VZL.js → chunk-MZN7AQOB.js} +8 -8
  27. package/dist/{chunk-CJGQQZWB.js → chunk-NX57IBNK.js} +1 -1
  28. package/dist/{chunk-DTDZXDQ3.js → chunk-P4MM66C6.js} +31 -18
  29. package/dist/{chunk-BEZSECPA.js → chunk-P6FX4D43.js} +1 -1
  30. package/dist/{chunk-A56PYPDF.js → chunk-R7OQTKWT.js} +2 -1
  31. package/dist/{chunk-TFIOXPZT.js → chunk-RLYZLUQ7.js} +67 -5
  32. package/dist/chunk-RMWLBUCJ.js +50 -0
  33. package/dist/{chunk-4HMXH2OA.js → chunk-SFFHGX3G.js} +1 -1
  34. package/dist/{chunk-3YFCWYBU.js → chunk-SVEP7PVH.js} +14 -14
  35. package/dist/chunk-T5VPP6H7.js +65 -0
  36. package/dist/{chunk-BGWTYRSS.js → chunk-TCIW27FM.js} +1 -1
  37. package/dist/{chunk-R7BJYFD2.js → chunk-TOPDNXHZ.js} +5 -5
  38. package/dist/{chunk-HKUH5AR2.js → chunk-XJKL4BNU.js} +3 -3
  39. package/dist/{cli-RQZXTOEI.js → cli-WSBIAVZU.js} +176 -88
  40. package/dist/{command-U6UGIBVT.js → command-N7BAB4XJ.js} +21 -22
  41. package/dist/{config-MKBX2ZQD.js → config-N3C6DFQA.js} +1 -1
  42. package/dist/{connect-cmd-5MIUNYAY.js → connect-cmd-FGYRLLXL.js} +5 -5
  43. package/dist/{context-adopt-A77G67CP.js → context-adopt-B3PWGFHL.js} +5 -5
  44. package/dist/{context-materialize-KQZYATQZ.js → context-materialize-7S6NLLRO.js} +5 -5
  45. package/dist/{dist-3M3ZMEZF.js → dist-LKDWQWZ7.js} +2 -2
  46. package/dist/{docker-WVRRMK6R.js → docker-BZ55BMBJ.js} +4 -4
  47. package/dist/{doctor-ZF4PYWVN.js → doctor-3H25Q7WT.js} +23 -20
  48. package/dist/{emit-artifact-cmd-VKPW577P.js → emit-artifact-cmd-IQCRXOH7.js} +9 -9
  49. package/dist/{emit-cmd-SU62J2PB.js → emit-cmd-KDSM5VAO.js} +4 -4
  50. package/dist/{emit-criteria-cmd-U2TL6FYY.js → emit-criteria-cmd-EYUXME26.js} +7 -7
  51. package/dist/emit-finding-cmd-P4RKBPBB.js +465 -0
  52. package/dist/{emit-result-cmd-GKBVPMU4.js → emit-result-cmd-6XYENU6H.js} +9 -9
  53. package/dist/{hook-fast-AQCAQIA6.js → hook-fast-PXWKQPN6.js} +1 -1
  54. package/dist/{import-capture-cmd-5NJVL2HN.js → import-capture-cmd-2BKM5I2N.js} +3 -3
  55. package/dist/{import-ruler-cmd-TUK3MRPC.js → import-ruler-cmd-IXR7YK47.js} +2 -2
  56. package/dist/index.js +3 -3
  57. package/dist/{init-PUY2BUHH.js → init-2LWVS4AH.js} +21 -17
  58. package/dist/{init-M5IBAGVE.js → init-ZL7ORPTF.js} +53 -32
  59. package/dist/{init-cmd-NPNR23UL.js → init-cmd-JXOBCOIB.js} +16 -14
  60. package/dist/{install-HKOVISUP.js → install-HDBIPHTX.js} +2 -4
  61. package/dist/{login-browser-7XGSV7MA.js → login-browser-QZCS3WW6.js} +2 -1
  62. package/dist/{loop-3FNROLW7.js → loop-XOAE6ZIY.js} +32 -30
  63. package/dist/{machine-RWDDJRWB.js → machine-G6PY2J2J.js} +16 -16
  64. package/dist/{mcp-install-cmd-XZARXNYT.js → mcp-install-cmd-VXVIH7PH.js} +1 -1
  65. package/dist/runner-env-XTC53CHN.js +15 -0
  66. package/dist/runner-key-TDTLNAKJ.js +154 -0
  67. package/dist/{session-sender-E3UHGSNV.js → session-sender-XVGZFWRK.js} +7 -7
  68. package/dist/{starter-pack-I35VNYAR.js → starter-pack-B7JPGEDO.js} +4 -4
  69. package/dist/{status-2OW5AKWL.js → status-MRTPG34B.js} +22 -22
  70. package/dist/{sync-cmd-ULKXCHO2.js → sync-cmd-UBUZMMDN.js} +6 -6
  71. package/dist/{watch-IU6NHB4K.js → watch-STNPEWD6.js} +6 -6
  72. package/dist/{work-claim-cmd-LXXSNEGF.js → work-claim-cmd-CWGYEIJE.js} +11 -11
  73. package/dist/{work-cmd-ZJY3NA2G.js → work-cmd-X7NMJDFL.js} +8 -8
  74. package/dist/{work-comment-cmd-34FTLPUO.js → work-comment-cmd-FI2TMAYQ.js} +8 -8
  75. package/dist/{work-open-pr-cmd-YZAENDP6.js → work-open-pr-cmd-OVHJ5I5H.js} +9 -9
  76. package/dist/{work-pr-cmd-EXTOGBJC.js → work-pr-cmd-Y5TDMQ4O.js} +8 -8
  77. package/package.json +1 -1
  78. package/skill-pack/maintained/reporting-findings/SKILL.md +84 -5
  79. package/skill-pack/template/build/SKILL.md +60 -33
  80. package/skill-pack/template/build/references/agent-briefs.md +4 -2
  81. package/skill-pack/template/build/references/release.md +1 -1
  82. package/skill-pack/template/build/references/review-loop.md +6 -2
  83. package/skill-pack/template/build/scripts/record-criteria.mjs +109 -143
  84. package/skill-pack/validators/code-review.yaml +4 -2
  85. package/dist/chunk-FBTE2A2X.js +0 -38
  86. package/dist/chunk-JKIWMRFH.js +0 -27
  87. package/dist/chunk-T6OIJQRT.js +0 -31
  88. package/dist/emit-finding-cmd-TMOOKHPD.js +0 -251
@@ -1,251 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire } from 'node:module';
3
- import { launchRefusalForSession } from './chunk-HHJDN6AU.js';
4
- import { autoConnect } from './chunk-ZQ5JGHUO.js';
5
- import { detectActiveSession } from './chunk-BFESLKPP.js';
6
- import './chunk-UES67HLJ.js';
7
- import './chunk-VDI5POCC.js';
8
- import { resolveRepoIdentity } from './chunk-IU4NZROR.js';
9
- import './chunk-USO2DKBD.js';
10
- import './chunk-N6LURUEF.js';
11
- import './chunk-YRYMNBGQ.js';
12
- import { launchedItemForSession } from './chunk-GQD22KKN.js';
13
- import { parseTrackerNumber, trackerNumberError } from './chunk-WZBHBH3J.js';
14
- import { readLatestProvenanceForSession } from './chunk-ZJSNLVCE.js';
15
- import { defaultFetch } from './chunk-YO4PSLVB.js';
16
- import { resolveGatewayCredentials, unauthorizedMessage } from './chunk-PLMTLGYH.js';
17
- import { FindingBatchSchema } from './chunk-YT35WGIP.js';
18
- import './chunk-EABW6AJQ.js';
19
- import './chunk-V7NIVOFD.js';
20
- import './chunk-ZM2IMMYN.js';
21
- import './chunk-BJ3KTMDH.js';
22
- import { homeFromEnv } from './chunk-VNVZDWO3.js';
23
- import './chunk-Z5GEFMRW.js';
24
- import { readFileSync } from 'fs';
25
-
26
- createRequire(import.meta.url);
27
- var GREEN = "\x1B[32m";
28
- var DIM = "\x1B[2m";
29
- var RESET = "\x1B[0m";
30
- var EmitFindingError = class extends Error {
31
- };
32
- var REMOVED_FINDING_FLAGS = ["subject", "kind", "severity", "verdict", "fixed", "source"];
33
- function refuseRemovedFindingFlags(opts) {
34
- const used = REMOVED_FINDING_FLAGS.find((flag) => opts[flag] !== void 0);
35
- if (used === void 0) return;
36
- throw new EmitFindingError(
37
- `--${used} is no longer accepted: findings record problems in the factory, not review verdicts. Pass --category <context|flaky-test|tooling|environment|defect|other> instead.`
38
- );
39
- }
40
- function parseItemFlag(raw) {
41
- if (raw === void 0) return void 0;
42
- const number = parseTrackerNumber(raw);
43
- if (number === void 0) {
44
- throw new EmitFindingError(trackerNumberError("--item", raw));
45
- }
46
- return { number };
47
- }
48
- function parseIntFlag(raw, flag, opts) {
49
- if (raw === void 0) return void 0;
50
- if (!/^-?\d+$/.test(raw)) {
51
- throw new EmitFindingError(`invalid ${flag} "${raw}" \u2014 expected a whole number`);
52
- }
53
- const n = Number(raw);
54
- if (!Number.isSafeInteger(n) || n < opts.min) {
55
- throw new EmitFindingError(`invalid ${flag} "${raw}" \u2014 expected a whole number >= ${opts.min}`);
56
- }
57
- return n;
58
- }
59
- async function readAllStdin() {
60
- const chunks = [];
61
- for await (const chunk of process.stdin) chunks.push(Buffer.from(chunk));
62
- return Buffer.concat(chunks).toString("utf8");
63
- }
64
- function recordFromFlags(opts) {
65
- const line = parseIntFlag(opts.line, "--line", { min: 1 });
66
- const ruleLine = parseIntFlag(opts.ruleLine, "--rule-line", { min: 1 });
67
- const turnIndex = parseIntFlag(opts.turn, "--turn", { min: 0 });
68
- const round = parseIntFlag(opts.round, "--round", { min: 0 });
69
- const hasRule = opts.rulePath !== void 0 || opts.ruleQuote !== void 0 || opts.ruleRelation !== void 0 || ruleLine !== void 0;
70
- return {
71
- id: opts.id,
72
- category: opts.category,
73
- title: opts.title,
74
- file: opts.file,
75
- line: line ?? null,
76
- rule: hasRule ? {
77
- path: opts.rulePath,
78
- line: ruleLine ?? null,
79
- ...opts.ruleQuote !== void 0 ? { quote: opts.ruleQuote } : {},
80
- relation: opts.ruleRelation
81
- } : null,
82
- where: {
83
- label: opts.where,
84
- ...opts.traceId !== void 0 ? { traceId: opts.traceId } : {},
85
- ...turnIndex !== void 0 ? { turnIndex } : {},
86
- ...round !== void 0 ? { round } : {}
87
- }
88
- };
89
- }
90
- function firstIssueMessage(result) {
91
- const issue = result.error.issues[0];
92
- return issue ? `${issue.path.join(".")}: ${issue.message}` : "malformed";
93
- }
94
- function detectUploadSessionId(opts) {
95
- const identity = resolveRepoIdentity(opts.cwd);
96
- return detectActiveSession({
97
- env: opts.env,
98
- home: opts.home,
99
- cwds: identity.repoRoot !== void 0 ? [identity.repoRoot, opts.cwd] : [opts.cwd],
100
- nowMs: opts.now().getTime()
101
- });
102
- }
103
- function resolveUploadTarget(opts) {
104
- const item = parseItemFlag(opts.item);
105
- const sessionId = opts.sessionId;
106
- if (sessionId !== void 0) {
107
- const refusal = launchRefusalForSession(sessionId, opts.home);
108
- if (refusal !== void 0) throw new EmitFindingError(refusal);
109
- }
110
- if (item !== void 0) {
111
- return sessionId !== void 0 ? { item, sessionId } : { item };
112
- }
113
- if (sessionId === void 0) {
114
- throw new EmitFindingError(
115
- "nothing to attach this to \u2014 no work item. Pass --item <number>, or run inside a recorded session launched with OUTERLAYER_WORK \u2014 its own launch record names the item automatically."
116
- );
117
- }
118
- const launchedNumber = launchedItemForSession(sessionId, opts.home);
119
- if (launchedNumber === void 0) {
120
- throw new EmitFindingError(
121
- "nothing to attach this to \u2014 no work item. Pass --item <number>; this recorded session's own launch record names no item either."
122
- );
123
- }
124
- return { item: { number: launchedNumber }, sessionId };
125
- }
126
- async function upload(batch, target, opts) {
127
- const refusal = await autoConnect(opts);
128
- if (refusal !== void 0) throw new EmitFindingError(refusal);
129
- const resolved = resolveGatewayCredentials(opts);
130
- if (!resolved.ok) throw new EmitFindingError(resolved.message);
131
- const { url, credential: apiKey, appId } = resolved;
132
- const request = {
133
- ...batch,
134
- item: target.item,
135
- ...target.sessionId !== void 0 ? { sessionId: target.sessionId } : {}
136
- };
137
- const fetchImpl = opts.fetchImpl ?? defaultFetch;
138
- const endpoint = new URL("/v1/findings", url).toString();
139
- let response;
140
- try {
141
- response = await fetchImpl(endpoint, {
142
- method: "POST",
143
- headers: {
144
- "content-type": "application/json",
145
- authorization: `Bearer ${apiKey}`,
146
- "x-outerlayer-app-id": appId
147
- },
148
- body: JSON.stringify(request)
149
- });
150
- } catch (err) {
151
- throw new EmitFindingError(`network error reaching ${endpoint}: ${String(err)}`);
152
- }
153
- if (response.status === 401) {
154
- throw new EmitFindingError(
155
- unauthorizedMessage(apiKey)
156
- );
157
- }
158
- if (!response.ok) {
159
- let detail = "";
160
- try {
161
- detail = (await response.text()).replace(/\s+/g, " ").trim().slice(0, 160);
162
- } catch {
163
- }
164
- throw new EmitFindingError(`emit failed (${response.status})${detail ? `: ${detail}` : ""}`);
165
- }
166
- let data = {};
167
- try {
168
- data = (await response.json()).data ?? {};
169
- } catch {
170
- }
171
- const count = typeof data.count === "number" ? data.count : batch.findings.length;
172
- const output = opts.json ? JSON.stringify(data) : `${GREEN}\u2713${RESET} recorded ${count} ${count === 1 ? "finding" : "findings"} ${DIM}\xB7${RESET} item #${target.item.number}`;
173
- if (!opts.quiet) process.stdout.write(output + "\n");
174
- return { data, output, exitCode: 0 };
175
- }
176
- async function runEmitFinding(opts) {
177
- const cwd = opts.cwd ?? process.cwd();
178
- const home = opts.home ?? homeFromEnv();
179
- const env = opts.env ?? process.env;
180
- const now = opts.now ?? (() => /* @__PURE__ */ new Date());
181
- const sessionId = detectUploadSessionId({ cwd, home, env, now });
182
- const contextSourceSha = opts.contextSourceSha ?? (sessionId !== void 0 ? readLatestProvenanceForSession(sessionId, home)?.sha ?? void 0 : void 0);
183
- const rawBatch = {
184
- schemaVersion: 2,
185
- ...opts.headSha !== void 0 ? { headSha: opts.headSha } : {},
186
- ...contextSourceSha !== void 0 ? { contextSourceSha } : {},
187
- findings: [recordFromFlags(opts)]
188
- };
189
- const parsed = FindingBatchSchema.safeParse(rawBatch);
190
- if (!parsed.success) {
191
- throw new EmitFindingError(`invalid finding \u2014 ${firstIssueMessage(parsed)}`);
192
- }
193
- const target = resolveUploadTarget({ item: opts.item, sessionId, home });
194
- return upload(parsed.data, target, {
195
- json: opts.json,
196
- url: opts.url,
197
- apiKey: opts.apiKey,
198
- appId: opts.appId,
199
- cwd,
200
- quiet: opts.quiet,
201
- home,
202
- env,
203
- fetchImpl: opts.fetchImpl
204
- });
205
- }
206
- async function runEmitFindings(opts) {
207
- const cwd = opts.cwd ?? process.cwd();
208
- const home = opts.home ?? homeFromEnv();
209
- const env = opts.env ?? process.env;
210
- const now = opts.now ?? (() => /* @__PURE__ */ new Date());
211
- let text;
212
- if (opts.file === "-") {
213
- text = await (opts.readStdin ?? readAllStdin)();
214
- } else {
215
- try {
216
- text = readFileSync(opts.file, "utf8");
217
- } catch (err) {
218
- throw new EmitFindingError(`cannot read "${opts.file}": ${String(err)}`);
219
- }
220
- }
221
- let raw;
222
- try {
223
- raw = JSON.parse(text);
224
- } catch (err) {
225
- throw new EmitFindingError(`"${opts.file}" is not valid JSON: ${String(err)}`);
226
- }
227
- if (typeof raw === "object" && raw !== null && raw.schemaVersion === 1) {
228
- throw new EmitFindingError(
229
- `"${opts.file}" uses schemaVersion 1, which is no longer accepted. Use schemaVersion 2: each finding takes a category (context, flaky-test, tooling, environment, defect or other) in place of subject, kind, severity, verdict, fixed and source.`
230
- );
231
- }
232
- const parsed = FindingBatchSchema.safeParse(raw);
233
- if (!parsed.success) {
234
- throw new EmitFindingError(`invalid finding batch \u2014 ${firstIssueMessage(parsed)}`);
235
- }
236
- const sessionId = detectUploadSessionId({ cwd, home, env, now });
237
- const target = resolveUploadTarget({ item: opts.item, sessionId, home });
238
- return upload(parsed.data, target, {
239
- json: opts.json,
240
- url: opts.url,
241
- apiKey: opts.apiKey,
242
- appId: opts.appId,
243
- cwd,
244
- quiet: opts.quiet,
245
- home,
246
- env,
247
- fetchImpl: opts.fetchImpl
248
- });
249
- }
250
-
251
- export { EmitFindingError, refuseRemovedFindingFlags, runEmitFinding, runEmitFindings };