create-egregore 0.21.1 → 0.21.3

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 (65) hide show
  1. package/assets/egregore-launcher.js +2 -2
  2. package/lib/renderer-install.js +42 -0
  3. package/lib/setup.js +15 -14
  4. package/package.json +2 -2
  5. package/runtime/claude/.claude/context/telemetry.md +27 -48
  6. package/runtime/claude/.claude/skills/issue/SKILL.md +13 -0
  7. package/runtime/claude/.claude/skills/view/SKILL.md +2 -1
  8. package/runtime/claude/bin/artifact-renderer-install.sh +157 -0
  9. package/runtime/claude/bin/artifact-renderer.sh +57 -0
  10. package/runtime/claude/bin/handoff-preview.sh +2 -4
  11. package/runtime/claude/bin/handoff-run.sh +4 -11
  12. package/runtime/claude/bin/lib/artifact-renderer/dependencies-lock.json +94 -0
  13. package/runtime/claude/bin/lib/artifact-renderer/dependencies.json +8 -0
  14. package/runtime/claude/bin/lib/dashboard-artifact.sh +2 -2
  15. package/runtime/claude/bin/lib/greeting.sh +2 -13
  16. package/runtime/claude/bin/post-update.sh +5 -0
  17. package/runtime/claude/bin/publish-artifact.sh +6 -27
  18. package/runtime/claude/bin/view-render.sh +2 -13
  19. package/runtime/claude/egregore_runtime/issue_reporting.py +38 -7
  20. package/runtime/claude/egregore_runtime/upgrade.py +51 -0
  21. package/runtime/claude/manifest.json +4 -0
  22. package/runtime/codex/bin/artifact-renderer-install.sh +157 -0
  23. package/runtime/codex/bin/artifact-renderer.sh +57 -0
  24. package/runtime/codex/bin/handoff-preview.sh +2 -4
  25. package/runtime/codex/bin/handoff-run.sh +4 -11
  26. package/runtime/codex/bin/lib/artifact-renderer/dependencies-lock.json +94 -0
  27. package/runtime/codex/bin/lib/artifact-renderer/dependencies.json +8 -0
  28. package/runtime/codex/bin/lib/dashboard-artifact.sh +2 -2
  29. package/runtime/codex/bin/lib/greeting.sh +2 -13
  30. package/runtime/codex/bin/post-update.sh +5 -0
  31. package/runtime/codex/bin/publish-artifact.sh +6 -27
  32. package/runtime/codex/bin/view-render.sh +2 -13
  33. package/runtime/codex/egregore_runtime/issue_reporting.py +38 -7
  34. package/runtime/codex/egregore_runtime/upgrade.py +51 -0
  35. package/runtime/codex/manifest.json +4 -0
  36. package/runtime/pi/bin/artifact-renderer-install.sh +157 -0
  37. package/runtime/pi/bin/artifact-renderer.sh +57 -0
  38. package/runtime/pi/bin/handoff-preview.sh +2 -4
  39. package/runtime/pi/bin/handoff-run.sh +4 -11
  40. package/runtime/pi/bin/lib/artifact-renderer/dependencies-lock.json +94 -0
  41. package/runtime/pi/bin/lib/artifact-renderer/dependencies.json +8 -0
  42. package/runtime/pi/bin/lib/dashboard-artifact.sh +2 -2
  43. package/runtime/pi/bin/lib/greeting.sh +2 -13
  44. package/runtime/pi/bin/pi-product-workflows.mjs +1 -4
  45. package/runtime/pi/bin/post-update.sh +5 -0
  46. package/runtime/pi/bin/publish-artifact.sh +6 -27
  47. package/runtime/pi/bin/view-render.sh +2 -13
  48. package/runtime/pi/egregore_runtime/issue_reporting.py +38 -7
  49. package/runtime/pi/egregore_runtime/upgrade.py +51 -0
  50. package/runtime/pi/manifest.json +4 -0
  51. package/runtime/prime/bin/artifact-renderer-install.sh +157 -0
  52. package/runtime/prime/bin/artifact-renderer.sh +57 -0
  53. package/runtime/prime/bin/handoff-preview.sh +2 -4
  54. package/runtime/prime/bin/handoff-run.sh +4 -11
  55. package/runtime/prime/bin/lib/artifact-renderer/dependencies-lock.json +94 -0
  56. package/runtime/prime/bin/lib/artifact-renderer/dependencies.json +8 -0
  57. package/runtime/prime/bin/lib/dashboard-artifact.sh +2 -2
  58. package/runtime/prime/bin/lib/greeting.sh +2 -13
  59. package/runtime/prime/bin/pi-product-workflows.mjs +1 -4
  60. package/runtime/prime/bin/post-update.sh +5 -0
  61. package/runtime/prime/bin/publish-artifact.sh +6 -27
  62. package/runtime/prime/bin/view-render.sh +2 -13
  63. package/runtime/prime/egregore_runtime/issue_reporting.py +38 -7
  64. package/runtime/prime/egregore_runtime/upgrade.py +51 -0
  65. package/runtime/prime/manifest.json +4 -0
