@aiwg/cli 0.0.0-bootstrap.0 → 2026.7.18
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/LICENSE +21 -0
- package/README.md +22 -1
- package/bin/aiwg.mjs +349 -0
- package/dist/src/a2a/agent-card.js +145 -0
- package/dist/src/a2a/client.js +411 -0
- package/dist/src/a2a/hitl-cli.js +171 -0
- package/dist/src/a2a/hitl-driver.js +370 -0
- package/dist/src/a2a/hitl.js +181 -0
- package/dist/src/a2a/http.js +193 -0
- package/dist/src/a2a/jcs.js +128 -0
- package/dist/src/a2a/jws.js +187 -0
- package/dist/src/a2a/types.js +24 -0
- package/dist/src/a2a/webhook.js +240 -0
- package/dist/src/activity-log/cli.js +348 -0
- package/dist/src/activity-log/parser.js +81 -0
- package/dist/src/activity-log/types.js +50 -0
- package/dist/src/agents/agent-deployer.js +367 -0
- package/dist/src/agents/agent-packager.js +271 -0
- package/dist/src/agents/agent-validator.js +271 -0
- package/dist/src/agents/grounding/knowledge-base.js +161 -0
- package/dist/src/agents/grounding/types.js +12 -0
- package/dist/src/agents/index.js +10 -0
- package/dist/src/agents/packaged-agent-inventory.js +75 -0
- package/dist/src/agents/types.js +7 -0
- package/dist/src/api/index.d.ts +10 -0
- package/dist/src/api/index.js +10 -0
- package/dist/src/artifacts/address-parser.js +73 -0
- package/dist/src/artifacts/audit/cli.js +183 -0
- package/dist/src/artifacts/audit/drift.js +122 -0
- package/dist/src/artifacts/audit/types.js +12 -0
- package/dist/src/artifacts/backends/graphology-backend.js +160 -0
- package/dist/src/artifacts/backends/json-backend.js +129 -0
- package/dist/src/artifacts/backends/sqlite-backend.js +199 -0
- package/dist/src/artifacts/browser-export.js +622 -0
- package/dist/src/artifacts/capability-resolver.js +94 -0
- package/dist/src/artifacts/checksum-manifest.js +91 -0
- package/dist/src/artifacts/citation-parser.js +162 -0
- package/dist/src/artifacts/cli.js +1486 -0
- package/dist/src/artifacts/corpus-tools/citation-densify.js +311 -0
- package/dist/src/artifacts/corpus-tools/cli.js +393 -0
- package/dist/src/artifacts/corpus-tools/corpus-graph.js +225 -0
- package/dist/src/artifacts/corpus-tools/curator.js +186 -0
- package/dist/src/artifacts/corpus-tools/discovery-log.js +70 -0
- package/dist/src/artifacts/corpus-tools/funder-network.js +141 -0
- package/dist/src/artifacts/corpus-tools/induction-audit.js +233 -0
- package/dist/src/artifacts/corpus-tools/integrity-scan.js +202 -0
- package/dist/src/artifacts/corpus-tools/profile-communities.js +166 -0
- package/dist/src/artifacts/corpus-tools/profile-edges.js +72 -0
- package/dist/src/artifacts/corpus-tools/profile-embed.js +113 -0
- package/dist/src/artifacts/corpus-tools/profile-generate-fm.js +167 -0
- package/dist/src/artifacts/corpus-tools/profile-generate.js +181 -0
- package/dist/src/artifacts/corpus-tools/profile-metrics.js +98 -0
- package/dist/src/artifacts/corpus-tools/profile-status.js +86 -0
- package/dist/src/artifacts/corpus-tools/profile-temporal.js +139 -0
- package/dist/src/artifacts/corpus-tools/radar-init.js +93 -0
- package/dist/src/artifacts/corpus-tools/radar-report.js +118 -0
- package/dist/src/artifacts/corpus-tools/radar-shared.js +189 -0
- package/dist/src/artifacts/corpus-tools/radar-status.js +68 -0
- package/dist/src/artifacts/corpus-tools/sidecar-lint.js +233 -0
- package/dist/src/artifacts/corpus-tools/sidecar-repair.js +277 -0
- package/dist/src/artifacts/corpus-tools/snapshot.js +591 -0
- package/dist/src/artifacts/corpus-tools/source-types.js +164 -0
- package/dist/src/artifacts/corpus-tools/vision-extract.js +243 -0
- package/dist/src/artifacts/corpus-views/build.js +126 -0
- package/dist/src/artifacts/corpus-views/corpus-config.js +124 -0
- package/dist/src/artifacts/corpus-views/ref-parser.js +437 -0
- package/dist/src/artifacts/corpus-views/renderers.js +353 -0
- package/dist/src/artifacts/corpus-views/taxonomies.js +131 -0
- package/dist/src/artifacts/dep-graph.js +173 -0
- package/dist/src/artifacts/discover-facets.js +375 -0
- package/dist/src/artifacts/embedding-index.js +354 -0
- package/dist/src/artifacts/enrichment/cli.js +240 -0
- package/dist/src/artifacts/enrichment/prompt.js +47 -0
- package/dist/src/artifacts/enrichment/store.js +90 -0
- package/dist/src/artifacts/enrichment/types.js +12 -0
- package/dist/src/artifacts/fortemi-core-query-adapter.js +475 -0
- package/dist/src/artifacts/fortemi-core-sync.js +251 -0
- package/dist/src/artifacts/fortemi-shard-export.js +44 -0
- package/dist/src/artifacts/fulltext.js +108 -0
- package/dist/src/artifacts/graph-backend.js +51 -0
- package/dist/src/artifacts/graph-query.js +247 -0
- package/dist/src/artifacts/hybrid-query.js +225 -0
- package/dist/src/artifacts/index-builder.js +1089 -0
- package/dist/src/artifacts/index-reader.js +112 -0
- package/dist/src/artifacts/index-status.js +193 -0
- package/dist/src/artifacts/legacy-index-migration.js +169 -0
- package/dist/src/artifacts/move.js +154 -0
- package/dist/src/artifacts/operational-state.js +239 -0
- package/dist/src/artifacts/prebuilt-build-lock.js +49 -0
- package/dist/src/artifacts/query-engine.js +1955 -0
- package/dist/src/artifacts/source-graph.js +529 -0
- package/dist/src/artifacts/stats.js +169 -0
- package/dist/src/artifacts/types.js +606 -0
- package/dist/src/artifacts/views/cli.js +293 -0
- package/dist/src/artifacts/views/definition.js +170 -0
- package/dist/src/artifacts/views/store.js +149 -0
- package/dist/src/artifacts/views/types.js +8 -0
- package/dist/src/artifacts/watcher.js +255 -0
- package/dist/src/catalog/builtin-models.json +636 -0
- package/dist/src/catalog/cli.js +228 -0
- package/dist/src/catalog/cli.mjs +289 -0
- package/dist/src/catalog/index.js +15 -0
- package/dist/src/catalog/loader.js +217 -0
- package/dist/src/catalog/loader.mjs +251 -0
- package/dist/src/catalog/sources.json +41 -0
- package/dist/src/catalog/types.js +8 -0
- package/dist/src/channel/manager.mjs +504 -0
- package/dist/src/cli/agent-spawn.js +178 -0
- package/dist/src/cli/cli-extension-loader.js +245 -0
- package/dist/src/cli/command-log.js +275 -0
- package/dist/src/cli/config-loader.js +232 -0
- package/dist/src/cli/env.js +82 -0
- package/dist/src/cli/errors.js +150 -0
- package/dist/src/cli/find-package-root.js +40 -0
- package/dist/src/cli/git-hooks.js +250 -0
- package/dist/src/cli/handlers/agentcard.js +206 -0
- package/dist/src/cli/handlers/artifacts.js +76 -0
- package/dist/src/cli/handlers/best-practices-audit.js +280 -0
- package/dist/src/cli/handlers/cockpit.js +137 -0
- package/dist/src/cli/handlers/command-log.js +37 -0
- package/dist/src/cli/handlers/daemon.js +59 -0
- package/dist/src/cli/handlers/diagnose.js +300 -0
- package/dist/src/cli/handlers/execution-mode.js +105 -0
- package/dist/src/cli/handlers/feedback.js +341 -0
- package/dist/src/cli/handlers/help.js +147 -0
- package/dist/src/cli/handlers/index.js +302 -0
- package/dist/src/cli/handlers/init.js +179 -0
- package/dist/src/cli/handlers/install.js +129 -0
- package/dist/src/cli/handlers/issues.js +46 -0
- package/dist/src/cli/handlers/lint.js +42 -0
- package/dist/src/cli/handlers/local-executor.js +315 -0
- package/dist/src/cli/handlers/marketplace.js +168 -0
- package/dist/src/cli/handlers/mc.js +1010 -0
- package/dist/src/cli/handlers/models.js +352 -0
- package/dist/src/cli/handlers/packages.js +155 -0
- package/dist/src/cli/handlers/ralph-launcher.js +717 -0
- package/dist/src/cli/handlers/ralph.js +575 -0
- package/dist/src/cli/handlers/refresh.js +432 -0
- package/dist/src/cli/handlers/regenerate.js +336 -0
- package/dist/src/cli/handlers/repo-access.js +109 -0
- package/dist/src/cli/handlers/run.js +165 -0
- package/dist/src/cli/handlers/runtime-info.js +301 -0
- package/dist/src/cli/handlers/sandbox.js +197 -0
- package/dist/src/cli/handlers/scaffolding.js +149 -0
- package/dist/src/cli/handlers/script-runner.js +121 -0
- package/dist/src/cli/handlers/sdlc-accelerate.js +148 -0
- package/dist/src/cli/handlers/serve.js +1835 -0
- package/dist/src/cli/handlers/session.js +348 -0
- package/dist/src/cli/handlers/setup.js +440 -0
- package/dist/src/cli/handlers/skill-lint.js +367 -0
- package/dist/src/cli/handlers/skill-usage.js +74 -0
- package/dist/src/cli/handlers/steward.js +567 -0
- package/dist/src/cli/handlers/subcommands.js +1702 -0
- package/dist/src/cli/handlers/team.js +337 -0
- package/dist/src/cli/handlers/types.js +11 -0
- package/dist/src/cli/handlers/use.js +2772 -0
- package/dist/src/cli/handlers/utilities.js +703 -0
- package/dist/src/cli/handlers/version.js +134 -0
- package/dist/src/cli/handlers/workspace-context.js +93 -0
- package/dist/src/cli/handlers/workspace.js +126 -0
- package/dist/src/cli/help-generator.js +178 -0
- package/dist/src/cli/hooks/builtin/activity-log-hook.js +126 -0
- package/dist/src/cli/hooks/executor.js +96 -0
- package/dist/src/cli/hooks/index.js +15 -0
- package/dist/src/cli/hooks/registry.js +143 -0
- package/dist/src/cli/hooks/types.js +13 -0
- package/dist/src/cli/log.js +492 -0
- package/dist/src/cli/project-isolation/detect.js +70 -0
- package/dist/src/cli/project-isolation/index.js +7 -0
- package/dist/src/cli/project-isolation/signals.js +17 -0
- package/dist/src/cli/project-isolation/warning.js +102 -0
- package/dist/src/cli/prompt-utils.js +155 -0
- package/dist/src/cli/provider-deployment-plan.js +126 -0
- package/dist/src/cli/provider-resolution.js +119 -0
- package/dist/src/cli/router.js +305 -0
- package/dist/src/cli/scope-resolver.js +392 -0
- package/dist/src/cli/skill-usage.js +616 -0
- package/dist/src/cli/ui.js +224 -0
- package/dist/src/cli/watch-service.js +203 -0
- package/dist/src/cli/workflow-orchestrator.js +478 -0
- package/dist/src/cli/workspace-signals.js +321 -0
- package/dist/src/community/footer.js +14 -0
- package/dist/src/community/links.js +123 -0
- package/dist/src/community/milestones.js +46 -0
- package/dist/src/community/nudge-policy.js +93 -0
- package/dist/src/config/aiwg-config.js +883 -0
- package/dist/src/config/cli.js +703 -0
- package/dist/src/config/gitignore.js +156 -0
- package/dist/src/config/project-artifacts.js +76 -0
- package/dist/src/config/user-config.js +428 -0
- package/dist/src/config/user-registry.js +127 -0
- package/dist/src/config/workspace.js +276 -0
- package/dist/src/contributors/detect.js +39 -0
- package/dist/src/contributors/discover.js +172 -0
- package/dist/src/contributors/heuristic.js +186 -0
- package/dist/src/contributors/index.js +11 -0
- package/dist/src/contributors/types.js +13 -0
- package/dist/src/contributors/validation.js +116 -0
- package/dist/src/data/community.schema.json +43 -0
- package/dist/src/data/community.yaml +16 -0
- package/dist/src/extensions/capability-index.js +270 -0
- package/dist/src/extensions/claude-hooks-installer.js +268 -0
- package/dist/src/extensions/commands/definitions.js +3485 -0
- package/dist/src/extensions/deployment-registration.js +463 -0
- package/dist/src/extensions/index.js +22 -0
- package/dist/src/extensions/loader.js +132 -0
- package/dist/src/extensions/managed-marker.js +100 -0
- package/dist/src/extensions/manifest.js +196 -0
- package/dist/src/extensions/project-local-activity.js +114 -0
- package/dist/src/extensions/project-local-discovery.js +261 -0
- package/dist/src/extensions/project-local-doctor.js +281 -0
- package/dist/src/extensions/project-local-gitignore.js +176 -0
- package/dist/src/extensions/project-local-paths.js +121 -0
- package/dist/src/extensions/project-local-promote.js +218 -0
- package/dist/src/extensions/project-local-remove.js +373 -0
- package/dist/src/extensions/project-local-scaffold.js +252 -0
- package/dist/src/extensions/project-quickref.js +291 -0
- package/dist/src/extensions/registry.js +368 -0
- package/dist/src/extensions/shadow-resolver.js +271 -0
- package/dist/src/extensions/types.js +86 -0
- package/dist/src/extensions/upstream-registry.js +195 -0
- package/dist/src/extensions/validation.js +631 -0
- package/dist/src/features/catalog.js +88 -0
- package/dist/src/features/cli.js +197 -0
- package/dist/src/features/installer.js +57 -0
- package/dist/src/features/paths.js +14 -0
- package/dist/src/features/runtime.js +21 -0
- package/dist/src/features/status.js +134 -0
- package/dist/src/hooks/laziness-detection.js +532 -0
- package/dist/src/intake/git-history-analyzer.js +486 -0
- package/dist/src/intake/index.js +9 -0
- package/dist/src/issues/cli.js +327 -0
- package/dist/src/issues/index.js +5 -0
- package/dist/src/issues/live.js +154 -0
- package/dist/src/issues/local.js +666 -0
- package/dist/src/issues/sync.js +143 -0
- package/dist/src/issues/types.js +2 -0
- package/dist/src/issues/workflows.js +164 -0
- package/dist/src/kb/cli.js +173 -0
- package/dist/src/lint/cli.js +171 -0
- package/dist/src/lint/loader.js +225 -0
- package/dist/src/lint/reporters.js +141 -0
- package/dist/src/lint/runner.js +364 -0
- package/dist/src/lint/types.js +10 -0
- package/dist/src/marketplace/cache.js +110 -0
- package/dist/src/marketplace/identifier.js +63 -0
- package/dist/src/marketplace/registry.js +36 -0
- package/dist/src/marketplace/sources/clawhub.js +53 -0
- package/dist/src/marketplace/sources/git.js +45 -0
- package/dist/src/marketplace/types.js +9 -0
- package/dist/src/mcp/adapters/codex-runtime.js +224 -0
- package/dist/src/mcp/cli.mjs +1197 -0
- package/dist/src/mcp/elicitation.mjs +149 -0
- package/dist/src/mcp/helpers.mjs +287 -0
- package/dist/src/mcp/index.mjs +11 -0
- package/dist/src/mcp/profiles.js +263 -0
- package/dist/src/mcp/profiles.mjs +360 -0
- package/dist/src/mcp/registry.js +376 -0
- package/dist/src/mcp/registry.mjs +387 -0
- package/dist/src/mcp/server.mjs +633 -0
- package/dist/src/mcp/test-simple.mjs +271 -0
- package/dist/src/mcp/tools/command-run.mjs +101 -0
- package/dist/src/mcp/tools/discovery.mjs +291 -0
- package/dist/src/mcp/tools/interaction.mjs +87 -0
- package/dist/src/mcp/tools/orchestration.mjs +320 -0
- package/dist/src/mcp/tools/subsystems.mjs +640 -0
- package/dist/src/memory/cli.js +166 -0
- package/dist/src/memory/project-registry.js +282 -0
- package/dist/src/metrics/artifact-metrics.js +184 -0
- package/dist/src/metrics/context-budget.js +174 -0
- package/dist/src/metrics/token-counter.js +133 -0
- package/dist/src/models/config-loader.js +228 -0
- package/dist/src/models/index.js +22 -0
- package/dist/src/models/model-capabilities.v1.json +120 -0
- package/dist/src/models/model-catalog.v1.json +96 -0
- package/dist/src/models/model-discovery.js +521 -0
- package/dist/src/models/provider-models.js +73 -0
- package/dist/src/models/provider-policy.js +273 -0
- package/dist/src/models/resolver.js +245 -0
- package/dist/src/models/router.js +70 -0
- package/dist/src/models/types.js +8 -0
- package/dist/src/models/wrapper-deployment.js +178 -0
- package/dist/src/models/wrapper-route.js +54 -0
- package/dist/src/ops/cli.js +268 -0
- package/dist/src/ops/registry.js +623 -0
- package/dist/src/packages/adapters/clawhub.js +113 -0
- package/dist/src/packages/adapters/git.js +153 -0
- package/dist/src/packages/adapters/gitea.js +93 -0
- package/dist/src/packages/adapters/github.js +69 -0
- package/dist/src/packages/adapters/local-cache.js +89 -0
- package/dist/src/packages/package-registry.js +143 -0
- package/dist/src/packages/registry.js +238 -0
- package/dist/src/packages/types.js +11 -0
- package/dist/src/plugin/cross-framework-ops.js +475 -0
- package/dist/src/plugin/framework-config-loader.js +235 -0
- package/dist/src/plugin/framework-detector.js +186 -0
- package/dist/src/plugin/framework-isolator.js +341 -0
- package/dist/src/plugin/framework-migration.js +371 -0
- package/dist/src/plugin/metadata-validator.js +906 -0
- package/dist/src/plugin/plugin-installer.js +436 -0
- package/dist/src/plugin/plugin-status.js +369 -0
- package/dist/src/plugin/plugin-uninstaller.js +473 -0
- package/dist/src/plugin/registry-validator.js +344 -0
- package/dist/src/plugin/skill-command-translator.js +415 -0
- package/dist/src/plugin/workspace-creator.js +189 -0
- package/dist/src/plugin/workspace-migrator.js +821 -0
- package/dist/src/policy/authorization.js +390 -0
- package/dist/src/policy/repo-access.js +215 -0
- package/dist/src/provenance/cli.js +16 -0
- package/dist/src/providers/capability-matrix.js +300 -0
- package/dist/src/providers/capability-matrix.yaml +514 -0
- package/dist/src/providers/provider-definitions.js +977 -0
- package/dist/src/providers/provider-definitions.mjs +159 -0
- package/dist/src/providers/provider-inventory.js +169 -0
- package/dist/src/quality/feedback-ab.js +174 -0
- package/dist/src/quality/feedback-collector.js +176 -0
- package/dist/src/quality/feedback-tracker.js +123 -0
- package/dist/src/quality/patterns/adr.json +24 -0
- package/dist/src/quality/patterns/sad.json +24 -0
- package/dist/src/quality/patterns/test-plan.json +24 -0
- package/dist/src/quality/patterns/use-case.json +24 -0
- package/dist/src/quality/scoring.js +157 -0
- package/dist/src/reflections/cli.js +15 -0
- package/dist/src/release/plan.js +139 -0
- package/dist/src/research/cache/manager.js +227 -0
- package/dist/src/research/clients/arxiv.js +156 -0
- package/dist/src/research/clients/base.js +197 -0
- package/dist/src/research/clients/crossref.js +112 -0
- package/dist/src/research/clients/semantic-scholar.js +126 -0
- package/dist/src/research/clients/unpaywall.js +87 -0
- package/dist/src/research/index.js +14 -0
- package/dist/src/research/query-cli.js +336 -0
- package/dist/src/research/services/acquisition.js +313 -0
- package/dist/src/research/services/archival.js +225 -0
- package/dist/src/research/services/citation.js +279 -0
- package/dist/src/research/services/discovery.js +243 -0
- package/dist/src/research/services/documentation.js +269 -0
- package/dist/src/research/services/index.js +14 -0
- package/dist/src/research/services/provenance.js +279 -0
- package/dist/src/research/services/quality.js +370 -0
- package/dist/src/research/services/types.js +7 -0
- package/dist/src/research/storage-cli.js +20 -0
- package/dist/src/research/types.js +47 -0
- package/dist/src/resources/index.d.ts +2 -0
- package/dist/src/resources/index.js +2 -0
- package/dist/src/resources/web-release.d.ts +89 -0
- package/dist/src/resources/web-release.js +886 -0
- package/dist/src/rlm/cache/cli.js +162 -0
- package/dist/src/rlm/cache/hash.js +35 -0
- package/dist/src/rlm/cache/store.js +170 -0
- package/dist/src/rlm/cache/types.js +8 -0
- package/dist/src/rlm/cli.js +650 -0
- package/dist/src/serve/a2a-terminal-observer.js +120 -0
- package/dist/src/serve/agent-router.js +205 -0
- package/dist/src/serve/dispatch-router.js +171 -0
- package/dist/src/serve/executor-registry.js +715 -0
- package/dist/src/serve/mission-conductor.js +177 -0
- package/dist/src/serve/orchestrator-adapter.js +113 -0
- package/dist/src/serve/orchestrator-override.js +94 -0
- package/dist/src/serve/orchestrator-pty.js +133 -0
- package/dist/src/serve/pty-bridge.js +799 -0
- package/dist/src/serve/sandbox-registry.js +832 -0
- package/dist/src/serve/screen-reader.js +228 -0
- package/dist/src/serve/stack-adapters.js +68 -0
- package/dist/src/serve/telemetry.js +143 -0
- package/dist/src/skills/adapters/clawhub.js +250 -0
- package/dist/src/skills/adapters/local.js +335 -0
- package/dist/src/skills/adapters/openclaw.js +316 -0
- package/dist/src/skills/cli.js +334 -0
- package/dist/src/skills/registry.js +117 -0
- package/dist/src/skills/run.js +259 -0
- package/dist/src/skills/runtime.js +94 -0
- package/dist/src/skills/types.js +10 -0
- package/dist/src/smiths/agentsmith/demo.js +116 -0
- package/dist/src/smiths/agentsmith/examples.js +300 -0
- package/dist/src/smiths/agentsmith/generator.js +503 -0
- package/dist/src/smiths/agentsmith/index.js +11 -0
- package/dist/src/smiths/agentsmith/types.js +8 -0
- package/dist/src/smiths/commandsmith/example.js +220 -0
- package/dist/src/smiths/commandsmith/generator.js +288 -0
- package/dist/src/smiths/commandsmith/index.js +41 -0
- package/dist/src/smiths/commandsmith/templates.js +296 -0
- package/dist/src/smiths/commandsmith/types.js +7 -0
- package/dist/src/smiths/context-pipeline/aiwg-md.js +104 -0
- package/dist/src/smiths/context-pipeline/allowlist.js +195 -0
- package/dist/src/smiths/context-pipeline/claude-hook.js +127 -0
- package/dist/src/smiths/context-pipeline/discovery.js +187 -0
- package/dist/src/smiths/context-pipeline/external-links-section.js +49 -0
- package/dist/src/smiths/context-pipeline/finalization.js +147 -0
- package/dist/src/smiths/context-pipeline/generator.js +477 -0
- package/dist/src/smiths/context-pipeline/index.js +30 -0
- package/dist/src/smiths/context-pipeline/legacy-inject.js +103 -0
- package/dist/src/smiths/context-pipeline/managed-hook.js +95 -0
- package/dist/src/smiths/context-pipeline/overflow.js +212 -0
- package/dist/src/smiths/context-pipeline/parallelism-section.js +94 -0
- package/dist/src/smiths/context-pipeline/provider-policy.js +64 -0
- package/dist/src/smiths/context-pipeline/sanitizer.js +93 -0
- package/dist/src/smiths/context-pipeline/types.js +23 -0
- package/dist/src/smiths/context-pipeline/workspace-context.js +988 -0
- package/dist/src/smiths/hook-bridge/codex-translator.js +129 -0
- package/dist/src/smiths/hook-bridge/copilot-translator.js +64 -0
- package/dist/src/smiths/hook-bridge/factory-translator.js +43 -0
- package/dist/src/smiths/hook-bridge/hermes-translator.js +88 -0
- package/dist/src/smiths/hook-bridge/index.js +79 -0
- package/dist/src/smiths/hook-bridge/loader.js +116 -0
- package/dist/src/smiths/hook-bridge/shim.js +89 -0
- package/dist/src/smiths/hook-bridge/types.js +31 -0
- package/dist/src/smiths/index.js +39 -0
- package/dist/src/smiths/mcpsmith/analyzers/cli-analyzer.js +390 -0
- package/dist/src/smiths/mcpsmith/example.js +119 -0
- package/dist/src/smiths/mcpsmith/generator.js +236 -0
- package/dist/src/smiths/mcpsmith/index.js +17 -0
- package/dist/src/smiths/mcpsmith/types.js +10 -0
- package/dist/src/smiths/platform-paths.js +101 -0
- package/dist/src/smiths/skillsmith/codex-sidecar.js +85 -0
- package/dist/src/smiths/skillsmith/collision-detector.js +249 -0
- package/dist/src/smiths/skillsmith/demo.js +83 -0
- package/dist/src/smiths/skillsmith/examples.js +161 -0
- package/dist/src/smiths/skillsmith/generator.js +316 -0
- package/dist/src/smiths/skillsmith/index.js +12 -0
- package/dist/src/smiths/skillsmith/namespace-adapter.js +180 -0
- package/dist/src/smiths/skillsmith/platform-resolver.js +157 -0
- package/dist/src/smiths/skillsmith/types.js +9 -0
- package/dist/src/smiths/toolsmith/index.js +10 -0
- package/dist/src/smiths/toolsmith/runtime-discovery.mjs +710 -0
- package/dist/src/smiths/toolsmith/types.js +8 -0
- package/dist/src/storage/backends/fortemi.js +227 -0
- package/dist/src/storage/backends/fs.js +134 -0
- package/dist/src/storage/backends/logseq.js +309 -0
- package/dist/src/storage/backends/obsidian.js +233 -0
- package/dist/src/storage/cli.js +468 -0
- package/dist/src/storage/config.js +272 -0
- package/dist/src/storage/index.js +108 -0
- package/dist/src/storage/subsystem-cli.js +201 -0
- package/dist/src/storage/types.js +33 -0
- package/dist/src/testing/corpus/corpus-builder.js +383 -0
- package/dist/src/testing/corpus/ground-truth-manager.js +460 -0
- package/dist/src/testing/corpus/index.js +10 -0
- package/dist/src/testing/fixtures/index.js +9 -0
- package/dist/src/testing/fixtures/test-data-factory.js +472 -0
- package/dist/src/testing/generators/index.js +11 -0
- package/dist/src/testing/generators/test-case-generator.js +393 -0
- package/dist/src/testing/generators/test-code-generator.js +384 -0
- package/dist/src/testing/generators/use-case-parser.js +325 -0
- package/dist/src/testing/index.js +11 -0
- package/dist/src/tracker/capability-protocol.js +118 -0
- package/dist/src/update/checker.mjs +396 -0
- package/dist/src/update/notifier.mjs +235 -0
- package/dist/src/writing/content-diversifier.js +804 -0
- package/dist/src/writing/example-generator.js +959 -0
- package/dist/src/writing/example-templates.js +99 -0
- package/dist/src/writing/pattern-library.js +486 -0
- package/dist/src/writing/patterns/banned-phrases.json +4413 -0
- package/dist/src/writing/patterns/formulaic-structures.json +1300 -0
- package/dist/src/writing/patterns/generic-adjectives.json +1510 -0
- package/dist/src/writing/patterns/hedging-language.json +2096 -0
- package/dist/src/writing/patterns/transition-words.json +1285 -0
- package/dist/src/writing/patterns/weak-verbs.json +1112 -0
- package/dist/src/writing/prompt-optimizer.js +660 -0
- package/dist/src/writing/prompt-templates.js +583 -0
- package/dist/src/writing/scoring-config-loader.js +168 -0
- package/dist/src/writing/validation-engine.js +595 -0
- package/dist/src/writing/validation-rules.js +380 -0
- package/dist/src/writing/voice-analyzer.js +439 -0
- package/dist/src/writing/voice-calibration.js +661 -0
- package/dist/src/writing/voice-profiles.json +588 -0
- package/package.json +65 -9
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Optimization Engine
|
|
3
|
+
*
|
|
4
|
+
* Analyzes and improves prompts to reduce AI patterns and increase authentic output quality.
|
|
5
|
+
* Incorporates AIWG principles to transform vague prompts into specific,
|
|
6
|
+
* constraint-rich instructions that produce human-like content.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Core Prompt Optimizer class
|
|
10
|
+
*/
|
|
11
|
+
export class PromptOptimizer {
|
|
12
|
+
bannedPhrases;
|
|
13
|
+
constructor() {
|
|
14
|
+
this.bannedPhrases = this.loadBannedPhrases();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Core optimization - analyzes and improves a prompt
|
|
18
|
+
*/
|
|
19
|
+
async optimize(prompt, context) {
|
|
20
|
+
const analysis = this.analyzePrompt(prompt);
|
|
21
|
+
const beforeScore = analysis.score;
|
|
22
|
+
let optimized = prompt;
|
|
23
|
+
const improvements = [];
|
|
24
|
+
// Apply optimization strategies in order
|
|
25
|
+
if (this.needsSpecificity(prompt)) {
|
|
26
|
+
const result = this.addSpecificity(optimized, context);
|
|
27
|
+
if (result.improved) {
|
|
28
|
+
improvements.push({
|
|
29
|
+
type: 'specificity',
|
|
30
|
+
description: 'Added specificity to vague terms',
|
|
31
|
+
before: optimized,
|
|
32
|
+
after: result.prompt,
|
|
33
|
+
impact: 'high'
|
|
34
|
+
});
|
|
35
|
+
optimized = result.prompt;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (this.needsExamples(prompt)) {
|
|
39
|
+
const result = this.addExamples(optimized, context?.domain);
|
|
40
|
+
if (result.improved) {
|
|
41
|
+
improvements.push({
|
|
42
|
+
type: 'examples',
|
|
43
|
+
description: 'Added concrete examples for clarity',
|
|
44
|
+
before: optimized,
|
|
45
|
+
after: result.prompt,
|
|
46
|
+
impact: 'high'
|
|
47
|
+
});
|
|
48
|
+
optimized = result.prompt;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Inject voice guidance BEFORE constraints (constraints include "acknowledge trade-offs" which
|
|
52
|
+
// would trigger hasVoiceGuidance and skip voice injection)
|
|
53
|
+
if (context?.voice) {
|
|
54
|
+
const result = this.injectVoiceGuidance(optimized, context.voice);
|
|
55
|
+
if (result.improved) {
|
|
56
|
+
improvements.push({
|
|
57
|
+
type: 'voice',
|
|
58
|
+
description: `Injected ${context.voice} voice guidance`,
|
|
59
|
+
before: optimized,
|
|
60
|
+
after: result.prompt,
|
|
61
|
+
impact: 'medium'
|
|
62
|
+
});
|
|
63
|
+
optimized = result.prompt;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (this.needsConstraints(prompt)) {
|
|
67
|
+
const constraints = this.generateConstraints(context);
|
|
68
|
+
const result = this.addConstraints(optimized, constraints);
|
|
69
|
+
if (result.improved) {
|
|
70
|
+
improvements.push({
|
|
71
|
+
type: 'constraints',
|
|
72
|
+
description: 'Added AIWG constraints',
|
|
73
|
+
before: optimized,
|
|
74
|
+
after: result.prompt,
|
|
75
|
+
impact: 'high'
|
|
76
|
+
});
|
|
77
|
+
optimized = result.prompt;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Remove vagueness
|
|
81
|
+
const vagueResult = this.removeVagueness(optimized);
|
|
82
|
+
if (vagueResult.improved) {
|
|
83
|
+
improvements.push({
|
|
84
|
+
type: 'specificity',
|
|
85
|
+
description: 'Removed vague language',
|
|
86
|
+
before: optimized,
|
|
87
|
+
after: vagueResult.prompt,
|
|
88
|
+
impact: 'medium'
|
|
89
|
+
});
|
|
90
|
+
optimized = vagueResult.prompt;
|
|
91
|
+
}
|
|
92
|
+
// Detect and fix anti-patterns
|
|
93
|
+
const antiPatterns = this.detectAntiPatterns(optimized);
|
|
94
|
+
for (const pattern of antiPatterns) {
|
|
95
|
+
const fixed = this.fixAntiPattern(optimized, pattern);
|
|
96
|
+
if (fixed !== optimized) {
|
|
97
|
+
improvements.push({
|
|
98
|
+
type: 'anti_pattern',
|
|
99
|
+
description: `Removed anti-pattern: ${pattern.description}`,
|
|
100
|
+
before: optimized,
|
|
101
|
+
after: fixed,
|
|
102
|
+
impact: 'high'
|
|
103
|
+
});
|
|
104
|
+
optimized = fixed;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const afterScore = this.scorePromptQuality(optimized);
|
|
108
|
+
return {
|
|
109
|
+
originalPrompt: prompt,
|
|
110
|
+
optimizedPrompt: optimized,
|
|
111
|
+
improvements,
|
|
112
|
+
score: {
|
|
113
|
+
before: beforeScore,
|
|
114
|
+
after: afterScore,
|
|
115
|
+
delta: afterScore - beforeScore
|
|
116
|
+
},
|
|
117
|
+
reasoning: this.generateReasoning(improvements, beforeScore, afterScore)
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Batch optimization - process multiple prompts
|
|
122
|
+
*/
|
|
123
|
+
async optimizeBatch(prompts) {
|
|
124
|
+
const results = new Map();
|
|
125
|
+
// Process in parallel batches of 10
|
|
126
|
+
const batchSize = 10;
|
|
127
|
+
for (let i = 0; i < prompts.length; i += batchSize) {
|
|
128
|
+
const batch = prompts.slice(i, i + batchSize);
|
|
129
|
+
const batchResults = await Promise.all(batch.map(p => this.optimize(p)));
|
|
130
|
+
batch.forEach((prompt, idx) => {
|
|
131
|
+
results.set(prompt, batchResults[idx]);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return results;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Analyze prompt quality
|
|
138
|
+
*/
|
|
139
|
+
analyzePrompt(prompt) {
|
|
140
|
+
const issues = [];
|
|
141
|
+
const strengths = [];
|
|
142
|
+
const antiPatterns = this.detectAntiPatterns(prompt);
|
|
143
|
+
const suggestions = [];
|
|
144
|
+
// Check for specificity
|
|
145
|
+
if (this.isVague(prompt)) {
|
|
146
|
+
issues.push({
|
|
147
|
+
severity: 'critical',
|
|
148
|
+
category: 'specificity',
|
|
149
|
+
message: 'Prompt lacks specific details and concrete examples'
|
|
150
|
+
});
|
|
151
|
+
suggestions.push('Add specific topics, technologies, or concepts');
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
strengths.push('Contains specific details');
|
|
155
|
+
}
|
|
156
|
+
// Check for constraints
|
|
157
|
+
if (!this.hasConstraints(prompt)) {
|
|
158
|
+
issues.push({
|
|
159
|
+
severity: 'warning',
|
|
160
|
+
category: 'constraints',
|
|
161
|
+
message: 'No constraints or guidelines specified'
|
|
162
|
+
});
|
|
163
|
+
suggestions.push('Add constraints to avoid AI patterns (word count, format, etc.)');
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
strengths.push('Includes constraints or guidelines');
|
|
167
|
+
}
|
|
168
|
+
// Check for examples
|
|
169
|
+
if (!this.hasExamples(prompt)) {
|
|
170
|
+
issues.push({
|
|
171
|
+
severity: 'warning',
|
|
172
|
+
category: 'examples',
|
|
173
|
+
message: 'No examples provided'
|
|
174
|
+
});
|
|
175
|
+
suggestions.push('Add concrete examples of desired output');
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
strengths.push('Provides examples');
|
|
179
|
+
}
|
|
180
|
+
// Check for audience specification
|
|
181
|
+
if (!this.hasAudience(prompt)) {
|
|
182
|
+
issues.push({
|
|
183
|
+
severity: 'info',
|
|
184
|
+
category: 'audience',
|
|
185
|
+
message: 'Target audience not specified'
|
|
186
|
+
});
|
|
187
|
+
suggestions.push('Specify target audience or expertise level');
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
strengths.push('Audience clearly defined');
|
|
191
|
+
}
|
|
192
|
+
// Check for format specification
|
|
193
|
+
if (!this.hasFormat(prompt)) {
|
|
194
|
+
issues.push({
|
|
195
|
+
severity: 'info',
|
|
196
|
+
category: 'format',
|
|
197
|
+
message: 'Output format not specified'
|
|
198
|
+
});
|
|
199
|
+
suggestions.push('Specify desired format (article, report, analysis, etc.)');
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
strengths.push('Output format specified');
|
|
203
|
+
}
|
|
204
|
+
// Anti-pattern warnings
|
|
205
|
+
if (antiPatterns.length > 0) {
|
|
206
|
+
issues.push({
|
|
207
|
+
severity: 'critical',
|
|
208
|
+
category: 'anti_pattern',
|
|
209
|
+
message: `Found ${antiPatterns.length} anti-pattern(s) that guarantee AI output`
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
const score = this.scorePromptQuality(prompt);
|
|
213
|
+
return {
|
|
214
|
+
score,
|
|
215
|
+
issues,
|
|
216
|
+
strengths,
|
|
217
|
+
antiPatterns,
|
|
218
|
+
suggestions
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Detect anti-patterns in prompts
|
|
223
|
+
*/
|
|
224
|
+
detectAntiPatterns(prompt) {
|
|
225
|
+
const patterns = [];
|
|
226
|
+
// Vague requests
|
|
227
|
+
if (/^write (about|an article|a guide)/i.test(prompt)) {
|
|
228
|
+
patterns.push({
|
|
229
|
+
pattern: 'vague_request',
|
|
230
|
+
description: 'Generic "write about" request with no specifics',
|
|
231
|
+
example: 'Write about authentication',
|
|
232
|
+
fix: 'Write about OAuth 2.0 authentication for mobile apps, focusing on PKCE flow',
|
|
233
|
+
locations: [0]
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
// No constraints
|
|
237
|
+
if (!/(avoid|don't|never use|exclude|without)/i.test(prompt)) {
|
|
238
|
+
patterns.push({
|
|
239
|
+
pattern: 'no_constraints',
|
|
240
|
+
description: 'No constraints or anti-patterns specified',
|
|
241
|
+
example: 'Write an article',
|
|
242
|
+
fix: 'Write an article that: 1) Avoids "delve into" and "it\'s important to note", 2) Includes metrics',
|
|
243
|
+
locations: []
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
// Asks for "comprehensive" or "robust" (but not when instructing to AVOID them)
|
|
247
|
+
const badWords = ['comprehensive', 'robust', 'innovative', 'cutting-edge', 'seamless'];
|
|
248
|
+
for (const word of badWords) {
|
|
249
|
+
const regex = new RegExp(`\\b${word}\\b`, 'gi');
|
|
250
|
+
const matches = Array.from(prompt.matchAll(regex));
|
|
251
|
+
// Filter out matches that are preceded by "avoid" within 100 chars (to handle lists of words to avoid)
|
|
252
|
+
const realMatches = matches.filter(m => {
|
|
253
|
+
const idx = m.index || 0;
|
|
254
|
+
const preceding = prompt.slice(Math.max(0, idx - 100), idx).toLowerCase();
|
|
255
|
+
return !preceding.includes('avoid');
|
|
256
|
+
});
|
|
257
|
+
if (realMatches.length > 0) {
|
|
258
|
+
patterns.push({
|
|
259
|
+
pattern: 'ai_trigger_word',
|
|
260
|
+
description: `Contains AI trigger word: "${word}"`,
|
|
261
|
+
example: `Write a comprehensive guide`,
|
|
262
|
+
fix: `Write a 1,500-word guide covering A, B, and C`,
|
|
263
|
+
locations: realMatches.map(m => m.index || 0)
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
// Generic tone request
|
|
268
|
+
if (/professional tone|formal tone|casual tone/i.test(prompt) && !/avoid|don't use/i.test(prompt)) {
|
|
269
|
+
patterns.push({
|
|
270
|
+
pattern: 'generic_tone',
|
|
271
|
+
description: 'Generic tone request without specific guidance',
|
|
272
|
+
example: 'Use a professional tone',
|
|
273
|
+
fix: 'Write for senior developers. Use technical precision, acknowledge edge cases',
|
|
274
|
+
locations: []
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
return patterns;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Score prompt quality (0-100)
|
|
281
|
+
*/
|
|
282
|
+
scorePromptQuality(prompt) {
|
|
283
|
+
// Empty or whitespace-only prompts get 0
|
|
284
|
+
if (!prompt || !prompt.trim()) {
|
|
285
|
+
return 0;
|
|
286
|
+
}
|
|
287
|
+
let score = 50; // baseline
|
|
288
|
+
// Positive factors
|
|
289
|
+
if (this.hasAudience(prompt))
|
|
290
|
+
score += 10;
|
|
291
|
+
if (this.hasExamples(prompt))
|
|
292
|
+
score += 10;
|
|
293
|
+
if (this.hasFormat(prompt))
|
|
294
|
+
score += 10;
|
|
295
|
+
if (this.hasConstraints(prompt))
|
|
296
|
+
score += 10;
|
|
297
|
+
if (this.hasVoiceGuidance(prompt))
|
|
298
|
+
score += 10;
|
|
299
|
+
if (this.hasMetrics(prompt))
|
|
300
|
+
score += 5;
|
|
301
|
+
if (this.hasNumericMetrics(prompt))
|
|
302
|
+
score += 3; // Bonus for actual numbers
|
|
303
|
+
if (this.hasSpecificTechnologies(prompt))
|
|
304
|
+
score += 5;
|
|
305
|
+
// Negative factors
|
|
306
|
+
const antiPatterns = this.detectAntiPatterns(prompt);
|
|
307
|
+
score -= antiPatterns.length * 10;
|
|
308
|
+
if (this.isVague(prompt))
|
|
309
|
+
score -= 20;
|
|
310
|
+
if (this.hasBannedPhrases(prompt))
|
|
311
|
+
score -= 15;
|
|
312
|
+
// Clamp to 0-100
|
|
313
|
+
return Math.max(0, Math.min(100, score));
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Add specificity to vague prompts
|
|
317
|
+
*/
|
|
318
|
+
addSpecificity(prompt, context) {
|
|
319
|
+
let improved = false;
|
|
320
|
+
let result = prompt;
|
|
321
|
+
// Replace vague "write about X" with specific focus
|
|
322
|
+
const writeAboutMatch = prompt.match(/write (about|an article about|a guide about) (\w+)/i);
|
|
323
|
+
if (writeAboutMatch) {
|
|
324
|
+
const topic = writeAboutMatch[2];
|
|
325
|
+
const specificTopic = this.makeTopicSpecific(topic, context?.domain);
|
|
326
|
+
result = prompt.replace(writeAboutMatch[0], `Write about ${specificTopic}`);
|
|
327
|
+
improved = true;
|
|
328
|
+
}
|
|
329
|
+
// Add word count if missing
|
|
330
|
+
if (!/\d+[\s-]word/i.test(result) && context?.targetLength) {
|
|
331
|
+
result = `Write a ${context.targetLength}-word ${result.replace(/^write (a |an )?/i, '')}`;
|
|
332
|
+
improved = true;
|
|
333
|
+
}
|
|
334
|
+
return { prompt: result, improved };
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Add examples to prompts
|
|
338
|
+
*/
|
|
339
|
+
addExamples(prompt, domain) {
|
|
340
|
+
if (this.hasExamples(prompt)) {
|
|
341
|
+
return { prompt, improved: false };
|
|
342
|
+
}
|
|
343
|
+
const exampleGuidance = this.generateExampleGuidance(domain);
|
|
344
|
+
const result = `${prompt}\n\n${exampleGuidance}`;
|
|
345
|
+
return { prompt: result, improved: true };
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Add constraints to avoid AI patterns
|
|
349
|
+
*/
|
|
350
|
+
addConstraints(prompt, rules) {
|
|
351
|
+
if (this.hasConstraints(prompt) && rules.length === 0) {
|
|
352
|
+
return { prompt, improved: false };
|
|
353
|
+
}
|
|
354
|
+
const constraintsSection = this.formatConstraints(rules);
|
|
355
|
+
const result = `${prompt}\n\n${constraintsSection}`;
|
|
356
|
+
return { prompt: result, improved: true };
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Inject voice guidance for different contexts
|
|
360
|
+
*/
|
|
361
|
+
injectVoiceGuidance(prompt, voice) {
|
|
362
|
+
if (this.hasVoiceGuidance(prompt)) {
|
|
363
|
+
return { prompt, improved: false };
|
|
364
|
+
}
|
|
365
|
+
const guidance = this.getVoiceGuidance(voice);
|
|
366
|
+
const result = `${prompt}\n\n${guidance}`;
|
|
367
|
+
return { prompt: result, improved: true };
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Remove vague language
|
|
371
|
+
*/
|
|
372
|
+
removeVagueness(prompt) {
|
|
373
|
+
let result = prompt;
|
|
374
|
+
let improved = false;
|
|
375
|
+
const vagueReplacements = {
|
|
376
|
+
'comprehensive guide': 'guide covering [specific topics]',
|
|
377
|
+
'robust solution': '[specific system description]',
|
|
378
|
+
'innovative approach': '[specific method or technique]',
|
|
379
|
+
'cutting-edge': 'new',
|
|
380
|
+
'state-of-the-art': 'current',
|
|
381
|
+
'best practices': 'specific techniques',
|
|
382
|
+
'industry standard': '[name specific standard]'
|
|
383
|
+
};
|
|
384
|
+
for (const [vague, specific] of Object.entries(vagueReplacements)) {
|
|
385
|
+
const regex = new RegExp(vague, 'gi');
|
|
386
|
+
if (regex.test(result)) {
|
|
387
|
+
result = result.replace(regex, specific);
|
|
388
|
+
improved = true;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return { prompt: result, improved };
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Compare original and optimized prompts
|
|
395
|
+
*/
|
|
396
|
+
comparePrompts(original, optimized) {
|
|
397
|
+
const differences = [];
|
|
398
|
+
// Simple diff based on line-by-line comparison
|
|
399
|
+
const originalLines = original.split('\n');
|
|
400
|
+
const optimizedLines = optimized.split('\n');
|
|
401
|
+
const maxLines = Math.max(originalLines.length, optimizedLines.length);
|
|
402
|
+
for (let i = 0; i < maxLines; i++) {
|
|
403
|
+
const origLine = originalLines[i] || '';
|
|
404
|
+
const optLine = optimizedLines[i] || '';
|
|
405
|
+
if (origLine !== optLine) {
|
|
406
|
+
if (!origLine) {
|
|
407
|
+
differences.push({
|
|
408
|
+
type: 'added',
|
|
409
|
+
after: optLine,
|
|
410
|
+
reason: 'Added new guidance'
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
else if (!optLine) {
|
|
414
|
+
differences.push({
|
|
415
|
+
type: 'removed',
|
|
416
|
+
before: origLine,
|
|
417
|
+
reason: 'Removed vague language'
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
differences.push({
|
|
422
|
+
type: 'modified',
|
|
423
|
+
before: origLine,
|
|
424
|
+
after: optLine,
|
|
425
|
+
reason: 'Enhanced specificity'
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
const originalScore = this.scorePromptQuality(original);
|
|
431
|
+
const optimizedScore = this.scorePromptQuality(optimized);
|
|
432
|
+
const improvement = optimizedScore - originalScore;
|
|
433
|
+
const summary = this.generateComparisonSummary(differences, improvement);
|
|
434
|
+
return {
|
|
435
|
+
differences,
|
|
436
|
+
improvement,
|
|
437
|
+
summary
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Load principles from AIWG
|
|
442
|
+
*/
|
|
443
|
+
loadPrinciplesFromGuide(_guidePath) {
|
|
444
|
+
// This would read from the guide files
|
|
445
|
+
// For now, we use the default principles
|
|
446
|
+
}
|
|
447
|
+
// Private helper methods
|
|
448
|
+
loadBannedPhrases() {
|
|
449
|
+
return new Set([
|
|
450
|
+
'plays a vital role', 'plays a crucial role', 'plays a key role',
|
|
451
|
+
'seamlessly', 'cutting-edge', 'state-of-the-art',
|
|
452
|
+
'comprehensive', 'robust', 'innovative',
|
|
453
|
+
'moreover', 'furthermore', 'additionally',
|
|
454
|
+
'in conclusion', 'to summarize', 'delve into',
|
|
455
|
+
'it is important to note', 'it is worth noting',
|
|
456
|
+
'revolutionary', 'game-changing', 'transformative',
|
|
457
|
+
'next-generation', 'best-in-class', 'industry-leading'
|
|
458
|
+
]);
|
|
459
|
+
}
|
|
460
|
+
needsSpecificity(prompt) {
|
|
461
|
+
return this.isVague(prompt);
|
|
462
|
+
}
|
|
463
|
+
needsExamples(prompt) {
|
|
464
|
+
return !this.hasExamples(prompt);
|
|
465
|
+
}
|
|
466
|
+
needsConstraints(prompt) {
|
|
467
|
+
return !this.hasConstraints(prompt);
|
|
468
|
+
}
|
|
469
|
+
isVague(prompt) {
|
|
470
|
+
const vagueIndicators = [
|
|
471
|
+
/^write about \w+$/i,
|
|
472
|
+
/^explain \w+$/i,
|
|
473
|
+
/^describe \w+$/i,
|
|
474
|
+
/write (a|an) (article|guide|document)$/i
|
|
475
|
+
];
|
|
476
|
+
return vagueIndicators.some(pattern => pattern.test(prompt.trim()));
|
|
477
|
+
}
|
|
478
|
+
hasConstraints(prompt) {
|
|
479
|
+
const constraintIndicators = [
|
|
480
|
+
/avoid/i, /don't use/i, /never use/i, /exclude/i,
|
|
481
|
+
/requirements?:?/i, /constraints?:?/i, /guidelines?:?/i,
|
|
482
|
+
/must not/i, /should not/i
|
|
483
|
+
];
|
|
484
|
+
return constraintIndicators.some(pattern => pattern.test(prompt));
|
|
485
|
+
}
|
|
486
|
+
hasExamples(prompt) {
|
|
487
|
+
const exampleIndicators = [
|
|
488
|
+
/examples?:?/i, /for example/i, /such as/i,
|
|
489
|
+
/like this:?/i, /format:?/i, /structure:?/i
|
|
490
|
+
];
|
|
491
|
+
return exampleIndicators.some(pattern => pattern.test(prompt));
|
|
492
|
+
}
|
|
493
|
+
hasAudience(prompt) {
|
|
494
|
+
const audienceIndicators = [
|
|
495
|
+
// "for X engineers/developers" where X can be backend, frontend, senior, etc.
|
|
496
|
+
/for\s+(\w+\s+)?(developers|engineers|executives|managers|students|beginners|experts)/i,
|
|
497
|
+
/(senior|junior|lead|staff|backend|frontend|fullstack|full-stack)\s+(developers?|engineers?)/i,
|
|
498
|
+
/audience:?/i, /readers?:?/i, /target\s+(senior|developers?|engineers?|audience)/i,
|
|
499
|
+
// Common audience qualifiers
|
|
500
|
+
/(DBAs|DevOps|SREs|architects|administrators)/i
|
|
501
|
+
];
|
|
502
|
+
return audienceIndicators.some(pattern => pattern.test(prompt));
|
|
503
|
+
}
|
|
504
|
+
hasFormat(prompt) {
|
|
505
|
+
const formatIndicators = [
|
|
506
|
+
/\d+[\s-]word/i, /\d+ words/i, /\d+ pages/i,
|
|
507
|
+
/(article|report|guide|tutorial|analysis|summary|documentation)/i,
|
|
508
|
+
/format:/i, /structure:/i
|
|
509
|
+
];
|
|
510
|
+
return formatIndicators.some(pattern => pattern.test(prompt));
|
|
511
|
+
}
|
|
512
|
+
hasVoiceGuidance(prompt) {
|
|
513
|
+
const voiceIndicators = [
|
|
514
|
+
/technical precision/i, /acknowledge\s+(trade-?offs|edge cases|limitations)/i,
|
|
515
|
+
/include opinions?/i, /based on experience/i,
|
|
516
|
+
/reference (real-world|actual) (challenges|implementation)/i,
|
|
517
|
+
/what goes wrong/i, /real-world scenarios/i
|
|
518
|
+
];
|
|
519
|
+
return voiceIndicators.some(pattern => pattern.test(prompt));
|
|
520
|
+
}
|
|
521
|
+
hasMetrics(prompt) {
|
|
522
|
+
// Match actual numeric metrics (higher value) - space is optional between number and unit
|
|
523
|
+
return /\d+%|\d+\s?(ms|seconds?|requests?|users?|bytes?|MB|GB|KB|TB)/i.test(prompt) ||
|
|
524
|
+
/(performance|benchmarks?|hit rates?|latency)/i.test(prompt);
|
|
525
|
+
}
|
|
526
|
+
hasNumericMetrics(prompt) {
|
|
527
|
+
// Match actual numeric values with units (more specific than just keywords)
|
|
528
|
+
return /\d+%|\d+\s?(ms|seconds?|requests?|users?|bytes?|MB|GB|KB|TB)/i.test(prompt);
|
|
529
|
+
}
|
|
530
|
+
hasSpecificTechnologies(prompt) {
|
|
531
|
+
const techPattern = /\b(OAuth|JWT|REST|GraphQL|React|Node|Python|Docker|Kubernetes|AWS|Azure|Redis|PostgreSQL|MongoDB|MySQL|Elasticsearch)\b/i;
|
|
532
|
+
return techPattern.test(prompt);
|
|
533
|
+
}
|
|
534
|
+
hasBannedPhrases(prompt) {
|
|
535
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
536
|
+
// Don't penalize if the banned phrase appears after "avoid" instruction
|
|
537
|
+
return Array.from(this.bannedPhrases).some(phrase => {
|
|
538
|
+
const idx = lowerPrompt.indexOf(phrase.toLowerCase());
|
|
539
|
+
if (idx === -1)
|
|
540
|
+
return false;
|
|
541
|
+
// Check if "avoid" appears within 50 chars before this phrase
|
|
542
|
+
const preceding = lowerPrompt.slice(Math.max(0, idx - 50), idx);
|
|
543
|
+
return !preceding.includes('avoid');
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
makeTopicSpecific(topic, _domain) {
|
|
547
|
+
// Add context-specific details
|
|
548
|
+
const examples = {
|
|
549
|
+
authentication: 'OAuth 2.0 authentication for mobile apps, focusing on PKCE flow and token refresh strategies',
|
|
550
|
+
security: 'application security focusing on OWASP Top 10 vulnerabilities with code examples',
|
|
551
|
+
performance: 'backend performance optimization using caching, database indexing, and query optimization',
|
|
552
|
+
testing: 'integration testing strategies for microservices with contract testing and service virtualization',
|
|
553
|
+
deployment: 'CI/CD pipeline implementation with GitHub Actions, including automated testing and rollback strategies'
|
|
554
|
+
};
|
|
555
|
+
return examples[topic.toLowerCase()] || `${topic} (specify exact subtopic, technologies, and scope)`;
|
|
556
|
+
}
|
|
557
|
+
generateConstraints(context) {
|
|
558
|
+
const baseConstraints = [
|
|
559
|
+
'Avoid AI detection patterns (no "delve into", "it\'s important to note", "seamlessly", etc.)',
|
|
560
|
+
'Include specific metrics and performance numbers where relevant',
|
|
561
|
+
'Acknowledge trade-offs and edge cases',
|
|
562
|
+
'Use varied sentence structure (mix short and long sentences)',
|
|
563
|
+
'Provide concrete code examples or specific implementation details'
|
|
564
|
+
];
|
|
565
|
+
if (context?.domain === 'technical') {
|
|
566
|
+
baseConstraints.push('Reference real-world implementation challenges', 'Include version numbers and specific tools', 'Mention what failed or what was difficult');
|
|
567
|
+
}
|
|
568
|
+
if (context?.domain === 'academic') {
|
|
569
|
+
baseConstraints.push('Cite specific sources', 'Acknowledge limitations and counterarguments', 'Use discipline-appropriate terminology');
|
|
570
|
+
}
|
|
571
|
+
if (context?.domain === 'executive') {
|
|
572
|
+
baseConstraints.push('Start with bottom-line impact (dollars, time, risk)', 'Avoid hedging - state positions clearly', 'Include 2-3 specific recommendations with rationale');
|
|
573
|
+
}
|
|
574
|
+
// Include user-provided custom constraints
|
|
575
|
+
if (context?.constraints && context.constraints.length > 0) {
|
|
576
|
+
baseConstraints.push(...context.constraints);
|
|
577
|
+
}
|
|
578
|
+
return baseConstraints;
|
|
579
|
+
}
|
|
580
|
+
generateExampleGuidance(domain) {
|
|
581
|
+
const base = 'Include concrete examples showing:\n- Specific scenario or use case\n- Expected input and output\n- Key implementation details';
|
|
582
|
+
if (domain === 'technical') {
|
|
583
|
+
return `${base}\n- Code snippets or architecture diagrams\n- Performance metrics and benchmarks`;
|
|
584
|
+
}
|
|
585
|
+
return base;
|
|
586
|
+
}
|
|
587
|
+
formatConstraints(rules) {
|
|
588
|
+
if (rules.length === 0) {
|
|
589
|
+
return '';
|
|
590
|
+
}
|
|
591
|
+
return `Requirements:\n${rules.map((r, i) => `${i + 1}. ${r}`).join('\n')}`;
|
|
592
|
+
}
|
|
593
|
+
getVoiceGuidance(voice) {
|
|
594
|
+
const guidance = {
|
|
595
|
+
academic: `Voice: Use academic style with:
|
|
596
|
+
- Discipline-appropriate terminology (not simplified)
|
|
597
|
+
- Cite specific sources and methodologies
|
|
598
|
+
- Acknowledge limitations and counterarguments
|
|
599
|
+
- Maintain formal but not stilted tone
|
|
600
|
+
- Avoid AI patterns like "it is worth noting"`,
|
|
601
|
+
technical: `Voice: Use technical style with:
|
|
602
|
+
- Write for senior developers/engineers
|
|
603
|
+
- Use technical precision and domain vocabulary
|
|
604
|
+
- Include opinions based on experience
|
|
605
|
+
- Acknowledge edge cases and failure modes
|
|
606
|
+
- Reference actual implementation challenges you've faced
|
|
607
|
+
- Avoid generic descriptions - be specific about technologies and versions`,
|
|
608
|
+
executive: `Voice: Use executive style with:
|
|
609
|
+
- Start with bottom-line impact (financial, time, risk)
|
|
610
|
+
- Avoid hedging - state clear positions
|
|
611
|
+
- Maximum brevity while maintaining completeness
|
|
612
|
+
- Include 2-3 specific recommendations with rationale
|
|
613
|
+
- No filler phrases or platitudes`
|
|
614
|
+
};
|
|
615
|
+
return guidance[voice] || '';
|
|
616
|
+
}
|
|
617
|
+
fixAntiPattern(prompt, pattern) {
|
|
618
|
+
// Basic fixes for common anti-patterns
|
|
619
|
+
if (pattern.pattern === 'vague_request') {
|
|
620
|
+
return prompt.replace(/^write (about|an article about|a guide about)/i, 'Write a detailed technical article about');
|
|
621
|
+
}
|
|
622
|
+
if (pattern.pattern === 'ai_trigger_word') {
|
|
623
|
+
let result = prompt;
|
|
624
|
+
// Remove trigger words
|
|
625
|
+
for (const word of ['comprehensive', 'robust', 'innovative', 'cutting-edge', 'seamless']) {
|
|
626
|
+
result = result.replace(new RegExp(`\\b${word}\\b`, 'gi'), '');
|
|
627
|
+
}
|
|
628
|
+
return result.replace(/\s+/g, ' ').trim();
|
|
629
|
+
}
|
|
630
|
+
return prompt;
|
|
631
|
+
}
|
|
632
|
+
generateReasoning(improvements, beforeScore, afterScore) {
|
|
633
|
+
const lines = [];
|
|
634
|
+
lines.push(`Original prompt scored ${beforeScore}/100.`);
|
|
635
|
+
if (improvements.length === 0) {
|
|
636
|
+
lines.push('No improvements needed - prompt already well-optimized.');
|
|
637
|
+
return lines.join(' ');
|
|
638
|
+
}
|
|
639
|
+
lines.push(`Applied ${improvements.length} optimization(s):`);
|
|
640
|
+
const highImpact = improvements.filter(i => i.impact === 'high');
|
|
641
|
+
const mediumImpact = improvements.filter(i => i.impact === 'medium');
|
|
642
|
+
if (highImpact.length > 0) {
|
|
643
|
+
lines.push(`\nHigh-impact changes (${highImpact.length}):`);
|
|
644
|
+
highImpact.forEach(i => lines.push(`- ${i.description}`));
|
|
645
|
+
}
|
|
646
|
+
if (mediumImpact.length > 0) {
|
|
647
|
+
lines.push(`\nMedium-impact changes (${mediumImpact.length}):`);
|
|
648
|
+
mediumImpact.forEach(i => lines.push(`- ${i.description}`));
|
|
649
|
+
}
|
|
650
|
+
lines.push(`\nOptimized prompt now scores ${afterScore}/100 (+${afterScore - beforeScore} points).`);
|
|
651
|
+
return lines.join('\n');
|
|
652
|
+
}
|
|
653
|
+
generateComparisonSummary(differences, improvement) {
|
|
654
|
+
const added = differences.filter(d => d.type === 'added').length;
|
|
655
|
+
const removed = differences.filter(d => d.type === 'removed').length;
|
|
656
|
+
const modified = differences.filter(d => d.type === 'modified').length;
|
|
657
|
+
return `Changed ${differences.length} section(s): ${added} added, ${removed} removed, ${modified} modified. Overall improvement: ${improvement > 0 ? '+' : ''}${improvement} points.`;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
//# sourceMappingURL=prompt-optimizer.js.map
|