iosm-cli 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/CHANGELOG.md +55 -0
- package/LICENSE +21 -0
- package/README.md +650 -0
- package/dist/cli/args.d.ts +54 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +331 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +79 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +92 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +34 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +15 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +88 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +262 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-profiles.d.ts +29 -0
- package/dist/core/agent-profiles.d.ts.map +1 -0
- package/dist/core/agent-profiles.js +86 -0
- package/dist/core/agent-profiles.js.map +1 -0
- package/dist/core/agent-session.d.ts +688 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +3112 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/agent-teams.d.ts +41 -0
- package/dist/core/agent-teams.d.ts.map +1 -0
- package/dist/core/agent-teams.js +90 -0
- package/dist/core/agent-teams.js.map +1 -0
- package/dist/core/ask-user-tool.d.ts +22 -0
- package/dist/core/ask-user-tool.d.ts.map +1 -0
- package/dist/core/ask-user-tool.js +115 -0
- package/dist/core/ask-user-tool.js.map +1 -0
- package/dist/core/auth-storage.d.ts +133 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +391 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +49 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +213 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +86 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +242 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +121 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +610 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.d.ts.map +1 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/index.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +35 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +138 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +71 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +34 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +222 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +971 -0
- package/dist/core/export-html/template.html +54 -0
- package/dist/core/export-html/template.js +1590 -0
- package/dist/core/export-html/tool-renderer.d.ts +35 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +63 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +6 -0
- package/dist/core/extensions/index.d.ts +11 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/index.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +25 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +447 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +146 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +652 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1074 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +35 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +27 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +102 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +32 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +134 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/hooks.d.ts +53 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/hooks.js +332 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +55 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +157 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/mcp/cli.d.ts +27 -0
- package/dist/core/mcp/cli.d.ts.map +1 -0
- package/dist/core/mcp/cli.js +275 -0
- package/dist/core/mcp/cli.js.map +1 -0
- package/dist/core/mcp/config.d.ts +11 -0
- package/dist/core/mcp/config.d.ts.map +1 -0
- package/dist/core/mcp/config.js +310 -0
- package/dist/core/mcp/config.js.map +1 -0
- package/dist/core/mcp/index.d.ts +5 -0
- package/dist/core/mcp/index.d.ts.map +1 -0
- package/dist/core/mcp/index.js +4 -0
- package/dist/core/mcp/index.js.map +1 -0
- package/dist/core/mcp/runtime.d.ts +42 -0
- package/dist/core/mcp/runtime.d.ts.map +1 -0
- package/dist/core/mcp/runtime.js +387 -0
- package/dist/core/mcp/runtime.js.map +1 -0
- package/dist/core/mcp/types.d.ts +76 -0
- package/dist/core/mcp/types.d.ts.map +1 -0
- package/dist/core/mcp/types.js +2 -0
- package/dist/core/mcp/types.js.map +1 -0
- package/dist/core/memory.d.ts +27 -0
- package/dist/core/memory.d.ts.map +1 -0
- package/dist/core/memory.js +203 -0
- package/dist/core/memory.js.map +1 -0
- package/dist/core/messages.d.ts +84 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +141 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +115 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +549 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +104 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +448 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/package-manager.d.ts +156 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +1465 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/parallel-task-agent.d.ts +19 -0
- package/dist/core/parallel-task-agent.d.ts.map +1 -0
- package/dist/core/parallel-task-agent.js +482 -0
- package/dist/core/parallel-task-agent.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +50 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +251 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/qwen-cli-provider.d.ts +10 -0
- package/dist/core/qwen-cli-provider.d.ts.map +1 -0
- package/dist/core/qwen-cli-provider.js +271 -0
- package/dist/core/qwen-cli-provider.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +17 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +60 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +195 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +820 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/sdk.d.ts +106 -0
- package/dist/core/sdk.d.ts.map +1 -0
- package/dist/core/sdk.js +460 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/session-manager.d.ts +323 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +1094 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +243 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +691 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +58 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +364 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +15 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +64 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/subagent-runs.d.ts +16 -0
- package/dist/core/subagent-runs.d.ts.map +1 -0
- package/dist/core/subagent-runs.js +70 -0
- package/dist/core/subagent-runs.js.map +1 -0
- package/dist/core/subagents.d.ts +45 -0
- package/dist/core/subagents.d.ts.map +1 -0
- package/dist/core/subagents.js +467 -0
- package/dist/core/subagents.js.map +1 -0
- package/dist/core/system-prompt.d.ts +28 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +196 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/task-plan.d.ts +32 -0
- package/dist/core/task-plan.d.ts.map +1 -0
- package/dist/core/task-plan.js +155 -0
- package/dist/core/task-plan.js.map +1 -0
- package/dist/core/timings.d.ts +7 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +26 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +58 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +275 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +63 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +243 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +42 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +158 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/find.d.ts +39 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +219 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +45 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +254 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/ignore-filter.d.ts +5 -0
- package/dist/core/tools/ignore-filter.d.ts.map +1 -0
- package/dist/core/tools/ignore-filter.js +97 -0
- package/dist/core/tools/ignore-filter.js.map +1 -0
- package/dist/core/tools/index.d.ts +97 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +78 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +46 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +136 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +8 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +81 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/permissions.d.ts +8 -0
- package/dist/core/tools/permissions.d.ts.map +1 -0
- package/dist/core/tools/permissions.js +2 -0
- package/dist/core/tools/permissions.js.map +1 -0
- package/dist/core/tools/read.d.ts +39 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +166 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/task.d.ts +109 -0
- package/dist/core/tools/task.d.ts.map +1 -0
- package/dist/core/tools/task.js +1065 -0
- package/dist/core/tools/task.js.map +1 -0
- package/dist/core/tools/todo.d.ts +42 -0
- package/dist/core/tools/todo.d.ts.map +1 -0
- package/dist/core/tools/todo.js +159 -0
- package/dist/core/tools/todo.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +70 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +205 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +32 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +90 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/iosm/agent-verification.d.ts +16 -0
- package/dist/iosm/agent-verification.d.ts.map +1 -0
- package/dist/iosm/agent-verification.js +138 -0
- package/dist/iosm/agent-verification.js.map +1 -0
- package/dist/iosm/automation.d.ts +40 -0
- package/dist/iosm/automation.d.ts.map +1 -0
- package/dist/iosm/automation.js +76 -0
- package/dist/iosm/automation.js.map +1 -0
- package/dist/iosm/config.d.ts +151 -0
- package/dist/iosm/config.d.ts.map +1 -0
- package/dist/iosm/config.js +323 -0
- package/dist/iosm/config.js.map +1 -0
- package/dist/iosm/context-loader.d.ts +12 -0
- package/dist/iosm/context-loader.d.ts.map +1 -0
- package/dist/iosm/context-loader.js +50 -0
- package/dist/iosm/context-loader.js.map +1 -0
- package/dist/iosm/cycle.d.ts +51 -0
- package/dist/iosm/cycle.d.ts.map +1 -0
- package/dist/iosm/cycle.js +861 -0
- package/dist/iosm/cycle.js.map +1 -0
- package/dist/iosm/guide.d.ts +31 -0
- package/dist/iosm/guide.d.ts.map +1 -0
- package/dist/iosm/guide.js +101 -0
- package/dist/iosm/guide.js.map +1 -0
- package/dist/iosm/index.d.ts +12 -0
- package/dist/iosm/index.d.ts.map +1 -0
- package/dist/iosm/index.js +11 -0
- package/dist/iosm/index.js.map +1 -0
- package/dist/iosm/init.d.ts +58 -0
- package/dist/iosm/init.d.ts.map +1 -0
- package/dist/iosm/init.js +1221 -0
- package/dist/iosm/init.js.map +1 -0
- package/dist/iosm/metrics.d.ts +23 -0
- package/dist/iosm/metrics.d.ts.map +1 -0
- package/dist/iosm/metrics.js +336 -0
- package/dist/iosm/metrics.js.map +1 -0
- package/dist/iosm/paths.d.ts +24 -0
- package/dist/iosm/paths.d.ts.map +1 -0
- package/dist/iosm/paths.js +77 -0
- package/dist/iosm/paths.js.map +1 -0
- package/dist/iosm/runtime-context.d.ts +20 -0
- package/dist/iosm/runtime-context.d.ts.map +1 -0
- package/dist/iosm/runtime-context.js +170 -0
- package/dist/iosm/runtime-context.js.map +1 -0
- package/dist/iosm/types.d.ts +151 -0
- package/dist/iosm/types.d.ts.map +1 -0
- package/dist/iosm/types.js +3 -0
- package/dist/iosm/types.js.map +1 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +1478 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +33 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +261 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/index.d.ts +9 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/dist/modes/interactive/components/armin.js +329 -0
- package/dist/modes/interactive/components/armin.js.map +1 -0
- package/dist/modes/interactive/components/ascii-logo.d.ts +11 -0
- package/dist/modes/interactive/components/ascii-logo.d.ts.map +1 -0
- package/dist/modes/interactive/components/ascii-logo.js +25 -0
- package/dist/modes/interactive/components/ascii-logo.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +16 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +92 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +36 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +170 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +48 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +42 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +43 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +470 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +28 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +63 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +74 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/dist/modes/interactive/components/daxnuts.js +138 -0
- package/dist/modes/interactive/components/daxnuts.js.map +1 -0
- package/dist/modes/interactive/components/decrypt-loader.d.ts +25 -0
- package/dist/modes/interactive/components/decrypt-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/decrypt-loader.js +102 -0
- package/dist/modes/interactive/components/decrypt-loader.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +20 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +105 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +55 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +24 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +71 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +39 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +285 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +33 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +34 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +50 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +85 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +42 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +139 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/mcp-selector.d.ts +31 -0
- package/dist/modes/interactive/components/mcp-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/mcp-selector.js +171 -0
- package/dist/modes/interactive/components/mcp-selector.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +51 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +292 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +134 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +49 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +271 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +839 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +60 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +311 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +34 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +45 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/subagent-message.d.ts +91 -0
- package/dist/modes/interactive/components/subagent-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/subagent-message.js +306 -0
- package/dist/modes/interactive/components/subagent-message.js.map +1 -0
- package/dist/modes/interactive/components/task-plan-message.d.ts +12 -0
- package/dist/modes/interactive/components/task-plan-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-plan-message.js +61 -0
- package/dist/modes/interactive/components/task-plan-message.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +44 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +46 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +78 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +880 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +70 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +921 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +110 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +9 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +27 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +453 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +8669 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +85 -0
- package/dist/modes/interactive/theme/light.json +84 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +78 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +944 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/print-mode.d.ts +28 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +101 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +217 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +404 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +580 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +409 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/utils/changelog.d.ts +21 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +87 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +162 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +7 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +14 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +67 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/git.d.ts +26 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +163 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +35 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-resize.d.ts +36 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +181 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +26 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/photon.d.ts +21 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/shell.d.ts +26 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +186 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +251 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/docs/README.md +32 -0
- package/docs/cli-reference.md +342 -0
- package/docs/configuration.md +301 -0
- package/docs/development-and-testing.md +295 -0
- package/docs/extensions-packages-themes.md +415 -0
- package/docs/getting-started.md +246 -0
- package/docs/interactive-mode.md +272 -0
- package/docs/iosm-init-and-cycles.md +355 -0
- package/docs/orchestration-and-subagents.md +273 -0
- package/docs/rpc-json-sdk.md +353 -0
- package/docs/sessions-traces-export.md +260 -0
- package/examples/README.md +120 -0
- package/examples/extensions/README.md +306 -0
- package/examples/extensions/antigravity-image-gen.ts +415 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/built-in-tool-renderer.ts +246 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +114 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +349 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/custom-provider-qwen-cli/index.ts +345 -0
- package/examples/extensions/custom-provider-qwen-cli/package.json +16 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/handoff.ts +150 -0
- package/examples/extensions/hello.ts +25 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +426 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +881 -0
- package/examples/extensions/overlay-test.ts +150 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +340 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +398 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/qna.ts +119 -0
- package/examples/extensions/question.ts +264 -0
- package/examples/extensions/questionnaire.ts +427 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +124 -0
- package/examples/extensions/sandbox/index.ts +318 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +40 -0
- package/examples/extensions/subagent/README.md +172 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +126 -0
- package/examples/extensions/subagent/index.ts +964 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +195 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +299 -0
- package/examples/extensions/tool-override.ts +143 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +40 -0
- package/examples/extensions/truncated-tool.ts +192 -0
- package/examples/extensions/widget-placement.ts +17 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/rpc-extension-ui.ts +632 -0
- package/examples/sdk/01-minimal.ts +22 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +55 -0
- package/examples/sdk/04-skills.ts +46 -0
- package/examples/sdk/05-tools.ts +56 -0
- package/examples/sdk/06-extensions.ts +88 -0
- package/examples/sdk/07-context-files.ts +40 -0
- package/examples/sdk/08-prompt-templates.ts +47 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +48 -0
- package/examples/sdk/10-settings.ts +51 -0
- package/examples/sdk/11-sessions.ts +48 -0
- package/examples/sdk/12-full-control.ts +82 -0
- package/examples/sdk/README.md +337 -0
- package/examples/tsconfig.json +3 -0
- package/package.json +107 -0
|
@@ -0,0 +1,1221 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync, } from "node:fs";
|
|
2
|
+
import { promises as fsPromises } from "node:fs";
|
|
3
|
+
import { basename, extname, join, relative, resolve } from "node:path";
|
|
4
|
+
import { stringify } from "yaml";
|
|
5
|
+
import { loadIosmConfig } from "./config.js";
|
|
6
|
+
import { calculateDecisionConfidence, calculateIosmIndex, calculateIosmMetricsFromRawMeasurements, createMetricRecord, hasCompleteNumericMetricRecord, hasCompleteTierMetricRecord, IOSM_METRICS, } from "./metrics.js";
|
|
7
|
+
import { listIosmCycles, planIosmCycle, recordIosmCycleHistory, } from "./cycle.js";
|
|
8
|
+
import { writeIosmGuideDocument } from "./guide.js";
|
|
9
|
+
import { getIosmBaselineReportPath, getIosmBaselinesDir, getIosmConfigPath, getIosmContractCatalogPath, getIosmCycleDir, getIosmCycleReportPath, getIosmCyclesDir, getIosmDecisionLogPath, getIosmHypothesesPath, getIosmInvariantCatalogPath, getIosmMetricsHistoryPath, getIosmPatternLibraryPath, getIosmPhaseReportPath, getIosmWaiverRegisterPath, getIosmWorkspaceDir, } from "./paths.js";
|
|
10
|
+
import { IOSM_PHASES } from "./types.js";
|
|
11
|
+
const MAX_ANALYZED_FILES = 6000;
|
|
12
|
+
const MAX_TEXT_FILE_BYTES = 1_000_000;
|
|
13
|
+
const IGNORED_DIRECTORIES = new Set([
|
|
14
|
+
".git",
|
|
15
|
+
".hg",
|
|
16
|
+
".svn",
|
|
17
|
+
"node_modules",
|
|
18
|
+
"dist",
|
|
19
|
+
"build",
|
|
20
|
+
"coverage",
|
|
21
|
+
".next",
|
|
22
|
+
".nuxt",
|
|
23
|
+
".turbo",
|
|
24
|
+
".cache",
|
|
25
|
+
"target",
|
|
26
|
+
"vendor",
|
|
27
|
+
".idea",
|
|
28
|
+
".vscode",
|
|
29
|
+
".iosm",
|
|
30
|
+
]);
|
|
31
|
+
const SOURCE_EXTENSIONS = new Set([
|
|
32
|
+
".ts",
|
|
33
|
+
".tsx",
|
|
34
|
+
".js",
|
|
35
|
+
".jsx",
|
|
36
|
+
".mjs",
|
|
37
|
+
".cjs",
|
|
38
|
+
".py",
|
|
39
|
+
".go",
|
|
40
|
+
".rs",
|
|
41
|
+
".java",
|
|
42
|
+
".kt",
|
|
43
|
+
".kts",
|
|
44
|
+
".cs",
|
|
45
|
+
".rb",
|
|
46
|
+
".php",
|
|
47
|
+
".swift",
|
|
48
|
+
".c",
|
|
49
|
+
".cc",
|
|
50
|
+
".cpp",
|
|
51
|
+
".h",
|
|
52
|
+
".hpp",
|
|
53
|
+
".sh",
|
|
54
|
+
".sql",
|
|
55
|
+
]);
|
|
56
|
+
const TEXT_CONFIG_EXTENSIONS = new Set([
|
|
57
|
+
".json",
|
|
58
|
+
".yaml",
|
|
59
|
+
".yml",
|
|
60
|
+
".toml",
|
|
61
|
+
".md",
|
|
62
|
+
".txt",
|
|
63
|
+
".ini",
|
|
64
|
+
".env",
|
|
65
|
+
".xml",
|
|
66
|
+
]);
|
|
67
|
+
const KNOWN_TEXT_BASENAMES = new Set([
|
|
68
|
+
"Dockerfile",
|
|
69
|
+
"Makefile",
|
|
70
|
+
"README",
|
|
71
|
+
"README.md",
|
|
72
|
+
"README.txt",
|
|
73
|
+
"LICENSE",
|
|
74
|
+
".gitignore",
|
|
75
|
+
"package.json",
|
|
76
|
+
"pnpm-workspace.yaml",
|
|
77
|
+
"bun.lockb",
|
|
78
|
+
"Cargo.toml",
|
|
79
|
+
"go.mod",
|
|
80
|
+
"pyproject.toml",
|
|
81
|
+
"requirements.txt",
|
|
82
|
+
"composer.json",
|
|
83
|
+
"Gemfile",
|
|
84
|
+
"pom.xml",
|
|
85
|
+
]);
|
|
86
|
+
const EXTENSION_TO_LANGUAGE = new Map([
|
|
87
|
+
[".ts", "TypeScript"],
|
|
88
|
+
[".tsx", "TypeScript"],
|
|
89
|
+
[".js", "JavaScript"],
|
|
90
|
+
[".jsx", "JavaScript"],
|
|
91
|
+
[".mjs", "JavaScript"],
|
|
92
|
+
[".cjs", "JavaScript"],
|
|
93
|
+
[".py", "Python"],
|
|
94
|
+
[".go", "Go"],
|
|
95
|
+
[".rs", "Rust"],
|
|
96
|
+
[".java", "Java"],
|
|
97
|
+
[".kt", "Kotlin"],
|
|
98
|
+
[".kts", "Kotlin"],
|
|
99
|
+
[".cs", "C#"],
|
|
100
|
+
[".rb", "Ruby"],
|
|
101
|
+
[".php", "PHP"],
|
|
102
|
+
[".swift", "Swift"],
|
|
103
|
+
[".c", "C/C++"],
|
|
104
|
+
[".cc", "C/C++"],
|
|
105
|
+
[".cpp", "C/C++"],
|
|
106
|
+
[".h", "C/C++"],
|
|
107
|
+
[".hpp", "C/C++"],
|
|
108
|
+
[".sql", "SQL"],
|
|
109
|
+
[".sh", "Shell"],
|
|
110
|
+
]);
|
|
111
|
+
const PRIMARY_SERVICE_DIRS = new Set(["services", "apps", "api", "server", "backend", "workers", "worker"]);
|
|
112
|
+
const DOMAIN_HINTS = ["domain", "core", "billing", "payment", "checkout", "auth", "identity", "user", "order"];
|
|
113
|
+
function round3(value) {
|
|
114
|
+
return Math.round(value * 1000) / 1000;
|
|
115
|
+
}
|
|
116
|
+
function clamp01(value) {
|
|
117
|
+
return Math.min(1, Math.max(0, value));
|
|
118
|
+
}
|
|
119
|
+
function pushUnique(target, value) {
|
|
120
|
+
if (!target.includes(value)) {
|
|
121
|
+
target.push(value);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function markPathByExistence(filePath, existedBefore, result) {
|
|
125
|
+
if (existedBefore) {
|
|
126
|
+
pushUnique(result.overwritten, filePath);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
pushUnique(result.created, filePath);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function isTestPath(path) {
|
|
133
|
+
const normalized = path.toLowerCase();
|
|
134
|
+
return (normalized.includes("/__tests__/") ||
|
|
135
|
+
normalized.includes("/tests/") ||
|
|
136
|
+
normalized.includes("/test/") ||
|
|
137
|
+
normalized.endsWith(".test.ts") ||
|
|
138
|
+
normalized.endsWith(".test.tsx") ||
|
|
139
|
+
normalized.endsWith(".test.js") ||
|
|
140
|
+
normalized.endsWith(".test.jsx") ||
|
|
141
|
+
normalized.endsWith(".spec.ts") ||
|
|
142
|
+
normalized.endsWith(".spec.tsx") ||
|
|
143
|
+
normalized.endsWith(".spec.js") ||
|
|
144
|
+
normalized.endsWith(".spec.jsx") ||
|
|
145
|
+
normalized.endsWith("_test.go") ||
|
|
146
|
+
normalized.includes("/spec/") ||
|
|
147
|
+
normalized.includes("/specs/"));
|
|
148
|
+
}
|
|
149
|
+
function isDocPath(path) {
|
|
150
|
+
const normalized = path.toLowerCase();
|
|
151
|
+
return (normalized === "readme.md" ||
|
|
152
|
+
normalized.startsWith("docs/") ||
|
|
153
|
+
normalized.endsWith(".md") ||
|
|
154
|
+
normalized.endsWith(".mdx"));
|
|
155
|
+
}
|
|
156
|
+
function isBinaryBuffer(buffer) {
|
|
157
|
+
const sampleLength = Math.min(buffer.length, 4096);
|
|
158
|
+
for (let index = 0; index < sampleLength; index++) {
|
|
159
|
+
if (buffer[index] === 0) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
function shouldIgnoreDirectory(name) {
|
|
166
|
+
if (IGNORED_DIRECTORIES.has(name)) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
if (name.startsWith(".")) {
|
|
170
|
+
return name !== ".github";
|
|
171
|
+
}
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
function isPotentialTextFile(filePath, extension, basenameValue) {
|
|
175
|
+
if (SOURCE_EXTENSIONS.has(extension) || TEXT_CONFIG_EXTENSIONS.has(extension)) {
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
if (KNOWN_TEXT_BASENAMES.has(basenameValue)) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
const lower = filePath.toLowerCase();
|
|
182
|
+
if (lower.endsWith(".proto") || lower.endsWith(".graphql") || lower.endsWith(".gql")) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
function collectProjectFiles(rootDir) {
|
|
188
|
+
const files = [];
|
|
189
|
+
const queue = [rootDir];
|
|
190
|
+
while (queue.length > 0 && files.length < MAX_ANALYZED_FILES) {
|
|
191
|
+
const current = queue.shift();
|
|
192
|
+
if (!current) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
let entries;
|
|
196
|
+
try {
|
|
197
|
+
entries = readdirSync(current, { withFileTypes: true });
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
for (const entry of entries) {
|
|
203
|
+
if (files.length >= MAX_ANALYZED_FILES) {
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
const absolutePath = join(current, entry.name);
|
|
207
|
+
const relativePath = relative(rootDir, absolutePath).split("\\").join("/");
|
|
208
|
+
if (entry.isDirectory()) {
|
|
209
|
+
if (!shouldIgnoreDirectory(entry.name)) {
|
|
210
|
+
queue.push(absolutePath);
|
|
211
|
+
}
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
if (!entry.isFile()) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
const extension = extname(entry.name).toLowerCase();
|
|
218
|
+
if (!isPotentialTextFile(relativePath, extension, entry.name)) {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
let bytes = 0;
|
|
222
|
+
try {
|
|
223
|
+
bytes = statSync(absolutePath).size;
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (bytes > MAX_TEXT_FILE_BYTES) {
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
let contentBuffer;
|
|
232
|
+
try {
|
|
233
|
+
contentBuffer = readFileSync(absolutePath);
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
if (isBinaryBuffer(contentBuffer)) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
const content = contentBuffer.toString("utf8");
|
|
242
|
+
const lines = content.length === 0 ? 0 : content.split(/\r?\n/).length;
|
|
243
|
+
files.push({
|
|
244
|
+
path: relativePath,
|
|
245
|
+
lines,
|
|
246
|
+
bytes,
|
|
247
|
+
extension,
|
|
248
|
+
basename: entry.name,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return files;
|
|
253
|
+
}
|
|
254
|
+
// Concurrency-limited Promise.all using a simple semaphore
|
|
255
|
+
async function withConcurrencyLimit(items, limit, fn) {
|
|
256
|
+
const executing = [];
|
|
257
|
+
for (const item of items) {
|
|
258
|
+
const p = fn(item).then(() => executing.splice(executing.indexOf(p), 1));
|
|
259
|
+
executing.push(p);
|
|
260
|
+
if (executing.length >= limit)
|
|
261
|
+
await Promise.race(executing);
|
|
262
|
+
}
|
|
263
|
+
await Promise.all(executing);
|
|
264
|
+
}
|
|
265
|
+
export async function collectProjectFilesAsync(rootDir) {
|
|
266
|
+
const files = [];
|
|
267
|
+
const queue = [rootDir];
|
|
268
|
+
while (queue.length > 0 && files.length < MAX_ANALYZED_FILES) {
|
|
269
|
+
const currentBatch = queue.splice(0, queue.length);
|
|
270
|
+
const pendingFiles = [];
|
|
271
|
+
await Promise.all(currentBatch.map(async (current) => {
|
|
272
|
+
let entries;
|
|
273
|
+
try {
|
|
274
|
+
entries = await fsPromises.readdir(current, { withFileTypes: true });
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
for (const entry of entries) {
|
|
280
|
+
if (files.length >= MAX_ANALYZED_FILES) {
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
const absolutePath = join(current, entry.name);
|
|
284
|
+
const relativePath = relative(rootDir, absolutePath).split("\\").join("/");
|
|
285
|
+
if (entry.isDirectory()) {
|
|
286
|
+
if (!shouldIgnoreDirectory(entry.name)) {
|
|
287
|
+
queue.push(absolutePath);
|
|
288
|
+
}
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (!entry.isFile()) {
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
const extension = extname(entry.name).toLowerCase();
|
|
295
|
+
if (!isPotentialTextFile(relativePath, extension, entry.name)) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
pendingFiles.push({ absolutePath, relativePath, extension, entryName: entry.name });
|
|
299
|
+
}
|
|
300
|
+
}));
|
|
301
|
+
await withConcurrencyLimit(pendingFiles, 10, async ({ absolutePath, relativePath, extension, entryName }) => {
|
|
302
|
+
if (files.length >= MAX_ANALYZED_FILES) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
let bytes = 0;
|
|
306
|
+
try {
|
|
307
|
+
bytes = (await fsPromises.stat(absolutePath)).size;
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (bytes > MAX_TEXT_FILE_BYTES) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
let contentBuffer;
|
|
316
|
+
try {
|
|
317
|
+
contentBuffer = Buffer.from(await fsPromises.readFile(absolutePath));
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (isBinaryBuffer(contentBuffer)) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
const content = contentBuffer.toString("utf8");
|
|
326
|
+
const lines = content.length === 0 ? 0 : content.split(/\r?\n/).length;
|
|
327
|
+
if (files.length < MAX_ANALYZED_FILES) {
|
|
328
|
+
files.push({
|
|
329
|
+
path: relativePath,
|
|
330
|
+
lines,
|
|
331
|
+
bytes,
|
|
332
|
+
extension,
|
|
333
|
+
basename: entryName,
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
return files;
|
|
339
|
+
}
|
|
340
|
+
function toMetricTier(confidence) {
|
|
341
|
+
if (confidence >= 0.85) {
|
|
342
|
+
return "A";
|
|
343
|
+
}
|
|
344
|
+
if (confidence >= 0.65) {
|
|
345
|
+
return "B";
|
|
346
|
+
}
|
|
347
|
+
return "C";
|
|
348
|
+
}
|
|
349
|
+
function detectContractSignals(files) {
|
|
350
|
+
const contracts = [];
|
|
351
|
+
for (const file of files) {
|
|
352
|
+
const normalized = file.path.toLowerCase();
|
|
353
|
+
if (normalized.endsWith(".proto")) {
|
|
354
|
+
contracts.push({
|
|
355
|
+
kind: "protobuf",
|
|
356
|
+
path: file.path,
|
|
357
|
+
description: "Protocol buffer service or schema",
|
|
358
|
+
});
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
if (normalized.endsWith(".graphql") || normalized.endsWith(".gql")) {
|
|
362
|
+
contracts.push({
|
|
363
|
+
kind: "graphql",
|
|
364
|
+
path: file.path,
|
|
365
|
+
description: "GraphQL schema contract",
|
|
366
|
+
});
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
if ((normalized.includes("openapi") || normalized.includes("swagger")) &&
|
|
370
|
+
(normalized.endsWith(".yaml") || normalized.endsWith(".yml") || normalized.endsWith(".json"))) {
|
|
371
|
+
contracts.push({
|
|
372
|
+
kind: "openapi",
|
|
373
|
+
path: file.path,
|
|
374
|
+
description: "OpenAPI/Swagger API contract",
|
|
375
|
+
});
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
if (normalized.includes("/contracts/") || normalized.includes("contract")) {
|
|
379
|
+
if (normalized.endsWith(".yaml") ||
|
|
380
|
+
normalized.endsWith(".yml") ||
|
|
381
|
+
normalized.endsWith(".json") ||
|
|
382
|
+
normalized.endsWith(".md")) {
|
|
383
|
+
contracts.push({
|
|
384
|
+
kind: "custom",
|
|
385
|
+
path: file.path,
|
|
386
|
+
description: "Repository contract declaration",
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const unique = new Map();
|
|
392
|
+
for (const contract of contracts) {
|
|
393
|
+
const key = `${contract.kind}:${contract.path}`;
|
|
394
|
+
if (!unique.has(key)) {
|
|
395
|
+
unique.set(key, contract);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return Array.from(unique.values()).slice(0, 20);
|
|
399
|
+
}
|
|
400
|
+
function detectTopModules(files) {
|
|
401
|
+
const moduleWeights = new Map();
|
|
402
|
+
const serviceWeights = new Map();
|
|
403
|
+
const domainCandidates = new Set();
|
|
404
|
+
for (const file of files) {
|
|
405
|
+
if (!SOURCE_EXTENSIONS.has(file.extension) || isTestPath(file.path)) {
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
const segments = file.path.split("/").filter((segment) => segment.length > 0);
|
|
409
|
+
if (segments.length === 0) {
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
if (segments[0] === "src" && segments.length >= 2) {
|
|
413
|
+
const moduleName = segments[1];
|
|
414
|
+
moduleWeights.set(moduleName, (moduleWeights.get(moduleName) ?? 0) + file.lines + 1);
|
|
415
|
+
if (DOMAIN_HINTS.some((hint) => moduleName.toLowerCase().includes(hint))) {
|
|
416
|
+
domainCandidates.add(moduleName);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
if (segments.length >= 2 && (segments[0] === "packages" || segments[0] === "modules")) {
|
|
420
|
+
const moduleName = `${segments[0]}/${segments[1]}`;
|
|
421
|
+
moduleWeights.set(moduleName, (moduleWeights.get(moduleName) ?? 0) + file.lines + 1);
|
|
422
|
+
}
|
|
423
|
+
if (PRIMARY_SERVICE_DIRS.has(segments[0])) {
|
|
424
|
+
const serviceName = segments[1] ? `${segments[0]}/${segments[1]}` : segments[0];
|
|
425
|
+
serviceWeights.set(serviceName, (serviceWeights.get(serviceName) ?? 0) + file.lines + 1);
|
|
426
|
+
if (segments[1] && DOMAIN_HINTS.some((hint) => segments[1].toLowerCase().includes(hint))) {
|
|
427
|
+
domainCandidates.add(segments[1]);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
const sortByWeight = (weights, limit) => Array.from(weights.entries())
|
|
432
|
+
.sort((left, right) => right[1] - left[1])
|
|
433
|
+
.map(([name]) => name)
|
|
434
|
+
.slice(0, limit);
|
|
435
|
+
const modules = sortByWeight(moduleWeights, 12);
|
|
436
|
+
const services = sortByWeight(serviceWeights, 8);
|
|
437
|
+
let domains = Array.from(domainCandidates).slice(0, 8);
|
|
438
|
+
if (domains.length === 0) {
|
|
439
|
+
domains = modules
|
|
440
|
+
.map((moduleName) => moduleName.split("/").pop() ?? moduleName)
|
|
441
|
+
.filter((entry) => entry.length > 0)
|
|
442
|
+
.slice(0, 6);
|
|
443
|
+
}
|
|
444
|
+
return { modules, services, domains };
|
|
445
|
+
}
|
|
446
|
+
function detectDependencyCount(rootDir) {
|
|
447
|
+
const packageJsonPath = join(rootDir, "package.json");
|
|
448
|
+
if (!existsSync(packageJsonPath)) {
|
|
449
|
+
return 0;
|
|
450
|
+
}
|
|
451
|
+
try {
|
|
452
|
+
const parsed = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
453
|
+
const dependencies = parsed.dependencies;
|
|
454
|
+
const devDependencies = parsed.devDependencies;
|
|
455
|
+
const depCount = dependencies && typeof dependencies === "object" ? Object.keys(dependencies).length : 0;
|
|
456
|
+
const devDepCount = devDependencies && typeof devDependencies === "object"
|
|
457
|
+
? Object.keys(devDependencies).length
|
|
458
|
+
: 0;
|
|
459
|
+
return depCount + devDepCount;
|
|
460
|
+
}
|
|
461
|
+
catch {
|
|
462
|
+
return 0;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
function detectSourceSystems(rootDir, files, topLanguages) {
|
|
466
|
+
const systems = [];
|
|
467
|
+
const lowerPaths = new Set(files.map((file) => file.path.toLowerCase()));
|
|
468
|
+
if (lowerPaths.has("package.json")) {
|
|
469
|
+
systems.push("npm");
|
|
470
|
+
}
|
|
471
|
+
if (lowerPaths.has("pnpm-workspace.yaml")) {
|
|
472
|
+
systems.push("pnpm-workspace");
|
|
473
|
+
}
|
|
474
|
+
if (lowerPaths.has("go.mod")) {
|
|
475
|
+
systems.push("go-mod");
|
|
476
|
+
}
|
|
477
|
+
if (lowerPaths.has("cargo.toml")) {
|
|
478
|
+
systems.push("cargo");
|
|
479
|
+
}
|
|
480
|
+
if (lowerPaths.has("pyproject.toml") || lowerPaths.has("requirements.txt")) {
|
|
481
|
+
systems.push("python-packaging");
|
|
482
|
+
}
|
|
483
|
+
if (existsSync(join(rootDir, ".github", "workflows"))) {
|
|
484
|
+
systems.push("github-actions");
|
|
485
|
+
}
|
|
486
|
+
for (const language of topLanguages.slice(0, 3)) {
|
|
487
|
+
systems.push(`lang:${language.language}`);
|
|
488
|
+
}
|
|
489
|
+
return Array.from(new Set(systems));
|
|
490
|
+
}
|
|
491
|
+
function computeNamingConsistency(files) {
|
|
492
|
+
let kebab = 0;
|
|
493
|
+
let snake = 0;
|
|
494
|
+
let camel = 0;
|
|
495
|
+
let other = 0;
|
|
496
|
+
for (const file of files) {
|
|
497
|
+
if (!SOURCE_EXTENSIONS.has(file.extension) || isTestPath(file.path)) {
|
|
498
|
+
continue;
|
|
499
|
+
}
|
|
500
|
+
const baseWithoutExt = file.basename.replace(/\.[^.]+$/, "");
|
|
501
|
+
if (/^[a-z0-9]+(?:-[a-z0-9]+)+$/.test(baseWithoutExt)) {
|
|
502
|
+
kebab += 1;
|
|
503
|
+
}
|
|
504
|
+
else if (/^[a-z0-9]+(?:_[a-z0-9]+)+$/.test(baseWithoutExt)) {
|
|
505
|
+
snake += 1;
|
|
506
|
+
}
|
|
507
|
+
else if (/^[a-z]+(?:[A-Z][a-z0-9]*)+$/.test(baseWithoutExt)) {
|
|
508
|
+
camel += 1;
|
|
509
|
+
}
|
|
510
|
+
else {
|
|
511
|
+
other += 1;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
const total = kebab + snake + camel + other;
|
|
515
|
+
if (total === 0) {
|
|
516
|
+
return 0.65;
|
|
517
|
+
}
|
|
518
|
+
const dominant = Math.max(kebab, snake, camel, 0);
|
|
519
|
+
const consistency = dominant / total;
|
|
520
|
+
return round3(clamp01(0.45 + consistency * 0.5));
|
|
521
|
+
}
|
|
522
|
+
async function deriveProjectSignals(rootDir) {
|
|
523
|
+
const files = await collectProjectFilesAsync(rootDir);
|
|
524
|
+
const languageAccumulator = new Map();
|
|
525
|
+
let sourceFileCount = 0;
|
|
526
|
+
let testFileCount = 0;
|
|
527
|
+
let docFileCount = 0;
|
|
528
|
+
let hasCiSignals = false;
|
|
529
|
+
for (const file of files) {
|
|
530
|
+
if (isDocPath(file.path)) {
|
|
531
|
+
docFileCount += 1;
|
|
532
|
+
}
|
|
533
|
+
if (file.path.toLowerCase().startsWith(".github/workflows/")) {
|
|
534
|
+
hasCiSignals = true;
|
|
535
|
+
}
|
|
536
|
+
if (!SOURCE_EXTENSIONS.has(file.extension)) {
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
sourceFileCount += 1;
|
|
540
|
+
if (isTestPath(file.path)) {
|
|
541
|
+
testFileCount += 1;
|
|
542
|
+
}
|
|
543
|
+
const language = EXTENSION_TO_LANGUAGE.get(file.extension) ?? "Other";
|
|
544
|
+
const current = languageAccumulator.get(language) ?? { files: 0, lines: 0 };
|
|
545
|
+
current.files += 1;
|
|
546
|
+
current.lines += file.lines;
|
|
547
|
+
languageAccumulator.set(language, current);
|
|
548
|
+
}
|
|
549
|
+
const topLanguages = Array.from(languageAccumulator.entries())
|
|
550
|
+
.sort((left, right) => right[1].lines - left[1].lines)
|
|
551
|
+
.map(([language, stats]) => ({
|
|
552
|
+
language,
|
|
553
|
+
files: stats.files,
|
|
554
|
+
lines: stats.lines,
|
|
555
|
+
}))
|
|
556
|
+
.slice(0, 6);
|
|
557
|
+
const { modules, services, domains } = detectTopModules(files);
|
|
558
|
+
const contracts = detectContractSignals(files);
|
|
559
|
+
const dependencyCount = detectDependencyCount(rootDir);
|
|
560
|
+
const namingConsistency = computeNamingConsistency(files);
|
|
561
|
+
const testRatio = sourceFileCount === 0 ? 0 : clamp01(testFileCount / Math.max(sourceFileCount, 1));
|
|
562
|
+
const docsRatio = files.length === 0 ? 0 : clamp01(docFileCount / Math.max(files.length, 1));
|
|
563
|
+
const sourceSystems = detectSourceSystems(rootDir, files, topLanguages);
|
|
564
|
+
return {
|
|
565
|
+
filesAnalyzed: files.length,
|
|
566
|
+
sourceFileCount,
|
|
567
|
+
testFileCount,
|
|
568
|
+
docFileCount,
|
|
569
|
+
topLanguages,
|
|
570
|
+
modules,
|
|
571
|
+
services,
|
|
572
|
+
domains,
|
|
573
|
+
contracts,
|
|
574
|
+
sourceSystems,
|
|
575
|
+
testRatio,
|
|
576
|
+
docsRatio,
|
|
577
|
+
namingConsistency,
|
|
578
|
+
dependencyCount,
|
|
579
|
+
hasCiSignals,
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
function buildCycleScope(signals, maxScopeItems) {
|
|
583
|
+
const scoped = {
|
|
584
|
+
modules: [],
|
|
585
|
+
services: [],
|
|
586
|
+
domains: [],
|
|
587
|
+
contracts: [],
|
|
588
|
+
rationale: "Auto-filled from repository structure during iosm init.",
|
|
589
|
+
};
|
|
590
|
+
let total = 0;
|
|
591
|
+
const append = (key, values) => {
|
|
592
|
+
for (const value of values) {
|
|
593
|
+
if (total >= maxScopeItems) {
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
if (!scoped[key].includes(value)) {
|
|
597
|
+
scoped[key].push(value);
|
|
598
|
+
total += 1;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
append("modules", signals.modules.slice(0, 8));
|
|
603
|
+
append("services", signals.services.slice(0, 6));
|
|
604
|
+
append("domains", signals.domains
|
|
605
|
+
.map((domain) => domain.split("/").pop() ?? domain)
|
|
606
|
+
.filter((domain) => domain.length > 0)
|
|
607
|
+
.slice(0, 6));
|
|
608
|
+
append("contracts", signals.contracts
|
|
609
|
+
.map((contract) => contract.path)
|
|
610
|
+
.slice(0, 4));
|
|
611
|
+
if (total === 0) {
|
|
612
|
+
scoped.modules = ["repository"];
|
|
613
|
+
total = 1;
|
|
614
|
+
}
|
|
615
|
+
const sourceLines = [`scope_items=${total}`, `max_scope_items=${maxScopeItems}`];
|
|
616
|
+
if (signals.modules.length > scoped.modules.length) {
|
|
617
|
+
sourceLines.push(`modules_truncated=${signals.modules.length - scoped.modules.length}`);
|
|
618
|
+
}
|
|
619
|
+
if (signals.services.length > scoped.services.length) {
|
|
620
|
+
sourceLines.push(`services_truncated=${signals.services.length - scoped.services.length}`);
|
|
621
|
+
}
|
|
622
|
+
scoped.rationale = `Auto-filled from repository structure (${sourceLines.join(", ")}).`;
|
|
623
|
+
return scoped;
|
|
624
|
+
}
|
|
625
|
+
function buildRawMeasurements(signals) {
|
|
626
|
+
const moduleCount = Math.max(signals.modules.length, 1);
|
|
627
|
+
const contractCount = signals.contracts.length;
|
|
628
|
+
const docsSignal = clamp01(0.25 + signals.docsRatio * 2.2 + (signals.docFileCount > 0 ? 0.1 : 0));
|
|
629
|
+
const ciBoost = signals.hasCiSignals ? 0.12 : 0;
|
|
630
|
+
const semanticGlossaryCoverage = round3(clamp01(0.45 + docsSignal * 0.45));
|
|
631
|
+
const semanticNamingConsistency = round3(clamp01(signals.namingConsistency));
|
|
632
|
+
const semanticAmbiguityRatio = round3(clamp01(0.35 - docsSignal * 0.2));
|
|
633
|
+
const logicInvariantPassRate = round3(clamp01(0.52 + signals.testRatio * 0.4 + ciBoost * 0.3));
|
|
634
|
+
const inferredInvariantCount = Math.max(3, Math.min(10, moduleCount + (contractCount > 0 ? 1 : 0)));
|
|
635
|
+
const performanceLatencyScore = round3(clamp01(0.48 + signals.testRatio * 0.22 + ciBoost));
|
|
636
|
+
const performanceReliabilityScore = round3(clamp01(0.58 + signals.testRatio * 0.2 + ciBoost));
|
|
637
|
+
const performanceResilienceScore = round3(clamp01(0.5 + (contractCount > 0 ? 0.08 : 0) + signals.testRatio * 0.18));
|
|
638
|
+
const simplicityApiSurfaceScore = round3(clamp01(1 - Math.min(0.65, moduleCount / 22)));
|
|
639
|
+
const simplicityDependencyHygiene = round3(clamp01(1 - Math.min(0.7, signals.dependencyCount / 140)));
|
|
640
|
+
const simplicityOnboardingScore = round3(clamp01(0.48 + docsSignal * 0.45));
|
|
641
|
+
const modularityCouplingScore = round3(clamp01(1 - Math.min(0.72, moduleCount / 20)));
|
|
642
|
+
const modularityCohesionScore = round3(clamp01(0.46 + Math.min(0.24, 1 / moduleCount) + (contractCount > 0 ? 0.12 : 0)));
|
|
643
|
+
const modularityContractScore = round3(contractCount > 0 ? 1 : 0.58);
|
|
644
|
+
const modularityChangeSurfaceScore = round3(clamp01(1 - Math.min(0.82, moduleCount / 18)));
|
|
645
|
+
const modularityChangeSurface = Math.max(1, Math.min(12, moduleCount));
|
|
646
|
+
const flowLeadTimeScore = round3(clamp01(0.45 + signals.testRatio * 0.2 + ciBoost));
|
|
647
|
+
const flowDeployFrequencyScore = round3(clamp01(0.4 + ciBoost + signals.docsRatio * 0.08));
|
|
648
|
+
const flowChangeFailureScore = round3(clamp01(0.62 + signals.testRatio * 0.25));
|
|
649
|
+
const flowReviewLatencyScore = round3(clamp01(0.5 + ciBoost + signals.docsRatio * 0.1));
|
|
650
|
+
return {
|
|
651
|
+
semantic: {
|
|
652
|
+
glossary_coverage: semanticGlossaryCoverage,
|
|
653
|
+
naming_consistency: semanticNamingConsistency,
|
|
654
|
+
ambiguity_ratio: semanticAmbiguityRatio,
|
|
655
|
+
},
|
|
656
|
+
logic: {
|
|
657
|
+
invariant_pass_rate: logicInvariantPassRate,
|
|
658
|
+
passed_invariants: Math.round(inferredInvariantCount * logicInvariantPassRate),
|
|
659
|
+
total_invariants: inferredInvariantCount,
|
|
660
|
+
},
|
|
661
|
+
performance: {
|
|
662
|
+
latency_score: performanceLatencyScore,
|
|
663
|
+
reliability_score: performanceReliabilityScore,
|
|
664
|
+
resilience_score: performanceResilienceScore,
|
|
665
|
+
error_budget_respected: performanceReliabilityScore >= 0.7,
|
|
666
|
+
},
|
|
667
|
+
simplicity: {
|
|
668
|
+
api_surface_score: simplicityApiSurfaceScore,
|
|
669
|
+
dependency_hygiene: simplicityDependencyHygiene,
|
|
670
|
+
onboarding_score: simplicityOnboardingScore,
|
|
671
|
+
},
|
|
672
|
+
modularity: {
|
|
673
|
+
coupling_score: modularityCouplingScore,
|
|
674
|
+
cohesion_score: modularityCohesionScore,
|
|
675
|
+
contract_score: modularityContractScore,
|
|
676
|
+
change_surface_score: modularityChangeSurfaceScore,
|
|
677
|
+
change_surface: modularityChangeSurface,
|
|
678
|
+
contracts_pass: modularityContractScore >= 0.8,
|
|
679
|
+
},
|
|
680
|
+
flow: {
|
|
681
|
+
lead_time_score: flowLeadTimeScore,
|
|
682
|
+
deploy_frequency_score: flowDeployFrequencyScore,
|
|
683
|
+
change_failure_score: flowChangeFailureScore,
|
|
684
|
+
review_latency_score: flowReviewLatencyScore,
|
|
685
|
+
},
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
function buildMetricConfidences(signals) {
|
|
689
|
+
const docsConfidence = clamp01(0.52 + signals.docsRatio * 0.35);
|
|
690
|
+
const testConfidence = clamp01(0.5 + signals.testRatio * 0.4 + (signals.hasCiSignals ? 0.08 : 0));
|
|
691
|
+
const dependencyConfidence = clamp01(0.55 + (signals.dependencyCount > 0 ? 0.12 : 0));
|
|
692
|
+
return {
|
|
693
|
+
semantic: round3(clamp01(docsConfidence)),
|
|
694
|
+
logic: round3(clamp01(testConfidence)),
|
|
695
|
+
performance: round3(clamp01(0.52 + signals.testRatio * 0.22 + (signals.hasCiSignals ? 0.1 : 0))),
|
|
696
|
+
simplicity: round3(clamp01(Math.max(docsConfidence, dependencyConfidence - 0.05))),
|
|
697
|
+
modularity: round3(clamp01(0.56 + (signals.modules.length > 0 ? 0.08 : 0) + (signals.contracts.length > 0 ? 0.08 : 0))),
|
|
698
|
+
flow: round3(clamp01(0.48 + (signals.hasCiSignals ? 0.14 : 0))),
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
function goalForMetric(metric) {
|
|
702
|
+
switch (metric) {
|
|
703
|
+
case "semantic":
|
|
704
|
+
return "Increase glossary coverage and naming consistency for core domain language.";
|
|
705
|
+
case "logic":
|
|
706
|
+
return "Increase invariant/test confidence for critical logic paths and edge cases.";
|
|
707
|
+
case "performance":
|
|
708
|
+
return "Improve latency and reliability signals for primary user journeys.";
|
|
709
|
+
case "simplicity":
|
|
710
|
+
return "Reduce onboarding friction by shrinking API/dependency surface complexity.";
|
|
711
|
+
case "modularity":
|
|
712
|
+
return "Reduce coupling and change surface while strengthening contract boundaries.";
|
|
713
|
+
case "flow":
|
|
714
|
+
return "Improve lead-time and review-latency flow signals for safer delivery cadence.";
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
function buildGoals(metrics) {
|
|
718
|
+
const ordered = IOSM_METRICS.map((metric) => ({ metric, value: metrics[metric] ?? 0 }))
|
|
719
|
+
.sort((left, right) => left.value - right.value)
|
|
720
|
+
.slice(0, 3)
|
|
721
|
+
.map((entry) => goalForMetric(entry.metric));
|
|
722
|
+
if (ordered.length === 0) {
|
|
723
|
+
return ["Establish IOSM baseline metrics and define an initial cycle scope."];
|
|
724
|
+
}
|
|
725
|
+
const unique = Array.from(new Set(ordered));
|
|
726
|
+
if (unique.length === 1) {
|
|
727
|
+
unique.push("Establish IOSM baseline metrics and define an initial cycle scope.");
|
|
728
|
+
}
|
|
729
|
+
return unique.slice(0, 3);
|
|
730
|
+
}
|
|
731
|
+
function createIosmConfigTemplate(systemName) {
|
|
732
|
+
const encodedSystemName = JSON.stringify(systemName);
|
|
733
|
+
return `iosm:
|
|
734
|
+
metadata:
|
|
735
|
+
system_name: ${encodedSystemName}
|
|
736
|
+
scope: repository
|
|
737
|
+
criticality_profile: standard
|
|
738
|
+
delivery_boundary: ${encodedSystemName}
|
|
739
|
+
planning:
|
|
740
|
+
use_economic_decision: true
|
|
741
|
+
prioritization_formula: wsjf_confidence
|
|
742
|
+
min_confidence: 0.70
|
|
743
|
+
hypothesis_required: true
|
|
744
|
+
cycle_scope_required: true
|
|
745
|
+
cycle_capacity:
|
|
746
|
+
max_goals: 3
|
|
747
|
+
max_scope_items: 5
|
|
748
|
+
max_expected_change_surface: 3
|
|
749
|
+
cycle_policy:
|
|
750
|
+
max_iterations_per_phase: 3
|
|
751
|
+
stabilization:
|
|
752
|
+
target_index: 0.98
|
|
753
|
+
consecutive_cycles: 3
|
|
754
|
+
global_metric_floor: 0.60
|
|
755
|
+
max_consecutive_unexplained_declines: 2
|
|
756
|
+
metric_floors:
|
|
757
|
+
logic: 0.95
|
|
758
|
+
performance: 0.85
|
|
759
|
+
quality_gates:
|
|
760
|
+
gate_I:
|
|
761
|
+
semantic_min: 0.95
|
|
762
|
+
logical_consistency_min: 1.00
|
|
763
|
+
duplication_max: 0.05
|
|
764
|
+
gate_O:
|
|
765
|
+
latency_ms:
|
|
766
|
+
p50_max: 60
|
|
767
|
+
p95_max: 150
|
|
768
|
+
p99_max: 250
|
|
769
|
+
error_budget_respected: true
|
|
770
|
+
chaos_pass_rate_min: 1.00
|
|
771
|
+
gate_S:
|
|
772
|
+
at_least_one_dimension: true
|
|
773
|
+
api_surface_reduction_min: 0.20
|
|
774
|
+
dependency_hygiene_min: 0.95
|
|
775
|
+
onboarding_time_minutes_max: 15
|
|
776
|
+
regression_budget_max: 0
|
|
777
|
+
gate_M:
|
|
778
|
+
change_surface_max: 3
|
|
779
|
+
coupling_max: 0.20
|
|
780
|
+
cohesion_min: 0.80
|
|
781
|
+
contracts_pass: true
|
|
782
|
+
guardrails:
|
|
783
|
+
max_negative_delta:
|
|
784
|
+
semantic: 0.02
|
|
785
|
+
logic: 0.00
|
|
786
|
+
performance: 0.03
|
|
787
|
+
simplicity: 0.03
|
|
788
|
+
modularity: 0.02
|
|
789
|
+
flow: 0.02
|
|
790
|
+
evidence:
|
|
791
|
+
min_decision_confidence: 0.80
|
|
792
|
+
freshness_sla_hours:
|
|
793
|
+
tier_a: 24
|
|
794
|
+
tier_b: 168
|
|
795
|
+
min_metric_confidence:
|
|
796
|
+
semantic: 0.70
|
|
797
|
+
logic: 0.90
|
|
798
|
+
performance: 0.90
|
|
799
|
+
simplicity: 0.70
|
|
800
|
+
modularity: 0.70
|
|
801
|
+
flow: 0.80
|
|
802
|
+
waivers:
|
|
803
|
+
max_duration_days: 14
|
|
804
|
+
require_human_approval: true
|
|
805
|
+
metric_targets:
|
|
806
|
+
semantic:
|
|
807
|
+
glossary_coverage_min: 0.95
|
|
808
|
+
naming_consistency_min: 0.95
|
|
809
|
+
ambiguity_ratio_max: 0.05
|
|
810
|
+
logic:
|
|
811
|
+
invariant_pass_rate_min: 1.00
|
|
812
|
+
performance:
|
|
813
|
+
latency_ms:
|
|
814
|
+
p50_max: 60
|
|
815
|
+
p95_max: 150
|
|
816
|
+
p99_max: 250
|
|
817
|
+
simplicity:
|
|
818
|
+
onboarding_time_minutes_max: 15
|
|
819
|
+
modularity:
|
|
820
|
+
change_surface_max: 3
|
|
821
|
+
flow:
|
|
822
|
+
lead_time_hours_max: 24
|
|
823
|
+
deploy_frequency_per_week_min: 5
|
|
824
|
+
change_failure_rate_max: 0.15
|
|
825
|
+
review_latency_hours_max: 24
|
|
826
|
+
index:
|
|
827
|
+
weights:
|
|
828
|
+
semantic: 0.15
|
|
829
|
+
logic: 0.20
|
|
830
|
+
performance: 0.25
|
|
831
|
+
simplicity: 0.15
|
|
832
|
+
modularity: 0.15
|
|
833
|
+
flow: 0.10
|
|
834
|
+
automation:
|
|
835
|
+
allow_agents: true
|
|
836
|
+
human_approval_required_for:
|
|
837
|
+
- waivers
|
|
838
|
+
- public_contract_changes
|
|
839
|
+
- threshold_relaxation
|
|
840
|
+
- destructive_data_changes
|
|
841
|
+
reporting:
|
|
842
|
+
persist_history: true
|
|
843
|
+
output_format: json
|
|
844
|
+
learning:
|
|
845
|
+
update_pattern_library: true
|
|
846
|
+
update_decision_log: true
|
|
847
|
+
update_glossary: true
|
|
848
|
+
`;
|
|
849
|
+
}
|
|
850
|
+
function writeScaffoldFileWithExistenceCheck(filePath, content, force, result) {
|
|
851
|
+
const existed = existsSync(filePath);
|
|
852
|
+
if (existed && !force) {
|
|
853
|
+
pushUnique(result.skipped, filePath);
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
writeFileSync(filePath, content, "utf8");
|
|
857
|
+
markPathByExistence(filePath, existed, result);
|
|
858
|
+
}
|
|
859
|
+
function writeJson(filePath, value) {
|
|
860
|
+
writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`, "utf8");
|
|
861
|
+
}
|
|
862
|
+
function readJson(filePath) {
|
|
863
|
+
return JSON.parse(readFileSync(filePath, "utf8"));
|
|
864
|
+
}
|
|
865
|
+
function countScopeItems(scope) {
|
|
866
|
+
return scope.modules.length + scope.services.length + scope.domains.length + scope.contracts.length;
|
|
867
|
+
}
|
|
868
|
+
function createInvariantsCatalog(signals, nowIso) {
|
|
869
|
+
const invariants = [
|
|
870
|
+
{
|
|
871
|
+
id: "inv-build-green",
|
|
872
|
+
statement: "Build/test pipeline remains green for cycle scope changes.",
|
|
873
|
+
status: "active",
|
|
874
|
+
evidence_tier: signals.hasCiSignals ? "B" : "C",
|
|
875
|
+
owner: "unassigned",
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
id: "inv-contract-compatibility",
|
|
879
|
+
statement: "Public contracts are backward compatible unless an approved waiver exists.",
|
|
880
|
+
status: "active",
|
|
881
|
+
evidence_tier: signals.contracts.length > 0 ? "B" : "C",
|
|
882
|
+
owner: "unassigned",
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
id: "inv-metric-freshness",
|
|
886
|
+
statement: "IOSM baseline and cycle metrics must be refreshed each cycle before decisioning.",
|
|
887
|
+
status: "active",
|
|
888
|
+
evidence_tier: "C",
|
|
889
|
+
owner: "unassigned",
|
|
890
|
+
},
|
|
891
|
+
];
|
|
892
|
+
return {
|
|
893
|
+
version: 1,
|
|
894
|
+
generated_at: nowIso,
|
|
895
|
+
invariants,
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
function createContractCatalog(signals, nowIso) {
|
|
899
|
+
return {
|
|
900
|
+
version: 1,
|
|
901
|
+
generated_at: nowIso,
|
|
902
|
+
contracts: signals.contracts.map((contract, index) => ({
|
|
903
|
+
id: `contract-${String(index + 1).padStart(3, "0")}`,
|
|
904
|
+
kind: contract.kind,
|
|
905
|
+
path: contract.path,
|
|
906
|
+
description: contract.description,
|
|
907
|
+
status: "tracked",
|
|
908
|
+
owner: "unassigned",
|
|
909
|
+
})),
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
function createWaiverRegister(nowIso) {
|
|
913
|
+
return {
|
|
914
|
+
version: 1,
|
|
915
|
+
generated_at: nowIso,
|
|
916
|
+
waivers: [],
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
function formatMetricInline(metric, value) {
|
|
920
|
+
return `${metric}=${value === null ? "n/a" : value.toFixed(3)}`;
|
|
921
|
+
}
|
|
922
|
+
function createDecisionLog(systemName, analysis) {
|
|
923
|
+
const metricLine = IOSM_METRICS.map((metric) => formatMetricInline(metric, analysis.metrics[metric])).join(", ");
|
|
924
|
+
const confidenceLine = IOSM_METRICS.map((metric) => `${metric}=${analysis.metric_confidences[metric].toFixed(2)}`).join(", ");
|
|
925
|
+
const goals = analysis.goals.map((goal) => `- ${goal}`).join("\n");
|
|
926
|
+
const contractsLine = analysis.detected_contracts.length > 0
|
|
927
|
+
? analysis.detected_contracts.map((contract) => `${contract.kind}:${contract.path}`).join(", ")
|
|
928
|
+
: "none";
|
|
929
|
+
const topLanguagesLine = analysis.top_languages.length > 0
|
|
930
|
+
? analysis.top_languages
|
|
931
|
+
.map((language) => `${language.language}(${language.files} files)`)
|
|
932
|
+
.join(", ")
|
|
933
|
+
: "unknown";
|
|
934
|
+
return [
|
|
935
|
+
"# IOSM Decision Log",
|
|
936
|
+
"",
|
|
937
|
+
`## Initialization Snapshot (${analysis.generated_at})`,
|
|
938
|
+
`- System: ${systemName}`,
|
|
939
|
+
`- Files analyzed: ${analysis.files_analyzed}`,
|
|
940
|
+
`- Source files: ${analysis.source_file_count}`,
|
|
941
|
+
`- Test files: ${analysis.test_file_count}`,
|
|
942
|
+
`- Docs files: ${analysis.doc_file_count}`,
|
|
943
|
+
`- Top languages: ${topLanguagesLine}`,
|
|
944
|
+
`- Contracts detected: ${contractsLine}`,
|
|
945
|
+
`- Baseline metrics: ${metricLine}`,
|
|
946
|
+
`- Metric confidence: ${confidenceLine}`,
|
|
947
|
+
"",
|
|
948
|
+
"## Initial Decision",
|
|
949
|
+
"- Decision: CONTINUE",
|
|
950
|
+
"- Rationale: Project baseline captured; continue through IOSM phases with evidence upgrades.",
|
|
951
|
+
"",
|
|
952
|
+
"## Initial Goals",
|
|
953
|
+
goals,
|
|
954
|
+
"",
|
|
955
|
+
].join("\n");
|
|
956
|
+
}
|
|
957
|
+
function createPatternLibrary(analysis) {
|
|
958
|
+
const modulesLine = analysis.cycle_scope.modules.length > 0 ? analysis.cycle_scope.modules.join(", ") : "none";
|
|
959
|
+
const servicesLine = analysis.cycle_scope.services.length > 0 ? analysis.cycle_scope.services.join(", ") : "none";
|
|
960
|
+
const domainsLine = analysis.cycle_scope.domains.length > 0 ? analysis.cycle_scope.domains.join(", ") : "none";
|
|
961
|
+
const contractsLine = analysis.detected_contracts.length > 0
|
|
962
|
+
? analysis.detected_contracts.map((contract) => contract.path).join(", ")
|
|
963
|
+
: "none";
|
|
964
|
+
return [
|
|
965
|
+
"# IOSM Pattern Library",
|
|
966
|
+
"",
|
|
967
|
+
`## Baseline Patterns (${analysis.generated_at})`,
|
|
968
|
+
`- Scoped modules: ${modulesLine}`,
|
|
969
|
+
`- Scoped services: ${servicesLine}`,
|
|
970
|
+
`- Scoped domains: ${domainsLine}`,
|
|
971
|
+
`- Contracts: ${contractsLine}`,
|
|
972
|
+
"",
|
|
973
|
+
"## Notes",
|
|
974
|
+
"- Entries above are auto-detected during `iosm init` and should be refined during Improve/Shrink phases.",
|
|
975
|
+
"- Capture validated reusable tactics here after cycle completion.",
|
|
976
|
+
"",
|
|
977
|
+
].join("\n");
|
|
978
|
+
}
|
|
979
|
+
function deriveInitAnalysis(signals, config) {
|
|
980
|
+
const nowIso = new Date().toISOString();
|
|
981
|
+
const maxScopeItems = Math.max(1, Math.min(config.iosm.cycle_capacity.max_scope_items, config.iosm.cycle_capacity.max_expected_change_surface));
|
|
982
|
+
const cycleScope = buildCycleScope(signals, maxScopeItems);
|
|
983
|
+
const rawMeasurements = buildRawMeasurements(signals);
|
|
984
|
+
const metrics = calculateIosmMetricsFromRawMeasurements(rawMeasurements, config);
|
|
985
|
+
const metricConfidences = buildMetricConfidences(signals);
|
|
986
|
+
const metricTiers = createMetricRecord((metric) => toMetricTier(metricConfidences[metric]));
|
|
987
|
+
const goals = buildGoals(metrics);
|
|
988
|
+
return {
|
|
989
|
+
generated_at: nowIso,
|
|
990
|
+
files_analyzed: signals.filesAnalyzed,
|
|
991
|
+
source_file_count: signals.sourceFileCount,
|
|
992
|
+
test_file_count: signals.testFileCount,
|
|
993
|
+
doc_file_count: signals.docFileCount,
|
|
994
|
+
top_languages: signals.topLanguages,
|
|
995
|
+
cycle_scope: cycleScope,
|
|
996
|
+
detected_contracts: signals.contracts,
|
|
997
|
+
source_systems: signals.sourceSystems,
|
|
998
|
+
goals,
|
|
999
|
+
raw_measurements: rawMeasurements,
|
|
1000
|
+
metrics,
|
|
1001
|
+
metric_confidences: metricConfidences,
|
|
1002
|
+
metric_tiers: metricTiers,
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
function seedCycleArtifactsFromAnalysis(rootDir, cycleId, analysis, config) {
|
|
1006
|
+
const baselinePath = getIosmBaselineReportPath(cycleId, rootDir);
|
|
1007
|
+
const reportPath = getIosmCycleReportPath(cycleId, rootDir);
|
|
1008
|
+
const hypothesesPath = getIosmHypothesesPath(cycleId, rootDir);
|
|
1009
|
+
if (!existsSync(baselinePath) || !existsSync(reportPath) || !existsSync(hypothesesPath)) {
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
const baseline = readJson(baselinePath);
|
|
1013
|
+
baseline.cycle_scope = analysis.cycle_scope;
|
|
1014
|
+
baseline.source_systems = analysis.source_systems.length > 0 ? analysis.source_systems : baseline.source_systems;
|
|
1015
|
+
baseline.baseline_metrics = {
|
|
1016
|
+
values: analysis.metrics,
|
|
1017
|
+
raw_measurements: analysis.raw_measurements,
|
|
1018
|
+
};
|
|
1019
|
+
baseline.captured_at = analysis.generated_at;
|
|
1020
|
+
writeJson(baselinePath, baseline);
|
|
1021
|
+
const report = readJson(reportPath);
|
|
1022
|
+
report.status = "active";
|
|
1023
|
+
report.cycle_scope = analysis.cycle_scope;
|
|
1024
|
+
report.raw_measurements = analysis.raw_measurements;
|
|
1025
|
+
report.metrics = analysis.metrics;
|
|
1026
|
+
report.metric_confidences = analysis.metric_confidences;
|
|
1027
|
+
report.metric_tiers = analysis.metric_tiers;
|
|
1028
|
+
report.metric_deltas = createMetricRecord(() => 0);
|
|
1029
|
+
report.decline_coverage = createMetricRecord(() => true);
|
|
1030
|
+
report.iosm_index = calculateIosmIndex(analysis.metrics, config.iosm.index.weights);
|
|
1031
|
+
report.decision_confidence = calculateDecisionConfidence(analysis.metric_confidences, config.iosm.index.weights);
|
|
1032
|
+
report.incomplete =
|
|
1033
|
+
!hasCompleteNumericMetricRecord(report.metrics) ||
|
|
1034
|
+
!hasCompleteNumericMetricRecord(report.metric_confidences) ||
|
|
1035
|
+
!hasCompleteTierMetricRecord(report.metric_tiers) ||
|
|
1036
|
+
report.window.length === 0;
|
|
1037
|
+
report.decision = "CONTINUE";
|
|
1038
|
+
report.automation_actors = [
|
|
1039
|
+
...(report.automation_actors ?? []),
|
|
1040
|
+
{
|
|
1041
|
+
type: "agent",
|
|
1042
|
+
role: "analyzer",
|
|
1043
|
+
identity: "iosm-init",
|
|
1044
|
+
provenance: "repo-static-analysis",
|
|
1045
|
+
},
|
|
1046
|
+
];
|
|
1047
|
+
const scopeItems = countScopeItems(analysis.cycle_scope);
|
|
1048
|
+
report.cycle_capacity = {
|
|
1049
|
+
goal_count: report.goals.length,
|
|
1050
|
+
scope_size: scopeItems,
|
|
1051
|
+
expected_change_surface: scopeItems > 0 ? scopeItems : Math.max(report.hypotheses.length, 1),
|
|
1052
|
+
pass: report.goals.length <= config.iosm.cycle_capacity.max_goals &&
|
|
1053
|
+
scopeItems <= config.iosm.cycle_capacity.max_scope_items &&
|
|
1054
|
+
(scopeItems > 0 ? scopeItems : Math.max(report.hypotheses.length, 1)) <=
|
|
1055
|
+
config.iosm.cycle_capacity.max_expected_change_surface,
|
|
1056
|
+
};
|
|
1057
|
+
writeJson(reportPath, report);
|
|
1058
|
+
}
|
|
1059
|
+
function getCycleArtifactPaths(rootDir, cycleId) {
|
|
1060
|
+
return [
|
|
1061
|
+
getIosmBaselineReportPath(cycleId, rootDir),
|
|
1062
|
+
getIosmHypothesesPath(cycleId, rootDir),
|
|
1063
|
+
getIosmCycleReportPath(cycleId, rootDir),
|
|
1064
|
+
...IOSM_PHASES.map((phase) => getIosmPhaseReportPath(cycleId, phase, rootDir)),
|
|
1065
|
+
];
|
|
1066
|
+
}
|
|
1067
|
+
function shouldReuseCycleForInit(cycle) {
|
|
1068
|
+
if (!cycle) {
|
|
1069
|
+
return false;
|
|
1070
|
+
}
|
|
1071
|
+
return cycle.decision === "CONTINUE" || cycle.decision === "unknown";
|
|
1072
|
+
}
|
|
1073
|
+
function planOrReuseCycle(rootDir, force, analysis, config, result) {
|
|
1074
|
+
let existingCycles = [];
|
|
1075
|
+
try {
|
|
1076
|
+
existingCycles = listIosmCycles(rootDir);
|
|
1077
|
+
}
|
|
1078
|
+
catch {
|
|
1079
|
+
existingCycles = [];
|
|
1080
|
+
}
|
|
1081
|
+
const latestCycle = existingCycles[0];
|
|
1082
|
+
const shouldReuse = shouldReuseCycleForInit(latestCycle);
|
|
1083
|
+
let planned;
|
|
1084
|
+
let reusedExistingCycle = false;
|
|
1085
|
+
const existedBeforePlan = new Map();
|
|
1086
|
+
if (!shouldReuse) {
|
|
1087
|
+
planned = planIosmCycle({
|
|
1088
|
+
cwd: rootDir,
|
|
1089
|
+
goals: analysis.goals,
|
|
1090
|
+
force,
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
else if (force) {
|
|
1094
|
+
reusedExistingCycle = true;
|
|
1095
|
+
const cycleId = latestCycle.cycleId;
|
|
1096
|
+
for (const artifactPath of getCycleArtifactPaths(rootDir, cycleId)) {
|
|
1097
|
+
existedBeforePlan.set(artifactPath, existsSync(artifactPath));
|
|
1098
|
+
}
|
|
1099
|
+
planned = planIosmCycle({
|
|
1100
|
+
cwd: rootDir,
|
|
1101
|
+
cycleId,
|
|
1102
|
+
goals: analysis.goals,
|
|
1103
|
+
force: true,
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
else {
|
|
1107
|
+
const cycleId = latestCycle.cycleId;
|
|
1108
|
+
return {
|
|
1109
|
+
cycleId,
|
|
1110
|
+
cycleDir: getIosmCycleDir(cycleId, rootDir),
|
|
1111
|
+
reportPath: getIosmCycleReportPath(cycleId, rootDir),
|
|
1112
|
+
baselineReportPath: getIosmBaselineReportPath(cycleId, rootDir),
|
|
1113
|
+
hypothesesPath: getIosmHypothesesPath(cycleId, rootDir),
|
|
1114
|
+
reusedExistingCycle: true,
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
if (!planned) {
|
|
1118
|
+
return undefined;
|
|
1119
|
+
}
|
|
1120
|
+
const artifactPaths = getCycleArtifactPaths(rootDir, planned.cycleId);
|
|
1121
|
+
for (const filePath of artifactPaths) {
|
|
1122
|
+
markPathByExistence(filePath, existedBeforePlan.get(filePath) ?? false, result);
|
|
1123
|
+
}
|
|
1124
|
+
seedCycleArtifactsFromAnalysis(rootDir, planned.cycleId, analysis, config);
|
|
1125
|
+
return {
|
|
1126
|
+
cycleId: planned.cycleId,
|
|
1127
|
+
cycleDir: planned.cycleDir,
|
|
1128
|
+
reportPath: planned.reportPath,
|
|
1129
|
+
baselineReportPath: planned.baselineReportPath,
|
|
1130
|
+
hypothesesPath: planned.hypothesesPath,
|
|
1131
|
+
reusedExistingCycle,
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
export async function initIosmWorkspace(options = {}) {
|
|
1135
|
+
const rootDir = resolve(options.cwd ?? process.cwd());
|
|
1136
|
+
const force = options.force ?? false;
|
|
1137
|
+
const bootstrapAnalysis = {
|
|
1138
|
+
generated_at: new Date().toISOString(),
|
|
1139
|
+
files_analyzed: 0,
|
|
1140
|
+
source_file_count: 0,
|
|
1141
|
+
test_file_count: 0,
|
|
1142
|
+
doc_file_count: 0,
|
|
1143
|
+
top_languages: [],
|
|
1144
|
+
cycle_scope: {
|
|
1145
|
+
modules: [],
|
|
1146
|
+
services: [],
|
|
1147
|
+
domains: [],
|
|
1148
|
+
contracts: [],
|
|
1149
|
+
rationale: "not analyzed",
|
|
1150
|
+
},
|
|
1151
|
+
detected_contracts: [],
|
|
1152
|
+
source_systems: [],
|
|
1153
|
+
goals: ["Establish IOSM baseline metrics and define an initial cycle scope."],
|
|
1154
|
+
raw_measurements: {},
|
|
1155
|
+
metrics: createMetricRecord(() => null),
|
|
1156
|
+
metric_confidences: createMetricRecord(() => 0.5),
|
|
1157
|
+
metric_tiers: createMetricRecord(() => "C"),
|
|
1158
|
+
};
|
|
1159
|
+
const result = {
|
|
1160
|
+
rootDir,
|
|
1161
|
+
created: [],
|
|
1162
|
+
overwritten: [],
|
|
1163
|
+
skipped: [],
|
|
1164
|
+
analysis: bootstrapAnalysis,
|
|
1165
|
+
};
|
|
1166
|
+
const systemName = basename(rootDir);
|
|
1167
|
+
mkdirSync(rootDir, { recursive: true });
|
|
1168
|
+
mkdirSync(getIosmWorkspaceDir(rootDir), { recursive: true });
|
|
1169
|
+
mkdirSync(getIosmBaselinesDir(rootDir), { recursive: true });
|
|
1170
|
+
mkdirSync(getIosmCyclesDir(rootDir), { recursive: true });
|
|
1171
|
+
writeScaffoldFileWithExistenceCheck(getIosmConfigPath(rootDir), createIosmConfigTemplate(systemName), force, result);
|
|
1172
|
+
const { config } = loadIosmConfig(rootDir);
|
|
1173
|
+
const signals = await deriveProjectSignals(rootDir);
|
|
1174
|
+
const analysis = deriveInitAnalysis(signals, config);
|
|
1175
|
+
result.analysis = analysis;
|
|
1176
|
+
const invariantsCatalog = createInvariantsCatalog(signals, analysis.generated_at);
|
|
1177
|
+
const contractsCatalog = createContractCatalog(signals, analysis.generated_at);
|
|
1178
|
+
const waiverRegister = createWaiverRegister(analysis.generated_at);
|
|
1179
|
+
const decisionLog = createDecisionLog(systemName, analysis);
|
|
1180
|
+
const patternLibrary = createPatternLibrary(analysis);
|
|
1181
|
+
writeScaffoldFileWithExistenceCheck(getIosmMetricsHistoryPath(rootDir), "", force, result);
|
|
1182
|
+
writeScaffoldFileWithExistenceCheck(getIosmWaiverRegisterPath(rootDir), stringify(waiverRegister), force, result);
|
|
1183
|
+
writeScaffoldFileWithExistenceCheck(getIosmInvariantCatalogPath(rootDir), stringify(invariantsCatalog), force, result);
|
|
1184
|
+
writeScaffoldFileWithExistenceCheck(getIosmContractCatalogPath(rootDir), stringify(contractsCatalog), force, result);
|
|
1185
|
+
writeScaffoldFileWithExistenceCheck(getIosmDecisionLogPath(rootDir), decisionLog, force, result);
|
|
1186
|
+
writeScaffoldFileWithExistenceCheck(getIosmPatternLibraryPath(rootDir), patternLibrary, force, result);
|
|
1187
|
+
writeScaffoldFileWithExistenceCheck(join(getIosmBaselinesDir(rootDir), ".gitkeep"), "", force, result);
|
|
1188
|
+
writeScaffoldFileWithExistenceCheck(join(getIosmCyclesDir(rootDir), ".gitkeep"), "", force, result);
|
|
1189
|
+
result.cycle = planOrReuseCycle(rootDir, force, analysis, config, result);
|
|
1190
|
+
const heuristicIndex = calculateIosmIndex(analysis.metrics, config.iosm.index.weights);
|
|
1191
|
+
const heuristicConfidence = calculateDecisionConfidence(analysis.metric_confidences, config.iosm.index.weights);
|
|
1192
|
+
const guideWrite = writeIosmGuideDocument({
|
|
1193
|
+
rootDir,
|
|
1194
|
+
cycleId: result.cycle?.cycleId,
|
|
1195
|
+
assessmentSource: "heuristic",
|
|
1196
|
+
metrics: analysis.metrics,
|
|
1197
|
+
iosmIndex: heuristicIndex,
|
|
1198
|
+
decisionConfidence: heuristicConfidence,
|
|
1199
|
+
goals: analysis.goals,
|
|
1200
|
+
filesAnalyzed: analysis.files_analyzed,
|
|
1201
|
+
sourceFileCount: analysis.source_file_count,
|
|
1202
|
+
testFileCount: analysis.test_file_count,
|
|
1203
|
+
docFileCount: analysis.doc_file_count,
|
|
1204
|
+
}, force);
|
|
1205
|
+
if (guideWrite.written) {
|
|
1206
|
+
markPathByExistence(guideWrite.path, guideWrite.existed, result);
|
|
1207
|
+
}
|
|
1208
|
+
else {
|
|
1209
|
+
pushUnique(result.skipped, guideWrite.path);
|
|
1210
|
+
}
|
|
1211
|
+
if (result.cycle) {
|
|
1212
|
+
try {
|
|
1213
|
+
recordIosmCycleHistory(rootDir, result.cycle.cycleId);
|
|
1214
|
+
}
|
|
1215
|
+
catch {
|
|
1216
|
+
// Keep init resilient even if history record cannot be persisted yet.
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
return result;
|
|
1220
|
+
}
|
|
1221
|
+
//# sourceMappingURL=init.js.map
|