@@ -121,7 +121,7 @@ mkdir -p /tmp
121
121
  } > "$_DB_MD" 2>/dev/null
122
122
 
123
123
  # --- Publish markdown → HTML → hosted URL ---
124
- # publish-artifact.sh handles HTML generation internally (npx egregore-artifacts)
124
+ # publish-artifact.sh handles HTML generation with the provisioned renderer.
125
125
  # then uploads. Don't pre-generate HTML — that causes double-wrapping.
126
126
  # https:// URLs are universally cmd+clickable across all terminal emulators.
127
127
  #
@@ -233,7 +233,7 @@ else
233
233
  if [ -z "$DASHBOARD_URL" ]; then
234
234
  _DB_HTML="/tmp/egregore-artifacts/dashboard-${EGREGORE_SESSION_ID}.html"
235
235
  mkdir -p /tmp/egregore-artifacts
236
- if npx egregore-artifacts@latest document "$_DB_MD" --output "$_DB_HTML" --no-open >/dev/null 2>&1 && [ -f "$_DB_HTML" ]; then
236
+ if bash "$SCRIPT_DIR/bin/artifact-renderer.sh" document "$_DB_MD" --output "$_DB_HTML" --no-open >/dev/null 2>&1 && [ -f "$_DB_HTML" ]; then
237
237
  DASHBOARD_URL="file://${_DB_HTML}"
238
238
  fi
239
239
  fi
@@ -481,19 +481,8 @@ bash "$SCRIPT_DIR/bin/telemetry.sh" emit "session_start" \
481
481
  # --- Health check-in (background, non-blocking) ---
482
482
  bash "$SCRIPT_DIR/bin/startup-check.sh" >/dev/null 2>&1 &
483
483
 
484
- # --- Warm npx cache for egregore-artifacts (background, throttled) ---
485
- # publish-artifact.sh spawns `npx egregore-artifacts` — first run in a
486
- # fresh npx cache pays a 5-10s npm download. Warmup is throttled to
487
- # once per hour via a marker file so we don't storm npm when a user
488
- # opens many tabs, and don't start runaway retry loops when offline.
489
- _WARM_TS_FILE="$HOME/.cache/egregore/npx-warm-ts"
490
- mkdir -p "$(dirname "$_WARM_TS_FILE")" 2>/dev/null
491
- _WARM_LAST=$(cat "$_WARM_TS_FILE" 2>/dev/null || echo 0)
492
- _WARM_NOW=$(date +%s)
493
- if [ $(( _WARM_NOW - _WARM_LAST )) -gt 3600 ]; then
494
- (npx -y egregore-artifacts@latest --help >/dev/null 2>&1 \
495
- && echo "$_WARM_NOW" > "$_WARM_TS_FILE" &) >/dev/null 2>&1
496
- fi
484
+ # Artifact dependencies are provisioned during explicit setup/update. Startup
485
+ # must not warm a floating npx cache that the offline renderer cannot resolve.
497
486
 
498
487
  # Clean up temp files
499
488
  rm -rf "$CTX_DIR"
@@ -106,10 +106,7 @@ export function parseViewRequest(root, rawArgs) {
106
106
  }
107
107
 
108
108
  function rendererCommand(root) {
109
- const local = join(root, "packages", "egregore-artifacts", "bin", "cli.js");
110
- const react = join(root, "packages", "egregore-artifacts", "node_modules", "react");
111
- if (existsSync(local) && existsSync(react)) return { command: "node", prefix: [local] };
112
- return { command: "npx", prefix: ["-y", "egregore-artifacts@latest"] };
109
+ return { command: "bash", prefix: [join(root, "bin", "artifact-renderer.sh")] };
113
110
  }
114
111
 
