@llblab/pi-kit 0.1.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.
- package/AGENTS.md +35 -0
- package/BACKLOG.md +3 -0
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +43 -0
- package/node_modules/@llblab/pi-actors/AGENTS.md +150 -0
- package/node_modules/@llblab/pi-actors/BACKLOG.md +6 -0
- package/node_modules/@llblab/pi-actors/CHANGELOG.md +865 -0
- package/node_modules/@llblab/pi-actors/README.md +231 -0
- package/node_modules/@llblab/pi-actors/banner.jpg +0 -0
- package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/artifact-manifest.json +9 -0
- package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/control-endpoint.json +6 -0
- package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/control-record.json +9 -0
- package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/recipe-summary.json +8 -0
- package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/run-state.json +10 -0
- package/node_modules/@llblab/pi-actors/dist/fixtures/protocol/trace-event.json +9 -0
- package/node_modules/@llblab/pi-actors/dist/index.d.ts +7 -0
- package/node_modules/@llblab/pi-actors/dist/index.js +17 -0
- package/node_modules/@llblab/pi-actors/dist/lib/async-runs.d.ts +146 -0
- package/node_modules/@llblab/pi-actors/dist/lib/async-runs.js +800 -0
- package/node_modules/@llblab/pi-actors/dist/lib/automatic-review-runtime.d.ts +20 -0
- package/node_modules/@llblab/pi-actors/dist/lib/automatic-review-runtime.js +103 -0
- package/node_modules/@llblab/pi-actors/dist/lib/command-templates.d.ts +85 -0
- package/node_modules/@llblab/pi-actors/dist/lib/command-templates.js +804 -0
- package/node_modules/@llblab/pi-actors/dist/lib/config.d.ts +34 -0
- package/node_modules/@llblab/pi-actors/dist/lib/config.js +216 -0
- package/node_modules/@llblab/pi-actors/dist/lib/control-projection.d.ts +20 -0
- package/node_modules/@llblab/pi-actors/dist/lib/control-projection.js +66 -0
- package/node_modules/@llblab/pi-actors/dist/lib/control.d.ts +15 -0
- package/node_modules/@llblab/pi-actors/dist/lib/control.js +97 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-consolidation-transaction.d.ts +65 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-consolidation-transaction.js +610 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-consolidation.d.ts +35 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-consolidation.js +126 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-review.d.ts +56 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-review.js +254 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-sleep.d.ts +65 -0
- package/node_modules/@llblab/pi-actors/dist/lib/draft-sleep.js +467 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution-output.d.ts +25 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution-output.js +88 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution-sessions.d.ts +17 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution-sessions.js +85 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution.d.ts +99 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution.js +725 -0
- package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.d.ts +21 -0
- package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.js +141 -0
- package/node_modules/@llblab/pi-actors/dist/lib/file-state.d.ts +18 -0
- package/node_modules/@llblab/pi-actors/dist/lib/file-state.js +310 -0
- package/node_modules/@llblab/pi-actors/dist/lib/identity.d.ts +9 -0
- package/node_modules/@llblab/pi-actors/dist/lib/identity.js +27 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-actions.d.ts +16 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-actions.js +57 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-command.d.ts +7 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-command.js +37 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-overlay.d.ts +100 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-overlay.js +824 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector.d.ts +20 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector.js +136 -0
- package/node_modules/@llblab/pi-actors/dist/lib/limits.d.ts +28 -0
- package/node_modules/@llblab/pi-actors/dist/lib/limits.js +28 -0
- package/node_modules/@llblab/pi-actors/dist/lib/model-context.d.ts +56 -0
- package/node_modules/@llblab/pi-actors/dist/lib/model-context.js +220 -0
- package/node_modules/@llblab/pi-actors/dist/lib/observability.d.ts +186 -0
- package/node_modules/@llblab/pi-actors/dist/lib/observability.js +951 -0
- package/node_modules/@llblab/pi-actors/dist/lib/paths.d.ts +27 -0
- package/node_modules/@llblab/pi-actors/dist/lib/paths.js +72 -0
- package/node_modules/@llblab/pi-actors/dist/lib/pi.d.ts +19 -0
- package/node_modules/@llblab/pi-actors/dist/lib/pi.js +21 -0
- package/node_modules/@llblab/pi-actors/dist/lib/preflight-diagnostics.d.ts +27 -0
- package/node_modules/@llblab/pi-actors/dist/lib/preflight-diagnostics.js +86 -0
- package/node_modules/@llblab/pi-actors/dist/lib/prompts.d.ts +24 -0
- package/node_modules/@llblab/pi-actors/dist/lib/prompts.js +49 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipe-control.d.ts +7 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipe-control.js +43 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-context.d.ts +36 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-context.js +197 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-discovery.d.ts +77 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-discovery.js +783 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-references.d.ts +113 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-references.js +1108 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-usage.d.ts +21 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-usage.js +494 -0
- package/node_modules/@llblab/pi-actors/dist/lib/registry.d.ts +67 -0
- package/node_modules/@llblab/pi-actors/dist/lib/registry.js +504 -0
- package/node_modules/@llblab/pi-actors/dist/lib/review-control.d.ts +14 -0
- package/node_modules/@llblab/pi-actors/dist/lib/review-control.js +110 -0
- package/node_modules/@llblab/pi-actors/dist/lib/review-diagnostics.d.ts +11 -0
- package/node_modules/@llblab/pi-actors/dist/lib/review-diagnostics.js +148 -0
- package/node_modules/@llblab/pi-actors/dist/lib/review-projection.d.ts +14 -0
- package/node_modules/@llblab/pi-actors/dist/lib/review-projection.js +166 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-evidence-policy.d.ts +95 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-evidence-policy.js +177 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.d.ts +18 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.js +125 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-artifacts.d.ts +21 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-artifacts.js +68 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control-delivery.d.ts +28 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control-delivery.js +150 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control.d.ts +21 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control.js +89 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-controls.d.ts +39 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-controls.js +283 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-identity.d.ts +5 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-identity.js +11 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-index.d.ts +27 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-index.js +142 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-ownership.d.ts +7 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-ownership.js +96 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-parent-teardown.d.ts +51 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-parent-teardown.js +172 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-process.d.ts +22 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-process.js +125 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-retention.d.ts +18 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-retention.js +108 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-start.d.ts +12 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-start.js +68 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-status.d.ts +10 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-status.js +68 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.d.ts +48 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.js +491 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runtime-identity.d.ts +7 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runtime-identity.js +35 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runtime-triage.d.ts +29 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runtime-triage.js +60 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runtime.d.ts +69 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runtime.js +339 -0
- package/node_modules/@llblab/pi-actors/dist/lib/schema.d.ts +60 -0
- package/node_modules/@llblab/pi-actors/dist/lib/schema.js +428 -0
- package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.d.ts +45 -0
- package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.js +204 -0
- package/node_modules/@llblab/pi-actors/dist/lib/state-readers.d.ts +21 -0
- package/node_modules/@llblab/pi-actors/dist/lib/state-readers.js +74 -0
- package/node_modules/@llblab/pi-actors/dist/lib/temp.d.ts +10 -0
- package/node_modules/@llblab/pi-actors/dist/lib/temp.js +90 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-lineage-transaction.d.ts +27 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-lineage-transaction.js +597 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-lineage.d.ts +24 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-lineage.js +98 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-scheduler.d.ts +80 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-scheduler.js +494 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-transaction.d.ts +50 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review-transaction.js +362 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review.d.ts +56 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tool-review.js +197 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-access.d.ts +19 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-access.js +44 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-inspect.d.ts +15 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-inspect.js +532 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-local.d.ts +17 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-local.js +191 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-message.d.ts +9 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-message.js +139 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-register.d.ts +18 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-register.js +41 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-response.d.ts +20 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-response.js +243 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-spawn.d.ts +15 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-spawn.js +133 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools.d.ts +28 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools.js +49 -0
- package/node_modules/@llblab/pi-actors/dist/lib/trace-projection.d.ts +22 -0
- package/node_modules/@llblab/pi-actors/dist/lib/trace-projection.js +231 -0
- package/node_modules/@llblab/pi-actors/dist/pi-actors/index.js +1 -0
- package/node_modules/@llblab/pi-actors/dist/scripts/async-runner.mjs +555 -0
- package/node_modules/@llblab/pi-actors/dist/scripts/build-dist.mjs +60 -0
- package/node_modules/@llblab/pi-actors/dist/scripts/conformance.mjs +63 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/SKILL.md +126 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/command-validate.json +13 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/jsonl-tail.json +10 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/recipe-validate.json +11 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/resource-locker-snapshot.json +11 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/resource-locker.json +25 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/run-ops-snapshot.json +15 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/run-state-files.json +13 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/recipes/run-summary.json +9 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/references/diagnostics.md +44 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/references/persistent-tools.md +76 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/references/recipes.md +51 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/references/runs.md +41 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/scripts/resource-locker.mjs +425 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/scripts/run-utils.mjs +164 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/scripts/validate-recipe.mjs +370 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/SKILL.md +33 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/bundle.json +77 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/file-write.json +14 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/manifest.json +14 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/report.json +39 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/recipes/write.json +53 -0
- package/node_modules/@llblab/pi-actors/dist/skills/artifacts/scripts/artifact-utils.mjs +63 -0
- package/node_modules/@llblab/pi-actors/dist/skills/music-player/SKILL.md +57 -0
- package/node_modules/@llblab/pi-actors/dist/skills/music-player/genapps/music-player.mjs +360 -0
- package/node_modules/@llblab/pi-actors/dist/skills/music-player/recipes/playback.json +29 -0
- package/node_modules/@llblab/pi-actors/dist/skills/music-player/scripts/playback-client.mjs +143 -0
- package/node_modules/@llblab/pi-actors/dist/skills/music-player/scripts/playback.mjs +1446 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/SKILL.md +37 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/changelog-head.json +11 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/changelog-section.json +11 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/docs-maintenance.json +66 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/git-log.json +11 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/git-status.json +9 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/markdown-index.json +14 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/package-summary.json +9 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/release-readiness.json +115 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/release-summary.json +74 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/repo-health.json +75 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/run-ops.json +56 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/recipes/skill-summary.json +11 -0
- package/node_modules/@llblab/pi-actors/dist/skills/project-work/scripts/project-utils.mjs +89 -0
- package/node_modules/@llblab/pi-actors/dist/skills/recipe-memory/SKILL.md +36 -0
- package/node_modules/@llblab/pi-actors/dist/skills/recipe-memory/recipes/draft-review.json +14 -0
- package/node_modules/@llblab/pi-actors/dist/skills/recipe-memory/recipes/tool-review.json +14 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/SKILL.md +84 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/architect.json +82 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/checkpoint-continuation.json +51 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/development-tasking.json +67 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/lens-review.json +63 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/quorum-review.json +65 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/research-synthesis.json +81 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/review-readiness.json +59 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-artifact.json +21 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-checkpoint.json +21 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-conflict-report.json +19 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-contradiction-map.json +20 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-critic.json +22 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-evidence-map.json +20 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-followup.json +21 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-judge.json +22 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-merge.json +24 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-normalize.json +20 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-plan.json +20 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-preflight.json +18 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-prompt.json +16 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-prompts.json +39 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-quorum.json +31 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-review-coordinator.json +170 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-review.json +26 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-task-card.json +22 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-tools.json +15 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/recipes/subagent-verify.json +23 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/references/development-swarm.md +189 -0
- package/node_modules/@llblab/pi-actors/dist/skills/swarm/references/review-swarms.md +115 -0
- package/node_modules/@llblab/pi-actors/docs/README.md +20 -0
- package/node_modules/@llblab/pi-actors/docs/actor-inspector.md +50 -0
- package/node_modules/@llblab/pi-actors/docs/async-runs.md +141 -0
- package/node_modules/@llblab/pi-actors/docs/command-templates.md +321 -0
- package/node_modules/@llblab/pi-actors/docs/recipe-library.md +89 -0
- package/node_modules/@llblab/pi-actors/docs/releasing.md +28 -0
- package/node_modules/@llblab/pi-actors/docs/template-recipes.md +175 -0
- package/node_modules/@llblab/pi-actors/docs/tool-registry.md +90 -0
- package/node_modules/@llblab/pi-actors/fixtures/protocol/artifact-manifest.json +9 -0
- package/node_modules/@llblab/pi-actors/fixtures/protocol/control-endpoint.json +6 -0
- package/node_modules/@llblab/pi-actors/fixtures/protocol/control-record.json +9 -0
- package/node_modules/@llblab/pi-actors/fixtures/protocol/recipe-summary.json +8 -0
- package/node_modules/@llblab/pi-actors/fixtures/protocol/run-state.json +10 -0
- package/node_modules/@llblab/pi-actors/fixtures/protocol/trace-event.json +9 -0
- package/node_modules/@llblab/pi-actors/index.ts +30 -0
- package/node_modules/@llblab/pi-actors/lib/async-runs.ts +1245 -0
- package/node_modules/@llblab/pi-actors/lib/automatic-review-runtime.ts +148 -0
- package/node_modules/@llblab/pi-actors/lib/command-templates.ts +1116 -0
- package/node_modules/@llblab/pi-actors/lib/config.ts +261 -0
- package/node_modules/@llblab/pi-actors/lib/control-projection.ts +105 -0
- package/node_modules/@llblab/pi-actors/lib/control.ts +117 -0
- package/node_modules/@llblab/pi-actors/lib/draft-consolidation-transaction.ts +821 -0
- package/node_modules/@llblab/pi-actors/lib/draft-consolidation.ts +181 -0
- package/node_modules/@llblab/pi-actors/lib/draft-review.ts +325 -0
- package/node_modules/@llblab/pi-actors/lib/draft-sleep.ts +575 -0
- package/node_modules/@llblab/pi-actors/lib/execution-output.ts +123 -0
- package/node_modules/@llblab/pi-actors/lib/execution-sessions.ts +111 -0
- package/node_modules/@llblab/pi-actors/lib/execution.ts +1153 -0
- package/node_modules/@llblab/pi-actors/lib/extension-runtime.ts +181 -0
- package/node_modules/@llblab/pi-actors/lib/file-state.ts +306 -0
- package/node_modules/@llblab/pi-actors/lib/identity.ts +29 -0
- package/node_modules/@llblab/pi-actors/lib/inspector-actions.ts +79 -0
- package/node_modules/@llblab/pi-actors/lib/inspector-command.ts +54 -0
- package/node_modules/@llblab/pi-actors/lib/inspector-overlay.ts +901 -0
- package/node_modules/@llblab/pi-actors/lib/inspector.ts +204 -0
- package/node_modules/@llblab/pi-actors/lib/limits.ts +29 -0
- package/node_modules/@llblab/pi-actors/lib/model-context.ts +359 -0
- package/node_modules/@llblab/pi-actors/lib/observability.ts +1337 -0
- package/node_modules/@llblab/pi-actors/lib/paths.ts +111 -0
- package/node_modules/@llblab/pi-actors/lib/pi.ts +47 -0
- package/node_modules/@llblab/pi-actors/lib/preflight-diagnostics.ts +132 -0
- package/node_modules/@llblab/pi-actors/lib/prompts.ts +69 -0
- package/node_modules/@llblab/pi-actors/lib/recipe-control.ts +52 -0
- package/node_modules/@llblab/pi-actors/lib/recipes-context.ts +268 -0
- package/node_modules/@llblab/pi-actors/lib/recipes-discovery.ts +1060 -0
- package/node_modules/@llblab/pi-actors/lib/recipes-references.ts +1598 -0
- package/node_modules/@llblab/pi-actors/lib/recipes-usage.ts +638 -0
- package/node_modules/@llblab/pi-actors/lib/registry.ts +806 -0
- package/node_modules/@llblab/pi-actors/lib/review-control.ts +136 -0
- package/node_modules/@llblab/pi-actors/lib/review-diagnostics.ts +164 -0
- package/node_modules/@llblab/pi-actors/lib/review-projection.ts +196 -0
- package/node_modules/@llblab/pi-actors/lib/run-evidence-policy.ts +242 -0
- package/node_modules/@llblab/pi-actors/lib/run-ui-runtime.ts +155 -0
- package/node_modules/@llblab/pi-actors/lib/runs-artifacts.ts +96 -0
- package/node_modules/@llblab/pi-actors/lib/runs-control-delivery.ts +209 -0
- package/node_modules/@llblab/pi-actors/lib/runs-control.ts +148 -0
- package/node_modules/@llblab/pi-actors/lib/runs-controls.ts +282 -0
- package/node_modules/@llblab/pi-actors/lib/runs-identity.ts +14 -0
- package/node_modules/@llblab/pi-actors/lib/runs-index.ts +192 -0
- package/node_modules/@llblab/pi-actors/lib/runs-ownership.ts +136 -0
- package/node_modules/@llblab/pi-actors/lib/runs-parent-teardown.ts +257 -0
- package/node_modules/@llblab/pi-actors/lib/runs-process.ts +174 -0
- package/node_modules/@llblab/pi-actors/lib/runs-retention.ts +140 -0
- package/node_modules/@llblab/pi-actors/lib/runs-start.ts +113 -0
- package/node_modules/@llblab/pi-actors/lib/runs-status.ts +101 -0
- package/node_modules/@llblab/pi-actors/lib/runs-trace.ts +611 -0
- package/node_modules/@llblab/pi-actors/lib/runtime-identity.ts +39 -0
- package/node_modules/@llblab/pi-actors/lib/runtime-triage.ts +106 -0
- package/node_modules/@llblab/pi-actors/lib/runtime.ts +430 -0
- package/node_modules/@llblab/pi-actors/lib/schema.ts +525 -0
- package/node_modules/@llblab/pi-actors/lib/session-evidence.ts +302 -0
- package/node_modules/@llblab/pi-actors/lib/state-readers.ts +93 -0
- package/node_modules/@llblab/pi-actors/lib/temp.ts +99 -0
- package/node_modules/@llblab/pi-actors/lib/tool-review-lineage-transaction.ts +881 -0
- package/node_modules/@llblab/pi-actors/lib/tool-review-lineage.ts +145 -0
- package/node_modules/@llblab/pi-actors/lib/tool-review-scheduler.ts +635 -0
- package/node_modules/@llblab/pi-actors/lib/tool-review-transaction.ts +563 -0
- package/node_modules/@llblab/pi-actors/lib/tool-review.ts +270 -0
- package/node_modules/@llblab/pi-actors/lib/tools-access.ts +68 -0
- package/node_modules/@llblab/pi-actors/lib/tools-inspect.ts +673 -0
- package/node_modules/@llblab/pi-actors/lib/tools-local.ts +303 -0
- package/node_modules/@llblab/pi-actors/lib/tools-message.ts +176 -0
- package/node_modules/@llblab/pi-actors/lib/tools-register.ts +63 -0
- package/node_modules/@llblab/pi-actors/lib/tools-response.ts +285 -0
- package/node_modules/@llblab/pi-actors/lib/tools-spawn.ts +212 -0
- package/node_modules/@llblab/pi-actors/lib/tools.ts +88 -0
- package/node_modules/@llblab/pi-actors/lib/trace-projection.ts +306 -0
- package/node_modules/@llblab/pi-actors/package.json +76 -0
- package/node_modules/@llblab/pi-actors/scripts/async-runner.mjs +555 -0
- package/node_modules/@llblab/pi-actors/scripts/build-dist.mjs +60 -0
- package/node_modules/@llblab/pi-actors/scripts/conformance.mjs +63 -0
- package/node_modules/@llblab/pi-actors/skills/actors/SKILL.md +126 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/command-validate.json +13 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/jsonl-tail.json +10 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/recipe-validate.json +11 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/resource-locker-snapshot.json +11 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/resource-locker.json +25 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/run-ops-snapshot.json +15 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/run-state-files.json +13 -0
- package/node_modules/@llblab/pi-actors/skills/actors/recipes/run-summary.json +9 -0
- package/node_modules/@llblab/pi-actors/skills/actors/references/diagnostics.md +44 -0
- package/node_modules/@llblab/pi-actors/skills/actors/references/persistent-tools.md +76 -0
- package/node_modules/@llblab/pi-actors/skills/actors/references/recipes.md +51 -0
- package/node_modules/@llblab/pi-actors/skills/actors/references/runs.md +41 -0
- package/node_modules/@llblab/pi-actors/skills/actors/scripts/resource-locker.mjs +425 -0
- package/node_modules/@llblab/pi-actors/skills/actors/scripts/run-utils.mjs +164 -0
- package/node_modules/@llblab/pi-actors/skills/actors/scripts/validate-recipe.mjs +370 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/SKILL.md +33 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/bundle.json +77 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/file-write.json +14 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/manifest.json +14 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/report.json +39 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/recipes/write.json +53 -0
- package/node_modules/@llblab/pi-actors/skills/artifacts/scripts/artifact-utils.mjs +63 -0
- package/node_modules/@llblab/pi-actors/skills/music-player/SKILL.md +57 -0
- package/node_modules/@llblab/pi-actors/skills/music-player/genapps/music-player.mjs +360 -0
- package/node_modules/@llblab/pi-actors/skills/music-player/recipes/playback.json +29 -0
- package/node_modules/@llblab/pi-actors/skills/music-player/scripts/playback-client.mjs +143 -0
- package/node_modules/@llblab/pi-actors/skills/music-player/scripts/playback.mjs +1446 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/SKILL.md +37 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/changelog-head.json +11 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/changelog-section.json +11 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/docs-maintenance.json +66 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/git-log.json +11 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/git-status.json +9 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/markdown-index.json +14 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/package-summary.json +9 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/release-readiness.json +115 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/release-summary.json +74 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/repo-health.json +75 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/run-ops.json +56 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/recipes/skill-summary.json +11 -0
- package/node_modules/@llblab/pi-actors/skills/project-work/scripts/project-utils.mjs +89 -0
- package/node_modules/@llblab/pi-actors/skills/recipe-memory/SKILL.md +36 -0
- package/node_modules/@llblab/pi-actors/skills/recipe-memory/recipes/draft-review.json +14 -0
- package/node_modules/@llblab/pi-actors/skills/recipe-memory/recipes/tool-review.json +14 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/SKILL.md +84 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/architect.json +82 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/checkpoint-continuation.json +51 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/development-tasking.json +67 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/lens-review.json +63 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/quorum-review.json +65 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/research-synthesis.json +81 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/review-readiness.json +59 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-artifact.json +21 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-checkpoint.json +21 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-conflict-report.json +19 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-contradiction-map.json +20 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-critic.json +22 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-evidence-map.json +20 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-followup.json +21 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-judge.json +22 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-merge.json +24 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-normalize.json +20 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-plan.json +20 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-preflight.json +18 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-prompt.json +16 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-prompts.json +39 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-quorum.json +31 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-review-coordinator.json +170 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-review.json +26 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-task-card.json +22 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-tools.json +15 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/recipes/subagent-verify.json +23 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/references/development-swarm.md +189 -0
- package/node_modules/@llblab/pi-actors/skills/swarm/references/review-swarms.md +115 -0
- package/node_modules/@llblab/pi-codex-usage/AGENTS.md +17 -0
- package/node_modules/@llblab/pi-codex-usage/BACKLOG.md +8 -0
- package/node_modules/@llblab/pi-codex-usage/CHANGELOG.md +80 -0
- package/node_modules/@llblab/pi-codex-usage/LICENSE +22 -0
- package/node_modules/@llblab/pi-codex-usage/README.md +113 -0
- package/node_modules/@llblab/pi-codex-usage/banner.jpg +0 -0
- package/node_modules/@llblab/pi-codex-usage/index.ts +1525 -0
- package/node_modules/@llblab/pi-codex-usage/package.json +59 -0
- package/node_modules/@llblab/pi-grow-loop/AGENTS.md +56 -0
- package/node_modules/@llblab/pi-grow-loop/BACKLOG.md +3 -0
- package/node_modules/@llblab/pi-grow-loop/CHANGELOG.md +126 -0
- package/node_modules/@llblab/pi-grow-loop/README.md +216 -0
- package/node_modules/@llblab/pi-grow-loop/banner.jpg +0 -0
- package/node_modules/@llblab/pi-grow-loop/index.ts +219 -0
- package/node_modules/@llblab/pi-grow-loop/package.json +64 -0
- package/node_modules/@llblab/pi-grow-loop/skills/grow-loop/SKILL.md +131 -0
- package/node_modules/@llblab/pi-grow-loop/skills/while-true/SKILL.md +233 -0
- package/node_modules/@llblab/pi-telegram/AGENTS.md +157 -0
- package/node_modules/@llblab/pi-telegram/BACKLOG.md +15 -0
- package/node_modules/@llblab/pi-telegram/CHANGELOG.md +886 -0
- package/node_modules/@llblab/pi-telegram/README.md +330 -0
- package/node_modules/@llblab/pi-telegram/api/activity.ts +15 -0
- package/node_modules/@llblab/pi-telegram/api/commands.ts +11 -0
- package/node_modules/@llblab/pi-telegram/api/delivery.ts +21 -0
- package/node_modules/@llblab/pi-telegram/api/inbound.ts +14 -0
- package/node_modules/@llblab/pi-telegram/api/keyboard.ts +11 -0
- package/node_modules/@llblab/pi-telegram/api/outbound.ts +11 -0
- package/node_modules/@llblab/pi-telegram/api/sections.ts +17 -0
- package/node_modules/@llblab/pi-telegram/api/status.ts +12 -0
- package/node_modules/@llblab/pi-telegram/api/updates.ts +16 -0
- package/node_modules/@llblab/pi-telegram/api/voice.ts +24 -0
- package/node_modules/@llblab/pi-telegram/docs/README.md +25 -0
- package/node_modules/@llblab/pi-telegram/docs/activity.md +304 -0
- package/node_modules/@llblab/pi-telegram/docs/architecture.md +418 -0
- package/node_modules/@llblab/pi-telegram/docs/callback-namespaces.md +48 -0
- package/node_modules/@llblab/pi-telegram/docs/command-templates.md +365 -0
- package/node_modules/@llblab/pi-telegram/docs/compact-matrix-literal.md +176 -0
- package/node_modules/@llblab/pi-telegram/docs/delivery.md +225 -0
- package/node_modules/@llblab/pi-telegram/docs/generative-apps.md +310 -0
- package/node_modules/@llblab/pi-telegram/docs/inbound.md +136 -0
- package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +467 -0
- package/node_modules/@llblab/pi-telegram/docs/outbound.md +193 -0
- package/node_modules/@llblab/pi-telegram/docs/public-api.md +599 -0
- package/node_modules/@llblab/pi-telegram/docs/sections.md +452 -0
- package/node_modules/@llblab/pi-telegram/docs/ui-style.md +256 -0
- package/node_modules/@llblab/pi-telegram/docs/updates.md +171 -0
- package/node_modules/@llblab/pi-telegram/docs/voice.md +217 -0
- package/node_modules/@llblab/pi-telegram/index.ts +1336 -0
- package/node_modules/@llblab/pi-telegram/lib/activity-verbosity.ts +714 -0
- package/node_modules/@llblab/pi-telegram/lib/activity.ts +782 -0
- package/node_modules/@llblab/pi-telegram/lib/agent-messages.ts +121 -0
- package/node_modules/@llblab/pi-telegram/lib/bindings.ts +1129 -0
- package/node_modules/@llblab/pi-telegram/lib/bus-api.ts +379 -0
- package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +1941 -0
- package/node_modules/@llblab/pi-telegram/lib/bus-leader.ts +2119 -0
- package/node_modules/@llblab/pi-telegram/lib/bus-transport.ts +244 -0
- package/node_modules/@llblab/pi-telegram/lib/bus.ts +2645 -0
- package/node_modules/@llblab/pi-telegram/lib/command-templates.ts +954 -0
- package/node_modules/@llblab/pi-telegram/lib/commands.ts +1854 -0
- package/node_modules/@llblab/pi-telegram/lib/config.ts +1143 -0
- package/node_modules/@llblab/pi-telegram/lib/delivery.ts +891 -0
- package/node_modules/@llblab/pi-telegram/lib/generative-app-worker.mjs +104 -0
- package/node_modules/@llblab/pi-telegram/lib/generative-apps.ts +958 -0
- package/node_modules/@llblab/pi-telegram/lib/inbound.ts +824 -0
- package/node_modules/@llblab/pi-telegram/lib/journal.ts +3140 -0
- package/node_modules/@llblab/pi-telegram/lib/keyboard.ts +59 -0
- package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +623 -0
- package/node_modules/@llblab/pi-telegram/lib/locks.ts +1422 -0
- package/node_modules/@llblab/pi-telegram/lib/logs.ts +393 -0
- package/node_modules/@llblab/pi-telegram/lib/media.ts +921 -0
- package/node_modules/@llblab/pi-telegram/lib/menu-model.ts +1182 -0
- package/node_modules/@llblab/pi-telegram/lib/menu-queue.ts +926 -0
- package/node_modules/@llblab/pi-telegram/lib/menu-settings.ts +876 -0
- package/node_modules/@llblab/pi-telegram/lib/menu-status.ts +274 -0
- package/node_modules/@llblab/pi-telegram/lib/menu-thinking.ts +185 -0
- package/node_modules/@llblab/pi-telegram/lib/menu.ts +867 -0
- package/node_modules/@llblab/pi-telegram/lib/model.ts +672 -0
- package/node_modules/@llblab/pi-telegram/lib/outbound-attachments.ts +981 -0
- package/node_modules/@llblab/pi-telegram/lib/outbound-buttons.ts +331 -0
- package/node_modules/@llblab/pi-telegram/lib/outbound-markup.ts +515 -0
- package/node_modules/@llblab/pi-telegram/lib/outbound-voice.ts +285 -0
- package/node_modules/@llblab/pi-telegram/lib/outbound.ts +1007 -0
- package/node_modules/@llblab/pi-telegram/lib/ownership.ts +298 -0
- package/node_modules/@llblab/pi-telegram/lib/paths.ts +127 -0
- package/node_modules/@llblab/pi-telegram/lib/pi.ts +197 -0
- package/node_modules/@llblab/pi-telegram/lib/polling.ts +1588 -0
- package/node_modules/@llblab/pi-telegram/lib/preview.ts +846 -0
- package/node_modules/@llblab/pi-telegram/lib/prompt-templates.ts +158 -0
- package/node_modules/@llblab/pi-telegram/lib/prompts.ts +218 -0
- package/node_modules/@llblab/pi-telegram/lib/queue.ts +3075 -0
- package/node_modules/@llblab/pi-telegram/lib/recovery.ts +464 -0
- package/node_modules/@llblab/pi-telegram/lib/rendering.ts +1213 -0
- package/node_modules/@llblab/pi-telegram/lib/replies.ts +892 -0
- package/node_modules/@llblab/pi-telegram/lib/routing.ts +2889 -0
- package/node_modules/@llblab/pi-telegram/lib/runtime.ts +628 -0
- package/node_modules/@llblab/pi-telegram/lib/sections.ts +710 -0
- package/node_modules/@llblab/pi-telegram/lib/setup.ts +220 -0
- package/node_modules/@llblab/pi-telegram/lib/skills.ts +21 -0
- package/node_modules/@llblab/pi-telegram/lib/status.ts +1550 -0
- package/node_modules/@llblab/pi-telegram/lib/sync.ts +883 -0
- package/node_modules/@llblab/pi-telegram/lib/target.ts +49 -0
- package/node_modules/@llblab/pi-telegram/lib/telegram-api.ts +1747 -0
- package/node_modules/@llblab/pi-telegram/lib/text-groups.ts +487 -0
- package/node_modules/@llblab/pi-telegram/lib/thread-reconciler.ts +1002 -0
- package/node_modules/@llblab/pi-telegram/lib/threads.ts +3183 -0
- package/node_modules/@llblab/pi-telegram/lib/time-injection.ts +78 -0
- package/node_modules/@llblab/pi-telegram/lib/turns.ts +753 -0
- package/node_modules/@llblab/pi-telegram/lib/updates.ts +4950 -0
- package/node_modules/@llblab/pi-telegram/lib/voice.ts +340 -0
- package/node_modules/@llblab/pi-telegram/package.json +83 -0
- package/node_modules/@llblab/pi-telegram/screenshot.png +0 -0
- package/node_modules/@llblab/pi-telegram/scripts/check-downgrade.mjs +435 -0
- package/node_modules/@llblab/pi-telegram/skills/generated-control-surface/SKILL.md +241 -0
- package/node_modules/@llblab/pi-telegram/skills/generative-apps/SKILL.md +114 -0
- package/node_modules/@llblab/pi-telegram/skills/telegram-bridge/SKILL.md +149 -0
- package/package.json +67 -0
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recipe usage and name-based lineage metadata.
|
|
3
|
+
* Zones: recipe lineage, launch telemetry, revision history, migration
|
|
4
|
+
* Owns priority-compatible recipe names and lifetime/revision counters for user recipes.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { existsSync, readFileSync, unlinkSync } from "node:fs";
|
|
9
|
+
import { basename, dirname, extname, join, relative, resolve } from "node:path";
|
|
10
|
+
|
|
11
|
+
import { withFileMutationLock, writeJsonAtomic } from "./file-state.ts";
|
|
12
|
+
|
|
13
|
+
interface RecipeUsageCounters {
|
|
14
|
+
calls?: number;
|
|
15
|
+
direct_calls?: number;
|
|
16
|
+
fingerprint?: string;
|
|
17
|
+
last_called?: string;
|
|
18
|
+
launch_kind?: string;
|
|
19
|
+
reset_at?: string;
|
|
20
|
+
reset_reason?: string;
|
|
21
|
+
spawn_calls?: number;
|
|
22
|
+
tool_calls?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface RecipeUsageIndex {
|
|
26
|
+
paths: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface RecipeLineageEvent {
|
|
30
|
+
at: string;
|
|
31
|
+
from?: string;
|
|
32
|
+
review_epoch?: string;
|
|
33
|
+
to?: string;
|
|
34
|
+
rollback_revision?: number;
|
|
35
|
+
revision?: number;
|
|
36
|
+
type: "created" | "demoted" | "merged" | "promoted" | "renamed" | "replaced" | "reviewed" | "revised" | "rollback" | "split";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface RecipeRevisionRecord {
|
|
40
|
+
fingerprint: string;
|
|
41
|
+
first_seen: string;
|
|
42
|
+
revision: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface RecipeUsageRecord extends RecipeUsageCounters {
|
|
46
|
+
calls: number;
|
|
47
|
+
current_path: string;
|
|
48
|
+
fingerprint: string;
|
|
49
|
+
first_seen: string;
|
|
50
|
+
former_names: string[];
|
|
51
|
+
former_paths: string[];
|
|
52
|
+
lifetime_calls: number;
|
|
53
|
+
lineage_events: RecipeLineageEvent[];
|
|
54
|
+
lineage_name: string;
|
|
55
|
+
review_epochs: string[];
|
|
56
|
+
reviewed_fingerprints: string[];
|
|
57
|
+
rollback_of_revision?: number;
|
|
58
|
+
revision: number;
|
|
59
|
+
revision_calls: number;
|
|
60
|
+
revision_direct_calls: number;
|
|
61
|
+
revision_spawn_calls: number;
|
|
62
|
+
revision_tool_calls: number;
|
|
63
|
+
revisions: RecipeRevisionRecord[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
67
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function normalizeCalls(value: unknown): number {
|
|
71
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0
|
|
72
|
+
? Math.floor(value)
|
|
73
|
+
: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function stableStringify(value: unknown): string {
|
|
77
|
+
if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
|
|
78
|
+
if (!isRecord(value)) return JSON.stringify(value);
|
|
79
|
+
return `{${Object.keys(value)
|
|
80
|
+
.sort()
|
|
81
|
+
.map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`)
|
|
82
|
+
.join(",")}}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function readRecipeSource(path: string): { fingerprint: string } | undefined {
|
|
86
|
+
const bytes = readFileSync(path);
|
|
87
|
+
if (extname(path).toLowerCase() !== ".json") {
|
|
88
|
+
return {
|
|
89
|
+
fingerprint: createHash("sha256").update(bytes).digest("hex"),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const parsed = JSON.parse(bytes.toString("utf8"));
|
|
93
|
+
if (!isRecord(parsed)) return undefined;
|
|
94
|
+
const { usage: _usage, ...content } = parsed;
|
|
95
|
+
return {
|
|
96
|
+
fingerprint: createHash("sha256")
|
|
97
|
+
.update(stableStringify(content))
|
|
98
|
+
.digest("hex"),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function inferRecipeRoot(path: string): string {
|
|
103
|
+
const parent = dirname(resolve(path));
|
|
104
|
+
return basename(parent) === "drafts" ? dirname(parent) : parent;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function pathKey(path: string, recipeRoot: string): string {
|
|
108
|
+
const relation = relative(resolve(recipeRoot), resolve(path));
|
|
109
|
+
if (!relation || relation.startsWith("..") || resolve(relation) === relation) {
|
|
110
|
+
throw new Error(`Recipe path escapes recipe root: ${path}`);
|
|
111
|
+
}
|
|
112
|
+
return relation.replaceAll("\\", "/");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function recipeName(path: string): string {
|
|
116
|
+
return basename(path).replace(/\.(?:json|md)$/u, "");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function lineageFilename(lineageName: string): string {
|
|
120
|
+
if (!lineageName || lineageName === "." || lineageName === "..") {
|
|
121
|
+
throw new Error("Invalid recipe lineage name.");
|
|
122
|
+
}
|
|
123
|
+
return `${encodeURIComponent(lineageName)}.json`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function appendBounded(values: string[], value: string, limit = 64): string[] {
|
|
127
|
+
const next = [...values.filter((item) => item !== value), value];
|
|
128
|
+
return next.slice(Math.max(0, next.length - limit));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function appendEvent(
|
|
132
|
+
events: RecipeLineageEvent[],
|
|
133
|
+
event: RecipeLineageEvent,
|
|
134
|
+
): RecipeLineageEvent[] {
|
|
135
|
+
return [...events, event].slice(-128);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function appendRevision(
|
|
139
|
+
revisions: RecipeRevisionRecord[],
|
|
140
|
+
revision: RecipeRevisionRecord,
|
|
141
|
+
): RecipeRevisionRecord[] {
|
|
142
|
+
return [...revisions, revision].slice(-128);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type RecipeLaunchKind = "direct" | "spawn" | "tool";
|
|
146
|
+
|
|
147
|
+
export function getRecipeUsageIndexPath(recipeRoot: string): string {
|
|
148
|
+
return join(resolve(recipeRoot), ".usage", "index.json");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function getRecipeUsageLedgerPath(
|
|
152
|
+
lineageName: string,
|
|
153
|
+
recipeRoot: string,
|
|
154
|
+
): string {
|
|
155
|
+
return join(
|
|
156
|
+
resolve(recipeRoot),
|
|
157
|
+
".usage",
|
|
158
|
+
"recipes",
|
|
159
|
+
lineageFilename(lineageName),
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export const RECIPE_REVISION_SNAPSHOT_LIMIT = 32;
|
|
164
|
+
|
|
165
|
+
export function getRecipeRevisionSnapshotPath(
|
|
166
|
+
lineageName: string,
|
|
167
|
+
revision: number,
|
|
168
|
+
recipeRoot: string,
|
|
169
|
+
): string {
|
|
170
|
+
if (!Number.isInteger(revision) || revision <= 0) {
|
|
171
|
+
throw new Error("Invalid recipe revision snapshot number.");
|
|
172
|
+
}
|
|
173
|
+
const slot = ((revision - 1) % RECIPE_REVISION_SNAPSHOT_LIMIT) + 1;
|
|
174
|
+
return join(
|
|
175
|
+
resolve(recipeRoot),
|
|
176
|
+
".usage",
|
|
177
|
+
"revisions",
|
|
178
|
+
encodeURIComponent(lineageName),
|
|
179
|
+
`${slot}.json`,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function readJsonRecord(path: string): Record<string, unknown> | undefined {
|
|
184
|
+
try {
|
|
185
|
+
const value = JSON.parse(readFileSync(path, "utf8"));
|
|
186
|
+
return isRecord(value) ? value : undefined;
|
|
187
|
+
} catch {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function readIndex(recipeRoot: string): RecipeUsageIndex {
|
|
193
|
+
const value = readJsonRecord(getRecipeUsageIndexPath(recipeRoot));
|
|
194
|
+
const paths = value?.paths;
|
|
195
|
+
return {
|
|
196
|
+
paths: isRecord(paths)
|
|
197
|
+
? Object.fromEntries(
|
|
198
|
+
Object.entries(paths).filter(
|
|
199
|
+
(entry): entry is [string, string] => typeof entry[1] === "string",
|
|
200
|
+
),
|
|
201
|
+
)
|
|
202
|
+
: {},
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function normalizeStoredLedger(
|
|
207
|
+
value: Record<string, unknown>,
|
|
208
|
+
lineageName: string,
|
|
209
|
+
): RecipeUsageRecord | undefined {
|
|
210
|
+
return value.lineage_name === lineageName
|
|
211
|
+
? value as unknown as RecipeUsageRecord
|
|
212
|
+
: undefined;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function readLedger(
|
|
216
|
+
lineageName: string,
|
|
217
|
+
recipeRoot: string,
|
|
218
|
+
): RecipeUsageRecord | undefined {
|
|
219
|
+
const value = readJsonRecord(getRecipeUsageLedgerPath(lineageName, recipeRoot));
|
|
220
|
+
return value ? normalizeStoredLedger(value, lineageName) : undefined;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function readIndexedLedger(
|
|
224
|
+
indexedName: string,
|
|
225
|
+
recipeRoot: string,
|
|
226
|
+
): { record: RecipeUsageRecord } | undefined {
|
|
227
|
+
const current = readLedger(indexedName, recipeRoot);
|
|
228
|
+
return current ? { record: current } : undefined;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function findRelocatedRecipe(
|
|
232
|
+
index: RecipeUsageIndex,
|
|
233
|
+
fingerprint: string,
|
|
234
|
+
recipeRoot: string,
|
|
235
|
+
): { indexedName: string; path: string; record: RecipeUsageRecord } | undefined {
|
|
236
|
+
const candidates = Object.entries(index.paths).flatMap(([oldPath, indexedName]) => {
|
|
237
|
+
if (existsSync(join(recipeRoot, oldPath))) return [];
|
|
238
|
+
const found = readIndexedLedger(indexedName, recipeRoot);
|
|
239
|
+
return found?.record.fingerprint === fingerprint
|
|
240
|
+
? [{ indexedName, path: oldPath, record: found.record }]
|
|
241
|
+
: [];
|
|
242
|
+
});
|
|
243
|
+
return candidates.length === 1 ? candidates[0] : undefined;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function launchCounterKey(
|
|
247
|
+
kind: RecipeLaunchKind,
|
|
248
|
+
): "direct_calls" | "spawn_calls" | "tool_calls" {
|
|
249
|
+
return `${kind}_calls` as "direct_calls" | "spawn_calls" | "tool_calls";
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function revisionCounterKey(
|
|
253
|
+
kind: RecipeLaunchKind,
|
|
254
|
+
): "revision_direct_calls" | "revision_spawn_calls" | "revision_tool_calls" {
|
|
255
|
+
return `revision_${kind}_calls` as
|
|
256
|
+
| "revision_direct_calls"
|
|
257
|
+
| "revision_spawn_calls"
|
|
258
|
+
| "revision_tool_calls";
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export function readRecipeUsage(
|
|
262
|
+
path: string,
|
|
263
|
+
recipeRoot = inferRecipeRoot(path),
|
|
264
|
+
): Record<string, unknown> | undefined {
|
|
265
|
+
try {
|
|
266
|
+
const key = pathKey(path, recipeRoot);
|
|
267
|
+
const indexedName = readIndex(recipeRoot).paths[key];
|
|
268
|
+
if (indexedName) {
|
|
269
|
+
return readIndexedLedger(indexedName, recipeRoot)?.record as unknown as
|
|
270
|
+
| Record<string, unknown>
|
|
271
|
+
| undefined;
|
|
272
|
+
}
|
|
273
|
+
return undefined;
|
|
274
|
+
} catch {
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export function ensureRecipeLineage(
|
|
280
|
+
path: string,
|
|
281
|
+
now = new Date(),
|
|
282
|
+
recipeRoot = inferRecipeRoot(path),
|
|
283
|
+
): boolean {
|
|
284
|
+
if (!existsSync(path)) return false;
|
|
285
|
+
const indexPath = getRecipeUsageIndexPath(recipeRoot);
|
|
286
|
+
return withFileMutationLock(indexPath, () => {
|
|
287
|
+
try {
|
|
288
|
+
const source = readRecipeSource(path);
|
|
289
|
+
if (!source) return false;
|
|
290
|
+
const key = pathKey(path, recipeRoot);
|
|
291
|
+
const name = recipeName(path);
|
|
292
|
+
const index = readIndex(recipeRoot);
|
|
293
|
+
const indexedName = index.paths[key];
|
|
294
|
+
if (indexedName) {
|
|
295
|
+
const found = readIndexedLedger(indexedName, recipeRoot);
|
|
296
|
+
if (!found || indexedName !== name) return false;
|
|
297
|
+
if (found.record.fingerprint === source.fingerprint) return true;
|
|
298
|
+
const ledgerPath = getRecipeUsageLedgerPath(name, recipeRoot);
|
|
299
|
+
return withFileMutationLock(ledgerPath, () => {
|
|
300
|
+
const current = readLedger(name, recipeRoot);
|
|
301
|
+
if (!current) return false;
|
|
302
|
+
if (current.fingerprint === source.fingerprint) return true;
|
|
303
|
+
const nowIso = now.toISOString();
|
|
304
|
+
const revision = current.revision + 1;
|
|
305
|
+
writeJsonAtomic(ledgerPath, {
|
|
306
|
+
...current,
|
|
307
|
+
fingerprint: source.fingerprint,
|
|
308
|
+
lineage_events: appendEvent(current.lineage_events, {
|
|
309
|
+
at: nowIso,
|
|
310
|
+
type: "revised",
|
|
311
|
+
}),
|
|
312
|
+
reset_at: nowIso,
|
|
313
|
+
reset_reason: "recipe content fingerprint changed",
|
|
314
|
+
revision,
|
|
315
|
+
revision_calls: 0,
|
|
316
|
+
revision_direct_calls: 0,
|
|
317
|
+
revision_spawn_calls: 0,
|
|
318
|
+
revision_tool_calls: 0,
|
|
319
|
+
revisions: appendRevision(current.revisions, {
|
|
320
|
+
fingerprint: source.fingerprint,
|
|
321
|
+
first_seen: nowIso,
|
|
322
|
+
revision,
|
|
323
|
+
}),
|
|
324
|
+
});
|
|
325
|
+
return true;
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
if (readLedger(name, recipeRoot)) return false;
|
|
329
|
+
const nowIso = now.toISOString();
|
|
330
|
+
const ledgerPath = getRecipeUsageLedgerPath(name, recipeRoot);
|
|
331
|
+
return withFileMutationLock(ledgerPath, () => {
|
|
332
|
+
if (readLedger(name, recipeRoot)) return false;
|
|
333
|
+
writeJsonAtomic(ledgerPath, {
|
|
334
|
+
calls: 0,
|
|
335
|
+
current_path: key,
|
|
336
|
+
fingerprint: source.fingerprint,
|
|
337
|
+
first_seen: nowIso,
|
|
338
|
+
former_names: [],
|
|
339
|
+
former_paths: [],
|
|
340
|
+
lifetime_calls: 0,
|
|
341
|
+
lineage_events: [{ at: nowIso, type: "created" }],
|
|
342
|
+
lineage_name: name,
|
|
343
|
+
review_epochs: [],
|
|
344
|
+
reviewed_fingerprints: [],
|
|
345
|
+
revision: 1,
|
|
346
|
+
revision_calls: 0,
|
|
347
|
+
revision_direct_calls: 0,
|
|
348
|
+
revision_spawn_calls: 0,
|
|
349
|
+
revision_tool_calls: 0,
|
|
350
|
+
revisions: [{ fingerprint: source.fingerprint, first_seen: nowIso, revision: 1 }],
|
|
351
|
+
} satisfies RecipeUsageRecord);
|
|
352
|
+
index.paths[key] = name;
|
|
353
|
+
writeJsonAtomic(indexPath, index);
|
|
354
|
+
return true;
|
|
355
|
+
});
|
|
356
|
+
} catch {
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export function isCurrentRecipeRevisionReviewed(
|
|
363
|
+
path: string,
|
|
364
|
+
recipeRoot = inferRecipeRoot(path),
|
|
365
|
+
): boolean {
|
|
366
|
+
const usage = readRecipeUsage(path, recipeRoot);
|
|
367
|
+
return Boolean(
|
|
368
|
+
usage &&
|
|
369
|
+
typeof usage.fingerprint === "string" &&
|
|
370
|
+
Array.isArray(usage.reviewed_fingerprints) &&
|
|
371
|
+
usage.reviewed_fingerprints.includes(usage.fingerprint),
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export interface RecipeLaunchRecordOptions {
|
|
376
|
+
onMutationLockContention?(): void;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export function recordRecipeLaunch(
|
|
380
|
+
path: string,
|
|
381
|
+
now = new Date(),
|
|
382
|
+
kind: RecipeLaunchKind = "direct",
|
|
383
|
+
recipeRoot = inferRecipeRoot(path),
|
|
384
|
+
options: RecipeLaunchRecordOptions = {},
|
|
385
|
+
): boolean {
|
|
386
|
+
return withFileMutationLock(recipeRoot, () => {
|
|
387
|
+
if (!existsSync(path)) return false;
|
|
388
|
+
const indexPath = getRecipeUsageIndexPath(recipeRoot);
|
|
389
|
+
return withFileMutationLock(indexPath, () => {
|
|
390
|
+
try {
|
|
391
|
+
const source = readRecipeSource(path);
|
|
392
|
+
if (!source) return false;
|
|
393
|
+
const { fingerprint } = source;
|
|
394
|
+
const key = pathKey(path, recipeRoot);
|
|
395
|
+
const desiredName = recipeName(path);
|
|
396
|
+
const index = readIndex(recipeRoot);
|
|
397
|
+
const relocated = index.paths[key]
|
|
398
|
+
? undefined
|
|
399
|
+
: findRelocatedRecipe(index, fingerprint, recipeRoot);
|
|
400
|
+
const indexedName = index.paths[key] ?? relocated?.indexedName;
|
|
401
|
+
const found = indexedName
|
|
402
|
+
? readIndexedLedger(indexedName, recipeRoot)
|
|
403
|
+
: undefined;
|
|
404
|
+
const existingAtDesired = readLedger(desiredName, recipeRoot);
|
|
405
|
+
if (!found && existingAtDesired) return false;
|
|
406
|
+
const stored = found?.record;
|
|
407
|
+
const ledgerPath = getRecipeUsageLedgerPath(desiredName, recipeRoot);
|
|
408
|
+
return withFileMutationLock(ledgerPath, () => {
|
|
409
|
+
const nowIso = now.toISOString();
|
|
410
|
+
const changed = Boolean(stored && stored.fingerprint !== fingerprint);
|
|
411
|
+
const renamed = Boolean(stored && stored.lineage_name !== desiredName);
|
|
412
|
+
const lifetimeCalls = normalizeCalls(
|
|
413
|
+
stored?.lifetime_calls ?? stored?.calls,
|
|
414
|
+
) + 1;
|
|
415
|
+
const counterKey = launchCounterKey(kind);
|
|
416
|
+
const revisionKey = revisionCounterKey(kind);
|
|
417
|
+
const revision = (stored?.revision ?? 1) + (changed ? 1 : 0);
|
|
418
|
+
let events = stored?.lineage_events ?? [];
|
|
419
|
+
if (renamed) {
|
|
420
|
+
events = appendEvent(events, {
|
|
421
|
+
at: nowIso,
|
|
422
|
+
from: stored!.lineage_name,
|
|
423
|
+
to: desiredName,
|
|
424
|
+
type: "renamed",
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
if (changed) events = appendEvent(events, { at: nowIso, type: "revised" });
|
|
428
|
+
if (events.length === 0) events = [{ at: nowIso, type: "created" }];
|
|
429
|
+
const existingRevisions = stored?.revisions ?? [];
|
|
430
|
+
const record: RecipeUsageRecord = {
|
|
431
|
+
...stored,
|
|
432
|
+
calls: lifetimeCalls,
|
|
433
|
+
current_path: key,
|
|
434
|
+
fingerprint,
|
|
435
|
+
first_seen: stored?.first_seen ?? nowIso,
|
|
436
|
+
former_names: renamed
|
|
437
|
+
? appendBounded(stored?.former_names ?? [], stored!.lineage_name)
|
|
438
|
+
: relocated
|
|
439
|
+
? appendBounded(stored?.former_names ?? [], recipeName(relocated.path))
|
|
440
|
+
: stored?.former_names ?? [],
|
|
441
|
+
former_paths: relocated
|
|
442
|
+
? appendBounded(stored?.former_paths ?? [], relocated.path)
|
|
443
|
+
: stored?.former_paths ?? [],
|
|
444
|
+
lifetime_calls: lifetimeCalls,
|
|
445
|
+
lineage_events: events,
|
|
446
|
+
lineage_name: desiredName,
|
|
447
|
+
review_epochs: stored?.review_epochs ?? [],
|
|
448
|
+
reviewed_fingerprints: stored?.reviewed_fingerprints ?? [],
|
|
449
|
+
revision,
|
|
450
|
+
revision_calls: (changed ? 0 : normalizeCalls(stored?.revision_calls)) + 1,
|
|
451
|
+
revision_direct_calls: changed ? 0 : normalizeCalls(stored?.revision_direct_calls),
|
|
452
|
+
revision_spawn_calls: changed ? 0 : normalizeCalls(stored?.revision_spawn_calls),
|
|
453
|
+
revision_tool_calls: changed ? 0 : normalizeCalls(stored?.revision_tool_calls),
|
|
454
|
+
revisions: changed
|
|
455
|
+
? appendRevision(existingRevisions, { fingerprint, first_seen: nowIso, revision })
|
|
456
|
+
: existingRevisions.length > 0
|
|
457
|
+
? existingRevisions
|
|
458
|
+
: [{ fingerprint, first_seen: nowIso, revision }],
|
|
459
|
+
[counterKey]: normalizeCalls(stored?.[counterKey]) + 1,
|
|
460
|
+
[revisionKey]: (changed ? 0 : normalizeCalls(stored?.[revisionKey])) + 1,
|
|
461
|
+
last_called: nowIso,
|
|
462
|
+
launch_kind: kind,
|
|
463
|
+
...(changed
|
|
464
|
+
? { reset_at: nowIso, reset_reason: "recipe content fingerprint changed" }
|
|
465
|
+
: {}),
|
|
466
|
+
};
|
|
467
|
+
writeJsonAtomic(ledgerPath, record);
|
|
468
|
+
if (indexedName && indexedName !== desiredName) {
|
|
469
|
+
const oldPath = getRecipeUsageLedgerPath(indexedName, recipeRoot);
|
|
470
|
+
if (existsSync(oldPath)) unlinkSync(oldPath);
|
|
471
|
+
}
|
|
472
|
+
if (relocated) delete index.paths[relocated.path];
|
|
473
|
+
index.paths[key] = desiredName;
|
|
474
|
+
writeJsonAtomic(indexPath, index);
|
|
475
|
+
return true;
|
|
476
|
+
});
|
|
477
|
+
} catch {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
}, { onContention: options.onMutationLockContention });
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export function recordRecipeReview(
|
|
485
|
+
path: string,
|
|
486
|
+
reviewEpoch: string,
|
|
487
|
+
now = new Date(),
|
|
488
|
+
recipeRoot = inferRecipeRoot(path),
|
|
489
|
+
): boolean {
|
|
490
|
+
if (!reviewEpoch.trim()) return false;
|
|
491
|
+
const indexPath = getRecipeUsageIndexPath(recipeRoot);
|
|
492
|
+
return withFileMutationLock(indexPath, () => {
|
|
493
|
+
try {
|
|
494
|
+
const key = pathKey(path, recipeRoot);
|
|
495
|
+
const lineageName = readIndex(recipeRoot).paths[key];
|
|
496
|
+
if (!lineageName) return false;
|
|
497
|
+
const ledgerPath = getRecipeUsageLedgerPath(lineageName, recipeRoot);
|
|
498
|
+
return withFileMutationLock(ledgerPath, () => {
|
|
499
|
+
const ledger = readLedger(lineageName, recipeRoot);
|
|
500
|
+
if (!ledger) return false;
|
|
501
|
+
if (ledger.review_epochs.includes(reviewEpoch)) return true;
|
|
502
|
+
writeJsonAtomic(ledgerPath, {
|
|
503
|
+
...ledger,
|
|
504
|
+
lineage_events: appendEvent(ledger.lineage_events ?? [], {
|
|
505
|
+
at: now.toISOString(),
|
|
506
|
+
review_epoch: reviewEpoch,
|
|
507
|
+
type: "reviewed",
|
|
508
|
+
}),
|
|
509
|
+
review_epochs: appendBounded(ledger.review_epochs, reviewEpoch, 128),
|
|
510
|
+
reviewed_fingerprints: appendBounded(
|
|
511
|
+
ledger.reviewed_fingerprints ?? [],
|
|
512
|
+
ledger.fingerprint,
|
|
513
|
+
128,
|
|
514
|
+
),
|
|
515
|
+
});
|
|
516
|
+
return true;
|
|
517
|
+
});
|
|
518
|
+
} catch {
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
export function recordRecipeRollback(
|
|
525
|
+
path: string,
|
|
526
|
+
rollbackRevision: number,
|
|
527
|
+
now = new Date(),
|
|
528
|
+
recipeRoot = inferRecipeRoot(path),
|
|
529
|
+
): boolean {
|
|
530
|
+
if (!Number.isInteger(rollbackRevision) || rollbackRevision <= 0) return false;
|
|
531
|
+
const indexPath = getRecipeUsageIndexPath(recipeRoot);
|
|
532
|
+
return withFileMutationLock(indexPath, () => {
|
|
533
|
+
try {
|
|
534
|
+
const key = pathKey(path, recipeRoot);
|
|
535
|
+
const lineageName = readIndex(recipeRoot).paths[key];
|
|
536
|
+
if (!lineageName) return false;
|
|
537
|
+
const ledgerPath = getRecipeUsageLedgerPath(lineageName, recipeRoot);
|
|
538
|
+
return withFileMutationLock(ledgerPath, () => {
|
|
539
|
+
const ledger = readLedger(lineageName, recipeRoot);
|
|
540
|
+
if (!ledger) return false;
|
|
541
|
+
if (ledger.rollback_of_revision === rollbackRevision) return true;
|
|
542
|
+
writeJsonAtomic(ledgerPath, {
|
|
543
|
+
...ledger,
|
|
544
|
+
lineage_events: appendEvent(ledger.lineage_events ?? [], {
|
|
545
|
+
at: now.toISOString(),
|
|
546
|
+
revision: ledger.revision,
|
|
547
|
+
rollback_revision: rollbackRevision,
|
|
548
|
+
type: "rollback",
|
|
549
|
+
}),
|
|
550
|
+
rollback_of_revision: rollbackRevision,
|
|
551
|
+
});
|
|
552
|
+
return true;
|
|
553
|
+
});
|
|
554
|
+
} catch {
|
|
555
|
+
return false;
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
export function retireRecipeUsage(
|
|
561
|
+
path: string,
|
|
562
|
+
recipeRoot = inferRecipeRoot(path),
|
|
563
|
+
): boolean {
|
|
564
|
+
const indexPath = getRecipeUsageIndexPath(recipeRoot);
|
|
565
|
+
return withFileMutationLock(indexPath, () => {
|
|
566
|
+
try {
|
|
567
|
+
const key = pathKey(path, recipeRoot);
|
|
568
|
+
const index = readIndex(recipeRoot);
|
|
569
|
+
const lineageName = index.paths[key];
|
|
570
|
+
if (!lineageName) return true;
|
|
571
|
+
delete index.paths[key];
|
|
572
|
+
writeJsonAtomic(indexPath, index);
|
|
573
|
+
const ledgerPath = getRecipeUsageLedgerPath(lineageName, recipeRoot);
|
|
574
|
+
if (existsSync(ledgerPath)) unlinkSync(ledgerPath);
|
|
575
|
+
return true;
|
|
576
|
+
} catch {
|
|
577
|
+
return false;
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
export function moveRecipeUsage(
|
|
583
|
+
fromPath: string,
|
|
584
|
+
toPath: string,
|
|
585
|
+
recipeRoot = inferRecipeRoot(fromPath),
|
|
586
|
+
): boolean {
|
|
587
|
+
const indexPath = getRecipeUsageIndexPath(recipeRoot);
|
|
588
|
+
return withFileMutationLock(indexPath, () => {
|
|
589
|
+
try {
|
|
590
|
+
const fromKey = pathKey(fromPath, recipeRoot);
|
|
591
|
+
const toKey = pathKey(toPath, recipeRoot);
|
|
592
|
+
const index = readIndex(recipeRoot);
|
|
593
|
+
const oldName = index.paths[fromKey];
|
|
594
|
+
const newName = recipeName(toPath);
|
|
595
|
+
if (!oldName) {
|
|
596
|
+
return index.paths[toKey] === newName && Boolean(readLedger(newName, recipeRoot));
|
|
597
|
+
}
|
|
598
|
+
if (index.paths[toKey]) return false;
|
|
599
|
+
const found = readIndexedLedger(oldName, recipeRoot);
|
|
600
|
+
if (!found || (oldName !== newName && readLedger(newName, recipeRoot))) return false;
|
|
601
|
+
const oldLedgerPath = getRecipeUsageLedgerPath(oldName, recipeRoot);
|
|
602
|
+
const newLedgerPath = getRecipeUsageLedgerPath(newName, recipeRoot);
|
|
603
|
+
return withFileMutationLock(newLedgerPath, () => {
|
|
604
|
+
const fromDraft = fromKey.startsWith("drafts/");
|
|
605
|
+
const toDraft = toKey.startsWith("drafts/");
|
|
606
|
+
const transition: RecipeLineageEvent["type"] = fromDraft && !toDraft
|
|
607
|
+
? "promoted"
|
|
608
|
+
: !fromDraft && toDraft
|
|
609
|
+
? "demoted"
|
|
610
|
+
: "renamed";
|
|
611
|
+
writeJsonAtomic(newLedgerPath, {
|
|
612
|
+
...found.record,
|
|
613
|
+
current_path: toKey,
|
|
614
|
+
former_names: oldName !== newName
|
|
615
|
+
? appendBounded(found.record.former_names, oldName)
|
|
616
|
+
: found.record.former_names,
|
|
617
|
+
former_paths: appendBounded(found.record.former_paths, fromKey),
|
|
618
|
+
lineage_events: appendEvent(found.record.lineage_events ?? [], {
|
|
619
|
+
at: new Date().toISOString(),
|
|
620
|
+
from: oldName,
|
|
621
|
+
to: newName,
|
|
622
|
+
type: transition,
|
|
623
|
+
}),
|
|
624
|
+
lineage_name: newName,
|
|
625
|
+
});
|
|
626
|
+
index.paths[toKey] = newName;
|
|
627
|
+
delete index.paths[fromKey];
|
|
628
|
+
writeJsonAtomic(indexPath, index);
|
|
629
|
+
if (oldLedgerPath !== newLedgerPath && existsSync(oldLedgerPath)) {
|
|
630
|
+
unlinkSync(oldLedgerPath);
|
|
631
|
+
}
|
|
632
|
+
return true;
|
|
633
|
+
});
|
|
634
|
+
} catch {
|
|
635
|
+
return false;
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
}
|