@shepai/cli 1.180.0 → 1.181.0-pr539.0993dc0
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/apis/json-schema/CavemanModeConfig.yaml +14 -0
- package/apis/json-schema/PhaseTiming.yaml +30 -0
- package/apis/json-schema/SubprocessFilterConfig.yaml +11 -0
- package/apis/json-schema/TokenOptimizationConfig.yaml +36 -0
- package/apis/json-schema/WorkflowConfig.yaml +9 -0
- package/dist/packages/core/src/application/ports/output/agents/agent-executor.interface.d.ts +8 -0
- package/dist/packages/core/src/application/ports/output/agents/agent-executor.interface.d.ts.map +1 -1
- package/dist/packages/core/src/application/ports/output/agents/phase-timing-repository.interface.d.ts +8 -1
- package/dist/packages/core/src/application/ports/output/agents/phase-timing-repository.interface.d.ts.map +1 -1
- package/dist/packages/core/src/application/ports/output/index.d.ts +1 -1
- package/dist/packages/core/src/application/ports/output/index.d.ts.map +1 -1
- package/dist/packages/core/src/application/ports/output/services/alias-compression.interface.d.ts +45 -0
- package/dist/packages/core/src/application/ports/output/services/alias-compression.interface.d.ts.map +1 -0
- package/dist/packages/core/src/application/ports/output/services/alias-compression.interface.js +13 -0
- package/dist/packages/core/src/application/ports/output/services/command-output-filter.interface.d.ts +50 -0
- package/dist/packages/core/src/application/ports/output/services/command-output-filter.interface.d.ts.map +1 -0
- package/dist/packages/core/src/application/ports/output/services/command-output-filter.interface.js +13 -0
- package/dist/packages/core/src/application/ports/output/services/delta-context.interface.d.ts +57 -0
- package/dist/packages/core/src/application/ports/output/services/delta-context.interface.d.ts.map +1 -0
- package/dist/packages/core/src/application/ports/output/services/delta-context.interface.js +13 -0
- package/dist/packages/core/src/application/ports/output/services/index.d.ts +7 -0
- package/dist/packages/core/src/application/ports/output/services/index.d.ts.map +1 -1
- package/dist/packages/core/src/application/ports/output/services/optimization-metrics.interface.d.ts +45 -0
- package/dist/packages/core/src/application/ports/output/services/optimization-metrics.interface.d.ts.map +1 -0
- package/dist/packages/core/src/application/ports/output/services/optimization-metrics.interface.js +13 -0
- package/dist/packages/core/src/application/ports/output/services/prompt-optimizer.interface.d.ts +86 -0
- package/dist/packages/core/src/application/ports/output/services/prompt-optimizer.interface.d.ts.map +1 -0
- package/dist/packages/core/src/application/ports/output/services/prompt-optimizer.interface.js +13 -0
- package/dist/packages/core/src/application/ports/output/services/semantic-compressor.interface.d.ts +43 -0
- package/dist/packages/core/src/application/ports/output/services/semantic-compressor.interface.d.ts.map +1 -0
- package/dist/packages/core/src/application/ports/output/services/semantic-compressor.interface.js +13 -0
- package/dist/packages/core/src/application/ports/output/services/skill-routing.interface.d.ts +41 -0
- package/dist/packages/core/src/application/ports/output/services/skill-routing.interface.d.ts.map +1 -0
- package/dist/packages/core/src/application/ports/output/services/skill-routing.interface.js +12 -0
- package/dist/packages/core/src/domain/factories/settings-defaults.factory.d.ts.map +1 -1
- package/dist/packages/core/src/domain/factories/settings-defaults.factory.js +21 -0
- package/dist/packages/core/src/domain/generated/output.d.ts +95 -0
- package/dist/packages/core/src/domain/generated/output.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/di/container.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/di/container.js +27 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/mappers/settings.mapper.d.ts +9 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/mappers/settings.mapper.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/persistence/sqlite/mappers/settings.mapper.js +68 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/055-add-token-optimization-config.d.ts +29 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/055-add-token-optimization-config.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/055-add-token-optimization-config.js +77 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/056-add-caveman-mode-config.d.ts +21 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/056-add-caveman-mode-config.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/056-add-caveman-mode-config.js +29 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/057-add-subprocess-filter-config.d.ts +17 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/057-add-subprocess-filter-config.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/057-add-subprocess-filter-config.js +22 -0
- package/dist/packages/core/src/infrastructure/repositories/sqlite-phase-timing.repository.d.ts +2 -1
- package/dist/packages/core/src/infrastructure/repositories/sqlite-phase-timing.repository.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/repositories/sqlite-phase-timing.repository.js +72 -0
- package/dist/packages/core/src/infrastructure/repositories/sqlite-settings.repository.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/repositories/sqlite-settings.repository.js +19 -3
- package/dist/packages/core/src/infrastructure/services/agents/analyze-repo/analyze-repository-graph.d.ts +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/common/executors/claude-code-executor.service.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/common/executors/claude-code-executor.service.js +9 -0
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/caveman-directive.d.ts +41 -0
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/caveman-directive.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/caveman-directive.js +51 -0
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/fast-feature-agent-graph.d.ts +6 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/fast-feature-agent-graph.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/feature-agent-graph.d.ts +18 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/feature-agent-graph.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/feature-agent-worker.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/feature-agent-worker.js +6 -0
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/evidence.node.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/evidence.node.js +2 -2
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/fast-implement.node.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/fast-implement.node.js +3 -2
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/implement.node.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/implement.node.js +5 -4
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/merge/merge.node.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/merge/merge.node.js +3 -4
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/node-helpers.d.ts +27 -0
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/node-helpers.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/node-helpers.js +71 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/prompt-optimization-context.d.ts +42 -0
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/prompt-optimization-context.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/prompt-optimization-context.js +92 -0
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/state.d.ts +1 -0
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/state.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/state.js +5 -0
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/subprocess-filter-context.d.ts +25 -0
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/subprocess-filter-context.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/subprocess-filter-context.js +67 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/generic-filter.d.ts +13 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/generic-filter.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/generic-filter.js +21 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/git-filter.d.ts +15 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/git-filter.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/git-filter.js +189 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/npm-filter.d.ts +13 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/npm-filter.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/npm-filter.js +96 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/shared-helpers.d.ts +29 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/shared-helpers.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/shared-helpers.js +85 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/shep-filter.d.ts +27 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/shep-filter.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/shep-filter.js +89 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/shim-generator.d.ts +39 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/shim-generator.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/subprocess-filter/shim-generator.js +53 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/alias-compression.service.d.ts +41 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/alias-compression.service.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/alias-compression.service.js +111 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/command-output-filter.service.d.ts +22 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/command-output-filter.service.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/command-output-filter.service.js +245 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/delta-context.service.d.ts +22 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/delta-context.service.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/delta-context.service.js +50 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/optimization-metrics.service.d.ts +36 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/optimization-metrics.service.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/optimization-metrics.service.js +123 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/prompt-optimizer.service.d.ts +57 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/prompt-optimizer.service.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/prompt-optimizer.service.js +241 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/semantic-compressor.service.d.ts +34 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/semantic-compressor.service.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/semantic-compressor.service.js +190 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/skill-routing.service.d.ts +26 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/skill-routing.service.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/token-optimization/skill-routing.service.js +51 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/web/.next/BUILD_ID +1 -1
- package/web/.next/build-manifest.json +2 -2
- package/web/.next/fallback-build-manifest.json +2 -2
- package/web/.next/prerender-manifest.json +3 -3
- package/web/.next/required-server-files.js +3 -3
- package/web/.next/required-server-files.json +3 -3
- package/web/.next/server/app/(dashboard)/@drawer/adopt/page/server-reference-manifest.json +32 -32
- package/web/.next/server/app/(dashboard)/@drawer/adopt/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/adopt/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/chat/page/server-reference-manifest.json +30 -30
- package/web/.next/server/app/(dashboard)/@drawer/chat/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/chat/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/create/page/server-reference-manifest.json +33 -33
- package/web/.next/server/app/(dashboard)/@drawer/create/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/create/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page/server-reference-manifest.json +41 -41
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page/server-reference-manifest.json +41 -41
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/[tab]/page/server-reference-manifest.json +31 -31
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/[tab]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/[tab]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page/server-reference-manifest.json +31 -31
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/chat/page/server-reference-manifest.json +30 -30
- package/web/.next/server/app/(dashboard)/chat/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/chat/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/create/page/server-reference-manifest.json +33 -33
- package/web/.next/server/app/(dashboard)/create/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/create/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page/server-reference-manifest.json +41 -41
- package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/feature/[featureId]/page/server-reference-manifest.json +41 -41
- package/web/.next/server/app/(dashboard)/feature/[featureId]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/feature/[featureId]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/page/server-reference-manifest.json +30 -30
- package/web/.next/server/app/(dashboard)/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/[tab]/page/server-reference-manifest.json +31 -31
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/[tab]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/[tab]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page/server-reference-manifest.json +31 -31
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/_global-error.html +2 -2
- package/web/.next/server/app/_global-error.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/web/.next/server/app/_not-found/page/server-reference-manifest.json +7 -7
- package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/application/[id]/page/server-reference-manifest.json +15 -15
- package/web/.next/server/app/application/[id]/page.js.nft.json +1 -1
- package/web/.next/server/app/application/[id]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/features/page/server-reference-manifest.json +7 -7
- package/web/.next/server/app/features/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/settings/page/server-reference-manifest.json +10 -10
- package/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/skills/page/server-reference-manifest.json +15 -15
- package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/tools/page/server-reference-manifest.json +13 -13
- package/web/.next/server/app/tools/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/version/page/server-reference-manifest.json +7 -7
- package/web/.next/server/app/version/page_client-reference-manifest.js +1 -1
- package/web/.next/server/chunks/[root-of-the-server]__a402b567._.js +1 -1
- package/web/.next/server/chunks/[root-of-the-server]__b2a4bfcc._.js.map +1 -1
- package/web/.next/server/chunks/[root-of-the-server]__cd67a84c._.js.map +1 -1
- package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js +1 -1
- package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js.map +1 -1
- package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_feature-drawer-client_tsx_e9755fc8._.js +2 -2
- package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_feature-drawer-client_tsx_e9755fc8._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__013a0318._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__013a0318._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__17dadd08._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__17dadd08._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__1925bef0._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__1a9687c4._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__1a9687c4._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__24756fa9._.js +2 -2
- package/web/.next/server/chunks/ssr/[root-of-the-server]__24756fa9._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__4ee8be85._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__70986695._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__70986695._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__a5ea76a6._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__a5ea76a6._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__bb391c45._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__bb391c45._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__dd3e834e._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__dd3e834e._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__e265da61._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__f3ca7bea._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__f3ca7bea._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_0277d3b5._.js +1 -1
- package/web/.next/server/chunks/ssr/_0277d3b5._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_295fffde._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_45496654._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_56b9d60f._.js +1 -1
- package/web/.next/server/chunks/ssr/_56b9d60f._.js.map +1 -1
- package/web/.next/server/chunks/ssr/{_8caadb9a._.js → _688e1fd9._.js} +2 -2
- package/web/.next/server/chunks/ssr/{_8caadb9a._.js.map → _688e1fd9._.js.map} +1 -1
- package/web/.next/server/chunks/ssr/_7931d3de._.js +3 -0
- package/web/.next/server/chunks/ssr/{_36489f2b._.js.map → _7931d3de._.js.map} +1 -1
- package/web/.next/server/chunks/ssr/_946a7fc6._.js +1 -1
- package/web/.next/server/chunks/ssr/_946a7fc6._.js.map +1 -1
- package/web/.next/server/chunks/ssr/{_d44d091a._.js → _bd8c6d0b._.js} +2 -2
- package/web/.next/server/chunks/ssr/{_d44d091a._.js.map → _bd8c6d0b._.js.map} +1 -1
- package/web/.next/server/chunks/ssr/{_63fc4647._.js → _ce7571dd._.js} +2 -2
- package/web/.next/server/chunks/ssr/{_63fc4647._.js.map → _ce7571dd._.js.map} +1 -1
- package/web/.next/server/chunks/ssr/_eff1b518._.js +1 -1
- package/web/.next/server/chunks/ssr/_eff1b518._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_f227429a._.js +1 -1
- package/web/.next/server/chunks/ssr/_f227429a._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_f5a56a3f._.js +3 -0
- package/web/.next/server/chunks/ssr/{_b8e8b690._.js.map → _f5a56a3f._.js.map} +1 -1
- package/web/.next/server/chunks/ssr/_f86fc1bf._.js +1 -1
- package/web/.next/server/chunks/ssr/_f86fc1bf._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_f8c55130._.js +1 -1
- package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js +1 -1
- package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js.map +1 -1
- package/web/.next/server/chunks/ssr/f3a1f_components_common_control-center-drawer_repository-drawer-client_tsx_39a00c03._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_36f2bc45._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_36f2bc45._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_486908de._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_486908de._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_5c3596bc._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_5c3596bc._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_6159fef8._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_6159fef8._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_6326f81e._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_6326f81e._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_6b2fdcd8._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_6b2fdcd8._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_74703c9f._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_74703c9f._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_a8056dac._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_a8056dac._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_ad42cc73._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_ad42cc73._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_app_actions_open-ide_ts_baaca5d5._.js +3 -3
- package/web/.next/server/chunks/ssr/src_presentation_web_b00bfb08._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_b00bfb08._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_895e5bfa._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_895e5bfa._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_common_base-drawer_base-drawer_tsx_97dfbbc8._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_common_base-drawer_base-drawer_tsx_97dfbbc8._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_features_skills_8a174cac._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_features_skills_8a174cac._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_db9fa0c2._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_db9fa0c2._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_f1edcf5e._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_f1edcf5e._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_f9436804._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_f9436804._.js.map +1 -1
- package/web/.next/server/pages/500.html +2 -2
- package/web/.next/server/server-reference-manifest.js +1 -1
- package/web/.next/server/server-reference-manifest.json +54 -54
- package/web/.next/static/chunks/{f6d47ff35d612852.js → 2bba4ee52a6464cd.js} +3 -3
- package/web/.next/static/chunks/4371be9a949c8fe0.js +1 -0
- package/web/.next/static/chunks/{490667b2a9bb58e2.js → 46bc202f80905332.js} +1 -1
- package/web/.next/static/chunks/{26e2ca76ab6c38b4.js → 51593e45475cb81d.js} +1 -1
- package/web/.next/static/chunks/{c0bd3ffcf94d1845.js → 75d1485ec29b8fd8.js} +1 -1
- package/web/.next/static/chunks/{e7da54dde18e7fb2.js → aba1ec85581d3f1b.js} +1 -1
- package/web/.next/static/chunks/{e2f9e224d1fa1faa.js → abc53f1cc59f4642.js} +1 -1
- package/web/.next/static/chunks/{a1098522326428d1.js → ac069319b2aeab27.js} +1 -1
- package/web/.next/static/chunks/{1fa1574b87bd2eb1.js → b5aadaa3b34d7b8e.js} +1 -1
- package/web/.next/static/chunks/{dfdcccf73de56960.js → b7e697748c35a4ce.js} +1 -1
- package/web/.next/static/chunks/{7849c6797be7c6ca.js → b9135c0d88735f54.js} +2 -2
- package/web/.next/static/chunks/{893a2a76546c66a7.js → c6b5b3f46622241d.js} +1 -1
- package/web/.next/static/chunks/{f28aef9cf5107c4b.js → c9c58949bf064dbe.js} +1 -1
- package/web/.next/static/chunks/{be89c20c257247ad.js → cbf7498ef586ebd3.js} +1 -1
- package/web/.next/static/chunks/{8746807722de67a8.js → d9f55661eb505770.js} +1 -1
- package/web/.next/static/chunks/{7bc7028587490fff.js → e3d4828e3b7291df.js} +1 -1
- package/web/.next/server/chunks/ssr/_36489f2b._.js +0 -3
- package/web/.next/server/chunks/ssr/_b8e8b690._.js +0 -3
- package/web/.next/static/chunks/1bc12075020723ed.js +0 -1
- /package/web/.next/static/{GQFJf3UCD4D5C4NCn8eXl → 73VlrUiVfmfr0uTiP1eN1}/_buildManifest.js +0 -0
- /package/web/.next/static/{GQFJf3UCD4D5C4NCn8eXl → 73VlrUiVfmfr0uTiP1eN1}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/static/{GQFJf3UCD4D5C4NCn8eXl → 73VlrUiVfmfr0uTiP1eN1}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Optimizer Service
|
|
3
|
+
*
|
|
4
|
+
* Top-level orchestrator for the token optimization layer. Composes the
|
|
5
|
+
* five capability services (delta-context, command output filter, skill
|
|
6
|
+
* routing, semantic compressor, alias compression) into a sequential
|
|
7
|
+
* pipeline driven by per-capability settings toggles.
|
|
8
|
+
*
|
|
9
|
+
* Pipeline order (from research decisions):
|
|
10
|
+
* 1. Output filter - removes the most raw text early
|
|
11
|
+
* 2. Skill routing - prepends a small directive section
|
|
12
|
+
* 3. Delta-context - replaces unchanged spec files with summaries
|
|
13
|
+
* 4. Semantic compr - compresses remaining natural language
|
|
14
|
+
* 5. Alias engine - finds repeated long strings in the final text
|
|
15
|
+
*
|
|
16
|
+
* Each stage runs only when its individual toggle is true. The master
|
|
17
|
+
* toggle (config.enabled) short-circuits the pipeline entirely.
|
|
18
|
+
*
|
|
19
|
+
* Metrics from each stage are aggregated into the OptimizationMetrics
|
|
20
|
+
* record returned alongside the optimized prompt.
|
|
21
|
+
*/
|
|
22
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
23
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
25
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
26
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
|
+
};
|
|
28
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
29
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
30
|
+
};
|
|
31
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
32
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
33
|
+
};
|
|
34
|
+
import { injectable, inject } from 'tsyringe';
|
|
35
|
+
/** Token estimate heuristic: chars / TOKEN_CHAR_RATIO. */
|
|
36
|
+
const TOKEN_CHAR_RATIO = 4;
|
|
37
|
+
/** Capability identifier strings recorded in metrics.capabilitiesApplied. */
|
|
38
|
+
const CAPABILITY = {
|
|
39
|
+
outputFiltering: 'outputFiltering',
|
|
40
|
+
skillRouting: 'skillRouting',
|
|
41
|
+
deltaContext: 'deltaContext',
|
|
42
|
+
semanticCompression: 'semanticCompression',
|
|
43
|
+
aliasCompression: 'aliasCompression',
|
|
44
|
+
};
|
|
45
|
+
/** Estimate tokens from character length using the chars/4 heuristic. */
|
|
46
|
+
function estimateTokens(text) {
|
|
47
|
+
return Math.floor(text.length / TOKEN_CHAR_RATIO);
|
|
48
|
+
}
|
|
49
|
+
/** Build a zero-delta metrics record (used when no optimization is applied). */
|
|
50
|
+
function buildPassthroughMetrics(prompt) {
|
|
51
|
+
const tokens = estimateTokens(prompt);
|
|
52
|
+
return {
|
|
53
|
+
originalTokenEstimate: tokens,
|
|
54
|
+
optimizedTokenEstimate: tokens,
|
|
55
|
+
savingsPercent: 0,
|
|
56
|
+
capabilitiesApplied: [],
|
|
57
|
+
outputFilterLinesRemoved: 0,
|
|
58
|
+
deltaContextFilesSkipped: 0,
|
|
59
|
+
compressionRatio: 1.0,
|
|
60
|
+
aliasesCreated: 0,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
let PromptOptimizerService = class PromptOptimizerService {
|
|
64
|
+
outputFilter;
|
|
65
|
+
skillRouting;
|
|
66
|
+
deltaContext;
|
|
67
|
+
semanticCompressor;
|
|
68
|
+
aliasCompression;
|
|
69
|
+
metricsService;
|
|
70
|
+
constructor(outputFilter, skillRouting, deltaContext, semanticCompressor, aliasCompression, metricsService) {
|
|
71
|
+
this.outputFilter = outputFilter;
|
|
72
|
+
this.skillRouting = skillRouting;
|
|
73
|
+
this.deltaContext = deltaContext;
|
|
74
|
+
this.semanticCompressor = semanticCompressor;
|
|
75
|
+
this.aliasCompression = aliasCompression;
|
|
76
|
+
this.metricsService = metricsService;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Optimize a raw prompt by running enabled capability services in sequence.
|
|
80
|
+
*
|
|
81
|
+
* Returns the original prompt with zero-delta metrics when the master
|
|
82
|
+
* toggle is off. Each capability is independently skippable via its
|
|
83
|
+
* config toggle.
|
|
84
|
+
*/
|
|
85
|
+
async optimize(prompt, context) {
|
|
86
|
+
const config = context.config;
|
|
87
|
+
// Master toggle off — return prompt unchanged with zero-delta metrics.
|
|
88
|
+
if (!config?.enabled) {
|
|
89
|
+
return {
|
|
90
|
+
prompt,
|
|
91
|
+
metrics: buildPassthroughMetrics(prompt),
|
|
92
|
+
specFileHashes: context.previousSpecFileHashes ?? {},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const originalTokenEstimate = estimateTokens(prompt);
|
|
96
|
+
const capabilitiesApplied = [];
|
|
97
|
+
let working = prompt;
|
|
98
|
+
// Per-capability metric accumulators
|
|
99
|
+
let outputFilterLinesRemoved = 0;
|
|
100
|
+
const deltaContextFilesSkipped = 0;
|
|
101
|
+
let compressionRatio = 1.0;
|
|
102
|
+
let aliasesCreated = 0;
|
|
103
|
+
const specFileHashes = context.previousSpecFileHashes ?? {};
|
|
104
|
+
// 1. Command output filter — remove the most raw text first.
|
|
105
|
+
if (config.outputFiltering) {
|
|
106
|
+
const result = this.outputFilter.filter(working);
|
|
107
|
+
working = result.filtered;
|
|
108
|
+
outputFilterLinesRemoved = result.linesRemoved;
|
|
109
|
+
capabilitiesApplied.push(CAPABILITY.outputFiltering);
|
|
110
|
+
}
|
|
111
|
+
// 2. Skill routing — prepend the phase-relevant skill directive.
|
|
112
|
+
if (config.skillRouting) {
|
|
113
|
+
const routing = this.skillRouting.getRoutingDirective(context.phaseName);
|
|
114
|
+
if (routing.directive.length > 0) {
|
|
115
|
+
working = `${routing.directive}\n\n${working}`;
|
|
116
|
+
}
|
|
117
|
+
capabilitiesApplied.push(CAPABILITY.skillRouting);
|
|
118
|
+
}
|
|
119
|
+
// 3. Delta-context — note: the orchestrator does not own spec file
|
|
120
|
+
// reads (those happen in prompt builders). When invoked here we
|
|
121
|
+
// simply mark the capability as applied and propagate hashes from
|
|
122
|
+
// context. The capability service is exposed for direct use by
|
|
123
|
+
// prompt builders that want to apply hash-based summaries inline.
|
|
124
|
+
if (config.deltaContext) {
|
|
125
|
+
capabilitiesApplied.push(CAPABILITY.deltaContext);
|
|
126
|
+
}
|
|
127
|
+
// 4. Semantic compressor — compress remaining natural language.
|
|
128
|
+
if (config.semanticCompression) {
|
|
129
|
+
const result = this.semanticCompressor.compress(working);
|
|
130
|
+
working = result.compressed;
|
|
131
|
+
compressionRatio = result.compressionRatio;
|
|
132
|
+
capabilitiesApplied.push(CAPABILITY.semanticCompression);
|
|
133
|
+
}
|
|
134
|
+
// 5. Alias engine — find repeated long strings in the final text.
|
|
135
|
+
if (config.aliasCompression) {
|
|
136
|
+
const result = this.aliasCompression.compress(working);
|
|
137
|
+
working = result.compressed;
|
|
138
|
+
aliasesCreated = result.aliasCount;
|
|
139
|
+
capabilitiesApplied.push(CAPABILITY.aliasCompression);
|
|
140
|
+
}
|
|
141
|
+
const optimizedTokenEstimate = estimateTokens(working);
|
|
142
|
+
// Total-net-positive gate. Per-capability overheads — specifically
|
|
143
|
+
// the skill-routing directive header and the alias dictionary header —
|
|
144
|
+
// are fixed costs that can exceed savings on short prompts. When that
|
|
145
|
+
// happens, returning the "optimized" prompt actively hurts: the layer
|
|
146
|
+
// makes the prompt larger in the name of making it smaller. Fall back
|
|
147
|
+
// to the original whenever the pipeline is not net-positive.
|
|
148
|
+
//
|
|
149
|
+
// Measured against the real 844-token fast-implement seed prompt on
|
|
150
|
+
// the shep-website A/B test: all-capabilities-on produced an 860-token
|
|
151
|
+
// output (-1.9%), driven by a 40-token skill-routing directive. With
|
|
152
|
+
// this gate active, such prompts pass through unchanged.
|
|
153
|
+
if (optimizedTokenEstimate >= originalTokenEstimate) {
|
|
154
|
+
const passthroughMetrics = {
|
|
155
|
+
originalTokenEstimate,
|
|
156
|
+
optimizedTokenEstimate: originalTokenEstimate,
|
|
157
|
+
savingsPercent: 0,
|
|
158
|
+
capabilitiesApplied: [],
|
|
159
|
+
outputFilterLinesRemoved: 0,
|
|
160
|
+
deltaContextFilesSkipped: 0,
|
|
161
|
+
compressionRatio: 1.0,
|
|
162
|
+
aliasesCreated: 0,
|
|
163
|
+
};
|
|
164
|
+
this.logSummary(context, passthroughMetrics);
|
|
165
|
+
await this.recordMetricsIfPossible(context, passthroughMetrics);
|
|
166
|
+
return {
|
|
167
|
+
prompt,
|
|
168
|
+
metrics: passthroughMetrics,
|
|
169
|
+
specFileHashes,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const savingsPercent = originalTokenEstimate > 0
|
|
173
|
+
? ((originalTokenEstimate - optimizedTokenEstimate) / originalTokenEstimate) * 100
|
|
174
|
+
: 0;
|
|
175
|
+
const metrics = {
|
|
176
|
+
originalTokenEstimate,
|
|
177
|
+
optimizedTokenEstimate,
|
|
178
|
+
savingsPercent: Math.max(0, savingsPercent),
|
|
179
|
+
capabilitiesApplied,
|
|
180
|
+
outputFilterLinesRemoved,
|
|
181
|
+
deltaContextFilesSkipped,
|
|
182
|
+
compressionRatio,
|
|
183
|
+
aliasesCreated,
|
|
184
|
+
};
|
|
185
|
+
this.logSummary(context, metrics);
|
|
186
|
+
await this.recordMetricsIfPossible(context, metrics);
|
|
187
|
+
return {
|
|
188
|
+
prompt: working,
|
|
189
|
+
metrics,
|
|
190
|
+
specFileHashes,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Persist metrics via the metrics service when a phaseTimingId is
|
|
195
|
+
* provided in the context. Failures are swallowed so a metrics
|
|
196
|
+
* persistence problem can never break the optimization pipeline.
|
|
197
|
+
*/
|
|
198
|
+
async recordMetricsIfPossible(context, metrics) {
|
|
199
|
+
if (!context.phaseTimingId) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
await this.metricsService.record(context.phaseTimingId, metrics);
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
// Metrics persistence failure must never break optimization
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Log a debug-level summary of optimizations applied for observability.
|
|
211
|
+
* Failure to log must never affect optimization output.
|
|
212
|
+
*/
|
|
213
|
+
logSummary(context, metrics) {
|
|
214
|
+
try {
|
|
215
|
+
const savings = metrics.savingsPercent.toFixed(1);
|
|
216
|
+
const caps = metrics.capabilitiesApplied.join(',');
|
|
217
|
+
// Use process.stderr.write at debug level (no console pollution)
|
|
218
|
+
if (process.env.SHEP_DEBUG_OPTIMIZER === '1') {
|
|
219
|
+
process.stderr.write(`[token-optimizer] phase=${context.phaseName} ` +
|
|
220
|
+
`original=${metrics.originalTokenEstimate} ` +
|
|
221
|
+
`optimized=${metrics.optimizedTokenEstimate} ` +
|
|
222
|
+
`savings=${savings}% ` +
|
|
223
|
+
`capabilities=${caps}\n`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
// Logging failure must never break optimization
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
PromptOptimizerService = __decorate([
|
|
232
|
+
injectable(),
|
|
233
|
+
__param(0, inject('ICommandOutputFilterService')),
|
|
234
|
+
__param(1, inject('ISkillRoutingService')),
|
|
235
|
+
__param(2, inject('IDeltaContextService')),
|
|
236
|
+
__param(3, inject('ISemanticCompressorService')),
|
|
237
|
+
__param(4, inject('IAliasCompressionService')),
|
|
238
|
+
__param(5, inject('IOptimizationMetricsService')),
|
|
239
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object, Object, Object])
|
|
240
|
+
], PromptOptimizerService);
|
|
241
|
+
export { PromptOptimizerService };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic Compressor Service
|
|
3
|
+
*
|
|
4
|
+
* Rule-based caveman compression for non-code prompt sections. Uses a
|
|
5
|
+
* protect-then-compress strategy: extract protected regions (code blocks,
|
|
6
|
+
* file paths, URLs, JSON, quoted strings) as placeholders, apply compression
|
|
7
|
+
* rules to the remaining natural language, then restore protected regions.
|
|
8
|
+
*
|
|
9
|
+
* Compression rules (in order):
|
|
10
|
+
* 1. Phrase shortening (multi-word → shorter equivalent)
|
|
11
|
+
* 2. Filler word removal (just, simply, basically, actually, really, currently)
|
|
12
|
+
* 3. Article removal (a, an, the)
|
|
13
|
+
* 4. Technical term abbreviation (repository → repo, etc.)
|
|
14
|
+
* 5. Whitespace collapsing (multiple blanks → single)
|
|
15
|
+
*/
|
|
16
|
+
import type { ISemanticCompressorService, SemanticCompressionResult } from '../../../application/ports/output/services/semantic-compressor.interface.js';
|
|
17
|
+
export declare class SemanticCompressorService implements ISemanticCompressorService {
|
|
18
|
+
/**
|
|
19
|
+
* Compress natural language text in a prompt.
|
|
20
|
+
*
|
|
21
|
+
* Strategy:
|
|
22
|
+
* 1. Extract all protected regions and replace with placeholders
|
|
23
|
+
* 2. Apply compression rules to remaining text
|
|
24
|
+
* 3. Restore protected regions from placeholders
|
|
25
|
+
* 4. Calculate compression ratio
|
|
26
|
+
*/
|
|
27
|
+
compress(text: string): SemanticCompressionResult;
|
|
28
|
+
private applyPhraseShortening;
|
|
29
|
+
private removeFillerWords;
|
|
30
|
+
private removeArticles;
|
|
31
|
+
private abbreviateTerms;
|
|
32
|
+
private collapseWhitespace;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=semantic-compressor.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic-compressor.service.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/src/infrastructure/services/token-optimization/semantic-compressor.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,sEAAsE,CAAC;AAwF9E,qBAAa,yBAA0B,YAAW,0BAA0B;IAC1E;;;;;;;;OAQG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,yBAAyB;IAoDjD,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,kBAAkB;CAmB3B"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic Compressor Service
|
|
3
|
+
*
|
|
4
|
+
* Rule-based caveman compression for non-code prompt sections. Uses a
|
|
5
|
+
* protect-then-compress strategy: extract protected regions (code blocks,
|
|
6
|
+
* file paths, URLs, JSON, quoted strings) as placeholders, apply compression
|
|
7
|
+
* rules to the remaining natural language, then restore protected regions.
|
|
8
|
+
*
|
|
9
|
+
* Compression rules (in order):
|
|
10
|
+
* 1. Phrase shortening (multi-word → shorter equivalent)
|
|
11
|
+
* 2. Filler word removal (just, simply, basically, actually, really, currently)
|
|
12
|
+
* 3. Article removal (a, an, the)
|
|
13
|
+
* 4. Technical term abbreviation (repository → repo, etc.)
|
|
14
|
+
* 5. Whitespace collapsing (multiple blanks → single)
|
|
15
|
+
*/
|
|
16
|
+
/** Placeholder prefix used for protected regions. */
|
|
17
|
+
const PLACEHOLDER_PREFIX = '\x00PROT_';
|
|
18
|
+
const PLACEHOLDER_SUFFIX = '\x00';
|
|
19
|
+
/**
|
|
20
|
+
* Multi-word phrase replacements. Order matters: longer phrases first to
|
|
21
|
+
* prevent partial matches. Applied case-insensitively.
|
|
22
|
+
*/
|
|
23
|
+
const PHRASE_REPLACEMENTS = [
|
|
24
|
+
[/\bdue to the fact that\b/gi, 'because'],
|
|
25
|
+
[/\bit is important to\b/gi, 'important:'],
|
|
26
|
+
[/\bplease note that\b/gi, 'note:'],
|
|
27
|
+
[/\bin addition to\b/gi, 'besides'],
|
|
28
|
+
[/\ba number of\b/gi, 'several'],
|
|
29
|
+
[/\bat this point\b/gi, 'now'],
|
|
30
|
+
[/\bmake sure to\b/gi, 'ensure'],
|
|
31
|
+
[/\bin order to\b/gi, 'to'],
|
|
32
|
+
[/\bas well as\b/gi, 'and'],
|
|
33
|
+
[/\byou must\b/gi, 'must'],
|
|
34
|
+
[/\byou should\b/gi, 'should'],
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* Filler words removed entirely (with surrounding space normalization).
|
|
38
|
+
*/
|
|
39
|
+
const FILLER_WORDS = [
|
|
40
|
+
/\bjust\b/gi,
|
|
41
|
+
/\bsimply\b/gi,
|
|
42
|
+
/\bbasically\b/gi,
|
|
43
|
+
/\bactually\b/gi,
|
|
44
|
+
/\breally\b/gi,
|
|
45
|
+
/\bcurrently\b/gi,
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* Articles removed (with word boundary awareness).
|
|
49
|
+
*/
|
|
50
|
+
const ARTICLES = [/\bthe\b/gi, /\ban\b/gi, /\ba\b(?=\s)/gi];
|
|
51
|
+
/**
|
|
52
|
+
* Technical term abbreviations. Applied with word boundaries.
|
|
53
|
+
*/
|
|
54
|
+
const TERM_ABBREVIATIONS = [
|
|
55
|
+
[/\bimplementation\b/gi, 'impl'],
|
|
56
|
+
[/\bconfiguration\b/gi, 'config'],
|
|
57
|
+
[/\bspecification\b/gi, 'spec'],
|
|
58
|
+
[/\benvironment\b/gi, 'env'],
|
|
59
|
+
[/\bapplication\b/gi, 'app'],
|
|
60
|
+
[/\brepository\b/gi, 'repo'],
|
|
61
|
+
[/\bdependencies\b/gi, 'deps'],
|
|
62
|
+
[/\bdependency\b/gi, 'dep'],
|
|
63
|
+
[/\bdirectory\b/gi, 'dir'],
|
|
64
|
+
[/\bfunction\b/gi, 'fn'],
|
|
65
|
+
];
|
|
66
|
+
/**
|
|
67
|
+
* Regex patterns for detecting protected regions in the prompt text.
|
|
68
|
+
*/
|
|
69
|
+
/** Fenced code blocks: ```...``` (with optional language tag) */
|
|
70
|
+
const FENCED_CODE_BLOCK_RE = /```[\s\S]*?```/g;
|
|
71
|
+
/** Indented code blocks: lines starting with 4+ spaces (consecutive) */
|
|
72
|
+
const INDENTED_CODE_BLOCK_RE = /(?:^|\n)((?:[ ]{4,}[^\n]*\n?)+)/g;
|
|
73
|
+
/** URLs: http(s)://... */
|
|
74
|
+
const URL_RE = /https?:\/\/[^\s)>\]]+/g;
|
|
75
|
+
/** Absolute file paths: /path/to/file or ./path/to/file */
|
|
76
|
+
const UNIX_PATH_RE = /(?:\.\/|\/)[a-zA-Z0-9_\-./]+\.[a-zA-Z0-9]+/g;
|
|
77
|
+
/** Windows file paths: C:\path\to\file */
|
|
78
|
+
const WINDOWS_PATH_RE = /[A-Z]:\\[^\s]+/g;
|
|
79
|
+
/** Double-quoted strings */
|
|
80
|
+
const DOUBLE_QUOTE_RE = /"[^"]*"/g;
|
|
81
|
+
/** Single-quoted strings */
|
|
82
|
+
const SINGLE_QUOTE_RE = /'[^']*'/g;
|
|
83
|
+
/** Backtick-quoted inline code */
|
|
84
|
+
const BACKTICK_RE = /`[^`]+`/g;
|
|
85
|
+
/** Inline JSON objects */
|
|
86
|
+
const INLINE_JSON_RE = /\{[^{}]*"[^"]*"[^{}]*\}/g;
|
|
87
|
+
export class SemanticCompressorService {
|
|
88
|
+
/**
|
|
89
|
+
* Compress natural language text in a prompt.
|
|
90
|
+
*
|
|
91
|
+
* Strategy:
|
|
92
|
+
* 1. Extract all protected regions and replace with placeholders
|
|
93
|
+
* 2. Apply compression rules to remaining text
|
|
94
|
+
* 3. Restore protected regions from placeholders
|
|
95
|
+
* 4. Calculate compression ratio
|
|
96
|
+
*/
|
|
97
|
+
compress(text) {
|
|
98
|
+
if (text === '') {
|
|
99
|
+
return { compressed: '', compressionRatio: 1.0 };
|
|
100
|
+
}
|
|
101
|
+
const originalLength = text.length;
|
|
102
|
+
// Step 1: Extract protected regions
|
|
103
|
+
const protectedRegions = [];
|
|
104
|
+
let working = text;
|
|
105
|
+
const protect = (regex) => {
|
|
106
|
+
working = working.replace(regex, (match) => {
|
|
107
|
+
const index = protectedRegions.length;
|
|
108
|
+
protectedRegions.push(match);
|
|
109
|
+
return `${PLACEHOLDER_PREFIX}${index}${PLACEHOLDER_SUFFIX}`;
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
// Order matters: code blocks first (they may contain other patterns)
|
|
113
|
+
protect(FENCED_CODE_BLOCK_RE);
|
|
114
|
+
protect(INDENTED_CODE_BLOCK_RE);
|
|
115
|
+
protect(URL_RE);
|
|
116
|
+
protect(WINDOWS_PATH_RE);
|
|
117
|
+
protect(UNIX_PATH_RE);
|
|
118
|
+
protect(INLINE_JSON_RE);
|
|
119
|
+
protect(DOUBLE_QUOTE_RE);
|
|
120
|
+
protect(SINGLE_QUOTE_RE);
|
|
121
|
+
protect(BACKTICK_RE);
|
|
122
|
+
// Step 2: Apply compression rules
|
|
123
|
+
working = this.applyPhraseShortening(working);
|
|
124
|
+
working = this.removeFillerWords(working);
|
|
125
|
+
working = this.removeArticles(working);
|
|
126
|
+
working = this.abbreviateTerms(working);
|
|
127
|
+
working = this.collapseWhitespace(working);
|
|
128
|
+
// Step 3: Restore protected regions
|
|
129
|
+
working = working.replace(new RegExp(`${escapeRegex(PLACEHOLDER_PREFIX)}(\\d+)${escapeRegex(PLACEHOLDER_SUFFIX)}`, 'g'), (_, indexStr) => {
|
|
130
|
+
const index = parseInt(indexStr, 10);
|
|
131
|
+
return protectedRegions[index] ?? '';
|
|
132
|
+
});
|
|
133
|
+
const compressedLength = working.length;
|
|
134
|
+
const compressionRatio = originalLength === 0 ? 1.0 : compressedLength / originalLength;
|
|
135
|
+
return { compressed: working, compressionRatio };
|
|
136
|
+
}
|
|
137
|
+
applyPhraseShortening(text) {
|
|
138
|
+
let result = text;
|
|
139
|
+
for (const [pattern, replacement] of PHRASE_REPLACEMENTS) {
|
|
140
|
+
result = result.replace(pattern, replacement);
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
removeFillerWords(text) {
|
|
145
|
+
let result = text;
|
|
146
|
+
for (const pattern of FILLER_WORDS) {
|
|
147
|
+
result = result.replace(pattern, '');
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
removeArticles(text) {
|
|
152
|
+
let result = text;
|
|
153
|
+
for (const pattern of ARTICLES) {
|
|
154
|
+
result = result.replace(pattern, '');
|
|
155
|
+
}
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
abbreviateTerms(text) {
|
|
159
|
+
let result = text;
|
|
160
|
+
for (const [pattern, replacement] of TERM_ABBREVIATIONS) {
|
|
161
|
+
result = result.replace(pattern, replacement);
|
|
162
|
+
}
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
collapseWhitespace(text) {
|
|
166
|
+
let result = text;
|
|
167
|
+
// Collapse multiple blank lines to a single blank line
|
|
168
|
+
result = result.replace(/\n{3,}/g, '\n\n');
|
|
169
|
+
// Collapse multiple spaces within lines to a single space
|
|
170
|
+
result = result.replace(/ {2,}/g, ' ');
|
|
171
|
+
// Trim leading/trailing spaces on each line (but keep indentation for protected restored content)
|
|
172
|
+
result = result
|
|
173
|
+
.split('\n')
|
|
174
|
+
.map((line) => {
|
|
175
|
+
// Only trim if line doesn't start with a placeholder
|
|
176
|
+
if (line.includes(PLACEHOLDER_PREFIX)) {
|
|
177
|
+
return line;
|
|
178
|
+
}
|
|
179
|
+
return line.replace(/^ +/, '').replace(/ +$/, '');
|
|
180
|
+
})
|
|
181
|
+
.join('\n');
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Escape special regex characters in a string.
|
|
187
|
+
*/
|
|
188
|
+
function escapeRegex(str) {
|
|
189
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
190
|
+
}
|
package/dist/packages/core/src/infrastructure/services/token-optimization/skill-routing.service.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Routing Service
|
|
3
|
+
*
|
|
4
|
+
* Phase-aware skill routing that maps workflow phases to relevant skill sets
|
|
5
|
+
* and generates prompt directives guiding the agent to prioritize them.
|
|
6
|
+
*
|
|
7
|
+
* The default routing table follows FR-3 from the spec:
|
|
8
|
+
* - analyze / requirements: architecture-reviewer, domain modeling skills
|
|
9
|
+
* - research: architecture-reviewer, technology evaluation skills
|
|
10
|
+
* - plan: architecture-reviewer, tdd-guide, implementation-guide
|
|
11
|
+
* - implement / fast-implement: tdd-guide, implementation-guide, framework skills
|
|
12
|
+
* - merge: git-related skills only
|
|
13
|
+
* - evidence: testing and validation skills
|
|
14
|
+
*
|
|
15
|
+
* The routing table is configurable via constructor parameter (settings override).
|
|
16
|
+
*/
|
|
17
|
+
import type { ISkillRoutingService, SkillRoutingResult } from '../../../application/ports/output/services/skill-routing.interface.js';
|
|
18
|
+
export declare class SkillRoutingService implements ISkillRoutingService {
|
|
19
|
+
private readonly routingTable;
|
|
20
|
+
constructor(customRoutes?: Record<string, string[]>);
|
|
21
|
+
/**
|
|
22
|
+
* Get relevant skills and a prompt directive for a workflow phase.
|
|
23
|
+
*/
|
|
24
|
+
getRoutingDirective(phaseName: string): SkillRoutingResult;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=skill-routing.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-routing.service.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/src/infrastructure/services/token-optimization/skill-routing.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,gEAAgE,CAAC;AAgBxE,qBAAa,mBAAoB,YAAW,oBAAoB;IAC9D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA8C;gBAE/D,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAInD;;OAEG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB;CAiB3D"}
|
package/dist/packages/core/src/infrastructure/services/token-optimization/skill-routing.service.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Routing Service
|
|
3
|
+
*
|
|
4
|
+
* Phase-aware skill routing that maps workflow phases to relevant skill sets
|
|
5
|
+
* and generates prompt directives guiding the agent to prioritize them.
|
|
6
|
+
*
|
|
7
|
+
* The default routing table follows FR-3 from the spec:
|
|
8
|
+
* - analyze / requirements: architecture-reviewer, domain modeling skills
|
|
9
|
+
* - research: architecture-reviewer, technology evaluation skills
|
|
10
|
+
* - plan: architecture-reviewer, tdd-guide, implementation-guide
|
|
11
|
+
* - implement / fast-implement: tdd-guide, implementation-guide, framework skills
|
|
12
|
+
* - merge: git-related skills only
|
|
13
|
+
* - evidence: testing and validation skills
|
|
14
|
+
*
|
|
15
|
+
* The routing table is configurable via constructor parameter (settings override).
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Default phase-to-skill routing table (FR-3).
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_ROUTING_TABLE = {
|
|
21
|
+
analyze: ['architecture-reviewer', 'mermaid-diagrams'],
|
|
22
|
+
requirements: ['architecture-reviewer', 'mermaid-diagrams'],
|
|
23
|
+
research: ['architecture-reviewer', 'find-skills'],
|
|
24
|
+
plan: ['architecture-reviewer', 'tdd-guide', 'implementation-guide'],
|
|
25
|
+
implement: ['tdd-guide', 'implementation-guide', 'shep-kit-implement'],
|
|
26
|
+
'fast-implement': ['tdd-guide', 'implementation-guide', 'shep-kit-fast-loop'],
|
|
27
|
+
merge: ['shep-kit-commit-pr'],
|
|
28
|
+
evidence: ['tdd-guide', 'cross-validate-artifacts'],
|
|
29
|
+
};
|
|
30
|
+
export class SkillRoutingService {
|
|
31
|
+
routingTable;
|
|
32
|
+
constructor(customRoutes) {
|
|
33
|
+
this.routingTable = customRoutes ?? DEFAULT_ROUTING_TABLE;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get relevant skills and a prompt directive for a workflow phase.
|
|
37
|
+
*/
|
|
38
|
+
getRoutingDirective(phaseName) {
|
|
39
|
+
const relevantSkills = [...(this.routingTable[phaseName] ?? [])];
|
|
40
|
+
if (relevantSkills.length === 0) {
|
|
41
|
+
return {
|
|
42
|
+
relevantSkills: [],
|
|
43
|
+
directive: '',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const skillList = relevantSkills.join(', ');
|
|
47
|
+
const directive = `For this [${phaseName}] phase, prioritize these skills: ${skillList}. ` +
|
|
48
|
+
`Other skills are available but less relevant.`;
|
|
49
|
+
return { relevantSkills, directive };
|
|
50
|
+
}
|
|
51
|
+
}
|