looply-cli 0.5.43 → 0.5.48

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 (114) hide show
  1. package/dist/.src-hash +1 -1
  2. package/dist/autonomy-controller.d.ts.map +1 -1
  3. package/dist/autonomy-controller.js +6 -0
  4. package/dist/autonomy-controller.js.map +1 -1
  5. package/dist/autonomy-tick.d.ts.map +1 -1
  6. package/dist/autonomy-tick.js +20 -2
  7. package/dist/autonomy-tick.js.map +1 -1
  8. package/dist/bin.d.ts.map +1 -1
  9. package/dist/bin.js +4 -0
  10. package/dist/bin.js.map +1 -1
  11. package/dist/branch-delivery-wiring.d.ts +37 -1
  12. package/dist/branch-delivery-wiring.d.ts.map +1 -1
  13. package/dist/branch-delivery-wiring.js +87 -1
  14. package/dist/branch-delivery-wiring.js.map +1 -1
  15. package/dist/branch-delivery.d.ts +20 -0
  16. package/dist/branch-delivery.d.ts.map +1 -1
  17. package/dist/branch-delivery.js +78 -6
  18. package/dist/branch-delivery.js.map +1 -1
  19. package/dist/canary-cmd.d.ts +42 -0
  20. package/dist/canary-cmd.d.ts.map +1 -0
  21. package/dist/canary-cmd.js +242 -0
  22. package/dist/canary-cmd.js.map +1 -0
  23. package/dist/canary-wiring.d.ts +31 -0
  24. package/dist/canary-wiring.d.ts.map +1 -0
  25. package/dist/canary-wiring.js +139 -0
  26. package/dist/canary-wiring.js.map +1 -0
  27. package/dist/canary.d.ts +123 -0
  28. package/dist/canary.d.ts.map +1 -0
  29. package/dist/canary.js +259 -0
  30. package/dist/canary.js.map +1 -0
  31. package/dist/coordinator-state.d.ts.map +1 -1
  32. package/dist/coordinator-state.js +6 -4
  33. package/dist/coordinator-state.js.map +1 -1
  34. package/dist/daemon-cmd.d.ts.map +1 -1
  35. package/dist/daemon-cmd.js +27 -2
  36. package/dist/daemon-cmd.js.map +1 -1
  37. package/dist/deliver-cmd.d.ts +11 -0
  38. package/dist/deliver-cmd.d.ts.map +1 -1
  39. package/dist/deliver-cmd.js +23 -0
  40. package/dist/deliver-cmd.js.map +1 -1
  41. package/dist/environment-hold.d.ts +32 -1
  42. package/dist/environment-hold.d.ts.map +1 -1
  43. package/dist/environment-hold.js +52 -5
  44. package/dist/environment-hold.js.map +1 -1
  45. package/dist/feature-report.d.ts +4 -2
  46. package/dist/feature-report.d.ts.map +1 -1
  47. package/dist/feature-report.js +24 -6
  48. package/dist/feature-report.js.map +1 -1
  49. package/dist/git-driver.d.ts +5 -0
  50. package/dist/git-driver.d.ts.map +1 -1
  51. package/dist/git-driver.js +8 -0
  52. package/dist/git-driver.js.map +1 -1
  53. package/dist/goal-adaptive.d.ts +25 -1
  54. package/dist/goal-adaptive.d.ts.map +1 -1
  55. package/dist/goal-adaptive.js +42 -1
  56. package/dist/goal-adaptive.js.map +1 -1
  57. package/dist/goal-compile.d.ts.map +1 -1
  58. package/dist/goal-compile.js +13 -0
  59. package/dist/goal-compile.js.map +1 -1
  60. package/dist/goal-gap.d.ts +14 -3
  61. package/dist/goal-gap.d.ts.map +1 -1
  62. package/dist/goal-gap.js +46 -6
  63. package/dist/goal-gap.js.map +1 -1
  64. package/dist/grant-waiting-wiring.d.ts +3 -2
  65. package/dist/grant-waiting-wiring.d.ts.map +1 -1
  66. package/dist/grant-waiting-wiring.js +5 -4
  67. package/dist/grant-waiting-wiring.js.map +1 -1
  68. package/dist/machine-settings.d.ts +4 -0
  69. package/dist/machine-settings.d.ts.map +1 -1
  70. package/dist/machine-settings.js +15 -1
  71. package/dist/machine-settings.js.map +1 -1
  72. package/dist/outcome-audit.d.ts +150 -0
  73. package/dist/outcome-audit.d.ts.map +1 -0
  74. package/dist/outcome-audit.js +310 -0
  75. package/dist/outcome-audit.js.map +1 -0
  76. package/dist/parts-attribution.d.ts +38 -0
  77. package/dist/parts-attribution.d.ts.map +1 -0
  78. package/dist/parts-attribution.js +61 -0
  79. package/dist/parts-attribution.js.map +1 -0
  80. package/dist/project-terminal.d.ts +3 -1
  81. package/dist/project-terminal.d.ts.map +1 -1
  82. package/dist/project-terminal.js +37 -5
  83. package/dist/project-terminal.js.map +1 -1
  84. package/dist/pursuit-delivery.d.ts +5 -20
  85. package/dist/pursuit-delivery.d.ts.map +1 -1
  86. package/dist/pursuit-delivery.js +30 -2
  87. package/dist/pursuit-delivery.js.map +1 -1
  88. package/dist/pursuit-ending.d.ts.map +1 -1
  89. package/dist/pursuit-ending.js +10 -0
  90. package/dist/pursuit-ending.js.map +1 -1
  91. package/dist/run-cmd.d.ts.map +1 -1
  92. package/dist/run-cmd.js +47 -1
  93. package/dist/run-cmd.js.map +1 -1
  94. package/dist/run-refusal-marks.d.ts +8 -1
  95. package/dist/run-refusal-marks.d.ts.map +1 -1
  96. package/dist/run-refusal-marks.js +14 -1
  97. package/dist/run-refusal-marks.js.map +1 -1
  98. package/dist/server-client.d.ts +26 -1
  99. package/dist/server-client.d.ts.map +1 -1
  100. package/dist/server-client.js +24 -0
  101. package/dist/server-client.js.map +1 -1
  102. package/dist/setup-check.d.ts +6 -0
  103. package/dist/setup-check.d.ts.map +1 -1
  104. package/dist/setup-check.js +19 -7
  105. package/dist/setup-check.js.map +1 -1
  106. package/dist/watchdog-wiring.d.ts +116 -5
  107. package/dist/watchdog-wiring.d.ts.map +1 -1
  108. package/dist/watchdog-wiring.js +302 -4
  109. package/dist/watchdog-wiring.js.map +1 -1
  110. package/dist/watchdog.d.ts +20 -3
  111. package/dist/watchdog.d.ts.map +1 -1
  112. package/dist/watchdog.js +24 -4
  113. package/dist/watchdog.js.map +1 -1
  114. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canary-cmd.d.ts","sourceRoot":"","sources":["../src/canary-cmd.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,YAAY,+lBAMmF,CAAC;AAE7G,0GAA0G;AAC1G,wBAAgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4DvD;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CASzD;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,iGAAiG;IACjG,GAAG,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5F,gGAAgG;IAChG,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrH,gCAAgC;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;CACjD;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBjG;AA8ED,uBAAuB;AACvB,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,aAAa,CA0BzG"}
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CANARY_USAGE = void 0;
4
+ exports.canaryTemplate = canaryTemplate;
5
+ exports.writeCanaryTemplate = writeCanaryTemplate;
6
+ exports.canaryCommand = canaryCommand;
7
+ exports.nodeCanaryCmdDeps = nodeCanaryCmdDeps;
8
+ const node_child_process_1 = require("node:child_process");
9
+ const node_fs_1 = require("node:fs");
10
+ const node_path_1 = require("node:path");
11
+ const core_1 = require("@looply/core");
12
+ const canary_1 = require("./canary");
13
+ const canary_wiring_1 = require("./canary-wiring");
14
+ const github_api_1 = require("./github-api");
15
+ const trusted_git_1 = require("./trusted-git");
16
+ const machine_secrets_1 = require("./machine-secrets");
17
+ const machine_settings_1 = require("./machine-settings");
18
+ const serve_cmd_1 = require("./serve-cmd");
19
+ /**
20
+ * `looply canary` — THE PIPELINE CANARY'S ONE-TIME SETUP AND ITS SWITCH (`canary.ts`).
21
+ *
22
+ * looply canary setup --create [--name looply-canary] make a PRIVATE GitHub repository for it (as this
23
+ * PC's GitHub login), fill it, and serve it
24
+ * looply canary setup --repo <url> use a repository made by hand (an empty one is filled)
25
+ * looply canary the last run, stage by stage
26
+ * looply canary on | off whether this PC runs it
27
+ *
28
+ * The repository lives in `~/.looply/canary/<name>`, apart from every project, and is served like any
29
+ * other: its daemon runs the canary. Nothing here touches a real project.
30
+ */
31
+ exports.CANARY_USAGE = `looply canary — Looply proves its own pipeline, daily and after every update
32
+
33
+ looply canary the last canary run, stage by stage
34
+ looply canary setup --create [--name <name>] make a private GitHub repository named looply-canary (or <name>,
35
+ which must start with looply-canary) and serve it on this PC
36
+ looply canary setup --repo <url> use an existing (or empty) looply-canary repository
37
+ looply canary on | off whether this PC runs the canary (on by default once set up)`;
38
+ /** The files a canary repository starts with. Ten lines of check, no dependencies, the smallest model. */
39
+ function canaryTemplate() {
40
+ return {
41
+ [core_1.CANARY_FILE]: [
42
+ core_1.CANARY_MARKER,
43
+ '',
44
+ 'This repository exists only for Looply\'s pipeline canary. Once a day, and after every Looply',
45
+ 'update, Looply rewrites the line below through its whole pipeline (plan, round, checks, goal',
46
+ 'check, pull request, merge) to prove the pipeline works. Put nothing else here.',
47
+ '',
48
+ 'canary-run: none',
49
+ '',
50
+ ].join('\n'),
51
+ 'check.js': [
52
+ "// The canary's only check: CANARY.md keeps its marker and has exactly one well-formed run line.",
53
+ "const fs = require('fs');",
54
+ "const lines = fs.readFileSync('CANARY.md', 'utf8').replace(/\\r\\n/g, '\\n').split('\\n');",
55
+ `if (lines[0].trim() !== '${core_1.CANARY_MARKER}') { console.error('CANARY.md lost its first line'); process.exit(1); }`,
56
+ "const runs = lines.filter((l) => l.trim().startsWith('canary-run:'));",
57
+ "if (runs.length !== 1) { console.error('CANARY.md must have exactly one canary-run line, has ' + runs.length); process.exit(1); }",
58
+ "if (!/^canary-run: (none|[a-z0-9]{8,24})$/.test(runs[0].trim())) { console.error('bad canary-run line: ' + runs[0]); process.exit(1); }",
59
+ "console.log('canary ok: ' + runs[0].trim());",
60
+ '',
61
+ ].join('\n'),
62
+ 'package.json': JSON.stringify({ name: 'looply-canary', private: true, version: '0.0.0', scripts: { test: 'node check.js' } }, null, 2) + '\n',
63
+ '.github/workflows/check.yml': [
64
+ '# The CI a merge waits for: the same ten-line check, a few seconds a day.',
65
+ 'name: check',
66
+ 'on:',
67
+ ' pull_request:',
68
+ ' push:',
69
+ ' branches: [main]',
70
+ 'jobs:',
71
+ ' check:',
72
+ ' runs-on: ubuntu-latest',
73
+ ' timeout-minutes: 5',
74
+ ' steps:',
75
+ ' - uses: actions/checkout@v4',
76
+ ' - run: node check.js',
77
+ '',
78
+ ].join('\n'),
79
+ '.looply/config.yaml': [
80
+ '# The pipeline canary (Looply `canary.ts`). Cheap on purpose: the smallest model at the lowest',
81
+ '# effort, one check, merged as soon as CI is green. Do not point this at a real project.',
82
+ 'project:',
83
+ ' name: "looply-canary"',
84
+ '',
85
+ 'agent:',
86
+ ' models:',
87
+ ' default: "claude-haiku-5-5"',
88
+ ' effort: "low"',
89
+ '',
90
+ 'gates:',
91
+ ' - { name: "check", run: "node check.js", timeout_s: 60, required: true }',
92
+ '',
93
+ 'deliver:',
94
+ ' mode: merge',
95
+ '',
96
+ ].join('\n'),
97
+ '.gitignore': '.looply/state/\nnode_modules/\n',
98
+ };
99
+ }
100
+ function writeCanaryTemplate(dir) {
101
+ const written = [];
102
+ for (const [rel, content] of Object.entries(canaryTemplate())) {
103
+ const p = (0, node_path_1.join)(dir, ...rel.split('/'));
104
+ (0, node_fs_1.mkdirSync)((0, node_path_1.join)(p, '..'), { recursive: true });
105
+ (0, node_fs_1.writeFileSync)(p, content, 'utf8');
106
+ written.push(rel);
107
+ }
108
+ return written;
109
+ }
110
+ async function canaryCommand(argv, deps) {
111
+ const [verb, ...rest] = argv;
112
+ if (verb === undefined || verb === 'status')
113
+ return status(deps);
114
+ if (verb === 'on' || verb === 'off') {
115
+ try {
116
+ (0, machine_settings_1.writeCanarySetting)(verb === 'on', deps.home);
117
+ }
118
+ catch (e) {
119
+ deps.err(`looply canary: ${e.message}`);
120
+ return serve_cmd_1.EXIT_REFUSED;
121
+ }
122
+ deps.out(verb === 'on' ? 'canary: on — this PC runs the pipeline canary once a day and after each Looply update.' : 'canary: off — this PC never runs the pipeline canary (`looply canary on` to undo).');
123
+ return serve_cmd_1.EXIT_OK;
124
+ }
125
+ if (verb === 'setup')
126
+ return setup(rest, deps);
127
+ if (verb === 'help' || verb === '--help') {
128
+ deps.out(exports.CANARY_USAGE);
129
+ return serve_cmd_1.EXIT_OK;
130
+ }
131
+ deps.err(`looply canary: ${JSON.stringify(verb)} — no idea what that means.\n\n${exports.CANARY_USAGE}`);
132
+ return serve_cmd_1.EXIT_USAGE;
133
+ }
134
+ function status(deps) {
135
+ const record = (0, canary_1.readCanaryRecord)((0, machine_secrets_1.looplyHome)(deps.home));
136
+ let off = null;
137
+ try {
138
+ off = (0, machine_settings_1.readLocalMachineSettings)(deps.home).canary === false ? 'off on this PC (`looply canary on` to undo)' : null;
139
+ }
140
+ catch {
141
+ /* said by the daemon */
142
+ }
143
+ const r = record.report;
144
+ if (r === null) {
145
+ deps.out(`canary: no run yet on this PC${off ? ` — ${off}` : ''}.${record.refused ? ` The server would not start one: ${record.refused.because}` : ' Set it up with `looply canary setup --create`.'}`);
146
+ return serve_cmd_1.EXIT_OK;
147
+ }
148
+ deps.out(`canary: ${r.state.toUpperCase()} — ${r.said}${off ? ` (${off})` : ''}`);
149
+ deps.out(` run ${r.runId} (${r.trigger}, Looply ${r.looplyVersion}), started ${r.startedAt}${r.endedAt ? `, ended ${r.endedAt}` : ''}; last passed ${r.lastPassedAt ?? 'never'}`);
150
+ for (const s of r.stages)
151
+ deps.out(` ${s.state.padEnd(7)} ${s.stage.padEnd(10)} ${s.detail ?? core_1.CANARY_STAGE_SAID[s.stage]}`);
152
+ return serve_cmd_1.EXIT_OK;
153
+ }
154
+ async function setup(rest, deps) {
155
+ const create = rest.includes('--create');
156
+ const at = (flag) => {
157
+ const i = rest.indexOf(flag);
158
+ return i >= 0 ? rest[i + 1] : undefined;
159
+ };
160
+ let url = at('--repo');
161
+ const name = at('--name') ?? (url ? (0, core_1.repoNameFromUrl)(url) : null) ?? 'looply-canary';
162
+ if (create === (url !== undefined)) {
163
+ deps.err(`looply canary setup: either --create or --repo <url>.\n\n${exports.CANARY_USAGE}`);
164
+ return serve_cmd_1.EXIT_USAGE;
165
+ }
166
+ if (!core_1.CANARY_REPO_NAME.test(name)) {
167
+ deps.err(`looply canary setup: the repository must be named looply-canary or looply-canary-<something> (not ${name}) — the server gives canary goals to no other`);
168
+ return serve_cmd_1.EXIT_REFUSED;
169
+ }
170
+ if (create) {
171
+ const made = await deps.createRepo(name);
172
+ if (!made.ok) {
173
+ deps.err(`looply canary setup: could not create the repository: ${made.because}`);
174
+ return serve_cmd_1.EXIT_REFUSED;
175
+ }
176
+ deps.out(`canary: created the private repository ${made.fullName}`);
177
+ url = made.cloneUrl;
178
+ }
179
+ const dir = (0, node_path_1.join)((0, machine_secrets_1.looplyHome)(deps.home), 'canary', name);
180
+ if (!(0, node_fs_1.existsSync)((0, node_path_1.join)(dir, '.git'))) {
181
+ (0, node_fs_1.mkdirSync)((0, node_path_1.join)(dir, '..'), { recursive: true });
182
+ const c = deps.git(['clone', url, dir], (0, node_path_1.join)(dir, '..'));
183
+ if (c.code !== 0) {
184
+ deps.err(`looply canary setup: git clone failed: ${(c.stderr || c.stdout).trim().slice(0, 300)}`);
185
+ return serve_cmd_1.EXIT_REFUSED;
186
+ }
187
+ }
188
+ const empty = !(0, node_fs_1.existsSync)((0, node_path_1.join)(dir, core_1.CANARY_FILE)) && (0, node_fs_1.readdirSync)(dir).filter((n) => n !== '.git').length === 0;
189
+ if (empty) {
190
+ writeCanaryTemplate(dir);
191
+ for (const args of [['checkout', '-B', 'main'], ['add', '-A'], ['commit', '-m', 'The Looply pipeline canary'], ['push', '-u', 'origin', 'main']]) {
192
+ const r = deps.git(args, dir);
193
+ if (r.code !== 0) {
194
+ deps.err(`looply canary setup: git ${args[0]} failed: ${(r.stderr || r.stdout).trim().slice(0, 300)}`);
195
+ return serve_cmd_1.EXIT_REFUSED;
196
+ }
197
+ }
198
+ deps.out('canary: filled the repository (CANARY.md, check.js, the check workflow, .looply/config.yaml) and pushed main');
199
+ }
200
+ const origin = deps.git(['remote', 'get-url', 'origin'], dir).stdout.trim() || null;
201
+ if (!(0, canary_wiring_1.isCanaryCheckout)(dir, origin)) {
202
+ deps.err(`looply canary setup: ${dir} is not a canary repository (its ${core_1.CANARY_FILE} must start with "${core_1.CANARY_MARKER}", and origin must be named looply-canary…). An empty repository is filled by itself; a non-empty one is never changed.`);
203
+ return serve_cmd_1.EXIT_REFUSED;
204
+ }
205
+ const served = await deps.serveAdd(dir);
206
+ if (served !== serve_cmd_1.EXIT_OK)
207
+ return served;
208
+ deps.out('canary: set up. The first run starts within minutes of `looply serve` picking it up, then daily and after each Looply update. `looply canary` shows it; `looply canary off` stops it.');
209
+ return serve_cmd_1.EXIT_OK;
210
+ }
211
+ /** Production deps. */
212
+ function nodeCanaryCmdDeps(home, serveAdd) {
213
+ return {
214
+ home,
215
+ out: (l) => process.stdout.write(`${l}\n`),
216
+ err: (l) => process.stderr.write(`${l}\n`),
217
+ git: (args, cwd) => {
218
+ // By absolute path, never a bare name the folder could supply (`trusted-git.ts`).
219
+ const bin = (0, trusted_git_1.gitBinary)();
220
+ if (bin === null)
221
+ return { code: 1, stdout: '', stderr: 'git was not found on PATH' };
222
+ const r = (0, node_child_process_1.spawnSync)(bin, [...args], { cwd, encoding: 'utf8', windowsHide: true });
223
+ return { code: r.status ?? 1, stdout: r.stdout ?? '', stderr: r.stderr ?? (r.error ? r.error.message : '') };
224
+ },
225
+ createRepo: async (name) => {
226
+ const t = await (0, github_api_1.githubToken)();
227
+ if (t === null)
228
+ return { ok: false, because: 'this PC has no GitHub login Looply can use (sign in with `gh auth login`, or let git store a github.com credential)' };
229
+ const r = await fetch('https://api.github.com/user/repos', {
230
+ method: 'POST',
231
+ headers: { authorization: `Bearer ${t.token}`, accept: 'application/vnd.github+json', 'user-agent': 'looply-canary', 'content-type': 'application/json' },
232
+ body: JSON.stringify({ name, private: true, auto_init: false, description: "Looply's pipeline canary: a throwaway repository Looply changes daily to prove its own pipeline." }),
233
+ });
234
+ const j = (await r.json().catch(() => ({})));
235
+ if (r.status !== 201 || typeof j.clone_url !== 'string')
236
+ return { ok: false, because: `GitHub said ${r.status}${j.message ? `: ${j.message}` : ''}` };
237
+ return { ok: true, cloneUrl: j.clone_url, fullName: j.full_name ?? name };
238
+ },
239
+ serveAdd,
240
+ };
241
+ }
242
+ //# sourceMappingURL=canary-cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canary-cmd.js","sourceRoot":"","sources":["../src/canary-cmd.ts"],"names":[],"mappings":";;;AAkCA,wCA4DC;AAED,kDASC;AAcD,sCAoBC;AA+ED,8CA0BC;AApPD,2DAA+C;AAC/C,qCAA4E;AAC5E,yCAAiC;AACjC,uCAAgH;AAChH,qCAA4C;AAC5C,mDAAmD;AACnD,6CAA2C;AAC3C,+CAA0C;AAC1C,uDAA+C;AAC/C,yDAAkF;AAClF,2CAAgE;AAEhE;;;;;;;;;;;GAWG;AAEU,QAAA,YAAY,GAA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EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC;YACtJ,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;QAC5E,CAAC;QACD,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { makeCanary, readCanaryRecord } from './canary';
2
+ import { type ServerClient } from './server-client';
3
+ /** Where the delivered commit is fetched to be read: the canary's own ref, outside refs/heads. */
4
+ export declare const CANARY_REF = "refs/looply/canary";
5
+ /**
6
+ * IS THIS CHECKOUT THIS PC'S CANARY? Both locks, read on the PC: `origin` is a repository named
7
+ * `looply-canary…` (`CANARY_REPO_NAME`) AND `CANARY.md` at the root starts with the marker. The
8
+ * server checks the first again on its side; nothing else in the daemon changes for any other repo.
9
+ */
10
+ export declare function isCanaryCheckout(cwd: string, originUrl: string | null): boolean;
11
+ /** Why the canary must not start now on this PC or for this project, or null. */
12
+ export declare function canaryOff(opts: {
13
+ stateDir: string;
14
+ env?: NodeJS.ProcessEnv;
15
+ home?: string;
16
+ }): string | null;
17
+ /** A server answer that means "not now, and asking again soon will not change it". */
18
+ export declare function canaryRefusal(e: unknown): string | null;
19
+ /** The daemon's canary, or null when this checkout is not a canary (the usual case: nothing runs). */
20
+ export declare function nodeCanary(opts: {
21
+ cwd: string;
22
+ stateDir: string;
23
+ projectId: string;
24
+ client: Pick<ServerClient, 'startCanary' | 'endCanary' | 'goalEvidence'>;
25
+ looplyVersion: string;
26
+ originUrl: string | null;
27
+ log(line: string): void;
28
+ }): ReturnType<typeof makeCanary> | null;
29
+ /** The card for every daemon's feature report on this PC: the canary record is machine-wide. */
30
+ export declare function canaryReportOnThisPc(home?: string): ReturnType<typeof readCanaryRecord>['report'];
31
+ //# sourceMappingURL=canary-wiring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canary-wiring.d.ts","sourceRoot":"","sources":["../src/canary-wiring.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAMxD,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGjE,kGAAkG;AAClG,eAAO,MAAM,UAAU,uBAAuB,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAU/E;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,IAAI,CAW3G;AAED,sFAAsF;AACtF,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAKvD;AAED,sGAAsG;AACtG,wBAAgB,UAAU,CAAC,IAAI,EAAE;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,GAAG,WAAW,GAAG,cAAc,CAAC,CAAC;IACzE,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI,CAqDvC;AAED,gGAAgG;AAChG,wBAAgB,oBAAoB,CAAC,IAAI,GAAE,MAAqB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,QAAQ,CAAC,CAG/G"}
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CANARY_REF = void 0;
4
+ exports.isCanaryCheckout = isCanaryCheckout;
5
+ exports.canaryOff = canaryOff;
6
+ exports.canaryRefusal = canaryRefusal;
7
+ exports.nodeCanary = nodeCanary;
8
+ exports.canaryReportOnThisPc = canaryReportOnThisPc;
9
+ const node_fs_1 = require("node:fs");
10
+ const node_path_1 = require("node:path");
11
+ const core_1 = require("@looply/core");
12
+ const canary_1 = require("./canary");
13
+ const delivery_rules_1 = require("./delivery-rules");
14
+ const feature_settings_cache_1 = require("./feature-settings-cache");
15
+ const github_api_1 = require("./github-api");
16
+ const machine_secrets_1 = require("./machine-secrets");
17
+ const machine_settings_1 = require("./machine-settings");
18
+ const server_client_1 = require("./server-client");
19
+ const setup_check_wiring_1 = require("./setup-check-wiring");
20
+ /** Where the delivered commit is fetched to be read: the canary's own ref, outside refs/heads. */
21
+ exports.CANARY_REF = 'refs/looply/canary';
22
+ /**
23
+ * IS THIS CHECKOUT THIS PC'S CANARY? Both locks, read on the PC: `origin` is a repository named
24
+ * `looply-canary…` (`CANARY_REPO_NAME`) AND `CANARY.md` at the root starts with the marker. The
25
+ * server checks the first again on its side; nothing else in the daemon changes for any other repo.
26
+ */
27
+ function isCanaryCheckout(cwd, originUrl) {
28
+ if (originUrl === null)
29
+ return false;
30
+ const name = (0, core_1.repoNameFromUrl)(originUrl);
31
+ if (name === null || !core_1.CANARY_REPO_NAME.test(name))
32
+ return false;
33
+ try {
34
+ const first = (0, node_fs_1.readFileSync)((0, node_path_1.join)(cwd, core_1.CANARY_FILE), 'utf8').replace(/^/, '').split(/\r?\n/)[0] ?? '';
35
+ return first.trim() === core_1.CANARY_MARKER;
36
+ }
37
+ catch {
38
+ return false;
39
+ }
40
+ }
41
+ /** Why the canary must not start now on this PC or for this project, or null. */
42
+ function canaryOff(opts) {
43
+ const env = opts.env ?? process.env;
44
+ const v = (env['LOOPLY_CANARY'] ?? '').trim().toLowerCase();
45
+ if (v === 'off' || v === '0' || v === 'false')
46
+ return 'switched off on this PC (LOOPLY_CANARY=off)';
47
+ try {
48
+ if ((0, machine_settings_1.readLocalMachineSettings)(opts.home).canary === false)
49
+ return 'switched off on this PC (looply canary off)';
50
+ }
51
+ catch {
52
+ /* an unreadable machine-settings.json is said by the daemon's own settings pass */
53
+ }
54
+ if ((0, feature_settings_cache_1.readFeatureSettingsCache)(opts.stateDir)?.settings?.canary?.enabled === false)
55
+ return 'switched off for the canary project (feature setting canary.enabled = false)';
56
+ return null;
57
+ }
58
+ /** A server answer that means "not now, and asking again soon will not change it". */
59
+ function canaryRefusal(e) {
60
+ if (!(e instanceof server_client_1.ServerError))
61
+ return null;
62
+ if (e.status === 404)
63
+ return 'this Looply server does not run pipeline canaries yet (it needs looply-api 0.5.45 or later), or the project is unknown';
64
+ if (e.status === 409 || e.status === 429 || e.status === 403 || e.status === 400)
65
+ return `the server would not start a canary: ${e.message}`;
66
+ return null;
67
+ }
68
+ /** The daemon's canary, or null when this checkout is not a canary (the usual case: nothing runs). */
69
+ function nodeCanary(opts) {
70
+ if (!isCanaryCheckout(opts.cwd, opts.originUrl))
71
+ return null;
72
+ const git = (0, setup_check_wiring_1.boundedGitExec)(opts.cwd, setup_check_wiring_1.NETWORK_GIT_TIMEOUT_MS);
73
+ const gh = opts.originUrl === null ? null : (0, delivery_rules_1.githubRepoOf)(opts.originUrl);
74
+ return (0, canary_1.makeCanary)({
75
+ home: (0, machine_secrets_1.looplyHome)(),
76
+ projectId: opts.projectId,
77
+ looplyVersion: opts.looplyVersion,
78
+ off: () => canaryOff({ stateDir: opts.stateDir }),
79
+ start: async (trigger) => opts.client.startCanary(opts.projectId, { trigger, looplyVersion: opts.looplyVersion }),
80
+ evidence: (goalId) => opts.client.goalEvidence(opts.projectId, goalId),
81
+ end: async (goalId) => {
82
+ await opts.client.endCanary(opts.projectId, goalId);
83
+ },
84
+ readDelivered: async ({ ref }) => {
85
+ /**
86
+ * Fetched into the canary's own private ref, never a branch: the served checkout's branches and files
87
+ * are never changed, and no other fetch (the daemon's, a run's) can move what is read in between,
88
+ * as it could FETCH_HEAD.
89
+ */
90
+ if (!/^[A-Za-z0-9._/-]{1,200}$/.test(ref) || ref.startsWith('-'))
91
+ return { ok: false, because: `"${ref}" is not a branch name` };
92
+ const f = await git(['fetch', '--no-tags', '--quiet', 'origin', `+refs/heads/${ref}:${exports.CANARY_REF}`]);
93
+ if (f.code !== 0)
94
+ return { ok: false, because: (f.stderr || f.stdout).trim().slice(0, 200) || `git fetch exited ${f.code}` };
95
+ const s = await git(['show', `${exports.CANARY_REF}:${core_1.CANARY_FILE}`]);
96
+ return s.code === 0 ? { ok: true, content: s.stdout } : { ok: false, because: (s.stderr || s.stdout).trim().slice(0, 200) || `git show exited ${s.code}` };
97
+ },
98
+ cleanUp: async ({ branch, runId }) => {
99
+ // Only the canary's own run branch: never the base, never a branch Looply did not name.
100
+ if (branch === null)
101
+ return { ok: true, detail: 'nothing was delivered, so there was nothing to clean up' };
102
+ if (!branch.startsWith('looply/'))
103
+ return { ok: false, because: `the delivered branch ${branch} is not a Looply run branch, so it was left alone` };
104
+ if (gh === null)
105
+ return { ok: false, because: 'origin is not a GitHub repository, so the branch could not be removed' };
106
+ const t = await (0, github_api_1.githubToken)();
107
+ if (t === null)
108
+ return { ok: false, because: 'this PC has no GitHub credentials Looply can use' };
109
+ const api = (0, github_api_1.makeGitHubApi)({ owner: gh.owner, repo: gh.repo, token: t.token });
110
+ const said = [];
111
+ const pull = await api.findPull(branch).catch(() => null);
112
+ if (pull !== null && pull.state === 'open') {
113
+ await api.closePull(pull.number, `Closed by Looply's pipeline canary (${runId}): it proved the pull request opens; nothing here is to be merged.`);
114
+ said.push(`closed pull request #${pull.number}`);
115
+ }
116
+ if (await api.branchExists(branch)) {
117
+ const r = await fetch(`https://api.github.com/repos/${encodeURIComponent(gh.owner)}/${encodeURIComponent(gh.repo)}/git/refs/heads/${branch.split('/').map(encodeURIComponent).join('/')}`, {
118
+ method: 'DELETE',
119
+ headers: { authorization: `Bearer ${t.token}`, accept: 'application/vnd.github+json', 'user-agent': 'looply-canary' },
120
+ });
121
+ if (r.status !== 204 && r.status !== 422)
122
+ return { ok: false, because: `GitHub would not delete ${branch} (HTTP ${r.status})` };
123
+ said.push(`deleted ${branch}`);
124
+ }
125
+ else
126
+ said.push(`${branch} was already gone`);
127
+ return { ok: true, detail: said.join('; ') };
128
+ },
129
+ refusal: canaryRefusal,
130
+ log: opts.log,
131
+ });
132
+ }
133
+ /** The card for every daemon's feature report on this PC: the canary record is machine-wide. */
134
+ function canaryReportOnThisPc(home = (0, machine_secrets_1.looplyHome)()) {
135
+ if (!(0, node_fs_1.existsSync)((0, node_path_1.join)(home, 'canary.json')))
136
+ return null;
137
+ return (0, canary_1.readCanaryRecord)(home).report;
138
+ }
139
+ //# sourceMappingURL=canary-wiring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canary-wiring.js","sourceRoot":"","sources":["../src/canary-wiring.ts"],"names":[],"mappings":";;;AAoBA,4CAUC;AAGD,8BAWC;AAGD,sCAKC;AAGD,gCA6DC;AAGD,oDAGC;AA1HD,qCAAmD;AACnD,yCAAiC;AACjC,uCAAiH;AACjH,qCAAwD;AACxD,qDAAgD;AAChD,qEAAoE;AACpE,6CAA0D;AAC1D,uDAA+C;AAC/C,yDAA8D;AAC9D,mDAAiE;AACjE,6DAA8E;AAE9E,kGAAkG;AACrF,QAAA,UAAU,GAAG,oBAAoB,CAAC;AAE/C;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,GAAW,EAAE,SAAwB;IACpE,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACrC,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,SAAS,CAAC,CAAC;IACxC,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,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D,OAAO,IAAA,yBAAgB,EAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AACvC,CAAC"}
@@ -0,0 +1,123 @@
1
+ import { type CanaryEvidence, type CanaryLocalFacts, type CanaryReport, type CanaryStageResult, type CanaryTrigger } from '@looply/core';
2
+ /**
3
+ * THE PIPELINE CANARY, ON THE PC (core `canary.ts` says why it exists).
4
+ *
5
+ * ─────────────────────────────────────────────────────────────────────────────
6
+ * Runs in the daemon that serves this PC's `looply-canary` checkout, on the five-minute cadence:
7
+ *
8
+ * 1. due? once a day, and once on each new Looply version; never while switched off
9
+ * (`looply canary off`, LOOPLY_CANARY=off, or the project's feature setting);
10
+ * 2. start ask the server for the day's canary goal (`POST …/canary-runs`): the server writes the
11
+ * goal and its two-Start grant; the daemon then takes it exactly as it takes a ticket;
12
+ * 3. watch read the goal's evidence as AutoRyn reads it, and judge each stage (`judgeCanary`):
13
+ * plan → round → gates → goal check → delivery → the expected line in the delivered
14
+ * commit → each environment → clean-up;
15
+ * 4. end once nothing is pending (or 4 h passed): the goal is abandoned on the server (no
16
+ * further Start), the canary's branch and pull request are removed, and the result is
17
+ * kept in `~/.looply/canary.json` — which every daemon on this PC puts in its feature
18
+ * report, so AutoRyn shows it per component and alerts once when a stage failed.
19
+ *
20
+ * Never throws; a server that does not know canaries (404) or refuses (not a canary project, off)
21
+ * is waited out for a day and said on the card.
22
+ * ─────────────────────────────────────────────────────────────────────────────
23
+ */
24
+ export declare const CANARY_RECORD = "canary.json";
25
+ /** After a refusal (old server, not a canary project, switched off), the next ask waits this long. */
26
+ export declare const CANARY_REFUSED_BACKOFF_MS: number;
27
+ /** After a failed ask (offline, 5xx), the next one waits this long. */
28
+ export declare const CANARY_RETRY_MS: number;
29
+ export interface CanaryRun {
30
+ /**
31
+ * The Looply project the run's goal belongs to. The record is machine-wide, but a goal can only be
32
+ * read and ended through its own project: a run of another project (a second canary checkout, a
33
+ * re-added one) is never followed here — see `makeCanary`.
34
+ */
35
+ projectId?: string;
36
+ runId: string;
37
+ goalId: string;
38
+ trigger: CanaryTrigger;
39
+ looplyVersion: string;
40
+ startedAt: string;
41
+ /** The delivered commit's check, once made (kept: the branch may be gone after the clean-up). */
42
+ result: CanaryLocalFacts['result'];
43
+ cleanup: CanaryLocalFacts['cleanup'];
44
+ /** The goal was ended on the server. */
45
+ ended: boolean;
46
+ stages: CanaryStageResult[];
47
+ /** Branch / pull request seen in the evidence (for the clean-up, even after the evidence moves on). */
48
+ branch: string | null;
49
+ pullRequestUrl: string | null;
50
+ }
51
+ export interface CanaryRecord {
52
+ version: 1;
53
+ current: CanaryRun | null;
54
+ /** The card: the run in progress, or the last finished one. */
55
+ report: CanaryReport | null;
56
+ lastPassedAt: string | null;
57
+ /** The Looply version the last run started on (a different one makes a run due). */
58
+ lastVersion: string | null;
59
+ /** When the last run started (daily cadence). */
60
+ lastStartedAt: string | null;
61
+ /** The last time the server would not start one, and why (waited out). */
62
+ refused: {
63
+ at: string;
64
+ because: string;
65
+ } | null;
66
+ /** The last time asking failed (offline), retried soon. */
67
+ failedAskAt: string | null;
68
+ }
69
+ export declare function readCanaryRecord(home: string): CanaryRecord;
70
+ export declare function writeCanaryRecord(home: string, record: CanaryRecord): void;
71
+ /** What the canary card adds to a checks report's notes: only a failure is news there. */
72
+ export declare function canaryNote(report: CanaryReport | null): string | null;
73
+ /** Why a run is due now, or null. */
74
+ export declare function canaryDue(record: CanaryRecord, version: string, now: number): CanaryTrigger | null;
75
+ export interface CanaryDeps {
76
+ /** Where the machine-wide record lives (`~/.looply`). */
77
+ home: string;
78
+ /** The Looply project this daemon serves: only a run of this project is followed here. */
79
+ projectId: string;
80
+ looplyVersion: string;
81
+ /** Why the canary must not run now (switched off on this PC or for the project), or null. */
82
+ off(): string | null;
83
+ start(trigger: CanaryTrigger): Promise<{
84
+ goalId: string;
85
+ runId: string;
86
+ }>;
87
+ evidence(goalId: string): Promise<CanaryEvidence>;
88
+ /** Abandon the goal on the server (no further Start). */
89
+ end(goalId: string): Promise<void>;
90
+ /** `CANARY.md` as the delivered ref has it: the base after a merge, else the pull request's branch. */
91
+ readDelivered(where: {
92
+ ref: string;
93
+ kind: 'base' | 'branch';
94
+ }): Promise<{
95
+ ok: true;
96
+ content: string;
97
+ } | {
98
+ ok: false;
99
+ because: string;
100
+ }>;
101
+ /** Close the pull request if still open and delete the canary's branch on origin. Never touches anything else. */
102
+ cleanUp(target: {
103
+ branch: string | null;
104
+ pullRequestUrl: string | null;
105
+ runId: string;
106
+ }): Promise<{
107
+ ok: true;
108
+ detail: string;
109
+ } | {
110
+ ok: false;
111
+ because: string;
112
+ }>;
113
+ /** A refusal the server gave (status and error code), so it is waited out rather than asked every tick. */
114
+ refusal?(e: unknown): string | null;
115
+ log(line: string): void;
116
+ now?: () => number;
117
+ }
118
+ /** The cadence's handle: `tick()` as often as the daemon likes; never throws. */
119
+ export declare function makeCanary(deps: CanaryDeps): {
120
+ tick(): Promise<void>;
121
+ running(): boolean;
122
+ };
123
+ //# sourceMappingURL=canary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canary.d.ts","sourceRoot":"","sources":["../src/canary.ts"],"names":[],"mappings":"AAEA,OAAO,EAQL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EACnB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAC3C,sGAAsG;AACtG,eAAO,MAAM,yBAAyB,QAAkB,CAAC;AACzD,uEAAuE;AACvE,eAAO,MAAM,eAAe,QAAc,CAAC;AAE3C,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,aAAa,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,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