115
112
  function artifactPath(output) {
@@ -10,6 +10,11 @@
10
10
 
11
11
  set -euo pipefail
12
12
 
13
+ # This migration entry point is invoked by explicit /update, never startup.
14
+ # The helper preserves a previous working install if provisioning fails.
15
+ SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
16
+ bash "$SCRIPT_DIR/bin/artifact-renderer-install.sh"
17
+
13
18
  MIGRATED=0
14
19
 
15
20
  # --- Migration: commands → skills (CC 2.0+) ---
@@ -242,34 +242,13 @@ else
242
242
  fi
243
243
  fi
244
244
 
245
- # Prefer the in-repo package copy when it's present AND its dependencies
246
- # have been installed — that way local edits to packages/egregore-artifacts
247
- # are exercised without waiting for an npm release. Fall back to the
248
- # published `npx egregore-artifacts` otherwise.
249
- # Set EGREGORE_USE_PUBLISHED=1 to force the npm-published renderer even
250
- # when a local install is present — useful in the upstream dev repo to
251
- # dogfood what teammates and OSS users actually run.
252
- LOCAL_CLI="$SCRIPT_DIR/packages/egregore-artifacts/bin/cli.js"
245
+ # Use the same provisioned renderer as previews and /view. Rendering never
246
+ # downloads a package; EGREGORE_USE_PUBLISHED skips the source checkout.
253
247
  RENDER_ERROR="/tmp/egregore-artifacts/render-error-$$.log"
254
- if [ "${EGREGORE_USE_PUBLISHED:-0}" != "1" ] && [ -f "$LOCAL_CLI" ] && [ -d "$SCRIPT_DIR/packages/egregore-artifacts/node_modules/react" ]; then
255
- if ! bash "$SCRIPT_DIR/bin/node-run.sh" "$LOCAL_CLI" "${RENDER_ARGS[@]}" >/dev/null 2>"$RENDER_ERROR"; then
256
- sed -n '1,4p' "$RENDER_ERROR" >&2
257
- rm -f "$RENDER_ERROR"
258
- exit 5
259
- fi
260
- else
261
- # Installed published renderer only — never npx/@latest: a hidden
262
- # registry fetch of a floating version is not an acceptable renderer.
263
- PUBLISHED_CLI="$(command -v egregore-artifacts || true)"
264
- if [ -z "$PUBLISHED_CLI" ]; then
265
- echo "no artifact renderer available: the checked-out packages/egregore-artifacts is unusable and no installed egregore-artifacts was found" >&2
266
- exit 5
267
- fi
268
- if ! bash "$SCRIPT_DIR/bin/node-run.sh" "$PUBLISHED_CLI" "${RENDER_ARGS[@]}" >/dev/null 2>"$RENDER_ERROR"; then
269
- sed -n '1,4p' "$RENDER_ERROR" >&2
270
- rm -f "$RENDER_ERROR"
271
- exit 5
272
- fi
248
+ if ! bash "$SCRIPT_DIR/bin/artifact-renderer.sh" "${RENDER_ARGS[@]}" >/dev/null 2>"$RENDER_ERROR"; then
249
+ sed -n '1,4p' "$RENDER_ERROR" >&2
250
+ rm -f "$RENDER_ERROR"
251
+ exit 5
273
252
  fi
274
253
  rm -f "$RENDER_ERROR"
275
254
  fi
@@ -49,19 +49,8 @@ _open() {
49
49
  }
50
50
 
51
51
  # --- Resolve the packaged deterministic renderer (never fetch, never npx) ---
52
- if [ -f "$SCRIPT_DIR/packages/egregore-artifacts/bin/cli.js" ] && [ -d "$SCRIPT_DIR/packages/egregore-artifacts/node_modules/react" ]; then
53
- RENDER=(bash "$SCRIPT_DIR/bin/node-run.sh" "$SCRIPT_DIR/packages/egregore-artifacts/bin/cli.js")
54
- RENDER_ID="$SCRIPT_DIR/packages/egregore-artifacts/bin/cli.js"
55
- elif [ -f "$SCRIPT_DIR/packages/egregore-artifacts/bin/cli.js" ]; then
56
- echo "The checked-out artifact renderer is missing its local dependencies." >&2
57
- exit 1
58
- elif command -v egregore-artifacts >/dev/null 2>&1; then
59
- RENDER=(bash "$SCRIPT_DIR/bin/node-run.sh" "$(command -v egregore-artifacts)")
60
- RENDER_ID="$(command -v egregore-artifacts)"
61
- else
62
- echo "The local artifact renderer is not installed for this instance." >&2
63
- exit 1
64
- fi
52
+ RENDER_ID="$(bash "$SCRIPT_DIR/bin/artifact-renderer.sh" --resolve)" || exit 1
53
+ RENDER=(bash "$SCRIPT_DIR/bin/node-run.sh" "$RENDER_ID")
65
54
 
66
55
  # --- Live surfaces render fresh every time (their data is the present) ------
67
56
  case "$TYPE" in
@@ -21,6 +21,26 @@ from .policy import scope_allows_path
21
21
  KINDS = {"bug", "improvement", "question"}
22
22
  AREAS = {"runtime", "onboarding", "connectors", "site", "other"}
23
23
  SEVERITIES = {"critical", "high", "normal"}
24
+ SUPPORT_STATES = {"filed", "failed", "submitting", "uncertain"}
25
+
26
+
27
+ def support_receipt(result, identifier):
28
+ """Accept only a receipt for this request; filing never proves notification."""
29
+ if (not isinstance(result, dict) or result.get('request_id') != identifier
30
+ or not isinstance(result.get('submission_state'), str)
31
+ or result['submission_state'] not in SUPPORT_STATES):
32
+ raise ValueError(f"private support returned an invalid receipt; keep request {identifier} and use report-status")
33
+ state = result['submission_state']
34
+ notices = {
35
+ 'filed': 'Filed with Egregore support. Telegram delivery has not been verified.',
36
+ 'failed': 'Report preserved; support filing failed. Retry this same request.',
37
+ 'submitting': 'Report preserved; support filing is not confirmed. Keep this request ID and check report-status.',
38
+ 'uncertain': 'Report preserved; support filing needs reconciliation. Keep this request ID and check report-status.',
39
+ }
40
+ return {'request_id': identifier, 'submission_state': state,
41
+ 'retryable': state == 'failed',
42
+ 'reconciliation_needed': state in {'submitting', 'uncertain'},
43
+ 'notification_state': 'unverified', 'notice': notices[state]}
24
44
 
25
45
 
26
46
  def _scrub(value, *, public=False):
@@ -207,18 +227,29 @@ class FrameworkReporting:
207
227
  return {'request_id':identifier,'status':result['status'],'github_url':result['github_url']}
208
228
  credential, _ = self._verified_credential(state['destination'],state['authenticated_org'])
209
229
  state['status'] = 'submitting'; GitHubIssues._save(path,state)
210
- code, result = self.api(self.root,state['destination'],'/api/v1/support-reports',
211
- {'request_id':identifier, **state['payload']},credential=credential)
212
- if code >= 400:
230
+ try:
231
+ code, result = self.api(self.root,state['destination'],'/api/v1/support-reports',
232
+ {'request_id':identifier, **state['payload']},credential=credential)
233
+ except OSError:
234
+ state['status'] = 'reconciliation_needed'; GitHubIssues._save(path,state)
235
+ raise OSError(f"private support response unavailable; keep request {identifier} and use report-status or confirm this same preview") from None
236
+ if not 200 <= code < 300:
213
237
  state['status'] = 'reconciliation_needed'; GitHubIssues._save(path,state)
214
238
  raise ValueError(f"private support request {identifier} needs recovery (HTTP {code}); use report-status or confirm this same preview")
215
- state['status'] = result.get('submission_state','unknown'); GitHubIssues._save(path,state)
216
- return result
239
+ try:
240
+ receipt = support_receipt(result, identifier)
241
+ except ValueError:
242
+ state['status'] = 'reconciliation_needed'; GitHubIssues._save(path,state)
243
+ raise
244
+ state['status'] = receipt['submission_state']; GitHubIssues._save(path,state)
245
+ if state['status'] != 'filed':
246
+ raise ValueError(f"private support request {identifier} needs recovery ({state['status']}); use report-status or confirm this same preview")
247
+ return receipt
217
248
 
218
249
  def status(self, identifier):
219
250
  path, state = self._load('report',identifier,write=False)
220
251
  credential, _ = self._verified_credential(state['destination'],state['authenticated_org'])
221
252
  code, result = self.api(self.root,state['destination'],f'/api/v1/support-reports/{identifier}',credential=credential)
222
- if code >= 400:
253
+ if not 200 <= code < 300:
223
254
  raise ValueError(f"private support status unavailable (HTTP {code}); keep request {identifier}")
224
- return result
255
+ return support_receipt(result, identifier)
@@ -17,6 +17,7 @@ from __future__ import annotations
17
17
  import json
18
18
  import os
19
19
  import re
20
+ import signal
20
21
  import subprocess
21
22
  import sys
22
23
  import time
@@ -27,6 +28,8 @@ from typing import Any, Mapping
27
28
  from .adapters.qmd import QMD_VERSION, RERANKING_ENABLED, QmdLocalRetriever
28
29
 
29
30
  SCHEMA_VERSION = "egregore-runtime-upgrade/v1"
31
+ _RENDERER_INSTALL_TIMEOUT_SECONDS = 180
32
+ _RENDERER_TERMINATE_GRACE_SECONDS = 5
30
33
 
31
34
  # Stage keys in preparation order. Labels are the user-facing truth shown by
32
35
  # Settings; keep them in plain team language.
@@ -628,6 +631,54 @@ class UpgradeEngine:
628
631
  if probe.returncode != 0:
629
632
  self._fail(state, "node", "the selected Node runtime failed its version probe")
630
633
  return False
634
+ # Explicit Runtime preparation owns package provisioning. Preview and
635
+ # session startup only resolve installed renderers. Older candidates
636
+ # predate this helper and retain their original upgrade contract.
637
+ renderer_installer = (
638
+ Path(state.get("installed_path") or "")
639
+ / "runtime" / APPLY_TREE / "bin" / "artifact-renderer-install.sh"
640
+ )
641
+ if renderer_installer.is_file():
642
+ environment = {**os.environ, **self.retriever.environment}
643
+ environment["PATH"] = str(Path(node).parent) + os.pathsep + environment.get("PATH", "")
644
+ try:
645
+ with subprocess.Popen(
646
+ ("bash", str(renderer_installer), "--root", str(self.repository_root)),
647
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True,
648
+ cwd=self.repository_root, env=environment, start_new_session=True,
649
+ ) as renderer:
650
+ try:
651
+ stdout, stderr = renderer.communicate(timeout=_RENDERER_INSTALL_TIMEOUT_SECONDS)
652
+ except subprocess.TimeoutExpired:
653
+ # npm is a child of the installer shell. Stop the entire
654
+ # group so its EXIT cleanup can run without an orphaned
655
+ # package manager still writing into the staging tree.
656
+ try:
657
+ os.killpg(renderer.pid, signal.SIGTERM)
658
+ except ProcessLookupError:
659
+ pass
660
+ try:
661
+ renderer.communicate(timeout=_RENDERER_TERMINATE_GRACE_SECONDS)
662
+ except subprocess.TimeoutExpired:
663
+ pass
664
+ finally:
665
+ # A child may ignore TERM even after Bash exits.
666
+ try:
667
+ os.killpg(renderer.pid, signal.SIGKILL)
668
+ except ProcessLookupError:
669
+ pass
670
+ renderer.communicate()
671
+ raise
672
+ except subprocess.TimeoutExpired:
673
+ self._fail(state, "node", f"artifact renderer provisioning timed out after {_RENDERER_INSTALL_TIMEOUT_SECONDS} seconds; retry preparation")
674
+ return False
675
+ except OSError as exc:
676
+ self._fail(state, "node", f"artifact renderer provisioning failed: {exc}")
677
+ return False
678
+ if renderer.returncode != 0:
679
+ detail = (stderr or stdout).strip()
680
+ self._fail(state, "node", f"artifact renderer provisioning failed: {detail}")
681
+ return False
631
682
  self._mark(state, "node", "done", f"{probe.stdout.strip()} at instance-selected path")
632
683
  return True
633
684
 
@@ -127,6 +127,8 @@
127
127
  "bin/agent.sh",
128
128
  "bin/api-call.sh",
129
129
  "bin/artifact-register.sh",
130
+ "bin/artifact-renderer-install.sh",
131
+ "bin/artifact-renderer.sh",
130
132
  "bin/artifact-writeback.sh",
131
133
  "bin/artifacts.sh",
132
134
  "bin/attendant.sh",
@@ -173,6 +175,8 @@
173
175
  "bin/issue.sh",
174
176
  "bin/knowledge.sh",
175
177
  "bin/lib/artifact-id.sh",
178
+ "bin/lib/artifact-renderer/dependencies-lock.json",
179
+ "bin/lib/artifact-renderer/dependencies.json",
176
180
  "bin/lib/config.sh",
177
181
  "bin/lib/context.sh",
178
182
  "bin/lib/dashboard-artifact.sh",