@kilnai/cli 1.0.4 → 2.0.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/README.md +31 -8
- package/dist/application/__tests__/session-report.test.d.ts +2 -0
- package/dist/application/__tests__/session-report.test.d.ts.map +1 -0
- package/dist/application/__tests__/session-report.test.js +100 -0
- package/dist/application/__tests__/session-report.test.js.map +1 -0
- package/dist/application/agent-loader.d.ts +30 -2
- package/dist/application/agent-loader.d.ts.map +1 -1
- package/dist/application/agent-loader.js +99 -3
- package/dist/application/agent-loader.js.map +1 -1
- package/dist/application/agent-loader.test.js +112 -18
- package/dist/application/agent-loader.test.js.map +1 -1
- package/dist/application/agent-skill-context.d.ts +12 -0
- package/dist/application/agent-skill-context.d.ts.map +1 -0
- package/dist/application/agent-skill-context.js +32 -0
- package/dist/application/agent-skill-context.js.map +1 -0
- package/dist/application/agent-skill-context.test.d.ts +2 -0
- package/dist/application/agent-skill-context.test.d.ts.map +1 -0
- package/dist/application/agent-skill-context.test.js +156 -0
- package/dist/application/agent-skill-context.test.js.map +1 -0
- package/dist/application/benchmark-session-executor.d.ts +14 -0
- package/dist/application/benchmark-session-executor.d.ts.map +1 -0
- package/dist/application/benchmark-session-executor.js +210 -0
- package/dist/application/benchmark-session-executor.js.map +1 -0
- package/dist/application/config-apply-tool.d.ts +30 -0
- package/dist/application/config-apply-tool.d.ts.map +1 -0
- package/dist/application/config-apply-tool.js +68 -0
- package/dist/application/config-apply-tool.js.map +1 -0
- package/dist/application/config-apply.d.ts +9 -0
- package/dist/application/config-apply.d.ts.map +1 -0
- package/dist/application/config-apply.js +146 -0
- package/dist/application/config-apply.js.map +1 -0
- package/dist/application/config-approval.d.ts +10 -0
- package/dist/application/config-approval.d.ts.map +1 -0
- package/dist/application/config-approval.js +30 -0
- package/dist/application/config-approval.js.map +1 -0
- package/dist/application/config-mutation-store.d.ts +25 -0
- package/dist/application/config-mutation-store.d.ts.map +1 -0
- package/dist/application/config-mutation-store.js +59 -0
- package/dist/application/config-mutation-store.js.map +1 -0
- package/dist/application/config-proposal.d.ts +22 -0
- package/dist/application/config-proposal.d.ts.map +1 -0
- package/dist/application/config-proposal.js +395 -0
- package/dist/application/config-proposal.js.map +1 -0
- package/dist/application/config-propose-tool.d.ts +30 -0
- package/dist/application/config-propose-tool.d.ts.map +1 -0
- package/dist/application/config-propose-tool.js +63 -0
- package/dist/application/config-propose-tool.js.map +1 -0
- package/dist/application/config-read-tool.d.ts +26 -0
- package/dist/application/config-read-tool.d.ts.map +1 -0
- package/dist/application/config-read-tool.js +51 -0
- package/dist/application/config-read-tool.js.map +1 -0
- package/dist/application/config-status.d.ts +9 -0
- package/dist/application/config-status.d.ts.map +1 -0
- package/dist/application/config-status.js +361 -0
- package/dist/application/config-status.js.map +1 -0
- package/dist/application/config-tools.d.ts +3 -0
- package/dist/application/config-tools.d.ts.map +1 -0
- package/dist/application/config-tools.js +11 -0
- package/dist/application/config-tools.js.map +1 -0
- package/dist/application/context-types.d.ts +4 -17
- package/dist/application/context-types.d.ts.map +1 -1
- package/dist/application/context-types.js.map +1 -1
- package/dist/application/first-party-agent-defaults.d.ts +3 -0
- package/dist/application/first-party-agent-defaults.d.ts.map +1 -0
- package/dist/application/first-party-agent-defaults.js +135 -0
- package/dist/application/first-party-agent-defaults.js.map +1 -0
- package/dist/application/instruction-profile-context.d.ts +15 -0
- package/dist/application/instruction-profile-context.d.ts.map +1 -0
- package/dist/application/instruction-profile-context.js +80 -0
- package/dist/application/instruction-profile-context.js.map +1 -0
- package/dist/application/instruction-profile-loader.d.ts +20 -0
- package/dist/application/instruction-profile-loader.d.ts.map +1 -0
- package/dist/application/instruction-profile-loader.js +132 -0
- package/dist/application/instruction-profile-loader.js.map +1 -0
- package/dist/application/instruction-profile-loader.test.d.ts +2 -0
- package/dist/application/instruction-profile-loader.test.d.ts.map +1 -0
- package/dist/application/instruction-profile-loader.test.js +100 -0
- package/dist/application/instruction-profile-loader.test.js.map +1 -0
- package/dist/application/operator-theme-preferences.d.ts +11 -0
- package/dist/application/operator-theme-preferences.d.ts.map +1 -0
- package/dist/application/operator-theme-preferences.js +49 -0
- package/dist/application/operator-theme-preferences.js.map +1 -0
- package/dist/application/project-context.d.ts +22 -0
- package/dist/application/project-context.d.ts.map +1 -0
- package/dist/application/project-context.js +139 -0
- package/dist/application/project-context.js.map +1 -0
- package/dist/application/project-root-resolver.d.ts +14 -0
- package/dist/application/project-root-resolver.d.ts.map +1 -0
- package/dist/application/project-root-resolver.js +71 -0
- package/dist/application/project-root-resolver.js.map +1 -0
- package/dist/application/repo-shim-projection.d.ts +48 -0
- package/dist/application/repo-shim-projection.d.ts.map +1 -0
- package/dist/application/repo-shim-projection.js +536 -0
- package/dist/application/repo-shim-projection.js.map +1 -0
- package/dist/application/resume-sidebar-info.d.ts +9 -0
- package/dist/application/resume-sidebar-info.d.ts.map +1 -0
- package/dist/application/resume-sidebar-info.js +40 -0
- package/dist/application/resume-sidebar-info.js.map +1 -0
- package/dist/application/resume-strategy-feedback.d.ts.map +1 -1
- package/dist/application/resume-strategy-feedback.js +2 -1
- package/dist/application/resume-strategy-feedback.js.map +1 -1
- package/dist/application/run-session.d.ts +15 -0
- package/dist/application/run-session.d.ts.map +1 -1
- package/dist/application/run-session.js +110 -19
- package/dist/application/run-session.js.map +1 -1
- package/dist/application/runtime-session-rehydration.d.ts +9 -0
- package/dist/application/runtime-session-rehydration.d.ts.map +1 -0
- package/dist/application/runtime-session-rehydration.js +115 -0
- package/dist/application/runtime-session-rehydration.js.map +1 -0
- package/dist/application/session-context-artifacts.d.ts +19 -0
- package/dist/application/session-context-artifacts.d.ts.map +1 -0
- package/dist/application/session-context-artifacts.js +60 -0
- package/dist/application/session-context-artifacts.js.map +1 -0
- package/dist/application/session-metadata.d.ts +35 -0
- package/dist/application/session-metadata.d.ts.map +1 -0
- package/dist/application/session-metadata.js +157 -0
- package/dist/application/session-metadata.js.map +1 -0
- package/dist/application/session-report.d.ts.map +1 -1
- package/dist/application/session-report.js +8 -0
- package/dist/application/session-report.js.map +1 -1
- package/dist/application/session-resume.d.ts +1 -1
- package/dist/application/session-resume.d.ts.map +1 -1
- package/dist/application/session-resume.js +4 -4
- package/dist/application/session-resume.js.map +1 -1
- package/dist/application/work-governance-context.d.ts +7 -0
- package/dist/application/work-governance-context.d.ts.map +1 -0
- package/dist/application/work-governance-context.js +64 -0
- package/dist/application/work-governance-context.js.map +1 -0
- package/dist/application/work-governance-context.test.d.ts +2 -0
- package/dist/application/work-governance-context.test.d.ts.map +1 -0
- package/dist/application/work-governance-context.test.js +55 -0
- package/dist/application/work-governance-context.test.js.map +1 -0
- package/dist/application/work-governance-policy.d.ts +15 -0
- package/dist/application/work-governance-policy.d.ts.map +1 -0
- package/dist/application/work-governance-policy.js +53 -0
- package/dist/application/work-governance-policy.js.map +1 -0
- package/dist/application/work-governance-tool.d.ts +421 -0
- package/dist/application/work-governance-tool.d.ts.map +1 -0
- package/dist/application/work-governance-tool.js +937 -0
- package/dist/application/work-governance-tool.js.map +1 -0
- package/dist/application/work-governance-tool.test.d.ts +2 -0
- package/dist/application/work-governance-tool.test.d.ts.map +1 -0
- package/dist/application/work-governance-tool.test.js +935 -0
- package/dist/application/work-governance-tool.test.js.map +1 -0
- package/dist/application/work-governance-workflows.d.ts +23 -0
- package/dist/application/work-governance-workflows.d.ts.map +1 -0
- package/dist/application/work-governance-workflows.js +177 -0
- package/dist/application/work-governance-workflows.js.map +1 -0
- package/dist/application/workflow-snapshot-export.d.ts +81 -0
- package/dist/application/workflow-snapshot-export.d.ts.map +1 -0
- package/dist/application/workflow-snapshot-export.js +141 -0
- package/dist/application/workflow-snapshot-export.js.map +1 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +242 -24
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/benchmark.d.ts +8 -0
- package/dist/commands/benchmark.d.ts.map +1 -0
- package/dist/commands/benchmark.js +287 -0
- package/dist/commands/benchmark.js.map +1 -0
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +369 -39
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/config.test.d.ts +2 -0
- package/dist/commands/config.test.d.ts.map +1 -0
- package/dist/commands/config.test.js +86 -0
- package/dist/commands/config.test.js.map +1 -0
- package/dist/commands/goal.d.ts +12 -0
- package/dist/commands/goal.d.ts.map +1 -0
- package/dist/commands/goal.js +469 -0
- package/dist/commands/goal.js.map +1 -0
- package/dist/commands/goal.test.d.ts +2 -0
- package/dist/commands/goal.test.d.ts.map +1 -0
- package/dist/commands/goal.test.js +317 -0
- package/dist/commands/goal.test.js.map +1 -0
- package/dist/commands/gui-options.d.ts +5 -0
- package/dist/commands/gui-options.d.ts.map +1 -0
- package/dist/commands/gui-options.js +18 -0
- package/dist/commands/gui-options.js.map +1 -0
- package/dist/commands/gui-session-detail.d.ts +4 -0
- package/dist/commands/gui-session-detail.d.ts.map +1 -0
- package/dist/commands/gui-session-detail.js +32 -0
- package/dist/commands/gui-session-detail.js.map +1 -0
- package/dist/commands/gui-session-summaries.d.ts +5 -0
- package/dist/commands/gui-session-summaries.d.ts.map +1 -0
- package/dist/commands/gui-session-summaries.js +62 -0
- package/dist/commands/gui-session-summaries.js.map +1 -0
- package/dist/commands/gui-shutdown-monitor.d.ts +8 -0
- package/dist/commands/gui-shutdown-monitor.d.ts.map +1 -0
- package/dist/commands/gui-shutdown-monitor.js +50 -0
- package/dist/commands/gui-shutdown-monitor.js.map +1 -0
- package/dist/commands/gui-window.d.ts +42 -0
- package/dist/commands/gui-window.d.ts.map +1 -0
- package/dist/commands/gui-window.js +287 -0
- package/dist/commands/gui-window.js.map +1 -0
- package/dist/commands/gui-workspace.d.ts +3 -0
- package/dist/commands/gui-workspace.d.ts.map +1 -0
- package/dist/commands/gui-workspace.js +297 -0
- package/dist/commands/gui-workspace.js.map +1 -0
- package/dist/commands/gui.d.ts +14 -0
- package/dist/commands/gui.d.ts.map +1 -0
- package/dist/commands/gui.js +392 -0
- package/dist/commands/gui.js.map +1 -0
- package/dist/commands/import-native.d.ts +34 -0
- package/dist/commands/import-native.d.ts.map +1 -0
- package/dist/commands/import-native.js +302 -0
- package/dist/commands/import-native.js.map +1 -0
- package/dist/commands/init-templates.d.ts.map +1 -1
- package/dist/commands/init-templates.js +13 -12
- package/dist/commands/init-templates.js.map +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mcp-config.d.ts.map +1 -1
- package/dist/commands/mcp-config.js +6 -3
- package/dist/commands/mcp-config.js.map +1 -1
- package/dist/commands/memory.d.ts +1 -1
- package/dist/commands/memory.d.ts.map +1 -1
- package/dist/commands/memory.js +188 -39
- package/dist/commands/memory.js.map +1 -1
- package/dist/commands/project.d.ts +3 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +64 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/route.d.ts +3 -0
- package/dist/commands/route.d.ts.map +1 -0
- package/dist/commands/route.js +19 -0
- package/dist/commands/route.js.map +1 -0
- package/dist/commands/run.d.ts +23 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +416 -81
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/skill-capture.js +34 -14
- package/dist/commands/skill-capture.js.map +1 -1
- package/dist/commands/skill.d.ts.map +1 -1
- package/dist/commands/skill.js +10 -9
- package/dist/commands/skill.js.map +1 -1
- package/dist/commands/status.d.ts +5 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +134 -5
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts +8 -6
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +173 -48
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/tools.d.ts +2 -0
- package/dist/commands/tools.d.ts.map +1 -1
- package/dist/commands/tools.js +34 -15
- package/dist/commands/tools.js.map +1 -1
- package/dist/commands/tui.d.ts +6 -4
- package/dist/commands/tui.d.ts.map +1 -1
- package/dist/commands/tui.js +594 -94
- package/dist/commands/tui.js.map +1 -1
- package/dist/commands/uninstall.d.ts +13 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +111 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/config/builtin-tool-surface-config.d.ts +6 -0
- package/dist/config/builtin-tool-surface-config.d.ts.map +1 -0
- package/dist/config/builtin-tool-surface-config.js +27 -0
- package/dist/config/builtin-tool-surface-config.js.map +1 -0
- package/dist/config/config-merger.d.ts +1 -1
- package/dist/config/config-merger.d.ts.map +1 -1
- package/dist/config/config-merger.js +21 -4
- package/dist/config/config-merger.js.map +1 -1
- package/dist/config/config-merger.test.js +202 -7
- package/dist/config/config-merger.test.js.map +1 -1
- package/dist/config/global-config.d.ts +59 -13
- package/dist/config/global-config.d.ts.map +1 -1
- package/dist/config/global-config.js +580 -5
- package/dist/config/global-config.js.map +1 -1
- package/dist/config/global-config.test.js +481 -8
- package/dist/config/global-config.test.js.map +1 -1
- package/dist/config/harness-integration-capabilities.d.ts +27 -0
- package/dist/config/harness-integration-capabilities.d.ts.map +1 -0
- package/dist/config/harness-integration-capabilities.js +64 -0
- package/dist/config/harness-integration-capabilities.js.map +1 -0
- package/dist/config/interactive-use-config.d.ts +25 -0
- package/dist/config/interactive-use-config.d.ts.map +1 -0
- package/dist/config/interactive-use-config.js +210 -0
- package/dist/config/interactive-use-config.js.map +1 -0
- package/dist/config/json-comments.d.ts +2 -0
- package/dist/config/json-comments.d.ts.map +1 -0
- package/dist/config/json-comments.js +21 -0
- package/dist/config/json-comments.js.map +1 -0
- package/dist/config/managed-agent-direct-adapters.d.ts +15 -0
- package/dist/config/managed-agent-direct-adapters.d.ts.map +1 -0
- package/dist/config/managed-agent-direct-adapters.js +54 -0
- package/dist/config/managed-agent-direct-adapters.js.map +1 -0
- package/dist/config/managed-agent-provider-models.d.ts +3 -0
- package/dist/config/managed-agent-provider-models.d.ts.map +1 -0
- package/dist/config/managed-agent-provider-models.js +12 -0
- package/dist/config/managed-agent-provider-models.js.map +1 -0
- package/dist/config/managed-agent-routes.d.ts +49 -0
- package/dist/config/managed-agent-routes.d.ts.map +1 -0
- package/dist/config/managed-agent-routes.js +578 -0
- package/dist/config/managed-agent-routes.js.map +1 -0
- package/dist/config/managed-invocation-context-resolver.d.ts +10 -0
- package/dist/config/managed-invocation-context-resolver.d.ts.map +1 -0
- package/dist/config/managed-invocation-context-resolver.js +98 -0
- package/dist/config/managed-invocation-context-resolver.js.map +1 -0
- package/dist/config/managed-invocation-context-resolver.test.d.ts +2 -0
- package/dist/config/managed-invocation-context-resolver.test.d.ts.map +1 -0
- package/dist/config/managed-invocation-context-resolver.test.js +133 -0
- package/dist/config/managed-invocation-context-resolver.test.js.map +1 -0
- package/dist/config/model-task-suitability.d.ts +9 -0
- package/dist/config/model-task-suitability.d.ts.map +1 -0
- package/dist/config/model-task-suitability.js +40 -0
- package/dist/config/model-task-suitability.js.map +1 -0
- package/dist/config/native-agent-projection.d.ts +16 -0
- package/dist/config/native-agent-projection.d.ts.map +1 -0
- package/dist/config/native-agent-projection.js +242 -0
- package/dist/config/native-agent-projection.js.map +1 -0
- package/dist/config/native-hook-projection.d.ts +11 -0
- package/dist/config/native-hook-projection.d.ts.map +1 -0
- package/dist/config/native-hook-projection.js +180 -0
- package/dist/config/native-hook-projection.js.map +1 -0
- package/dist/config/native-permission-projection.d.ts +12 -0
- package/dist/config/native-permission-projection.d.ts.map +1 -0
- package/dist/config/native-permission-projection.js +162 -0
- package/dist/config/native-permission-projection.js.map +1 -0
- package/dist/config/native-projection-backup.d.ts +8 -0
- package/dist/config/native-projection-backup.d.ts.map +1 -0
- package/dist/config/native-projection-backup.js +19 -0
- package/dist/config/native-projection-backup.js.map +1 -0
- package/dist/config/native-projection-policy.d.ts +10 -0
- package/dist/config/native-projection-policy.d.ts.map +1 -0
- package/dist/config/native-projection-policy.js +9 -0
- package/dist/config/native-projection-policy.js.map +1 -0
- package/dist/config/native-projection-state.d.ts +57 -0
- package/dist/config/native-projection-state.d.ts.map +1 -0
- package/dist/config/native-projection-state.js +199 -0
- package/dist/config/native-projection-state.js.map +1 -0
- package/dist/config/native-skill-projection.d.ts +24 -0
- package/dist/config/native-skill-projection.d.ts.map +1 -0
- package/dist/config/native-skill-projection.js +170 -0
- package/dist/config/native-skill-projection.js.map +1 -0
- package/dist/config/operator-identity-context.d.ts +7 -0
- package/dist/config/operator-identity-context.d.ts.map +1 -0
- package/dist/config/operator-identity-context.js +46 -0
- package/dist/config/operator-identity-context.js.map +1 -0
- package/dist/config/operator-identity-context.test.d.ts +2 -0
- package/dist/config/operator-identity-context.test.d.ts.map +1 -0
- package/dist/config/operator-identity-context.test.js +61 -0
- package/dist/config/operator-identity-context.test.js.map +1 -0
- package/dist/config/operator-voice.d.ts +10 -0
- package/dist/config/operator-voice.d.ts.map +1 -0
- package/dist/config/operator-voice.js +29 -0
- package/dist/config/operator-voice.js.map +1 -0
- package/dist/config/provider-route-candidates.d.ts +20 -0
- package/dist/config/provider-route-candidates.d.ts.map +1 -0
- package/dist/config/provider-route-candidates.js +211 -0
- package/dist/config/provider-route-candidates.js.map +1 -0
- package/dist/config/provider-route-candidates.test.d.ts +2 -0
- package/dist/config/provider-route-candidates.test.d.ts.map +1 -0
- package/dist/config/provider-route-candidates.test.js +150 -0
- package/dist/config/provider-route-candidates.test.js.map +1 -0
- package/dist/config/skill-registry.d.ts +9 -0
- package/dist/config/skill-registry.d.ts.map +1 -0
- package/dist/config/skill-registry.js +13 -0
- package/dist/config/skill-registry.js.map +1 -0
- package/dist/config/skill-registry.test.d.ts +2 -0
- package/dist/config/skill-registry.test.d.ts.map +1 -0
- package/dist/config/skill-registry.test.js +64 -0
- package/dist/config/skill-registry.test.js.map +1 -0
- package/dist/config/task-skill-selection.d.ts +24 -0
- package/dist/config/task-skill-selection.d.ts.map +1 -0
- package/dist/config/task-skill-selection.js +79 -0
- package/dist/config/task-skill-selection.js.map +1 -0
- package/dist/config/translators/claude-translator.d.ts +7 -0
- package/dist/config/translators/claude-translator.d.ts.map +1 -0
- package/dist/config/translators/claude-translator.js +30 -0
- package/dist/config/translators/claude-translator.js.map +1 -0
- package/dist/config/translators/codex-translator.d.ts +7 -0
- package/dist/config/translators/codex-translator.d.ts.map +1 -0
- package/dist/config/translators/codex-translator.js +20 -0
- package/dist/config/translators/codex-translator.js.map +1 -0
- package/dist/config/translators/opencode-translator.d.ts +7 -0
- package/dist/config/translators/opencode-translator.d.ts.map +1 -0
- package/dist/config/translators/opencode-translator.js +19 -0
- package/dist/config/translators/opencode-translator.js.map +1 -0
- package/dist/config/translators/permission-projection.d.ts +26 -0
- package/dist/config/translators/permission-projection.d.ts.map +1 -0
- package/dist/config/translators/permission-projection.js +22 -0
- package/dist/config/translators/permission-projection.js.map +1 -0
- package/dist/config/web-tools-config.d.ts +45 -0
- package/dist/config/web-tools-config.d.ts.map +1 -0
- package/dist/config/web-tools-config.js +846 -0
- package/dist/config/web-tools-config.js.map +1 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/engines/engine-registry.d.ts +45 -0
- package/dist/engines/engine-registry.d.ts.map +1 -0
- package/dist/engines/engine-registry.js +125 -0
- package/dist/engines/engine-registry.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +141 -18
- package/dist/index.js.map +1 -1
- package/dist/kiln-yaml-types.d.ts +207 -1
- package/dist/kiln-yaml-types.d.ts.map +1 -1
- package/dist/kiln-yaml-types.js +29 -0
- package/dist/kiln-yaml-types.js.map +1 -1
- package/dist/kiln-yaml.d.ts +1 -1
- package/dist/kiln-yaml.d.ts.map +1 -1
- package/dist/kiln-yaml.js +93 -0
- package/dist/kiln-yaml.js.map +1 -1
- package/dist/mcp/config-generator.d.ts.map +1 -1
- package/dist/mcp/config-generator.js +8 -7
- package/dist/mcp/config-generator.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -25
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -103
- package/dist/mcp/index.js.map +1 -1
- package/dist/wrapper/__tests__/session-manager-context-governor.test.d.ts +2 -0
- package/dist/wrapper/__tests__/session-manager-context-governor.test.d.ts.map +1 -0
- package/dist/wrapper/__tests__/session-manager-context-governor.test.js +210 -0
- package/dist/wrapper/__tests__/session-manager-context-governor.test.js.map +1 -0
- package/dist/wrapper/claude-code-process.d.ts +1 -0
- package/dist/wrapper/claude-code-process.d.ts.map +1 -1
- package/dist/wrapper/claude-code-process.js +32 -19
- package/dist/wrapper/claude-code-process.js.map +1 -1
- package/dist/wrapper/cleanup-registry.d.ts.map +1 -1
- package/dist/wrapper/cleanup-registry.js +3 -1
- package/dist/wrapper/cleanup-registry.js.map +1 -1
- package/dist/wrapper/codex-session.d.ts +3 -0
- package/dist/wrapper/codex-session.d.ts.map +1 -1
- package/dist/wrapper/codex-session.js +193 -85
- package/dist/wrapper/codex-session.js.map +1 -1
- package/dist/wrapper/debug.d.ts.map +1 -1
- package/dist/wrapper/debug.js +2 -0
- package/dist/wrapper/debug.js.map +1 -1
- package/dist/wrapper/direct-provider-adapter-factory.d.ts +12 -0
- package/dist/wrapper/direct-provider-adapter-factory.d.ts.map +1 -0
- package/dist/wrapper/direct-provider-adapter-factory.js +99 -0
- package/dist/wrapper/direct-provider-adapter-factory.js.map +1 -0
- package/dist/wrapper/index.d.ts +0 -2
- package/dist/wrapper/index.d.ts.map +1 -1
- package/dist/wrapper/index.js +0 -1
- package/dist/wrapper/index.js.map +1 -1
- package/dist/wrapper/opencode-session.d.ts +4 -0
- package/dist/wrapper/opencode-session.d.ts.map +1 -1
- package/dist/wrapper/opencode-session.js +245 -38
- package/dist/wrapper/opencode-session.js.map +1 -1
- package/dist/wrapper/permission-evaluator.d.ts +2 -1
- package/dist/wrapper/permission-evaluator.d.ts.map +1 -1
- package/dist/wrapper/permission-evaluator.js +54 -0
- package/dist/wrapper/permission-evaluator.js.map +1 -1
- package/dist/wrapper/permission-normalizer.d.ts +5 -1
- package/dist/wrapper/permission-normalizer.d.ts.map +1 -1
- package/dist/wrapper/permission-normalizer.js +17 -0
- package/dist/wrapper/permission-normalizer.js.map +1 -1
- package/dist/wrapper/permission-policy-authorizer.d.ts +1 -1
- package/dist/wrapper/permission-policy-authorizer.js +1 -1
- package/dist/wrapper/pooled-harness-session.d.ts +24 -0
- package/dist/wrapper/pooled-harness-session.d.ts.map +1 -0
- package/dist/wrapper/pooled-harness-session.js +123 -0
- package/dist/wrapper/pooled-harness-session.js.map +1 -0
- package/dist/wrapper/preamble-builder.d.ts +4 -1
- package/dist/wrapper/preamble-builder.d.ts.map +1 -1
- package/dist/wrapper/preamble-builder.js +48 -20
- package/dist/wrapper/preamble-builder.js.map +1 -1
- package/dist/wrapper/provider-session.d.ts +25 -5
- package/dist/wrapper/provider-session.d.ts.map +1 -1
- package/dist/wrapper/provider-session.js +562 -138
- package/dist/wrapper/provider-session.js.map +1 -1
- package/dist/wrapper/session-manager.d.ts.map +1 -1
- package/dist/wrapper/session-manager.js +16 -5
- package/dist/wrapper/session-manager.js.map +1 -1
- package/dist/wrapper/session-registry.d.ts +11 -1
- package/dist/wrapper/session-registry.d.ts.map +1 -1
- package/dist/wrapper/session-registry.js +167 -259
- package/dist/wrapper/session-registry.js.map +1 -1
- package/dist/wrapper/session-store.d.ts +33 -10
- package/dist/wrapper/session-store.d.ts.map +1 -1
- package/dist/wrapper/session-store.js +327 -84
- package/dist/wrapper/session-store.js.map +1 -1
- package/dist/wrapper/session.d.ts +55 -2
- package/dist/wrapper/session.d.ts.map +1 -1
- package/dist/wrapper/session.js +11 -2
- package/dist/wrapper/session.js.map +1 -1
- package/package.json +6 -5
- package/dist/application/__tests__/plan-exit-tool.test.d.ts +0 -2
- package/dist/application/__tests__/plan-exit-tool.test.d.ts.map +0 -1
- package/dist/application/__tests__/plan-exit-tool.test.js +0 -12
- package/dist/application/__tests__/plan-exit-tool.test.js.map +0 -1
- package/dist/application/context-governor.d.ts +0 -26
- package/dist/application/context-governor.d.ts.map +0 -1
- package/dist/application/context-governor.js +0 -164
- package/dist/application/context-governor.js.map +0 -1
- package/dist/application/plan-exit-tool.d.ts +0 -19
- package/dist/application/plan-exit-tool.d.ts.map +0 -1
- package/dist/application/plan-exit-tool.js +0 -13
- package/dist/application/plan-exit-tool.js.map +0 -1
- package/dist/commands/serve.d.ts +0 -7
- package/dist/commands/serve.d.ts.map +0 -1
- package/dist/commands/serve.js +0 -24
- package/dist/commands/serve.js.map +0 -1
- package/dist/mcp/server.d.ts +0 -36
- package/dist/mcp/server.d.ts.map +0 -1
- package/dist/mcp/server.js +0 -156
- package/dist/mcp/server.js.map +0 -1
- package/dist/mcp/transports.d.ts +0 -28
- package/dist/mcp/transports.d.ts.map +0 -1
- package/dist/mcp/transports.js +0 -108
- package/dist/mcp/transports.js.map +0 -1
- package/dist/mcp-entry.d.ts +0 -3
- package/dist/mcp-entry.d.ts.map +0 -1
- package/dist/mcp-entry.js +0 -19
- package/dist/mcp-entry.js.map +0 -1
- package/dist/sync/agent-sync.d.ts +0 -13
- package/dist/sync/agent-sync.d.ts.map +0 -1
- package/dist/sync/agent-sync.js +0 -130
- package/dist/sync/agent-sync.js.map +0 -1
- package/dist/sync/agent-sync.test.d.ts +0 -2
- package/dist/sync/agent-sync.test.d.ts.map +0 -1
- package/dist/sync/agent-sync.test.js +0 -130
- package/dist/sync/agent-sync.test.js.map +0 -1
- package/dist/sync/agents-md-sync.d.ts +0 -7
- package/dist/sync/agents-md-sync.d.ts.map +0 -1
- package/dist/sync/agents-md-sync.js +0 -44
- package/dist/sync/agents-md-sync.js.map +0 -1
- package/dist/sync/agents-md-sync.test.d.ts +0 -2
- package/dist/sync/agents-md-sync.test.d.ts.map +0 -1
- package/dist/sync/agents-md-sync.test.js +0 -154
- package/dist/sync/agents-md-sync.test.js.map +0 -1
- package/dist/sync/hook-sync.d.ts +0 -8
- package/dist/sync/hook-sync.d.ts.map +0 -1
- package/dist/sync/hook-sync.js +0 -90
- package/dist/sync/hook-sync.js.map +0 -1
- package/dist/sync/security-sync.d.ts +0 -9
- package/dist/sync/security-sync.d.ts.map +0 -1
- package/dist/sync/security-sync.js +0 -161
- package/dist/sync/security-sync.js.map +0 -1
- package/dist/sync/skill-sync.d.ts +0 -10
- package/dist/sync/skill-sync.d.ts.map +0 -1
- package/dist/sync/skill-sync.js +0 -87
- package/dist/sync/skill-sync.js.map +0 -1
- package/dist/sync/skill-sync.test.d.ts +0 -2
- package/dist/sync/skill-sync.test.d.ts.map +0 -1
- package/dist/sync/skill-sync.test.js +0 -163
- package/dist/sync/skill-sync.test.js.map +0 -1
- package/dist/wrapper/executable-provider-session.d.ts +0 -26
- package/dist/wrapper/executable-provider-session.d.ts.map +0 -1
- package/dist/wrapper/executable-provider-session.js +0 -214
- package/dist/wrapper/executable-provider-session.js.map +0 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
3
|
+
export function resolveProjectRoot(options = {}) {
|
|
4
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
5
|
+
const start = normalizeStartPath(resolve(cwd, options.explicitPath ?? "."));
|
|
6
|
+
const kilnRoot = findAncestor(start, (candidate) => existsSync(join(candidate, ".kiln", "kiln.yaml")));
|
|
7
|
+
if (kilnRoot) {
|
|
8
|
+
return {
|
|
9
|
+
rootPath: kilnRoot,
|
|
10
|
+
source: "kiln-yaml",
|
|
11
|
+
hasKilnYaml: true,
|
|
12
|
+
hasGitRoot: hasGitMarker(kilnRoot),
|
|
13
|
+
projectName: readProjectName(kilnRoot),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const gitRoot = findAncestor(start, hasGitMarker);
|
|
17
|
+
if (gitRoot) {
|
|
18
|
+
return {
|
|
19
|
+
rootPath: gitRoot,
|
|
20
|
+
source: "git",
|
|
21
|
+
hasKilnYaml: false,
|
|
22
|
+
hasGitRoot: true,
|
|
23
|
+
projectName: readProjectName(gitRoot),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
rootPath: start,
|
|
28
|
+
source: options.explicitPath ? "explicit" : "cwd",
|
|
29
|
+
hasKilnYaml: false,
|
|
30
|
+
hasGitRoot: false,
|
|
31
|
+
projectName: readProjectName(start),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function normalizeStartPath(path) {
|
|
35
|
+
if (!existsSync(path)) {
|
|
36
|
+
return path;
|
|
37
|
+
}
|
|
38
|
+
return statSync(path).isFile() ? dirname(path) : path;
|
|
39
|
+
}
|
|
40
|
+
function findAncestor(start, predicate) {
|
|
41
|
+
let current = start;
|
|
42
|
+
while (true) {
|
|
43
|
+
if (predicate(current)) {
|
|
44
|
+
return current;
|
|
45
|
+
}
|
|
46
|
+
const parent = dirname(current);
|
|
47
|
+
if (parent === current) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
current = parent;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function hasGitMarker(candidate) {
|
|
54
|
+
return existsSync(join(candidate, ".git"));
|
|
55
|
+
}
|
|
56
|
+
function readProjectName(projectPath) {
|
|
57
|
+
const packageJsonPath = join(projectPath, "package.json");
|
|
58
|
+
if (existsSync(packageJsonPath)) {
|
|
59
|
+
try {
|
|
60
|
+
const parsed = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
61
|
+
if (typeof parsed.name === "string" && parsed.name.trim().length > 0) {
|
|
62
|
+
return parsed.name.trim();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return basename(projectPath);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return basename(projectPath);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=project-root-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-root-resolver.js","sourceRoot":"","sources":["../../src/application/project-root-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiB7D,MAAM,UAAU,kBAAkB,CAAC,UAAqC,EAAE;IACxE,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,kBAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,YAAY,IAAI,GAAG,CAAC,CAAC,CAAC;IAC5E,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAEvG,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO;YACL,QAAQ,EAAE,QAAQ;YAClB,MAAM,EAAE,WAAW;YACnB,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,YAAY,CAAC,QAAQ,CAAC;YAClC,WAAW,EAAE,eAAe,CAAC,QAAQ,CAAC;SACvC,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAClD,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO;YACL,QAAQ,EAAE,OAAO;YACjB,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,KAAK;YAClB,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,eAAe,CAAC,OAAO,CAAC;SACtC,CAAC;IACJ,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK;QACjD,WAAW,EAAE,KAAK;QAClB,UAAU,EAAE,KAAK;QACjB,WAAW,EAAE,eAAe,CAAC,KAAK,CAAC;KACpC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY;IACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACxD,CAAC;AAED,SAAS,YAAY,CAAC,KAAa,EAAE,SAAyC;IAC5E,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YACvB,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,SAAiB;IACrC,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,eAAe,CAAC,WAAmB;IAC1C,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAC1D,IAAI,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QAChC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAuB,CAAC;YACxF,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type WorkflowSnapshotExport } from "./workflow-snapshot-export.js";
|
|
2
|
+
export type RepoShimKind = "agents" | "claude";
|
|
3
|
+
export interface RepoShimProjectionTargetResult {
|
|
4
|
+
readonly kind: RepoShimKind;
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly written: boolean;
|
|
7
|
+
readonly status: "written" | "blocked" | "unchanged";
|
|
8
|
+
readonly errors: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
export interface RepoShimProjectionResult {
|
|
11
|
+
readonly written: boolean;
|
|
12
|
+
readonly targets: readonly RepoShimProjectionTargetResult[];
|
|
13
|
+
readonly workflowSnapshot?: WorkflowSnapshotExport;
|
|
14
|
+
readonly workflowSnapshotProjection?: WorkflowSnapshotProjectionResult;
|
|
15
|
+
readonly workflowSnapshotManifest?: WorkflowSnapshotManifestResult;
|
|
16
|
+
readonly errors: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
export interface WorkflowSnapshotProjectionResult {
|
|
19
|
+
readonly path: string;
|
|
20
|
+
readonly written: boolean;
|
|
21
|
+
readonly status: "written" | "unchanged";
|
|
22
|
+
readonly errors: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
export interface WorkflowSnapshotManifestResult {
|
|
25
|
+
readonly path: string;
|
|
26
|
+
readonly written: boolean;
|
|
27
|
+
readonly status: "written" | "unchanged";
|
|
28
|
+
readonly errors: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
export interface WorkflowSnapshotManifestStatus {
|
|
31
|
+
readonly path: string;
|
|
32
|
+
readonly status: "missing" | "current" | "stale" | "drifted";
|
|
33
|
+
readonly expectedHash?: string;
|
|
34
|
+
readonly currentHash?: string;
|
|
35
|
+
readonly details?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface RepoShimProjectionStatus {
|
|
38
|
+
readonly target: RepoShimKind;
|
|
39
|
+
readonly path: string;
|
|
40
|
+
readonly status: "missing" | "current" | "stale" | "drifted" | "unmanaged";
|
|
41
|
+
}
|
|
42
|
+
export interface RepoShimProjectionOptions {
|
|
43
|
+
readonly force?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare function writeRepoShimProjections(projectPath: string, options?: RepoShimProjectionOptions): Promise<RepoShimProjectionResult>;
|
|
46
|
+
export declare function readRepoShimProjectionStatuses(projectPath: string): Promise<readonly RepoShimProjectionStatus[]>;
|
|
47
|
+
export declare function readWorkflowSnapshotManifestStatus(projectPath: string): Promise<WorkflowSnapshotManifestStatus>;
|
|
48
|
+
//# sourceMappingURL=repo-shim-projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-shim-projection.d.ts","sourceRoot":"","sources":["../../src/application/repo-shim-projection.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAC;AAKvC,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAQ/C,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;IACrD,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,8BAA8B,EAAE,CAAC;IAC5D,QAAQ,CAAC,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IACnD,QAAQ,CAAC,0BAA0B,CAAC,EAAE,gCAAgC,CAAC;IACvE,QAAQ,CAAC,wBAAwB,CAAC,EAAE,8BAA8B,CAAC;IACnE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAC7D,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;CAC5E;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAqBD,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,wBAAwB,CAAC,CA8DnC;AAED,wBAAsB,8BAA8B,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,wBAAwB,EAAE,CAAC,CA2CtH;AAED,wBAAsB,kCAAkC,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAkCrH"}
|
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { join, relative } from "node:path";
|
|
4
|
+
import { loadAgentDefinitions } from "./agent-loader.js";
|
|
5
|
+
import { findInstructionProfile, loadInstructionProfiles, } from "./instruction-profile-loader.js";
|
|
6
|
+
import { loadKilnConfig } from "../config/config-merger.js";
|
|
7
|
+
import { collectProjectContextEvidence, readProjectContextMarkdown, } from "./project-context.js";
|
|
8
|
+
import { buildWorkflowSnapshotExport, } from "./workflow-snapshot-export.js";
|
|
9
|
+
const GENERATOR_VERSION = "repo-shims-v1";
|
|
10
|
+
const SIGNATURE = "kiln:repo-shim:v1";
|
|
11
|
+
const TARGETS = [
|
|
12
|
+
{
|
|
13
|
+
kind: "agents",
|
|
14
|
+
filename: "AGENTS.md",
|
|
15
|
+
audience: "Codex CLI and OpenCode",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
kind: "claude",
|
|
19
|
+
filename: "CLAUDE.md",
|
|
20
|
+
audience: "Claude Code",
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
const WORKFLOW_SNAPSHOT_MARKDOWN_FILE = ".kiln/projections/workflow-snapshot.md";
|
|
24
|
+
export async function writeRepoShimProjections(projectPath, options = {}) {
|
|
25
|
+
const results = [];
|
|
26
|
+
let workflowSnapshot;
|
|
27
|
+
let workflowSnapshotProjection;
|
|
28
|
+
let workflowSnapshotManifest;
|
|
29
|
+
try {
|
|
30
|
+
const agents = await loadAgentDefinitions(projectPath);
|
|
31
|
+
const instructionProfiles = loadInstructionProfiles(projectPath);
|
|
32
|
+
const kilnYaml = await loadKilnConfig(projectPath);
|
|
33
|
+
const repoContext = collectProjectContextEvidence(projectPath);
|
|
34
|
+
const adoptedProjectContext = readProjectContextMarkdown(projectPath);
|
|
35
|
+
const sourceProfiles = kilnYaml?.activeInstructionProfiles ?? [];
|
|
36
|
+
const projectRootId = hashText(repoContext.projectName.toLowerCase()).slice(0, 16);
|
|
37
|
+
for (const target of TARGETS) {
|
|
38
|
+
results.push(writeRepoShimTarget({
|
|
39
|
+
projectPath,
|
|
40
|
+
target,
|
|
41
|
+
agents,
|
|
42
|
+
instructionProfiles,
|
|
43
|
+
kilnYaml,
|
|
44
|
+
repoContext,
|
|
45
|
+
adoptedProjectContext,
|
|
46
|
+
sourceProfiles,
|
|
47
|
+
projectRootId,
|
|
48
|
+
force: options.force ?? false,
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
workflowSnapshot = buildWorkflowSnapshotExport({
|
|
52
|
+
generatedAt: new Date().toISOString(),
|
|
53
|
+
generatedFiles: workflowSnapshotGeneratedFiles(),
|
|
54
|
+
projectContext: repoContext,
|
|
55
|
+
instructionProfiles,
|
|
56
|
+
kilnConfig: kilnYaml,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
61
|
+
return {
|
|
62
|
+
written: false,
|
|
63
|
+
targets: [],
|
|
64
|
+
errors: [message],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const errors = results.flatMap((result) => [...result.errors]);
|
|
68
|
+
if (errors.length === 0 && workflowSnapshot) {
|
|
69
|
+
workflowSnapshotProjection = writeWorkflowSnapshotProjection(projectPath, workflowSnapshot);
|
|
70
|
+
workflowSnapshotManifest = writeWorkflowSnapshotManifest(projectPath, workflowSnapshot);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
written: errors.length === 0 && (results.some((result) => result.written)
|
|
74
|
+
|| (workflowSnapshotProjection?.written ?? false)
|
|
75
|
+
|| (workflowSnapshotManifest?.written ?? false)),
|
|
76
|
+
targets: results,
|
|
77
|
+
workflowSnapshot,
|
|
78
|
+
workflowSnapshotProjection,
|
|
79
|
+
workflowSnapshotManifest,
|
|
80
|
+
errors,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export async function readRepoShimProjectionStatuses(projectPath) {
|
|
84
|
+
const agents = await loadAgentDefinitions(projectPath);
|
|
85
|
+
const instructionProfiles = loadInstructionProfiles(projectPath);
|
|
86
|
+
const kilnYaml = await loadKilnConfig(projectPath);
|
|
87
|
+
const repoContext = collectProjectContextEvidence(projectPath);
|
|
88
|
+
const adoptedProjectContext = readProjectContextMarkdown(projectPath);
|
|
89
|
+
const sourceProfiles = kilnYaml?.activeInstructionProfiles ?? [];
|
|
90
|
+
const projectRootId = hashText(repoContext.projectName.toLowerCase()).slice(0, 16);
|
|
91
|
+
return TARGETS.map((target) => {
|
|
92
|
+
const path = join(projectPath, target.filename);
|
|
93
|
+
const expected = renderSignedProjection({
|
|
94
|
+
body: renderRepoShimBody({
|
|
95
|
+
projectPath,
|
|
96
|
+
target,
|
|
97
|
+
agents,
|
|
98
|
+
instructionProfiles,
|
|
99
|
+
kilnYaml,
|
|
100
|
+
repoContext,
|
|
101
|
+
adoptedProjectContext,
|
|
102
|
+
}),
|
|
103
|
+
target,
|
|
104
|
+
sourceProfiles,
|
|
105
|
+
projectRootId,
|
|
106
|
+
projectName: repoContext.projectName,
|
|
107
|
+
});
|
|
108
|
+
if (!existsSync(path)) {
|
|
109
|
+
return { target: target.kind, path, status: "missing" };
|
|
110
|
+
}
|
|
111
|
+
const existing = readFileSync(path, "utf-8");
|
|
112
|
+
const existingState = classifyExistingProjection(existing, target.kind);
|
|
113
|
+
if (existingState === "unmanaged" || existingState === "drifted") {
|
|
114
|
+
return { target: target.kind, path, status: existingState };
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
target: target.kind,
|
|
118
|
+
path,
|
|
119
|
+
status: existing === expected ? "current" : "stale",
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
export async function readWorkflowSnapshotManifestStatus(projectPath) {
|
|
124
|
+
const manifestPath = workflowSnapshotManifestPath(projectPath);
|
|
125
|
+
if (!existsSync(manifestPath)) {
|
|
126
|
+
return { path: manifestPath, status: "missing" };
|
|
127
|
+
}
|
|
128
|
+
const content = readFileSync(manifestPath, "utf-8");
|
|
129
|
+
const currentHash = readManifestHash(content);
|
|
130
|
+
if (!currentHash) {
|
|
131
|
+
return {
|
|
132
|
+
path: manifestPath,
|
|
133
|
+
status: "drifted",
|
|
134
|
+
details: "workflow snapshot manifest is not valid JSON",
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const expected = await buildCurrentWorkflowSnapshot(projectPath);
|
|
138
|
+
const expectedHash = expected.manifest.hash;
|
|
139
|
+
if (currentHash !== expectedHash) {
|
|
140
|
+
return {
|
|
141
|
+
path: manifestPath,
|
|
142
|
+
status: "stale",
|
|
143
|
+
expectedHash,
|
|
144
|
+
currentHash,
|
|
145
|
+
details: `workflow snapshot manifest hash is stale: expected ${expectedHash}, found ${currentHash}`,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
path: manifestPath,
|
|
150
|
+
status: "current",
|
|
151
|
+
expectedHash,
|
|
152
|
+
currentHash,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function writeRepoShimTarget(input) {
|
|
156
|
+
const targetPath = join(input.projectPath, input.target.filename);
|
|
157
|
+
const body = renderRepoShimBody(input);
|
|
158
|
+
const content = renderSignedProjection({
|
|
159
|
+
body,
|
|
160
|
+
target: input.target,
|
|
161
|
+
sourceProfiles: input.sourceProfiles,
|
|
162
|
+
projectRootId: input.projectRootId,
|
|
163
|
+
projectName: input.repoContext.projectName,
|
|
164
|
+
});
|
|
165
|
+
const existing = existsSync(targetPath) ? readFileSync(targetPath, "utf-8") : null;
|
|
166
|
+
const existingState = existing ? classifyExistingProjection(existing, input.target.kind) : "missing";
|
|
167
|
+
if (existingState === "unmanaged" && !input.force) {
|
|
168
|
+
return {
|
|
169
|
+
kind: input.target.kind,
|
|
170
|
+
path: targetPath,
|
|
171
|
+
written: false,
|
|
172
|
+
status: "blocked",
|
|
173
|
+
errors: [`${input.target.filename}: unmanaged guidance file exists; adopt or back up before generating repo shims`],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (existingState === "drifted" && !input.force) {
|
|
177
|
+
return {
|
|
178
|
+
kind: input.target.kind,
|
|
179
|
+
path: targetPath,
|
|
180
|
+
written: false,
|
|
181
|
+
status: "blocked",
|
|
182
|
+
errors: [`${input.target.filename}: managed repo shim drift detected; rerun with --force after reviewing changes`],
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
if (existing === content) {
|
|
186
|
+
return {
|
|
187
|
+
kind: input.target.kind,
|
|
188
|
+
path: targetPath,
|
|
189
|
+
written: false,
|
|
190
|
+
status: "unchanged",
|
|
191
|
+
errors: [],
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
if (existing && input.force) {
|
|
195
|
+
backupExistingShim(input.projectPath, input.target.filename, existing);
|
|
196
|
+
}
|
|
197
|
+
writeFileSync(targetPath, content, "utf-8");
|
|
198
|
+
return {
|
|
199
|
+
kind: input.target.kind,
|
|
200
|
+
path: targetPath,
|
|
201
|
+
written: true,
|
|
202
|
+
status: "written",
|
|
203
|
+
errors: [],
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function renderRepoShimBody(input) {
|
|
207
|
+
const { projectPath, target, agents, instructionProfiles, kilnYaml, repoContext, adoptedProjectContext } = input;
|
|
208
|
+
const domain = kilnYaml?.domain ?? "default";
|
|
209
|
+
const provider = kilnYaml?.provider ?? "provider default";
|
|
210
|
+
const model = kilnYaml?.model?.default ?? "provider default";
|
|
211
|
+
const maxDepth = String(kilnYaml?.maxDepth ?? 3);
|
|
212
|
+
const parallelWorkers = String(kilnYaml?.parallelWorkers ?? 1);
|
|
213
|
+
const rows = [...agents]
|
|
214
|
+
.sort((left, right) => left.name.localeCompare(right.name))
|
|
215
|
+
.map(formatAgentRow);
|
|
216
|
+
const lines = [
|
|
217
|
+
target.kind === "claude" ? "# Claude Project Guidance" : "# Agents",
|
|
218
|
+
"",
|
|
219
|
+
`> Generated by kiln sync --repo-shims for ${target.audience}. Do not edit manually.`,
|
|
220
|
+
"",
|
|
221
|
+
"## Project",
|
|
222
|
+
"",
|
|
223
|
+
`- Name: ${repoContext.projectName}`,
|
|
224
|
+
`- Domain: ${domain}`,
|
|
225
|
+
`- Default provider: ${provider}`,
|
|
226
|
+
`- Default model: ${model}`,
|
|
227
|
+
`- Max depth: ${maxDepth}`,
|
|
228
|
+
`- Parallel workers: ${parallelWorkers}`,
|
|
229
|
+
"",
|
|
230
|
+
];
|
|
231
|
+
if (!adoptedProjectContext && (repoContext.packageManager || repoContext.scripts.length > 0 || repoContext.workspacePackages.length > 0)) {
|
|
232
|
+
lines.push("## Repository Evidence", "");
|
|
233
|
+
if (repoContext.packageManager) {
|
|
234
|
+
lines.push(`- Package manager: ${repoContext.packageManager}`);
|
|
235
|
+
}
|
|
236
|
+
for (const [name, command] of repoContext.scripts) {
|
|
237
|
+
lines.push(`- Script \`${name}\`: \`${command}\``);
|
|
238
|
+
}
|
|
239
|
+
for (const workspacePackage of repoContext.workspacePackages) {
|
|
240
|
+
lines.push(`- Workspace package: \`${workspacePackage}\``);
|
|
241
|
+
}
|
|
242
|
+
lines.push("");
|
|
243
|
+
}
|
|
244
|
+
if (!adoptedProjectContext && repoContext.docs.length > 0) {
|
|
245
|
+
lines.push("## Canonical Project References", "", ...repoContext.docs.map((doc) => `- ${doc}`), "");
|
|
246
|
+
}
|
|
247
|
+
if (adoptedProjectContext) {
|
|
248
|
+
lines.push("## Adopted Project Context", "", "Canonical source: `.kiln/project-context.md`.", "", stripFrontmatter(adoptedProjectContext).trim(), "");
|
|
249
|
+
}
|
|
250
|
+
if (kilnYaml?.activeInstructionProfiles && kilnYaml.activeInstructionProfiles.length > 0) {
|
|
251
|
+
const profileLines = kilnYaml.activeInstructionProfiles.map((profileId) => {
|
|
252
|
+
const profile = findInstructionProfile(instructionProfiles, profileId);
|
|
253
|
+
return profile
|
|
254
|
+
? `- ${profile.name} (${profile.scope}): ${formatProfilePath(profile, projectPath)}${formatDoctrineSummary(profile.doctrine)}`
|
|
255
|
+
: `- ${profileId} (missing; create the canonical Kiln instruction profile before relying on this shim)`;
|
|
256
|
+
});
|
|
257
|
+
lines.push("## Active Instruction Profiles", "", "Read these canonical Kiln instruction profiles before work. They are the source of durable operator/team doctrine; this file is only a projection.", "", ...profileLines, "");
|
|
258
|
+
}
|
|
259
|
+
if (kilnYaml?.workGovernance) {
|
|
260
|
+
lines.push("## Work Governance", "", "Follow the resolved Kiln work-governance policy before choosing direct execution.", ...[
|
|
261
|
+
kilnYaml.workGovernance.defaultPosture ? `- Default posture: ${kilnYaml.workGovernance.defaultPosture}` : undefined,
|
|
262
|
+
kilnYaml.workGovernance.directExecution
|
|
263
|
+
? `- Direct execution: ${formatDirectExecution(kilnYaml.workGovernance.directExecution)}`
|
|
264
|
+
: undefined,
|
|
265
|
+
kilnYaml.workGovernance.requireDelegationFor && kilnYaml.workGovernance.requireDelegationFor.length > 0
|
|
266
|
+
? `- Orchestrate/delegate for: ${kilnYaml.workGovernance.requireDelegationFor.join(", ")}`
|
|
267
|
+
: undefined,
|
|
268
|
+
kilnYaml.workGovernance.requiredEvidence && kilnYaml.workGovernance.requiredEvidence.length > 0
|
|
269
|
+
? `- Evidence before done: ${kilnYaml.workGovernance.requiredEvidence.join(", ")}`
|
|
270
|
+
: undefined,
|
|
271
|
+
].filter((line) => line !== undefined), "");
|
|
272
|
+
}
|
|
273
|
+
lines.push("## Agents", "", "| Name | Display | Role | Tools | Model | Skills | Instruction Profiles |", "|------|---------|------|-------|-------|--------|----------------------|", ...rows, "");
|
|
274
|
+
if (rows.length === 0) {
|
|
275
|
+
lines.push("No agent profiles defined. Create `.kiln/agents/<name>.md` or `~/.kiln/agents/<name>.md` to add one.", "");
|
|
276
|
+
}
|
|
277
|
+
lines.push("## Usage", "", "Use canonical Kiln profiles, instruction profiles, and skills as the source of truth.", "Do not add durable workflow doctrine directly to this generated file.", "Update Kiln config and rerun `kiln sync --repo-shims` instead.", "");
|
|
278
|
+
return lines.join("\n");
|
|
279
|
+
}
|
|
280
|
+
function formatDirectExecution(config) {
|
|
281
|
+
if (!config) {
|
|
282
|
+
return "configured";
|
|
283
|
+
}
|
|
284
|
+
const parts = [
|
|
285
|
+
config.maxFiles !== undefined ? `maxFiles=${config.maxFiles}` : undefined,
|
|
286
|
+
config.maxRisk ? `maxRisk=${config.maxRisk}` : undefined,
|
|
287
|
+
].filter((part) => part !== undefined);
|
|
288
|
+
return parts.length > 0 ? parts.join(", ") : "configured";
|
|
289
|
+
}
|
|
290
|
+
function formatAgentRow(agent) {
|
|
291
|
+
const tools = agent.tools && agent.tools.length > 0 ? agent.tools.join(", ") : "-";
|
|
292
|
+
const skills = agent.skills && agent.skills.length > 0 ? agent.skills.join(", ") : "-";
|
|
293
|
+
const taskAffinity = agent.taskAffinity && agent.taskAffinity.length > 0 ? `; tasks: ${agent.taskAffinity.join(", ")}` : "";
|
|
294
|
+
const displayName = agent.displayName ?? "-";
|
|
295
|
+
const instructionProfiles = agent.instructionProfiles && agent.instructionProfiles.length > 0
|
|
296
|
+
? agent.instructionProfiles.join(", ")
|
|
297
|
+
: "-";
|
|
298
|
+
return `| ${agent.name} (${agent.scope}) | ${displayName} | ${agent.role}${taskAffinity} | ${tools} | ${agent.model ?? "-"} | ${skills} | ${instructionProfiles} |`;
|
|
299
|
+
}
|
|
300
|
+
function formatProfilePath(profile, projectPath) {
|
|
301
|
+
const normalizedPath = profile.filePath.replace(/\\/g, "/");
|
|
302
|
+
const globalMarker = "/.kiln/instructions/";
|
|
303
|
+
const globalIndex = normalizedPath.indexOf(globalMarker);
|
|
304
|
+
if (profile.scope === "global" && globalIndex >= 0) {
|
|
305
|
+
return `~/.kiln/instructions/${normalizedPath.slice(globalIndex + globalMarker.length)}`;
|
|
306
|
+
}
|
|
307
|
+
const relativePath = relative(projectPath, profile.filePath).replace(/\\/g, "/");
|
|
308
|
+
if (!relativePath.startsWith("..") && !relativePath.startsWith("/") && !/^[A-Za-z]:/.test(relativePath)) {
|
|
309
|
+
return relativePath;
|
|
310
|
+
}
|
|
311
|
+
return normalizedPath;
|
|
312
|
+
}
|
|
313
|
+
function renderSignedProjection(input) {
|
|
314
|
+
const contentHash = hashText(input.body);
|
|
315
|
+
return [
|
|
316
|
+
"<!--",
|
|
317
|
+
SIGNATURE,
|
|
318
|
+
`target: ${input.target.kind}`,
|
|
319
|
+
`projectName: ${input.projectName}`,
|
|
320
|
+
`projectRootId: sha256:${input.projectRootId}`,
|
|
321
|
+
`sourceProfiles: ${input.sourceProfiles.length > 0 ? input.sourceProfiles.join(",") : "-"}`,
|
|
322
|
+
`generator: ${GENERATOR_VERSION}`,
|
|
323
|
+
`contentHash: sha256:${contentHash}`,
|
|
324
|
+
"-->",
|
|
325
|
+
input.body,
|
|
326
|
+
].join("\n");
|
|
327
|
+
}
|
|
328
|
+
function stripFrontmatter(content) {
|
|
329
|
+
const normalized = content.replace(/^\uFEFF/, "");
|
|
330
|
+
const match = /^---\s*\r?\n[\s\S]*?\r?\n---\s*([\s\S]*)$/u.exec(normalized);
|
|
331
|
+
return match?.[1] ?? normalized;
|
|
332
|
+
}
|
|
333
|
+
function classifyExistingProjection(content, expectedTarget) {
|
|
334
|
+
const metadata = readProjectionMetadata(content);
|
|
335
|
+
if (!metadata || metadata.target !== expectedTarget) {
|
|
336
|
+
return "unmanaged";
|
|
337
|
+
}
|
|
338
|
+
const body = content.slice(content.indexOf("-->") + 3).replace(/^\r?\n/, "");
|
|
339
|
+
return metadata.contentHash === `sha256:${hashText(body)}` ? "managed" : "drifted";
|
|
340
|
+
}
|
|
341
|
+
function readProjectionMetadata(content) {
|
|
342
|
+
const end = content.indexOf("-->");
|
|
343
|
+
if (!content.startsWith("<!--") || end === -1) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
const lines = content.slice(4, end).split(/\r?\n/).map((line) => line.trim());
|
|
347
|
+
if (!lines.includes(SIGNATURE)) {
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
const values = new Map();
|
|
351
|
+
for (const line of lines) {
|
|
352
|
+
const separator = line.indexOf(":");
|
|
353
|
+
if (separator > 0) {
|
|
354
|
+
values.set(line.slice(0, separator), line.slice(separator + 1).trim());
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
const target = values.get("target");
|
|
358
|
+
const contentHash = values.get("contentHash");
|
|
359
|
+
if (!target || !contentHash) {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
return { target, contentHash };
|
|
363
|
+
}
|
|
364
|
+
function backupExistingShim(projectPath, filename, content) {
|
|
365
|
+
const backupDir = join(projectPath, ".kiln", "backups", "repo-shims");
|
|
366
|
+
mkdirSync(backupDir, { recursive: true });
|
|
367
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
368
|
+
writeFileSync(join(backupDir, `${filename}.${timestamp}.bak`), content, "utf-8");
|
|
369
|
+
}
|
|
370
|
+
function writeWorkflowSnapshotManifest(projectPath, workflowSnapshot) {
|
|
371
|
+
const manifestPath = workflowSnapshotManifestPath(projectPath);
|
|
372
|
+
const existing = existsSync(manifestPath) ? readFileSync(manifestPath, "utf-8") : null;
|
|
373
|
+
const existingHash = existing ? readManifestHash(existing) : null;
|
|
374
|
+
if (existingHash === workflowSnapshot.manifest.hash) {
|
|
375
|
+
return {
|
|
376
|
+
path: manifestPath,
|
|
377
|
+
written: false,
|
|
378
|
+
status: "unchanged",
|
|
379
|
+
errors: [],
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
mkdirSync(join(projectPath, ".kiln", "projections"), { recursive: true });
|
|
383
|
+
writeFileSync(manifestPath, `${JSON.stringify(workflowSnapshot.manifest, null, 2)}\n`, "utf-8");
|
|
384
|
+
return {
|
|
385
|
+
path: manifestPath,
|
|
386
|
+
written: true,
|
|
387
|
+
status: "written",
|
|
388
|
+
errors: [],
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
function workflowSnapshotManifestPath(projectPath) {
|
|
392
|
+
return join(projectPath, ".kiln", "projections", "workflow-snapshot-manifest.json");
|
|
393
|
+
}
|
|
394
|
+
function readManifestHash(content) {
|
|
395
|
+
try {
|
|
396
|
+
const parsed = JSON.parse(content);
|
|
397
|
+
return typeof parsed.hash === "string" ? parsed.hash : null;
|
|
398
|
+
}
|
|
399
|
+
catch {
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
async function buildCurrentWorkflowSnapshot(projectPath) {
|
|
404
|
+
const instructionProfiles = loadInstructionProfiles(projectPath);
|
|
405
|
+
const kilnYaml = await loadKilnConfig(projectPath);
|
|
406
|
+
return buildWorkflowSnapshotExport({
|
|
407
|
+
generatedAt: new Date().toISOString(),
|
|
408
|
+
generatedFiles: workflowSnapshotGeneratedFiles(),
|
|
409
|
+
projectContext: collectProjectContextEvidence(projectPath),
|
|
410
|
+
instructionProfiles,
|
|
411
|
+
kilnConfig: kilnYaml,
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
function workflowSnapshotGeneratedFiles() {
|
|
415
|
+
return [
|
|
416
|
+
...TARGETS.map((target) => target.filename),
|
|
417
|
+
WORKFLOW_SNAPSHOT_MARKDOWN_FILE,
|
|
418
|
+
];
|
|
419
|
+
}
|
|
420
|
+
function writeWorkflowSnapshotProjection(projectPath, workflowSnapshot) {
|
|
421
|
+
const snapshotPath = workflowSnapshotMarkdownPath(projectPath);
|
|
422
|
+
const content = renderWorkflowSnapshotMarkdown(workflowSnapshot);
|
|
423
|
+
const existing = existsSync(snapshotPath) ? readFileSync(snapshotPath, "utf-8") : null;
|
|
424
|
+
if (existing === content) {
|
|
425
|
+
return {
|
|
426
|
+
path: snapshotPath,
|
|
427
|
+
written: false,
|
|
428
|
+
status: "unchanged",
|
|
429
|
+
errors: [],
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
mkdirSync(join(projectPath, ".kiln", "projections"), { recursive: true });
|
|
433
|
+
writeFileSync(snapshotPath, content, "utf-8");
|
|
434
|
+
return {
|
|
435
|
+
path: snapshotPath,
|
|
436
|
+
written: true,
|
|
437
|
+
status: "written",
|
|
438
|
+
errors: [],
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
function workflowSnapshotMarkdownPath(projectPath) {
|
|
442
|
+
return join(projectPath, WORKFLOW_SNAPSHOT_MARKDOWN_FILE);
|
|
443
|
+
}
|
|
444
|
+
function renderWorkflowSnapshotMarkdown(workflowSnapshot) {
|
|
445
|
+
const body = renderWorkflowSnapshotBody(workflowSnapshot);
|
|
446
|
+
return [
|
|
447
|
+
"<!--",
|
|
448
|
+
"kiln:workflow-snapshot:v1",
|
|
449
|
+
`generator: ${workflowSnapshot.manifest.generator}`,
|
|
450
|
+
`contentHash: sha256:${hashText(body)}`,
|
|
451
|
+
"-->",
|
|
452
|
+
body,
|
|
453
|
+
].join("\n");
|
|
454
|
+
}
|
|
455
|
+
function renderWorkflowSnapshotBody(workflowSnapshot) {
|
|
456
|
+
const lines = [
|
|
457
|
+
"# Kiln Workflow Snapshot",
|
|
458
|
+
"",
|
|
459
|
+
"> Generated by kiln sync --repo-shims from canonical Kiln workflow evidence. Do not edit manually.",
|
|
460
|
+
"",
|
|
461
|
+
"## Manifest",
|
|
462
|
+
"",
|
|
463
|
+
`- Hash: ${workflowSnapshot.manifest.hash}`,
|
|
464
|
+
`- Sources: ${workflowSnapshot.manifest.sourceIds.join(", ")}`,
|
|
465
|
+
`- Generated files: ${workflowSnapshot.manifest.generatedFiles.join(", ")}`,
|
|
466
|
+
"",
|
|
467
|
+
"## Specification",
|
|
468
|
+
"",
|
|
469
|
+
`- Project: ${workflowSnapshot.specification.projectName}`,
|
|
470
|
+
`- Package manager: ${workflowSnapshot.specification.packageManager ?? "unknown"}`,
|
|
471
|
+
`- Workspaces: ${formatSnapshotList(workflowSnapshot.specification.workspacePackages)}`,
|
|
472
|
+
`- Canonical docs: ${formatSnapshotList(workflowSnapshot.specification.canonicalDocs)}`,
|
|
473
|
+
"",
|
|
474
|
+
"## Plan",
|
|
475
|
+
"",
|
|
476
|
+
`- Default posture: ${workflowSnapshot.plan.defaultPosture ?? "unspecified"}`,
|
|
477
|
+
`- Orchestration triggers: ${formatSnapshotList(workflowSnapshot.plan.orchestrationTriggers)}`,
|
|
478
|
+
`- Evidence before done: ${formatSnapshotList(workflowSnapshot.plan.evidenceBeforeDone)}`,
|
|
479
|
+
"",
|
|
480
|
+
"## Authority",
|
|
481
|
+
"",
|
|
482
|
+
`- Default posture: ${workflowSnapshot.authorityPosture.defaultPosture ?? "unspecified"}`,
|
|
483
|
+
`- Direct execution: ${formatDirectExecutionSnapshot(workflowSnapshot.authorityPosture.directExecution)}`,
|
|
484
|
+
"",
|
|
485
|
+
"## Model Policy",
|
|
486
|
+
"",
|
|
487
|
+
`- Default provider: ${workflowSnapshot.modelPolicyGuidance.defaultProvider ?? "provider default"}`,
|
|
488
|
+
`- Default model: ${workflowSnapshot.modelPolicyGuidance.defaultModel ?? "provider default"}`,
|
|
489
|
+
`- Max depth: ${workflowSnapshot.modelPolicyGuidance.maxDepth ?? "unspecified"}`,
|
|
490
|
+
`- Parallel workers: ${workflowSnapshot.modelPolicyGuidance.parallelWorkers ?? "unspecified"}`,
|
|
491
|
+
"",
|
|
492
|
+
"## Work Item Profiles",
|
|
493
|
+
"",
|
|
494
|
+
"| Profile | Risk | Evidence | Gates |",
|
|
495
|
+
"|---------|------|----------|-------|",
|
|
496
|
+
...workflowSnapshot.workItems.map((profile) => `| ${profile.id} | ${profile.minimumRisk} | ${formatSnapshotList(profile.requiredEvidence)} | ${formatSnapshotList(profile.verificationGates)} |`),
|
|
497
|
+
"",
|
|
498
|
+
"## Instruction Profiles",
|
|
499
|
+
"",
|
|
500
|
+
...(workflowSnapshot.instructionProfiles.length > 0
|
|
501
|
+
? workflowSnapshot.instructionProfiles.map((profile) => `- ${profile.id} (${profile.scope}): ${profile.sourcePath}${profile.doctrineFacets.length > 0 ? ` - ${profile.doctrineFacets.join(", ")}` : ""}`)
|
|
502
|
+
: ["- none"]),
|
|
503
|
+
"",
|
|
504
|
+
];
|
|
505
|
+
return lines.join("\n");
|
|
506
|
+
}
|
|
507
|
+
function formatSnapshotList(values) {
|
|
508
|
+
return values.length > 0 ? values.join(", ") : "none";
|
|
509
|
+
}
|
|
510
|
+
function formatDirectExecutionSnapshot(directExecution) {
|
|
511
|
+
if (!directExecution) {
|
|
512
|
+
return "unspecified";
|
|
513
|
+
}
|
|
514
|
+
const parts = [
|
|
515
|
+
directExecution.maxFiles !== undefined ? `maxFiles=${directExecution.maxFiles}` : undefined,
|
|
516
|
+
directExecution.maxRisk ? `maxRisk=${directExecution.maxRisk}` : undefined,
|
|
517
|
+
].filter((part) => part !== undefined);
|
|
518
|
+
return parts.length > 0 ? parts.join(", ") : "configured";
|
|
519
|
+
}
|
|
520
|
+
function hashText(value) {
|
|
521
|
+
return createHash("sha256").update(value).digest("hex");
|
|
522
|
+
}
|
|
523
|
+
function formatDoctrineSummary(doctrine) {
|
|
524
|
+
if (!doctrine) {
|
|
525
|
+
return "";
|
|
526
|
+
}
|
|
527
|
+
const facets = [
|
|
528
|
+
doctrine.principles && doctrine.principles.length > 0 ? "principles" : undefined,
|
|
529
|
+
doctrine.workflow && doctrine.workflow.length > 0 ? "workflow" : undefined,
|
|
530
|
+
doctrine.qualityGates && doctrine.qualityGates.length > 0 ? "quality gates" : undefined,
|
|
531
|
+
doctrine.reviewPosture && doctrine.reviewPosture.length > 0 ? "review posture" : undefined,
|
|
532
|
+
doctrine.delegation && doctrine.delegation.length > 0 ? "delegation" : undefined,
|
|
533
|
+
].filter((facet) => facet !== undefined);
|
|
534
|
+
return facets.length > 0 ? ` - doctrine: ${facets.join(", ")}` : "";
|
|
535
|
+
}
|
|
536
|
+
//# sourceMappingURL=repo-shim-projection.js.map
|