wicked-crew 0.17.1 → 0.18.1
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 +49 -14
- package/adapters/web-source.lock +1314 -0
- package/dist/api/audit.d.ts +5 -0
- package/dist/api/audit.d.ts.map +1 -1
- package/dist/api/audit.js +20 -0
- package/dist/api/audit.js.map +1 -1
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +3 -0
- package/dist/api/auth.js.map +1 -1
- package/dist/api/chat-context.js +1 -1
- package/dist/api/chat-history.d.ts +3 -0
- package/dist/api/chat-history.d.ts.map +1 -1
- package/dist/api/chat-history.js +6 -1
- package/dist/api/chat-history.js.map +1 -1
- package/dist/api/chat-jobs.d.ts +30 -1
- package/dist/api/chat-jobs.d.ts.map +1 -1
- package/dist/api/chat-jobs.js +172 -10
- package/dist/api/chat-jobs.js.map +1 -1
- package/dist/api/chat-proposals.d.ts +178 -8
- package/dist/api/chat-proposals.d.ts.map +1 -1
- package/dist/api/chat-proposals.js +775 -54
- package/dist/api/chat-proposals.js.map +1 -1
- package/dist/api/chat-requirements.d.ts +54 -0
- package/dist/api/chat-requirements.d.ts.map +1 -0
- package/dist/api/chat-requirements.js +282 -0
- package/dist/api/chat-requirements.js.map +1 -0
- package/dist/api/chat-scope.d.ts +56 -0
- package/dist/api/chat-scope.d.ts.map +1 -1
- package/dist/api/chat-scope.js +175 -5
- package/dist/api/chat-scope.js.map +1 -1
- package/dist/api/chat-transcripts.d.ts +7 -0
- package/dist/api/chat-transcripts.d.ts.map +1 -1
- package/dist/api/chat-transcripts.js +17 -1
- package/dist/api/chat-transcripts.js.map +1 -1
- package/dist/api/delivery-index.d.ts +109 -5
- package/dist/api/delivery-index.d.ts.map +1 -1
- package/dist/api/delivery-index.js +199 -7
- package/dist/api/delivery-index.js.map +1 -1
- package/dist/api/mcp.d.ts +7 -2
- package/dist/api/mcp.d.ts.map +1 -1
- package/dist/api/mcp.js +1 -1
- package/dist/api/mcp.js.map +1 -1
- package/dist/api/needs.d.ts.map +1 -1
- package/dist/api/needs.js +19 -1
- package/dist/api/needs.js.map +1 -1
- package/dist/api/product.d.ts +9 -2
- package/dist/api/product.d.ts.map +1 -1
- package/dist/api/product.js +10 -2
- package/dist/api/product.js.map +1 -1
- package/dist/api/proposal-theme.d.ts +23 -0
- package/dist/api/proposal-theme.d.ts.map +1 -0
- package/dist/api/proposal-theme.js +30 -0
- package/dist/api/proposal-theme.js.map +1 -0
- package/dist/api/recording.d.ts +70 -10
- package/dist/api/recording.d.ts.map +1 -1
- package/dist/api/recording.js +278 -39
- package/dist/api/recording.js.map +1 -1
- package/dist/api/repo-input.d.ts +55 -0
- package/dist/api/repo-input.d.ts.map +1 -0
- package/dist/api/repo-input.js +113 -0
- package/dist/api/repo-input.js.map +1 -0
- package/dist/api/requirements.d.ts +75 -0
- package/dist/api/requirements.d.ts.map +1 -1
- package/dist/api/requirements.js +97 -9
- package/dist/api/requirements.js.map +1 -1
- package/dist/api/review-change.d.ts +64 -0
- package/dist/api/review-change.d.ts.map +1 -0
- package/dist/api/review-change.js +214 -0
- package/dist/api/review-change.js.map +1 -0
- package/dist/api/roster-standing.d.ts +4 -0
- package/dist/api/roster-standing.d.ts.map +1 -1
- package/dist/api/roster-standing.js +43 -10
- package/dist/api/roster-standing.js.map +1 -1
- package/dist/api/routes.d.ts +63 -6
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +818 -269
- package/dist/api/routes.js.map +1 -1
- package/dist/api/run-documents.d.ts +97 -0
- package/dist/api/run-documents.d.ts.map +1 -0
- package/dist/api/run-documents.js +458 -0
- package/dist/api/run-documents.js.map +1 -0
- package/dist/api/run-sources.d.ts +51 -0
- package/dist/api/run-sources.d.ts.map +1 -0
- package/dist/api/run-sources.js +133 -0
- package/dist/api/run-sources.js.map +1 -0
- package/dist/api/runtime-state.d.ts +41 -0
- package/dist/api/runtime-state.d.ts.map +1 -0
- package/dist/api/runtime-state.js +75 -0
- package/dist/api/runtime-state.js.map +1 -0
- package/dist/api/seat-container-login.d.ts +51 -0
- package/dist/api/seat-container-login.d.ts.map +1 -1
- package/dist/api/seat-container-login.js +317 -1
- package/dist/api/seat-container-login.js.map +1 -1
- package/dist/api/seat-images.d.ts.map +1 -1
- package/dist/api/seat-images.js +7 -0
- package/dist/api/seat-images.js.map +1 -1
- package/dist/api/server.d.ts +7 -0
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +206 -25
- package/dist/api/server.js.map +1 -1
- package/dist/api/skills.d.ts +8 -0
- package/dist/api/skills.d.ts.map +1 -1
- package/dist/api/skills.js +21 -0
- package/dist/api/skills.js.map +1 -1
- package/dist/api/system-snapshot.d.ts +7 -2
- package/dist/api/system-snapshot.d.ts.map +1 -1
- package/dist/api/system-snapshot.js +31 -7
- package/dist/api/system-snapshot.js.map +1 -1
- package/dist/api/testing.d.ts +3 -3
- package/dist/api/ui-text.d.ts +45 -0
- package/dist/api/ui-text.d.ts.map +1 -0
- package/dist/api/ui-text.js +188 -0
- package/dist/api/ui-text.js.map +1 -0
- package/dist/apps/actions/card.d.ts +62 -0
- package/dist/apps/actions/card.d.ts.map +1 -0
- package/dist/apps/actions/card.js +111 -0
- package/dist/apps/actions/card.js.map +1 -0
- package/dist/apps/actions/write-path.d.ts.map +1 -1
- package/dist/apps/actions/write-path.js +26 -77
- package/dist/apps/actions/write-path.js.map +1 -1
- package/dist/apps/exec/sources.d.ts.map +1 -1
- package/dist/apps/exec/sources.js +3 -0
- package/dist/apps/exec/sources.js.map +1 -1
- package/dist/apps/publish/artifacts.d.ts +18 -0
- package/dist/apps/publish/artifacts.d.ts.map +1 -0
- package/dist/apps/publish/artifacts.js +87 -0
- package/dist/apps/publish/artifacts.js.map +1 -0
- package/dist/apps/publish/check.d.ts +103 -0
- package/dist/apps/publish/check.d.ts.map +1 -0
- package/dist/apps/publish/check.js +235 -0
- package/dist/apps/publish/check.js.map +1 -0
- package/dist/apps/publish/image.d.ts +2 -0
- package/dist/apps/publish/image.d.ts.map +1 -1
- package/dist/apps/publish/image.js +2 -1
- package/dist/apps/publish/image.js.map +1 -1
- package/dist/apps/publish/render.d.ts +71 -0
- package/dist/apps/publish/render.d.ts.map +1 -0
- package/dist/apps/publish/render.js +122 -0
- package/dist/apps/publish/render.js.map +1 -0
- package/dist/apps/publish/run.d.ts +35 -0
- package/dist/apps/publish/run.d.ts.map +1 -0
- package/dist/apps/publish/run.js +127 -0
- package/dist/apps/publish/run.js.map +1 -0
- package/dist/apps/routes.d.ts +54 -2
- package/dist/apps/routes.d.ts.map +1 -1
- package/dist/apps/routes.js +124 -7
- package/dist/apps/routes.js.map +1 -1
- package/dist/apps/spec.d.ts +8 -8
- package/dist/apps/store.d.ts +84 -5
- package/dist/apps/store.d.ts.map +1 -1
- package/dist/apps/store.js +191 -4
- package/dist/apps/store.js.map +1 -1
- package/dist/apps/turns.d.ts +19 -1
- package/dist/apps/turns.d.ts.map +1 -1
- package/dist/apps/turns.js +60 -2
- package/dist/apps/turns.js.map +1 -1
- package/dist/apps/views.d.ts +5 -1
- package/dist/apps/views.d.ts.map +1 -1
- package/dist/apps/views.js +18 -7
- package/dist/apps/views.js.map +1 -1
- package/dist/apps-server/Dockerfile +25 -0
- package/dist/apps-server/runners/sqlite-runner.mjs +110 -0
- package/dist/apps-server/server/lib/bundle/server.mjs +92523 -0
- package/dist/apps-server/server/node_modules/@pgsql/types/LICENSE +22 -0
- package/dist/apps-server/server/node_modules/@pgsql/types/README.md +106 -0
- package/dist/apps-server/server/node_modules/@pgsql/types/enums.d.ts +76 -0
- package/dist/apps-server/server/node_modules/@pgsql/types/enums.js +2 -0
- package/dist/apps-server/server/node_modules/@pgsql/types/esm/enums.js +1 -0
- package/dist/apps-server/server/node_modules/@pgsql/types/esm/index.js +2 -0
- package/dist/apps-server/server/node_modules/@pgsql/types/esm/types.js +1 -0
- package/dist/apps-server/server/node_modules/@pgsql/types/index.d.ts +2 -0
- package/dist/apps-server/server/node_modules/@pgsql/types/index.js +18 -0
- package/dist/apps-server/server/node_modules/@pgsql/types/package.json +36 -0
- package/dist/apps-server/server/node_modules/@pgsql/types/types.d.ts +2488 -0
- package/dist/apps-server/server/node_modules/@pgsql/types/types.js +2 -0
- package/dist/apps-server/server/node_modules/libpg-query/LICENSE +22 -0
- package/dist/apps-server/server/node_modules/libpg-query/README.md +275 -0
- package/dist/apps-server/server/node_modules/libpg-query/package.json +58 -0
- package/dist/apps-server/server/node_modules/libpg-query/wasm/index.cjs +369 -0
- package/dist/apps-server/server/node_modules/libpg-query/wasm/index.d.ts +48 -0
- package/dist/apps-server/server/node_modules/libpg-query/wasm/index.js +344 -0
- package/dist/apps-server/server/node_modules/libpg-query/wasm/libpg-query.js +2 -0
- package/dist/apps-server/server/node_modules/libpg-query/wasm/libpg-query.wasm +0 -0
- package/dist/apps-server/server/shim/host.css +22 -0
- package/dist/apps-server/server/shim/host.js +1 -0
- package/dist/cli/apps-check.d.ts +18 -0
- package/dist/cli/apps-check.d.ts.map +1 -1
- package/dist/cli/apps-check.js +179 -5
- package/dist/cli/apps-check.js.map +1 -1
- package/dist/cli/apps-produce.d.ts +9 -0
- package/dist/cli/apps-produce.d.ts.map +1 -0
- package/dist/cli/apps-produce.js +27 -0
- package/dist/cli/apps-produce.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +15 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/insights-facts.d.ts +17 -0
- package/dist/cli/insights-facts.d.ts.map +1 -0
- package/dist/cli/insights-facts.js +56 -0
- package/dist/cli/insights-facts.js.map +1 -0
- package/dist/core/adapter.d.ts +74 -15
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +245 -53
- package/dist/core/adapter.js.map +1 -1
- package/dist/core/engine-roster.d.ts.map +1 -1
- package/dist/core/engine-roster.js +1 -0
- package/dist/core/engine-roster.js.map +1 -1
- package/dist/core/estate-mcp-client.d.ts +3 -2
- package/dist/core/estate-mcp-client.d.ts.map +1 -1
- package/dist/core/estate-mcp-client.js +3 -2
- package/dist/core/estate-mcp-client.js.map +1 -1
- package/dist/core/run-identity.d.ts.map +1 -1
- package/dist/core/run-identity.js +3 -0
- package/dist/core/run-identity.js.map +1 -1
- package/dist/core/types.d.ts +5 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/editors/conformance-runtime.d.ts +107 -0
- package/dist/editors/conformance-runtime.d.ts.map +1 -1
- package/dist/editors/conformance-runtime.js +268 -13
- package/dist/editors/conformance-runtime.js.map +1 -1
- package/dist/editors/csp.d.ts +2 -2
- package/dist/editors/csp.d.ts.map +1 -1
- package/dist/editors/csp.js +4 -2
- package/dist/editors/csp.js.map +1 -1
- package/dist/editors/pack-install.d.ts +28 -13
- package/dist/editors/pack-install.d.ts.map +1 -1
- package/dist/editors/pack-install.js +96 -48
- package/dist/editors/pack-install.js.map +1 -1
- package/dist/editors/registry.d.ts +111 -8
- package/dist/editors/registry.d.ts.map +1 -1
- package/dist/editors/registry.js +183 -7
- package/dist/editors/registry.js.map +1 -1
- package/dist/editors/routes.d.ts +66 -13
- package/dist/editors/routes.d.ts.map +1 -1
- package/dist/editors/routes.js +277 -44
- package/dist/editors/routes.js.map +1 -1
- package/dist/evals/replay.d.ts +6 -0
- package/dist/evals/replay.d.ts.map +1 -1
- package/dist/evals/replay.js +24 -1
- package/dist/evals/replay.js.map +1 -1
- package/dist/evals/routes.d.ts.map +1 -1
- package/dist/evals/routes.js +17 -2
- package/dist/evals/routes.js.map +1 -1
- package/dist/evals/runner.d.ts.map +1 -1
- package/dist/evals/runner.js +5 -0
- package/dist/evals/runner.js.map +1 -1
- package/dist/evals/shape-corrections.d.ts +146 -0
- package/dist/evals/shape-corrections.d.ts.map +1 -0
- package/dist/evals/shape-corrections.js +394 -0
- package/dist/evals/shape-corrections.js.map +1 -0
- package/dist/evals/shape.d.ts +145 -0
- package/dist/evals/shape.d.ts.map +1 -0
- package/dist/evals/shape.js +376 -0
- package/dist/evals/shape.js.map +1 -0
- package/dist/evals/types.d.ts +2 -2
- package/dist/evals/types.d.ts.map +1 -1
- package/dist/evals/types.js +2 -1
- package/dist/evals/types.js.map +1 -1
- package/dist/insights/analyze.d.ts +14 -1
- package/dist/insights/analyze.d.ts.map +1 -1
- package/dist/insights/analyze.js +35 -8
- package/dist/insights/analyze.js.map +1 -1
- package/dist/insights/cost.d.ts +123 -0
- package/dist/insights/cost.d.ts.map +1 -0
- package/dist/insights/cost.js +221 -0
- package/dist/insights/cost.js.map +1 -0
- package/dist/insights/review-service.d.ts +20 -1
- package/dist/insights/review-service.d.ts.map +1 -1
- package/dist/insights/review-service.js +50 -25
- package/dist/insights/review-service.js.map +1 -1
- package/dist/insights/routes.d.ts +29 -0
- package/dist/insights/routes.d.ts.map +1 -1
- package/dist/insights/routes.js +62 -0
- package/dist/insights/routes.js.map +1 -1
- package/dist/insights/run-facts.d.ts +16 -0
- package/dist/insights/run-facts.d.ts.map +1 -1
- package/dist/insights/run-facts.js +26 -3
- package/dist/insights/run-facts.js.map +1 -1
- package/dist/interactive/bridge-pool.d.ts +11 -2
- package/dist/interactive/bridge-pool.d.ts.map +1 -1
- package/dist/interactive/bridge-pool.js +10 -1
- package/dist/interactive/bridge-pool.js.map +1 -1
- package/dist/interactive/chat-events.d.ts +74 -1
- package/dist/interactive/chat-events.d.ts.map +1 -1
- package/dist/interactive/chat-events.js +338 -6
- package/dist/interactive/chat-events.js.map +1 -1
- package/dist/interactive/doc-binding.d.ts +15 -0
- package/dist/interactive/doc-binding.d.ts.map +1 -1
- package/dist/interactive/doc-binding.js +4 -0
- package/dist/interactive/doc-binding.js.map +1 -1
- package/dist/interactive/doc-checks-routes.d.ts +34 -1
- package/dist/interactive/doc-checks-routes.d.ts.map +1 -1
- package/dist/interactive/doc-checks-routes.js +84 -0
- package/dist/interactive/doc-checks-routes.js.map +1 -1
- package/dist/interactive/draft-events.d.ts +7 -0
- package/dist/interactive/draft-events.d.ts.map +1 -1
- package/dist/interactive/draft-events.js +38 -6
- package/dist/interactive/draft-events.js.map +1 -1
- package/dist/interactive/draft-skill.d.ts +76 -6
- package/dist/interactive/draft-skill.d.ts.map +1 -1
- package/dist/interactive/draft-skill.js +219 -17
- package/dist/interactive/draft-skill.js.map +1 -1
- package/dist/interactive/edit-events.d.ts.map +1 -1
- package/dist/interactive/edit-events.js +4 -2
- package/dist/interactive/edit-events.js.map +1 -1
- package/dist/interactive/landing-guard.d.ts +47 -0
- package/dist/interactive/landing-guard.d.ts.map +1 -0
- package/dist/interactive/landing-guard.js +43 -0
- package/dist/interactive/landing-guard.js.map +1 -0
- package/dist/interactive/landing-record.d.ts +68 -0
- package/dist/interactive/landing-record.d.ts.map +1 -0
- package/dist/interactive/landing-record.js +154 -0
- package/dist/interactive/landing-record.js.map +1 -0
- package/dist/interactive/proposal-create.d.ts +3 -1
- package/dist/interactive/proposal-create.d.ts.map +1 -1
- package/dist/interactive/proposal-create.js +14 -2
- package/dist/interactive/proposal-create.js.map +1 -1
- package/dist/interactive/proposal-refine.d.ts +48 -0
- package/dist/interactive/proposal-refine.d.ts.map +1 -0
- package/dist/interactive/proposal-refine.js +99 -0
- package/dist/interactive/proposal-refine.js.map +1 -0
- package/dist/interactive/protected-edits.d.ts +67 -0
- package/dist/interactive/protected-edits.d.ts.map +1 -0
- package/dist/interactive/protected-edits.js +160 -0
- package/dist/interactive/protected-edits.js.map +1 -0
- package/dist/interactive/proxy-routes.js +2 -2
- package/dist/interactive/review-events.js +1 -1
- package/dist/interactive/run-units.d.ts +1 -1
- package/dist/interactive/run-units.d.ts.map +1 -1
- package/dist/interactive/run-units.js +8 -2
- package/dist/interactive/run-units.js.map +1 -1
- package/dist/interactive/source-packet.d.ts +66 -1
- package/dist/interactive/source-packet.d.ts.map +1 -1
- package/dist/interactive/source-packet.js +309 -60
- package/dist/interactive/source-packet.js.map +1 -1
- package/dist/interactive/theme-events.js +1 -1
- package/dist/knowledge/adapters/web/egress.d.ts +99 -0
- package/dist/knowledge/adapters/web/egress.d.ts.map +1 -0
- package/dist/knowledge/adapters/web/egress.js +330 -0
- package/dist/knowledge/adapters/web/egress.js.map +1 -0
- package/dist/knowledge/adapters/web/engine.d.ts +54 -0
- package/dist/knowledge/adapters/web/engine.d.ts.map +1 -0
- package/dist/knowledge/adapters/web/engine.js +101 -0
- package/dist/knowledge/adapters/web/engine.js.map +1 -0
- package/dist/knowledge/adapters/web/fetch.d.ts +131 -0
- package/dist/knowledge/adapters/web/fetch.d.ts.map +1 -0
- package/dist/knowledge/adapters/web/fetch.js +325 -0
- package/dist/knowledge/adapters/web/fetch.js.map +1 -0
- package/dist/knowledge/adapters/web/gate-web.d.ts +182 -0
- package/dist/knowledge/adapters/web/gate-web.d.ts.map +1 -0
- package/dist/knowledge/adapters/web/gate-web.js +496 -0
- package/dist/knowledge/adapters/web/gate-web.js.map +1 -0
- package/dist/knowledge/adapters/web/routes.d.ts +36 -0
- package/dist/knowledge/adapters/web/routes.d.ts.map +1 -0
- package/dist/knowledge/adapters/web/routes.js +99 -0
- package/dist/knowledge/adapters/web/routes.js.map +1 -0
- package/dist/knowledge/adapters/web/searxng.d.ts +89 -0
- package/dist/knowledge/adapters/web/searxng.d.ts.map +1 -0
- package/dist/knowledge/adapters/web/searxng.js +274 -0
- package/dist/knowledge/adapters/web/searxng.js.map +1 -0
- package/dist/knowledge/adapters/web/source.d.ts +65 -0
- package/dist/knowledge/adapters/web/source.d.ts.map +1 -0
- package/dist/knowledge/adapters/web/source.js +192 -0
- package/dist/knowledge/adapters/web/source.js.map +1 -0
- package/dist/knowledge/gate/gate.d.ts +22 -0
- package/dist/knowledge/gate/gate.d.ts.map +1 -1
- package/dist/knowledge/gate/gate.js +62 -1
- package/dist/knowledge/gate/gate.js.map +1 -1
- package/dist/knowledge/gate/sources.d.ts +2 -0
- package/dist/knowledge/gate/sources.d.ts.map +1 -1
- package/dist/knowledge/gate/sources.js +5 -2
- package/dist/knowledge/gate/sources.js.map +1 -1
- package/dist/knowledge/package.d.ts +7 -0
- package/dist/knowledge/package.d.ts.map +1 -1
- package/dist/knowledge/package.js +15 -1
- package/dist/knowledge/package.js.map +1 -1
- package/dist/knowledge/trackers/actions.js +1 -1
- package/dist/knowledge/trackers/actions.js.map +1 -1
- package/dist/knowledge/trackers/bindings.d.ts +3 -3
- package/dist/knowledge/trackers/bindings.d.ts.map +1 -1
- package/dist/knowledge/trackers/bindings.js +36 -23
- package/dist/knowledge/trackers/bindings.js.map +1 -1
- package/dist/knowledge/trackers/routes.js +1 -1
- package/dist/knowledge/trackers/routes.js.map +1 -1
- package/dist/learnings/service.d.ts.map +1 -1
- package/dist/learnings/service.js +2 -0
- package/dist/learnings/service.js.map +1 -1
- package/dist/mcp/broker.d.ts +8 -0
- package/dist/mcp/broker.d.ts.map +1 -1
- package/dist/mcp/broker.js +48 -3
- package/dist/mcp/broker.js.map +1 -1
- package/dist/mcp/estate-relay.d.ts +43 -1
- package/dist/mcp/estate-relay.d.ts.map +1 -1
- package/dist/mcp/estate-relay.js +38 -2
- package/dist/mcp/estate-relay.js.map +1 -1
- package/dist/mcp/registry.d.ts +6 -0
- package/dist/mcp/registry.d.ts.map +1 -1
- package/dist/mcp/registry.js +42 -3
- package/dist/mcp/registry.js.map +1 -1
- package/dist/mcp/run-fence.d.ts +57 -0
- package/dist/mcp/run-fence.d.ts.map +1 -0
- package/dist/mcp/run-fence.js +86 -0
- package/dist/mcp/run-fence.js.map +1 -0
- package/dist/mcp/tool-list.d.ts +5 -0
- package/dist/mcp/tool-list.d.ts.map +1 -1
- package/dist/mcp/tool-list.js +7 -3
- package/dist/mcp/tool-list.js.map +1 -1
- package/dist/presets/routes.d.ts.map +1 -1
- package/dist/presets/routes.js +6 -0
- package/dist/presets/routes.js.map +1 -1
- package/dist/projects/routes.d.ts +1 -1
- package/dist/projects/state-home-preflight.d.ts.map +1 -1
- package/dist/projects/state-home-preflight.js +2 -0
- package/dist/projects/state-home-preflight.js.map +1 -1
- package/dist/setup/tool-path.d.ts +16 -0
- package/dist/setup/tool-path.d.ts.map +1 -0
- package/dist/setup/tool-path.js +66 -0
- package/dist/setup/tool-path.js.map +1 -0
- package/dist/skills/plugin-source.d.ts +46 -88
- package/dist/skills/plugin-source.d.ts.map +1 -1
- package/dist/skills/plugin-source.js +144 -100
- package/dist/skills/plugin-source.js.map +1 -1
- package/dist/skills/runtime.d.ts +47 -0
- package/dist/skills/runtime.d.ts.map +1 -1
- package/dist/skills/runtime.js +110 -14
- package/dist/skills/runtime.js.map +1 -1
- package/dist/skills/store.d.ts +2 -0
- package/dist/skills/store.d.ts.map +1 -1
- package/dist/skills/store.js +29 -14
- package/dist/skills/store.js.map +1 -1
- package/dist/skills/usage.d.ts +238 -0
- package/dist/skills/usage.d.ts.map +1 -0
- package/dist/skills/usage.js +789 -0
- package/dist/skills/usage.js.map +1 -0
- package/dist/skills/venv.d.ts +18 -2
- package/dist/skills/venv.d.ts.map +1 -1
- package/dist/skills/venv.js +2 -2
- package/dist/skills/venv.js.map +1 -1
- package/dist/sources/routes.d.ts +3 -1
- package/dist/sources/routes.d.ts.map +1 -1
- package/dist/sources/routes.js +11 -0
- package/dist/sources/routes.js.map +1 -1
- package/dist/standing-orders/parse.d.ts +19 -0
- package/dist/standing-orders/parse.d.ts.map +1 -1
- package/dist/standing-orders/parse.js +61 -18
- package/dist/standing-orders/parse.js.map +1 -1
- package/dist/studio/apps-standalone/fixture.html +12 -0
- package/dist/studio/apps-standalone/fixture.js +10 -0
- package/dist/studio/apps-standalone/runtime.css +139 -0
- package/dist/studio/apps-standalone/runtime.js +1 -0
- package/dist/studio/assets/{KnowledgeGraph-Cpm46tEp.js → KnowledgeGraph-BT5Y-B8b.js} +1 -1
- package/dist/studio/assets/index-B_JwrHVF.css +32 -0
- package/dist/studio/assets/index-Bl9m8ldl.js +1104 -0
- package/dist/studio/editors/wicked-apps/editor.json +1 -1
- package/dist/studio/editors/wicked-apps/index.html +2 -2
- package/dist/studio/editors/wicked-deck/editor.json +1 -1
- package/dist/studio/editors/wicked-deck/index.html +14 -1
- package/dist/studio/editors/wicked-doc/editor.json +1 -1
- package/dist/studio/editors/wicked-doc/index.html +1 -1
- package/dist/studio/editors/wicked-insights/editor.json +1 -1
- package/dist/studio/editors/wicked-insights/index.html +1 -1
- package/dist/studio/editors/wicked-page/editor.json +10 -1
- package/dist/studio/editors/wicked-page/index.html +2 -2
- package/dist/studio/editors/wicked-video/editor.json +7 -2
- package/dist/studio/editors/wicked-video/index.html +14 -11
- package/dist/studio/index.html +2 -2
- package/dist/studio/testid-inventory.json +2073 -240
- package/dist/team/routes.d.ts +1 -1
- package/dist/workflow-catalog/build-v2.d.ts +6 -2
- package/dist/workflow-catalog/build-v2.d.ts.map +1 -1
- package/dist/workflow-catalog/build-v2.js +37 -13
- package/dist/workflow-catalog/build-v2.js.map +1 -1
- package/dist/workflow-catalog/catalog-data-v2.d.ts.map +1 -1
- package/dist/workflow-catalog/catalog-data-v2.js +310 -105
- package/dist/workflow-catalog/catalog-data-v2.js.map +1 -1
- package/dist/workflow-catalog/catalog-data.d.ts.map +1 -1
- package/dist/workflow-catalog/catalog-data.js +2 -20
- package/dist/workflow-catalog/catalog-data.js.map +1 -1
- package/dist/workflow-catalog/detect-service.d.ts +95 -0
- package/dist/workflow-catalog/detect-service.d.ts.map +1 -0
- package/dist/workflow-catalog/detect-service.js +239 -0
- package/dist/workflow-catalog/detect-service.js.map +1 -0
- package/dist/workflow-catalog/detect.d.ts +213 -0
- package/dist/workflow-catalog/detect.d.ts.map +1 -0
- package/dist/workflow-catalog/detect.js +653 -0
- package/dist/workflow-catalog/detect.js.map +1 -0
- package/dist/workflow-catalog/shape.d.ts +3 -1
- package/dist/workflow-catalog/shape.d.ts.map +1 -1
- package/dist/workflow-catalog/shape.js +7 -1
- package/dist/workflow-catalog/shape.js.map +1 -1
- package/dist/working-doc/bridge-backend.js +2 -2
- package/dist/working-doc/event-lines.d.ts +67 -2
- package/dist/working-doc/event-lines.d.ts.map +1 -1
- package/dist/working-doc/event-lines.js +155 -8
- package/dist/working-doc/event-lines.js.map +1 -1
- package/dist/working-doc/notes-index.d.ts +35 -0
- package/dist/working-doc/notes-index.d.ts.map +1 -0
- package/dist/working-doc/notes-index.js +82 -0
- package/dist/working-doc/notes-index.js.map +1 -0
- package/dist/working-doc/routes.js +4 -4
- package/dist/working-doc/sections.js +2 -2
- package/dist/working-doc/service.d.ts +260 -21
- package/dist/working-doc/service.d.ts.map +1 -1
- package/dist/working-doc/service.js +791 -90
- package/dist/working-doc/service.js.map +1 -1
- package/dist/working-doc/store.d.ts +50 -1
- package/dist/working-doc/store.d.ts.map +1 -1
- package/dist/working-doc/store.js +4 -1
- package/dist/working-doc/store.js.map +1 -1
- package/endpoint-manifest.json +187 -3
- package/evals/corpora/shape-corrections-v1.json +594 -0
- package/evals/corpora/shape-corrections-v1.seat-fixture.json +186 -0
- package/evals/corpora/shape-v1.json +2113 -0
- package/evals/corpora/shape-v1.seat-fixture.json +1800 -0
- package/package.json +11 -7
- package/scripts/apps-render.py +226 -0
- package/workflows/detect-shape.json +29 -0
- package/dist/studio/assets/index-BRBwWQMH.css +0 -32
- package/dist/studio/assets/index-CVrWDGRP.js +0 -1097
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
import { CATALOG_V2_CARDS, CATALOG_V2_CATEGORIES } from './catalog-data-v2.js';
|
|
2
|
+
// ── the band table (frozen for 1.0, §9.3) ──────────────────────────────────────────────────────────────────────────
|
|
3
|
+
/** sure at 0.85 or more; ask below 0.50 (or when the seat returned an ask list); likely between. Frozen for 1.0: the
|
|
4
|
+
* release checks are judged on data it has not seen (the rig run and the audited sample). */
|
|
5
|
+
export const DETECT_BANDS = Object.freeze({ sure: 0.85, ask: 0.5 });
|
|
6
|
+
/** The band of a confidence (§2.3 `bandOf`). An ask list always asks. */
|
|
7
|
+
export function bandOf(confidence, ask) {
|
|
8
|
+
if (ask)
|
|
9
|
+
return 'ask';
|
|
10
|
+
if (!Number.isFinite(confidence))
|
|
11
|
+
return 'ask';
|
|
12
|
+
if (confidence >= DETECT_BANDS.sure)
|
|
13
|
+
return 'sure';
|
|
14
|
+
if (confidence < DETECT_BANDS.ask)
|
|
15
|
+
return 'ask';
|
|
16
|
+
return 'likely';
|
|
17
|
+
}
|
|
18
|
+
// ── the cards detection may name ───────────────────────────────────────────────────────────────────────────────────
|
|
19
|
+
/** A card detection may name: not hidden, not deferred or as-is (those are reached elsewhere, never by detection). */
|
|
20
|
+
export function detectable(c) {
|
|
21
|
+
return c.hidden !== true && (c.release === '1.0' || c.release === '1.1' || c.release === '1.2');
|
|
22
|
+
}
|
|
23
|
+
/** Coming: the card (or the option) is not launchable in this release. */
|
|
24
|
+
export function comingCard(c, option = null) {
|
|
25
|
+
return c.status === 'coming_soon' || option?.status === 'coming_soon' || (c.launch === undefined && c.variant === undefined);
|
|
26
|
+
}
|
|
27
|
+
/** An Investigate card (§3: depth is a brief line on these only; garden's catalog mode reads the digest's mark). */
|
|
28
|
+
export const isInvestigate = (c) => c.category === 'investigate' || c.depth === true;
|
|
29
|
+
const DETECTABLE = CATALOG_V2_CARDS.filter(detectable);
|
|
30
|
+
const byId = (id) => DETECTABLE.find((c) => c.id === id);
|
|
31
|
+
/** Whether a card's options run different plans (a wrong option there is a wrong plan, not a wrong brief line). */
|
|
32
|
+
export function planChangingAxis(c) {
|
|
33
|
+
const opts = c.variant?.options ?? [];
|
|
34
|
+
return new Set(opts.map((o) => JSON.stringify([o.launch ?? null, o.compose ?? null]))).size > 1;
|
|
35
|
+
}
|
|
36
|
+
/** Whether two options of one card run different plans. */
|
|
37
|
+
export function differentPlan(c, a, b) {
|
|
38
|
+
const opt = (id) => c.variant?.options.find((o) => o.id === (id ?? c.variant.default));
|
|
39
|
+
const plan = (o) => JSON.stringify([o?.launch ?? c.launch ?? null, o?.compose ?? null]);
|
|
40
|
+
return plan(opt(a)) !== plan(opt(b));
|
|
41
|
+
}
|
|
42
|
+
// ── the digest (§2.3 `catalogDigest`) ──────────────────────────────────────────────────────────────────────────────
|
|
43
|
+
/** The chat digest rides EVERY chat turn: it stays under this many bytes (a test pins it). */
|
|
44
|
+
export const CHAT_DIGEST_MAX_BYTES = 2048;
|
|
45
|
+
/** The classify digest (the one-shot `detect-shape` turn): outcomes, option one-liners and the coming cards. */
|
|
46
|
+
export const CLASSIFY_DIGEST_MAX_BYTES = 8192;
|
|
47
|
+
/**
|
|
48
|
+
* The catalog as a seat reads it. One generator, two sizes:
|
|
49
|
+
* - **chat** (≤ 2 KB): each available card's id and command, its options' ids, and `[depth]` on Investigate cards;
|
|
50
|
+
* coming cards by id only. The seat routes with these ids; crew resolves everything else.
|
|
51
|
+
* - **classify** (~6.5 KB): adds the title and outcome, each option's one-liner, and the coming cards with status.
|
|
52
|
+
*/
|
|
53
|
+
export function catalogDigest(mode, view = {}) {
|
|
54
|
+
const status = (c, o) => view.status?.(c.id, o?.id ?? null) ?? (comingCard(c, o) ? 'coming_soon' : 'available');
|
|
55
|
+
if (mode === 'chat') {
|
|
56
|
+
const live = [];
|
|
57
|
+
const coming = [];
|
|
58
|
+
for (const c of DETECTABLE) {
|
|
59
|
+
const st = status(c, null);
|
|
60
|
+
if (st === 'coming_soon') {
|
|
61
|
+
coming.push(c.id);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
// Only what this daemon can run is offered to the chat seat (the classify digest says why the rest is not): a card
|
|
65
|
+
// with options stays while ANY option is available, its default named only when it is one of them (codex r2).
|
|
66
|
+
const opts = (c.variant?.options ?? []).filter((o) => status(c, o) === 'available').map((o) => o.id);
|
|
67
|
+
if (c.variant === undefined ? st === 'unavailable' : opts.length === 0)
|
|
68
|
+
continue;
|
|
69
|
+
const dflt = c.variant !== undefined && opts.includes(c.variant.default) ? `; default ${c.variant.default}` : '';
|
|
70
|
+
live.push(`${c.id}${isInvestigate(c) ? ' [depth]' : ''}${opts.length > 0 ? ` (${opts.join('|')}${dflt})` : ''}`);
|
|
71
|
+
}
|
|
72
|
+
return [
|
|
73
|
+
'Job cards (id [depth: Investigate, takes quick|standard|deep] (options; default)):',
|
|
74
|
+
live.join('; '),
|
|
75
|
+
// No line when nothing is coming (CS8 shipped every coming card): an empty list is not a card to name.
|
|
76
|
+
...(coming.length > 0 ? [`Coming (name one only when it is the right shape): ${coming.join(', ')}.`] : []),
|
|
77
|
+
].join('\n');
|
|
78
|
+
}
|
|
79
|
+
const lines = ['CATALOG (card id [category] title: what you get; options are card:option; [depth] = an Investigate card):'];
|
|
80
|
+
const cat = new Map(CATALOG_V2_CATEGORIES.map((c) => [c.id, c.title]));
|
|
81
|
+
for (const c of DETECTABLE) {
|
|
82
|
+
const st = status(c, null);
|
|
83
|
+
lines.push(`- ${c.id} [${cat.get(c.category) ?? c.category}]${isInvestigate(c) ? ' [depth]' : ''} ${c.title}: ${c.outcome ?? ''}${st === 'coming_soon' ? ` (COMING in ${c.release})` : st === 'unavailable' ? ' (NOT ON THIS DAEMON)' : ''}`.trimEnd());
|
|
84
|
+
for (const o of c.variant?.options ?? []) {
|
|
85
|
+
const os = status(c, o);
|
|
86
|
+
lines.push(` - ${c.id}:${o.id}${o.id === c.variant.default ? ' (default)' : ''} ${o.title}: ${o.summary ?? ''}${os === 'coming_soon' ? ' (COMING)' : ''}`.trimEnd());
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return lines.join('\n');
|
|
90
|
+
}
|
|
91
|
+
// ── the words layer (§2.3 `wordsLayer`; studio `board/workflowCatalog.ts` `scoreEntry`, Enter mode) ───────────────
|
|
92
|
+
const STOP = new Set([
|
|
93
|
+
'a', 'an', 'the', 'and', 'or', 'of', 'for', 'to', 'in', 'on', 'at', 'by', 'with', 'from', 'into', 'about',
|
|
94
|
+
'my', 'our', 'your', 'me', 'we', 'i', 'it', 'its', 'this', 'that', 'these', 'those', 'is', 'are', 'was', 'were',
|
|
95
|
+
'be', 'do', 'does', 'did', 'can', 'could', 'should', 'would', 'please', 'want', 'need', 'some', 'new', 'x',
|
|
96
|
+
]);
|
|
97
|
+
/** Words people type for what a job does, said as the words the catalog uses (studio's lexicon, as is). */
|
|
98
|
+
const LEXICON = {
|
|
99
|
+
doc: ['documentation', 'docs', 'document'],
|
|
100
|
+
document: ['documentation', 'docs'],
|
|
101
|
+
documentation: ['docs', 'document'],
|
|
102
|
+
readme: ['documentation', 'docs'],
|
|
103
|
+
guide: ['documentation', 'walkthrough'],
|
|
104
|
+
write: ['author', 'documentation'],
|
|
105
|
+
explain: ['documentation', 'walkthrough', 'learn'],
|
|
106
|
+
learn: ['walkthrough', 'research'],
|
|
107
|
+
slide: ['presentation', 'deck'],
|
|
108
|
+
deck: ['presentation', 'slide'],
|
|
109
|
+
pitch: ['presentation'],
|
|
110
|
+
video: ['demo', 'recording'],
|
|
111
|
+
record: ['demo', 'video'],
|
|
112
|
+
screencast: ['demo', 'video'],
|
|
113
|
+
bug: ['issue', 'fix'],
|
|
114
|
+
issue: ['bug', 'fix'],
|
|
115
|
+
fix: ['issue', 'bug', 'resolve'],
|
|
116
|
+
broken: ['issue', 'bug', 'fail'],
|
|
117
|
+
break: ['issue', 'bug', 'fail'],
|
|
118
|
+
crash: ['issue', 'bug', 'fail'],
|
|
119
|
+
error: ['issue', 'bug', 'fail'],
|
|
120
|
+
fail: ['failure', 'review', 'issue'],
|
|
121
|
+
failure: ['fail', 'review'],
|
|
122
|
+
why: ['review', 'analyze'],
|
|
123
|
+
went: ['review'],
|
|
124
|
+
happen: ['review'],
|
|
125
|
+
run: ['runs', 'review'],
|
|
126
|
+
job: ['runs', 'review'],
|
|
127
|
+
upgrade: ['migrate', 'migration'],
|
|
128
|
+
migrate: ['migration', 'upgrade', 'port'],
|
|
129
|
+
port: ['migrate', 'migration'],
|
|
130
|
+
move: ['migrate', 'migration'],
|
|
131
|
+
test: ['tests', 'testing', 'qe'],
|
|
132
|
+
coverage: ['test', 'tests', 'analysis'],
|
|
133
|
+
plan: ['planning'],
|
|
134
|
+
automate: ['automation'],
|
|
135
|
+
domain: ['extraction', 'model'],
|
|
136
|
+
business: ['domain'],
|
|
137
|
+
plugin: ['plugins', 'extension'],
|
|
138
|
+
extension: ['plugin'],
|
|
139
|
+
editor: ['plugin'],
|
|
140
|
+
tool: ['mcp', 'tools'],
|
|
141
|
+
mcp: ['tool', 'server'],
|
|
142
|
+
build: ['feature', 'create'],
|
|
143
|
+
add: ['feature'],
|
|
144
|
+
feature: ['build'],
|
|
145
|
+
app: ['vibe', 'builder', 'dashboard'],
|
|
146
|
+
dashboard: ['vibe', 'app'],
|
|
147
|
+
validate: ['validation', 'check', 'verify'],
|
|
148
|
+
check: ['validate', 'review'],
|
|
149
|
+
verify: ['validate'],
|
|
150
|
+
review: ['analyze', 'check'],
|
|
151
|
+
};
|
|
152
|
+
/** Plain English stemming (studio's `stem`). */
|
|
153
|
+
export function stem(w) {
|
|
154
|
+
let s = w.toLowerCase();
|
|
155
|
+
if (s.length > 5 && s.endsWith('ing'))
|
|
156
|
+
s = s.slice(0, -3);
|
|
157
|
+
else if (s.length > 4 && s.endsWith('ed'))
|
|
158
|
+
s = s.slice(0, -2);
|
|
159
|
+
else if (s.length > 4 && s.endsWith('ies'))
|
|
160
|
+
s = `${s.slice(0, -3)}y`;
|
|
161
|
+
else if (s.length > 3 && s.endsWith('es') && /(ss|sh|ch|x)es$/u.test(s))
|
|
162
|
+
s = s.slice(0, -2);
|
|
163
|
+
else if (s.length > 3 && s.endsWith('s') && !s.endsWith('ss'))
|
|
164
|
+
s = s.slice(0, -1);
|
|
165
|
+
return s;
|
|
166
|
+
}
|
|
167
|
+
/** The content words of a text: lower case, split on anything not a letter or digit, stop words out, stemmed. */
|
|
168
|
+
export function tokens(text) {
|
|
169
|
+
return text.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter((t) => t !== '' && !STOP.has(t)).map(stem).filter((t) => t !== '' && !STOP.has(t));
|
|
170
|
+
}
|
|
171
|
+
const FIELD_WEIGHT = { title: 6, words: 4, gets: 2, other: 1 };
|
|
172
|
+
const EXPANSION_FACTOR = 0.5;
|
|
173
|
+
const own = (rec, k) => (Object.hasOwn(rec, k) ? rec[k] : undefined);
|
|
174
|
+
function scoreFields(fields, query) {
|
|
175
|
+
const qs = tokens(query);
|
|
176
|
+
if (qs.length === 0)
|
|
177
|
+
return 0;
|
|
178
|
+
let score = 0;
|
|
179
|
+
let matched = 0;
|
|
180
|
+
for (const q of qs) {
|
|
181
|
+
let direct = 0;
|
|
182
|
+
for (const f of fields)
|
|
183
|
+
if (f.t.has(q))
|
|
184
|
+
direct = Math.max(direct, f.w);
|
|
185
|
+
let expanded = 0;
|
|
186
|
+
for (const x of own(LEXICON, q) ?? []) {
|
|
187
|
+
const sx = stem(x);
|
|
188
|
+
for (const f of fields)
|
|
189
|
+
if (f.t.has(sx))
|
|
190
|
+
expanded = Math.max(expanded, f.w * EXPANSION_FACTOR);
|
|
191
|
+
}
|
|
192
|
+
const best = Math.max(direct, expanded);
|
|
193
|
+
if (best > 0)
|
|
194
|
+
matched += 1;
|
|
195
|
+
score += best;
|
|
196
|
+
}
|
|
197
|
+
return score * (0.5 + (0.5 * matched) / qs.length);
|
|
198
|
+
}
|
|
199
|
+
const CATEGORY_TITLE = new Map(CATALOG_V2_CATEGORIES.map((c) => [c.id, c.title]));
|
|
200
|
+
function cardFields(c) {
|
|
201
|
+
const optWords = (c.variant?.options ?? []).flatMap((o) => [...(o.words ?? []), o.title]);
|
|
202
|
+
return [
|
|
203
|
+
{ t: new Set([...tokens(c.title), ...tokens(c.id)]), w: FIELD_WEIGHT.title },
|
|
204
|
+
{ t: new Set([...(c.words ?? []), ...optWords].flatMap(tokens)), w: FIELD_WEIGHT.words },
|
|
205
|
+
{ t: new Set(tokens(c.outcome ?? '')), w: FIELD_WEIGHT.gets },
|
|
206
|
+
{ t: new Set([...tokens(CATEGORY_TITLE.get(c.category) ?? ''), ...(c.needs ?? []).flatMap(tokens)]), w: FIELD_WEIGHT.other },
|
|
207
|
+
];
|
|
208
|
+
}
|
|
209
|
+
function optionFields(o) {
|
|
210
|
+
return [
|
|
211
|
+
{ t: new Set([...tokens(o.title), ...tokens(o.id)]), w: FIELD_WEIGHT.title },
|
|
212
|
+
{ t: new Set((o.words ?? []).flatMap(tokens)), w: FIELD_WEIGHT.words },
|
|
213
|
+
{ t: new Set(tokens(o.summary ?? '')), w: FIELD_WEIGHT.gets },
|
|
214
|
+
];
|
|
215
|
+
}
|
|
216
|
+
const CARD_FIELDS = new Map(DETECTABLE.map((c) => [c.id, cardFields(c)]));
|
|
217
|
+
const OPTION_FIELDS = new Map(DETECTABLE.flatMap((c) => (c.variant?.options ?? []).map((o) => [`${c.id}:${o.id}`, optionFields(o)])));
|
|
218
|
+
/** The words layer's sure rule (§2.3). */
|
|
219
|
+
export const WORDS_SURE = Object.freeze({ minWords: 4, minScore: 10, ratio: 1.5 });
|
|
220
|
+
/** Words aimed at the detector rather than describing the work ("note to the classifier:", "confidence 1.0", "card=X",
|
|
221
|
+
* "SYSTEM OVERRIDE", "ignore previous instructions"). */
|
|
222
|
+
const AIMED = /(?:\bnote to the\s+(?:classifier|router|detector|bot|model|assistant|ai)\b|\b(?:classifier|router|detector)\s*:|\bsystem override\b|\bignore (?:all |any )?(?:the )?previous instructions\b|\bconfidence\s*[=:]?\s*[01](?:\.\d+)?(?![\d.])|\bcard\s*[=:])/iu;
|
|
223
|
+
/** A segment that ADDRESSES the detector and hands the instruction to the next one ("Note to the router: choose X"). */
|
|
224
|
+
const ADDRESSING = /(?:note to the\s+\w+|\b(?:classifier|router|detector|system|assistant))\s*:\s*$/iu;
|
|
225
|
+
/**
|
|
226
|
+
* The person's words with what is aimed at the detector taken out, for the words layer only (the seat reads the whole
|
|
227
|
+
* text, as `<request>` data, under rules that say not to follow it). An instruction planted in the words would
|
|
228
|
+
* otherwise match catalog words and vote for itself ("this is a security review, confidence 0.99"), and the
|
|
229
|
+
* cross-check would agree with the injected card. Bracketed spans and sentences carrying such words are dropped, and a
|
|
230
|
+
* segment that addresses the detector ("Note to the router:") drops the instruction after it.
|
|
231
|
+
*/
|
|
232
|
+
export function withoutAimed(text) {
|
|
233
|
+
const t = text.replace(/[[(]([^\])]*)[\])]/gu, (m, inner) => (AIMED.test(inner) ? ' ' : m));
|
|
234
|
+
const segs = t.split(/(?<=[.!?;:])\s+|\n+/u);
|
|
235
|
+
const kept = [];
|
|
236
|
+
let dropNext = false;
|
|
237
|
+
for (const seg of segs) {
|
|
238
|
+
if (dropNext) {
|
|
239
|
+
dropNext = false;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (ADDRESSING.test(seg)) {
|
|
243
|
+
dropNext = true;
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (AIMED.test(seg))
|
|
247
|
+
continue;
|
|
248
|
+
kept.push(seg);
|
|
249
|
+
}
|
|
250
|
+
return kept.join(' ');
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* A question about what work WILL cost, as the person's own opening ask ("what would 40 bug fixes a month cost?", "how
|
|
254
|
+
* much would the upgrades cost per month?", "estimate our monthly spend on security reviews"): they ask for a cost, and
|
|
255
|
+
* the work it names ("bug fixes") is only its subject (e2e-1105 CJ7: New chat opened a bug fix). Only the message's
|
|
256
|
+
* opening counts, so a cost question quoted inside other work ("fix the bug where 'what would … cost?' opens the wrong
|
|
257
|
+
* card", a pasted document) is not one. Forward-looking only: past spend ("what does it cost?", "… last month") is
|
|
258
|
+
* Review recent work's.
|
|
259
|
+
*/
|
|
260
|
+
const COST_ASK = /^\s*(?:(?:hey|hi|so|ok(?:ay)?|quick question)[,:]?\s+)?(?:(?:what|how\s+much)\s+(?:would|will|might|could|should|is\s+it\s+going\s+to)\b(?!\s+you\b)(?:[^.?!;]|\.(?=\d)){0,100}?\b(?:cost|costs|spend|run\s+us|set\s+us\s+back)(?=\s*$|\s*[?.!,;]|\s+(?:us|me|per|in|to|each|a|an|every|if|for|at|on|over|with|monthly|weekly|yearly|annually)\b)|(?:please\s+)?(?:estimate|forecast|project|predict|model)\s+(?:(?:our|the|my|a|monthly|weekly|quarterly|annual|yearly|total|likely|expected)\s+){0,2}(?:spend|spending|costs?|budget|bill)\b|budget\s+for\b)/iu;
|
|
261
|
+
/** Past spend: Review recent work reads what runs DID cost. */
|
|
262
|
+
const PAST_SPEND = /\b(?:last|past|previous)\s+\w+|\b(?:yesterday|ago|so far|to date|spent|has cost|have cost)\b/iu;
|
|
263
|
+
/** The price of new work ("how much would it cost to build the portal", "quote …"): Estimate and price answers it. */
|
|
264
|
+
const PRICE_OF_WORK = /\bcosts?\s+(?:us\s+)?to\s+(?:build|create|develop|implement|make|design|write|ship|deliver)\b|\b(?:price|pricing|quote|charge)\b/iu;
|
|
265
|
+
/** The cards that answer a cost question: the run cost model (the default answer), and the price of new work. */
|
|
266
|
+
export const COST_CARDS = ['run-cost', 'estimate-price'];
|
|
267
|
+
/** Whether the words open with a question about what work will cost (then a card that does not answer a cost is never
|
|
268
|
+
* the reading). */
|
|
269
|
+
export function costAsked(text) {
|
|
270
|
+
return COST_ASK.test(text) && !PAST_SPEND.test(text);
|
|
271
|
+
}
|
|
272
|
+
/** The cost card a cost question leads with: the price of new work, else the run cost model. */
|
|
273
|
+
export function costCardOf(text) {
|
|
274
|
+
return PRICE_OF_WORK.test(text) ? COST_CARDS[1] : COST_CARDS[0];
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* What the person asks to GET BACK, when their words say it outright: a plan, a review, an explanation, a write-up, an
|
|
278
|
+
* investigation, an estimate, a decision. The words layer ranks cards by the work's SUBJECT too ("Plan how to upgrade
|
|
279
|
+
* Node" scores the upgrade), so when the words ask for an outcome the top card does not deliver, they do not decide
|
|
280
|
+
* alone: the seat reads the outcome (classify's first rule).
|
|
281
|
+
*/
|
|
282
|
+
const OUTCOME_CUES = [
|
|
283
|
+
{ re: /\b(?:plan(?:ning)?|roadmap|break (?:it |this |the work )?down)\b/iu, cards: ['plan-it', 'plan-tests', 'backlog', 'release'] },
|
|
284
|
+
{ re: /\b(?:review|reviewing|audit|assess|critique|poke holes)\b/iu, cards: ['review-change', 'risk', 'security', 'review-recent-work', 'critique', 'retro', 'analyze-runs', 'evaluate-rules', 'release'] },
|
|
285
|
+
{ re: /\b(?:explain|walk me through|overview of|how does)\b/iu, cards: ['analyze-codebase', 'map-requirements', 'document', 'communicate'] },
|
|
286
|
+
{ re: /\b(?:document|documentation|write[- ]up|readme|deck|slides|presentation|release notes|changelog|announcement|status update)\b/iu, cards: ['document', 'communicate', 'interactive-page', 'operating-model', 'analyze-codebase'] },
|
|
287
|
+
{ re: /\b(?:root cause|investigate|what happened|why (?:is|did|does|do|are))\b/iu, cards: ['incident', 'reconstruct', 'research', 'bug'] },
|
|
288
|
+
{ re: /\b(?:estimate|how long will|how much will)\b/iu, cards: ['estimate-price', 'run-cost'] },
|
|
289
|
+
{ re: COST_ASK, cards: COST_CARDS },
|
|
290
|
+
{ re: /\b(?:should we|decide|choose between|which is better)\b/iu, cards: ['decide'] },
|
|
291
|
+
];
|
|
292
|
+
/**
|
|
293
|
+
* Work the words name only to rule it out or to refer to it ("do not modernize…", "leave the migration alone", "instead
|
|
294
|
+
* of a rewrite", "summarize the migration ticket"): the words then do not decide alone (codex r3).
|
|
295
|
+
*/
|
|
296
|
+
const WORK_VERB = String.raw `(?:moderniz|migrat|upgrad|mov|port|rewrit|refactor|build|implement|fix|releas|plan|review|test|chang|touch)\w*`;
|
|
297
|
+
const NEGATED_WORK = new RegExp(String.raw `\b(?:don'?t|do\s+not|never|no\s+longer|instead\s+of|avoid(?:ing)?|rather\s+than)\s+(?:\w+\s+){0,2}?${WORK_VERB}\b|\bleave\b[^.;]*\balone\b`, 'iu');
|
|
298
|
+
const REFERENCED_WORK = /\b(?:summari[sz]e|summary\s+of|recap|the\s+ticket|ticket\s+for)\b/iu;
|
|
299
|
+
/** Whether the words rule the work out ("do not modernize…", "leave the migration alone"). */
|
|
300
|
+
const straight = (t) => t.replace(/[\u2018\u2019]/gu, "'");
|
|
301
|
+
export function negatedWork(text) {
|
|
302
|
+
return NEGATED_WORK.test(straight(text));
|
|
303
|
+
}
|
|
304
|
+
/** Whether the words rule out or only refer to work (then they do not decide alone). */
|
|
305
|
+
export function negatedOrReferenced(text) {
|
|
306
|
+
return NEGATED_WORK.test(straight(text)) || REFERENCED_WORK.test(text);
|
|
307
|
+
}
|
|
308
|
+
/** An explicit writing request ("write the release notes for…", "draft a summary of…"): an unambiguous outcome. */
|
|
309
|
+
const WRITING_ASK = /\b(?:write|draft|prepare|put\s+together|compose)\s+(?:\w+\s+){0,2}?(?:release\s+notes|changelog|announcement|status\s+update|summary|write-?up|readme|docs?|documentation|deck|slides|presentation|memo|email|message)\b/iu;
|
|
310
|
+
const WRITING_CARDS = new Set(['document', 'communicate', 'interactive-page', 'operating-model', 'release', 'analyze-codebase']);
|
|
311
|
+
/** Whether the words explicitly ask to WRITE something the card does not make (a seat's sure is then held; codex r7). */
|
|
312
|
+
export function writingAskedOf(text, card) {
|
|
313
|
+
return WRITING_ASK.test(text) && !WRITING_CARDS.has(card);
|
|
314
|
+
}
|
|
315
|
+
/** Whether the words ask for an outcome the card does not deliver (then they do not decide alone). */
|
|
316
|
+
export function outcomeConflict(text, card) {
|
|
317
|
+
// Every outcome the words ask for must be one the card delivers, for the words to decide alone: "Plan a security
|
|
318
|
+
// review" is a plan of a review, and the review card does not decide it (codex r2). The seat then reads it.
|
|
319
|
+
return OUTCOME_CUES.some((c) => c.re.test(text) && !c.cards.includes(card));
|
|
320
|
+
}
|
|
321
|
+
/** An Investigate card's depth when the words say it ("a quick look", "deep dive"); `null` = they do not. */
|
|
322
|
+
export function depthFromWords(text) {
|
|
323
|
+
if (/\b(?:deep(?:ly)?|deep[- ]dive|thorough(?:ly)?|exhaustive|in[- ]depth|full timeline|every (?:cause|release|step))\b/iu.test(text))
|
|
324
|
+
return 'deep';
|
|
325
|
+
if (/\b(?:quick(?:ly)?|brief(?:ly)?|fast look|just a look|short look|skim)\b/iu.test(text))
|
|
326
|
+
return 'quick';
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
/** Rank every detectable card for `text` and say whether the words alone decide (§2.3 `wordsLayer`). */
|
|
330
|
+
export function wordsLayer(raw) {
|
|
331
|
+
const text = withoutAimed(raw);
|
|
332
|
+
const words = tokens(text).length;
|
|
333
|
+
const ranked = DETECTABLE.map((c) => ({ card: c.id, score: scoreFields(CARD_FIELDS.get(c.id), text) }))
|
|
334
|
+
.filter((x) => x.score > 0)
|
|
335
|
+
.sort((a, b) => b.score - a.score || DETECTABLE.findIndex((c) => c.id === a.card) - DETECTABLE.findIndex((c) => c.id === b.card));
|
|
336
|
+
const top = ranked[0]?.score ?? 0;
|
|
337
|
+
const runnerUp = ranked[1]?.score ?? 0;
|
|
338
|
+
const card = ranked[0]?.card ?? null;
|
|
339
|
+
const seed = card === null ? undefined : byId(card);
|
|
340
|
+
let option = null;
|
|
341
|
+
let optionDecided = true;
|
|
342
|
+
if (seed?.variant !== undefined) {
|
|
343
|
+
const os = seed.variant.options
|
|
344
|
+
.map((o) => ({ id: o.id, score: scoreFields(OPTION_FIELDS.get(`${seed.id}:${o.id}`), text) }))
|
|
345
|
+
.sort((a, b) => b.score - a.score);
|
|
346
|
+
if (os[0].score > 0) {
|
|
347
|
+
option = os[0].id;
|
|
348
|
+
optionDecided = os.length === 1 || os[0].score >= WORDS_SURE.ratio * Math.max(os[1].score, 0.01);
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
option = seed.variant.default;
|
|
352
|
+
optionDecided = false;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const sure = seed !== undefined
|
|
356
|
+
&& !outcomeConflict(text, seed.id)
|
|
357
|
+
&& !negatedOrReferenced(text)
|
|
358
|
+
&& !writingAskedOf(text, seed.id)
|
|
359
|
+
&& words >= WORDS_SURE.minWords
|
|
360
|
+
&& top >= WORDS_SURE.minScore
|
|
361
|
+
&& top >= WORDS_SURE.ratio * Math.max(runnerUp, 0.01)
|
|
362
|
+
// Scoring is exact on every option (§9.2), so the words decide a card with options alone only when they also
|
|
363
|
+
// decided its option (a framing option the words did not choose is the seat's to read, not the default's).
|
|
364
|
+
&& (seed.variant === undefined || optionDecided);
|
|
365
|
+
return { ranked, card, option, optionDecided, sure, words, top, runnerUp };
|
|
366
|
+
}
|
|
367
|
+
/** One plain line, at most 140 characters: no markdown, no newline, no control characters. */
|
|
368
|
+
export function plainReason(raw) {
|
|
369
|
+
if (typeof raw !== 'string')
|
|
370
|
+
return '';
|
|
371
|
+
const flat = raw
|
|
372
|
+
.replace(/[\u0000-\u001f\u007f\u2028\u2029]+/gu, ' ')
|
|
373
|
+
.replace(/[`*_#>[\]<]+/gu, '')
|
|
374
|
+
.replace(/\s+/gu, ' ')
|
|
375
|
+
.trim();
|
|
376
|
+
return flat.length <= 140 ? flat : `${flat.slice(0, 139).trimEnd()}…`;
|
|
377
|
+
}
|
|
378
|
+
const DEPTHS = new Set(['quick', 'standard', 'deep']);
|
|
379
|
+
/** A card and option as a seat may spell them: `card`, `card:option`, or an option written `card:option` beside its card. */
|
|
380
|
+
function readShape(card, option) {
|
|
381
|
+
if (typeof card !== 'string' || card.trim() === '')
|
|
382
|
+
return null;
|
|
383
|
+
let c = card.trim();
|
|
384
|
+
let o = option === null || option === undefined || option === 'null' || option === '' ? undefined : typeof option === 'string' ? option.trim() : undefined;
|
|
385
|
+
if (option !== null && option !== undefined && typeof option !== 'string')
|
|
386
|
+
return null;
|
|
387
|
+
if (c.includes(':')) {
|
|
388
|
+
const [head, tail] = c.split(':', 2);
|
|
389
|
+
c = head;
|
|
390
|
+
if (o === undefined)
|
|
391
|
+
o = tail;
|
|
392
|
+
}
|
|
393
|
+
if (o !== undefined && o !== null && o.includes(':')) {
|
|
394
|
+
const [head, tail] = o.split(':', 2);
|
|
395
|
+
if (head !== c)
|
|
396
|
+
return null;
|
|
397
|
+
o = tail;
|
|
398
|
+
}
|
|
399
|
+
return { card: c, option: o };
|
|
400
|
+
}
|
|
401
|
+
/** The shape a card and option resolve to, or why not: an unknown card, a hidden or deferred one, an unknown option. */
|
|
402
|
+
function shapeOf(card, option) {
|
|
403
|
+
const seed = byId(card);
|
|
404
|
+
if (seed === undefined)
|
|
405
|
+
return card === 'triage' ? 'the seat could not tell (triage)' : `no card “${card.slice(0, 60)}”`;
|
|
406
|
+
if (seed.variant === undefined) {
|
|
407
|
+
if (option !== undefined && option !== null)
|
|
408
|
+
return `${seed.title} has no option “${option.slice(0, 60)}”`;
|
|
409
|
+
return { card: seed.id, option: null };
|
|
410
|
+
}
|
|
411
|
+
if (option === undefined || option === null)
|
|
412
|
+
return { card: seed.id, option: seed.variant.default };
|
|
413
|
+
if (!seed.variant.options.some((o) => o.id === option))
|
|
414
|
+
return `${seed.title} has no option “${option.slice(0, 60)}”`;
|
|
415
|
+
return { card: seed.id, option };
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Validate a seat's reading against the catalog (§2.3): an unknown card or option, or an option of another card, is
|
|
419
|
+
* dropped and the guess becomes an ask; confidence is clamped to [0, 1]; the reason is one plain line. A coming card
|
|
420
|
+
* stays named (the proposal offers its nearest). Never throws.
|
|
421
|
+
*/
|
|
422
|
+
export function validateGuess(raw) {
|
|
423
|
+
const r = raw !== null && typeof raw === 'object' ? raw : {};
|
|
424
|
+
const confRaw = typeof r.confidence === 'number' ? r.confidence : typeof r.confidence === 'string' ? Number(r.confidence) : Number.NaN;
|
|
425
|
+
const confidence = Number.isFinite(confRaw) ? Math.min(1, Math.max(0, confRaw)) : 0;
|
|
426
|
+
const reason = plainReason(r.reason);
|
|
427
|
+
const ask = [];
|
|
428
|
+
if (Array.isArray(r.ask)) {
|
|
429
|
+
for (const a of r.ask.slice(0, 6)) {
|
|
430
|
+
const read = readShape(a, undefined);
|
|
431
|
+
if (read === null)
|
|
432
|
+
continue;
|
|
433
|
+
// An ask names a card ("bug") or a card's option ("suite-health:flaky"); a bare card with options takes its default.
|
|
434
|
+
const s = shapeOf(read.card, read.option);
|
|
435
|
+
if (typeof s === 'string')
|
|
436
|
+
continue;
|
|
437
|
+
if (!ask.some((x) => x.card === s.card && x.option === s.option))
|
|
438
|
+
ask.push(s);
|
|
439
|
+
if (ask.length === 3)
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
const read = readShape(r.card ?? r.entry, r.option);
|
|
444
|
+
const shape = read === null ? 'no card named' : shapeOf(read.card, read.option);
|
|
445
|
+
if (typeof shape === 'string') {
|
|
446
|
+
return { card: null, option: null, depth: null, confidence: 0, ask, reason, dropped: shape };
|
|
447
|
+
}
|
|
448
|
+
const seed = byId(shape.card);
|
|
449
|
+
const depth = isInvestigate(seed) && typeof r.depth === 'string' && DEPTHS.has(r.depth) ? r.depth : null;
|
|
450
|
+
return { card: shape.card, option: shape.option, depth, confidence, ask: ask.length >= 2 ? ask : [], reason, dropped: null };
|
|
451
|
+
}
|
|
452
|
+
// ── the cross-check (§2.3 `crossCheck`) ────────────────────────────────────────────────────────────────────────────
|
|
453
|
+
/**
|
|
454
|
+
* A card the words count as a strong candidate: it matches at least this fraction of the words' top score. Chosen on the
|
|
455
|
+
* corpus like the bands (§9.3): at 0.4 the recorded seat is held as likely on 8 % of clear cases with 0 wrong at sure,
|
|
456
|
+
* and a hostile seat naming a wrong card at 1.0 reaches sure on under 5 % (at 0.5, 11 % held; with no check on weak
|
|
457
|
+
* words, as spike 2 measured it, a hostile seat was sure-and-wrong on 59 %).
|
|
458
|
+
*/
|
|
459
|
+
export const WORDS_AGREE_FRACTION = 0.4;
|
|
460
|
+
/** Whether the words layer agrees on a card: it ranks it at {@link WORDS_AGREE_FRACTION} of its top score or more. */
|
|
461
|
+
export function wordsAgree(words, card) {
|
|
462
|
+
const hit = words.ranked.find((r) => r.card === card);
|
|
463
|
+
return hit !== undefined && words.top > 0 && hit.score >= WORDS_AGREE_FRACTION * words.top;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* A seat's band, checked against the words layer (§2.3, §9.2 (i)).
|
|
467
|
+
*
|
|
468
|
+
* - **The `detect-shape` turn** (`classify`): a seat's **sure** stands only when the words layer agrees on the card: it
|
|
469
|
+
* ranks the seat's card as a strong candidate ({@link wordsAgree}: at least 0.4 of its top score). Words that match no
|
|
470
|
+
* card agree with nothing, so a seat cannot be sure on words the catalog does not recognise. And when the words
|
|
471
|
+
* decided an option of that card that runs a different plan, the seat's option must be it. (See
|
|
472
|
+
* {@link WORDS_AGREE_FRACTION} for what it holds on the corpus.)
|
|
473
|
+
* - **The chat door** (`chat`): the seat's self-reported confidence is capped at **likely** unless the words layer's
|
|
474
|
+
* top card AND option are the seat's, because a chat seat reads a whole conversation the person did not write alone.
|
|
475
|
+
*
|
|
476
|
+
* This sets how the card is first shown; it is not the safety boundary (nothing launches without Start, and a
|
|
477
|
+
* chat-launched repository job is held at its plan).
|
|
478
|
+
*/
|
|
479
|
+
export function crossCheck(guess, words) {
|
|
480
|
+
if (guess.band !== 'sure')
|
|
481
|
+
return guess.band;
|
|
482
|
+
const seed = byId(guess.card);
|
|
483
|
+
if (seed === undefined)
|
|
484
|
+
return 'likely';
|
|
485
|
+
if (guess.source === 'chat') {
|
|
486
|
+
return words.card === guess.card && words.option === guess.option ? 'sure' : 'likely';
|
|
487
|
+
}
|
|
488
|
+
if (!wordsAgree(words, guess.card))
|
|
489
|
+
return 'likely';
|
|
490
|
+
if (words.card === guess.card && words.optionDecided && seed.variant !== undefined && words.option !== guess.option && differentPlan(seed, words.option, guess.option))
|
|
491
|
+
return 'likely';
|
|
492
|
+
return 'sure';
|
|
493
|
+
}
|
|
494
|
+
// ── one detection ──────────────────────────────────────────────────────────────────────────────────────────────────
|
|
495
|
+
/** How a card and option are named to the person in a question. */
|
|
496
|
+
export function shapeLabel(card, option) {
|
|
497
|
+
const seed = CATALOG_V2_CARDS.find((c) => c.id === card);
|
|
498
|
+
if (seed === undefined)
|
|
499
|
+
return card;
|
|
500
|
+
const o = seed.variant?.options.find((x) => x.id === option);
|
|
501
|
+
return o !== undefined ? `${seed.title} · ${o.title}` : seed.title;
|
|
502
|
+
}
|
|
503
|
+
function questionOf(choices) {
|
|
504
|
+
const uniq = [];
|
|
505
|
+
for (const c of choices)
|
|
506
|
+
if (!uniq.some((u) => u.card === c.card && u.option === c.option))
|
|
507
|
+
uniq.push(c);
|
|
508
|
+
const list = uniq.slice(0, 3).map((c) => ({ label: shapeLabel(c.card, c.option), card: c.card, option: c.option }));
|
|
509
|
+
if (list.length === 0)
|
|
510
|
+
return { text: 'What should this job do? Pick one with /, or say it in other words.', choices: [] };
|
|
511
|
+
const names = list.map((c) => c.label);
|
|
512
|
+
const joined = names.length === 1 ? names[0] : `${names.slice(0, -1).join(', ')} or ${names[names.length - 1]}`;
|
|
513
|
+
return { text: `Which job is this: ${joined}?`, choices: list };
|
|
514
|
+
}
|
|
515
|
+
/** The words layer's best candidates as ask choices (distinct cards, their word-picked option). */
|
|
516
|
+
function wordsChoices(words) {
|
|
517
|
+
return words.ranked.slice(0, 3).map((x) => {
|
|
518
|
+
if (x.card === words.card)
|
|
519
|
+
return { card: x.card, option: words.option };
|
|
520
|
+
const seed = byId(x.card);
|
|
521
|
+
return { card: x.card, option: seed.variant?.default ?? null };
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* One detection (§2.3): the words layer first, alone when it is sure; else the seat's reading, validated, banded and
|
|
526
|
+
* cross-checked. With no seat reading, the words' top card is at most likely (a timed-out turn is never sure), and
|
|
527
|
+
* words that match nothing clearly ask.
|
|
528
|
+
*/
|
|
529
|
+
export function detect(input) {
|
|
530
|
+
const words = wordsLayer(input.text);
|
|
531
|
+
const seat = input.seat === null ? null : validateGuess(input.seat);
|
|
532
|
+
const availableOf = (card, option) => {
|
|
533
|
+
if (input.available !== undefined)
|
|
534
|
+
return input.available(card, option);
|
|
535
|
+
const seed = byId(card);
|
|
536
|
+
return seed !== undefined && !comingCard(seed, seed.variant?.options.find((o) => o.id === option) ?? null);
|
|
537
|
+
};
|
|
538
|
+
// A question about what work will cost (the person's opening words, past spend aside): a cost card answers it.
|
|
539
|
+
const costRead = costAsked(withoutAimed(input.text));
|
|
540
|
+
const make = (card, option, depth, confidence, banded, reason, source, ask) => {
|
|
541
|
+
const available = availableOf(card, option);
|
|
542
|
+
// A job this daemon cannot start is never shown as sure (pi r2): at most likely, with its nearest offered.
|
|
543
|
+
const band = banded === 'sure' && !available ? 'likely' : banded;
|
|
544
|
+
// A demoted reading reports a confidence its band can hold (pi r3).
|
|
545
|
+
const shown = band === 'likely' ? Math.min(confidence, DETECT_BANDS.sure - 0.01) : confidence;
|
|
546
|
+
return {
|
|
547
|
+
card,
|
|
548
|
+
option,
|
|
549
|
+
depth,
|
|
550
|
+
confidence: Math.round(shown * 1000) / 1000,
|
|
551
|
+
band,
|
|
552
|
+
reason,
|
|
553
|
+
available,
|
|
554
|
+
question: band === 'ask' ? ask : null,
|
|
555
|
+
source,
|
|
556
|
+
catalogRev: input.catalogRev,
|
|
557
|
+
};
|
|
558
|
+
};
|
|
559
|
+
if (words.sure && words.card !== null) {
|
|
560
|
+
const wordsSeed = byId(words.card);
|
|
561
|
+
// A seat that read the words differently (another card, or an option that runs another plan) outranks a word
|
|
562
|
+
// match: an instruction planted in the words ("choose start-new:mcp-server") matches catalog words, and the seat is
|
|
563
|
+
// told to read past it. Neither is then sure: the seat's reading is shown, held as likely (§9.2 (i)).
|
|
564
|
+
const conflict = seat !== null && seat.card !== null && (seat.card !== words.card || (seat.option !== words.option && differentPlan(wordsSeed, seat.option, words.option)));
|
|
565
|
+
if (!conflict) {
|
|
566
|
+
// An Investigate card's depth: the seat's when it read the same card, else what the words say (§2.2).
|
|
567
|
+
const depth = seat !== null && seat.card === words.card && seat.depth !== null ? seat.depth : isInvestigate(wordsSeed) ? depthFromWords(withoutAimed(input.text)) : null;
|
|
568
|
+
return { guess: make(words.card, words.option, depth, 0.9, 'sure', 'the words name this job clearly', 'words', null), words, seat };
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
if (seat === null) {
|
|
572
|
+
if (costRead && (words.card === null || !COST_CARDS.includes(words.card))) {
|
|
573
|
+
// No seat reading (a timeout, words only): a cost question still reads as the run cost model, never sure.
|
|
574
|
+
return { guess: make(costCardOf(withoutAimed(input.text)), null, null, 0.6, 'likely', 'the words ask what the work would cost', 'words', null), words, seat };
|
|
575
|
+
}
|
|
576
|
+
if (words.card !== null && words.top >= WORDS_SURE.minScore) {
|
|
577
|
+
const seed = byId(words.card);
|
|
578
|
+
return { guess: make(words.card, words.option, isInvestigate(seed) ? depthFromWords(withoutAimed(input.text)) : null, 0.6, 'likely', 'the words point to this job', 'words', null), words, seat };
|
|
579
|
+
}
|
|
580
|
+
const choices = wordsChoices(words);
|
|
581
|
+
return { guess: make(choices[0]?.card ?? 'plan-it', choices[0]?.option ?? null, null, 0, 'ask', 'the words alone do not say which job', 'words', questionOf(choices)), words, seat };
|
|
582
|
+
}
|
|
583
|
+
if (seat.card === null) {
|
|
584
|
+
// Nothing valid named: the seat's own ask list if it gave one, else the words' best candidates.
|
|
585
|
+
const choices = seat.ask.length > 0 ? seat.ask : wordsChoices(words);
|
|
586
|
+
const first = choices[0];
|
|
587
|
+
return {
|
|
588
|
+
guess: make(first?.card ?? 'plan-it', first?.option ?? null, null, 0, 'ask', seat.reason !== '' ? seat.reason : 'not sure which job this is', input.source, questionOf(choices)),
|
|
589
|
+
words,
|
|
590
|
+
seat,
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
if (costRead && !COST_CARDS.includes(seat.card) && seat.ask.length === 0 && bandOf(seat.confidence, false) !== 'ask') {
|
|
594
|
+
// The words open with a question about what work will cost and the seat read the work they name instead ("what
|
|
595
|
+
// would 40 bug fixes a month cost?" read as a bug fix; e2e-1105 CJ7): the run cost model is the reading, never
|
|
596
|
+
// sure (the seat disagreed). A seat that asked, or was unsure, still asks.
|
|
597
|
+
return { guess: make(costCardOf(withoutAimed(input.text)), null, null, 0.6, 'likely', 'the words ask what the work would cost', input.source, null), words, seat };
|
|
598
|
+
}
|
|
599
|
+
const banded = bandOf(seat.confidence, seat.ask.length > 0);
|
|
600
|
+
const checked = crossCheck({ card: seat.card, option: seat.option, band: banded, source: input.source }, words);
|
|
601
|
+
// A seat sure of work the words rule out ("do not fix…", "leave … alone") is held as likely (codex r3). The outcome
|
|
602
|
+
// cues are NOT applied to a seat's reading: which of nested outcomes is asked is the seat's to read (classify's first
|
|
603
|
+
// rule), and outcome words double as subjects ("our code review conventions", "repo-audit", "should we test"): on the
|
|
604
|
+
// corpus the veto held 6 more right answers as likely and prevented no wrong sure.
|
|
605
|
+
const cleaned = withoutAimed(input.text);
|
|
606
|
+
const band = checked === 'sure' && (negatedWork(cleaned) || writingAskedOf(cleaned, seat.card)) ? 'likely' : checked;
|
|
607
|
+
const choices = seat.ask.length > 0 ? seat.ask : [{ card: seat.card, option: seat.option }, ...wordsChoices(words)];
|
|
608
|
+
return { guess: make(seat.card, seat.option, seat.depth, seat.confidence, band, seat.reason, input.source, questionOf(choices)), words, seat };
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* The `detect-shape` path's orchestration (§2.3), shared by the service and the corpus scorer so CI scores what ships:
|
|
612
|
+
* the words alone when they are sure (no seat is asked), else the seat's reading. `seat` is asked only then.
|
|
613
|
+
*/
|
|
614
|
+
export async function classifyPath(input, seat) {
|
|
615
|
+
const words = detect({ ...input, seat: null, source: 'classify' });
|
|
616
|
+
if (words.guess.band === 'sure')
|
|
617
|
+
return { ...words, asked: false };
|
|
618
|
+
return { ...detect({ ...input, seat: await seat(), source: 'classify' }), asked: true };
|
|
619
|
+
}
|
|
620
|
+
/** {@link classifyPath} with a seat answer already in hand (the corpus fixture): synchronous, the same decisions. */
|
|
621
|
+
export function classifyPathSync(input, seat) {
|
|
622
|
+
const words = detect({ ...input, seat: null, source: 'classify' });
|
|
623
|
+
if (words.guess.band === 'sure')
|
|
624
|
+
return { ...words, asked: false };
|
|
625
|
+
return { ...detect({ ...input, seat, source: 'classify' }), asked: true };
|
|
626
|
+
}
|
|
627
|
+
// ── parsing a seat's answer ────────────────────────────────────────────────────────────────────────────────────────
|
|
628
|
+
/** The LAST one-line JSON object in a seat's answer that names a card (classify's catalog-mode output), or `null`. */
|
|
629
|
+
export function parseClassifyAnswer(answer) {
|
|
630
|
+
const lines = answer.split(/\r?\n/u).map((l) => l.trim()).filter((l) => l.startsWith('{') && l.endsWith('}'));
|
|
631
|
+
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
632
|
+
try {
|
|
633
|
+
const o = JSON.parse(lines[i]);
|
|
634
|
+
if (o !== null && typeof o === 'object' && !Array.isArray(o) && ('card' in o || 'entry' in o))
|
|
635
|
+
return o;
|
|
636
|
+
}
|
|
637
|
+
catch {
|
|
638
|
+
// not this line
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
// A fenced or inline object on one line with prose around it.
|
|
642
|
+
const m = /\{[^{}\n]*"(?:card|entry)"\s*:[^{}\n]*\}/u.exec(answer);
|
|
643
|
+
if (m !== null) {
|
|
644
|
+
try {
|
|
645
|
+
return JSON.parse(m[0]);
|
|
646
|
+
}
|
|
647
|
+
catch {
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return null;
|
|
652
|
+
}
|
|
653
|
+
//# sourceMappingURL=detect.js.map
|