@vpxa/aikit 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1207 -0
- package/bin/aikit.mjs +10 -0
- package/package.json +92 -0
- package/packages/aikit-client/dist/direct-client.d.ts +37 -0
- package/packages/aikit-client/dist/direct-client.js +1 -0
- package/packages/aikit-client/dist/index.d.ts +5 -0
- package/packages/aikit-client/dist/index.js +1 -0
- package/packages/aikit-client/dist/mcp-client.d.ts +19 -0
- package/packages/aikit-client/dist/mcp-client.js +4 -0
- package/packages/aikit-client/dist/parsers.d.ts +35 -0
- package/packages/aikit-client/dist/parsers.js +2 -0
- package/packages/aikit-client/dist/types.d.ts +62 -0
- package/packages/aikit-client/dist/types.js +1 -0
- package/packages/analyzers/dist/blast-radius-analyzer.d.ts +19 -0
- package/packages/analyzers/dist/blast-radius-analyzer.js +6 -0
- package/packages/analyzers/dist/dependency-analyzer.d.ts +32 -0
- package/packages/analyzers/dist/dependency-analyzer.js +8 -0
- package/packages/analyzers/dist/diagram-generator.d.ts +16 -0
- package/packages/analyzers/dist/diagram-generator.js +2 -0
- package/packages/analyzers/dist/entry-point-analyzer.d.ts +40 -0
- package/packages/analyzers/dist/entry-point-analyzer.js +4 -0
- package/packages/analyzers/dist/index.d.ts +12 -0
- package/packages/analyzers/dist/index.js +1 -0
- package/packages/analyzers/dist/knowledge-producer.d.ts +40 -0
- package/packages/analyzers/dist/knowledge-producer.js +26 -0
- package/packages/analyzers/dist/pattern-analyzer.d.ts +15 -0
- package/packages/analyzers/dist/pattern-analyzer.js +2 -0
- package/packages/analyzers/dist/regex-call-graph.d.ts +10 -0
- package/packages/analyzers/dist/regex-call-graph.js +1 -0
- package/packages/analyzers/dist/structure-analyzer.d.ts +19 -0
- package/packages/analyzers/dist/structure-analyzer.js +4 -0
- package/packages/analyzers/dist/symbol-analyzer.d.ts +14 -0
- package/packages/analyzers/dist/symbol-analyzer.js +9 -0
- package/packages/analyzers/dist/ts-call-graph.d.ts +29 -0
- package/packages/analyzers/dist/ts-call-graph.js +1 -0
- package/packages/analyzers/dist/types.d.ts +110 -0
- package/packages/analyzers/dist/types.js +1 -0
- package/packages/chunker/dist/call-graph-extractor.d.ts +25 -0
- package/packages/chunker/dist/call-graph-extractor.js +1 -0
- package/packages/chunker/dist/chunker-factory.d.ts +19 -0
- package/packages/chunker/dist/chunker-factory.js +1 -0
- package/packages/chunker/dist/chunker.interface.d.ts +13 -0
- package/packages/chunker/dist/chunker.interface.js +1 -0
- package/packages/chunker/dist/code-chunker.d.ts +17 -0
- package/packages/chunker/dist/code-chunker.js +11 -0
- package/packages/chunker/dist/extractors/call-extractor.d.ts +24 -0
- package/packages/chunker/dist/extractors/call-extractor.js +1 -0
- package/packages/chunker/dist/extractors/entry-point-detector.d.ts +14 -0
- package/packages/chunker/dist/extractors/entry-point-detector.js +1 -0
- package/packages/chunker/dist/extractors/import-extractor.d.ts +14 -0
- package/packages/chunker/dist/extractors/import-extractor.js +1 -0
- package/packages/chunker/dist/extractors/pattern-detector.d.ts +14 -0
- package/packages/chunker/dist/extractors/pattern-detector.js +1 -0
- package/packages/chunker/dist/extractors/scope-resolver.d.ts +26 -0
- package/packages/chunker/dist/extractors/scope-resolver.js +1 -0
- package/packages/chunker/dist/extractors/symbol-extractor.d.ts +14 -0
- package/packages/chunker/dist/extractors/symbol-extractor.js +3 -0
- package/packages/chunker/dist/extractors/types.d.ts +44 -0
- package/packages/chunker/dist/extractors/types.js +1 -0
- package/packages/chunker/dist/generic-chunker.d.ts +15 -0
- package/packages/chunker/dist/generic-chunker.js +5 -0
- package/packages/chunker/dist/index.d.ts +19 -0
- package/packages/chunker/dist/index.js +1 -0
- package/packages/chunker/dist/markdown-chunker.d.ts +17 -0
- package/packages/chunker/dist/markdown-chunker.js +3 -0
- package/packages/chunker/dist/wasm/languages.d.ts +18 -0
- package/packages/chunker/dist/wasm/languages.js +1 -0
- package/packages/chunker/dist/wasm/query-executor.d.ts +70 -0
- package/packages/chunker/dist/wasm/query-executor.js +1 -0
- package/packages/chunker/dist/wasm/runtime.d.ts +44 -0
- package/packages/chunker/dist/wasm/runtime.js +1 -0
- package/packages/chunker/dist/wasm/types.d.ts +84 -0
- package/packages/chunker/dist/wasm/types.js +1 -0
- package/packages/chunker/dist/wasm-chunker.d.ts +23 -0
- package/packages/chunker/dist/wasm-chunker.js +6 -0
- package/packages/chunker/src/queries/go/calls.scm +11 -0
- package/packages/chunker/src/queries/go/entry-points.scm +20 -0
- package/packages/chunker/src/queries/go/imports.scm +6 -0
- package/packages/chunker/src/queries/go/patterns.scm +25 -0
- package/packages/chunker/src/queries/go/symbols.scm +26 -0
- package/packages/chunker/src/queries/java/calls.scm +10 -0
- package/packages/chunker/src/queries/java/entry-points.scm +27 -0
- package/packages/chunker/src/queries/java/imports.scm +11 -0
- package/packages/chunker/src/queries/java/patterns.scm +27 -0
- package/packages/chunker/src/queries/java/symbols.scm +28 -0
- package/packages/chunker/src/queries/javascript/calls.scm +21 -0
- package/packages/chunker/src/queries/javascript/entry-points.scm +31 -0
- package/packages/chunker/src/queries/javascript/imports.scm +32 -0
- package/packages/chunker/src/queries/javascript/patterns.scm +28 -0
- package/packages/chunker/src/queries/javascript/symbols.scm +52 -0
- package/packages/chunker/src/queries/python/calls.scm +11 -0
- package/packages/chunker/src/queries/python/entry-points.scm +21 -0
- package/packages/chunker/src/queries/python/imports.scm +14 -0
- package/packages/chunker/src/queries/python/patterns.scm +25 -0
- package/packages/chunker/src/queries/python/symbols.scm +17 -0
- package/packages/chunker/src/queries/rust/calls.scm +20 -0
- package/packages/chunker/src/queries/rust/entry-points.scm +7 -0
- package/packages/chunker/src/queries/rust/imports.scm +26 -0
- package/packages/chunker/src/queries/rust/patterns.scm +18 -0
- package/packages/chunker/src/queries/rust/symbols.scm +73 -0
- package/packages/chunker/src/queries/typescript/calls.scm +21 -0
- package/packages/chunker/src/queries/typescript/entry-points.scm +48 -0
- package/packages/chunker/src/queries/typescript/imports.scm +35 -0
- package/packages/chunker/src/queries/typescript/patterns.scm +47 -0
- package/packages/chunker/src/queries/typescript/symbols.scm +79 -0
- package/packages/chunker/wasm/tree-sitter-c.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-cpp.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-go.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-java.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-javascript.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-kotlin.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-php.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-python.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-ruby.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-rust.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-scala.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-swift.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-typescript.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter.wasm +0 -0
- package/packages/cli/dist/aikit-init.d.ts +54 -0
- package/packages/cli/dist/aikit-init.js +1 -0
- package/packages/cli/dist/commands/analyze.d.ts +6 -0
- package/packages/cli/dist/commands/analyze.js +2 -0
- package/packages/cli/dist/commands/context-cmds.d.ts +6 -0
- package/packages/cli/dist/commands/context-cmds.js +1 -0
- package/packages/cli/dist/commands/environment.d.ts +6 -0
- package/packages/cli/dist/commands/environment.js +1 -0
- package/packages/cli/dist/commands/execution.d.ts +6 -0
- package/packages/cli/dist/commands/execution.js +1 -0
- package/packages/cli/dist/commands/flow.d.ts +6 -0
- package/packages/cli/dist/commands/flow.js +1 -0
- package/packages/cli/dist/commands/graph.d.ts +6 -0
- package/packages/cli/dist/commands/graph.js +6 -0
- package/packages/cli/dist/commands/init/adapters.d.ts +28 -0
- package/packages/cli/dist/commands/init/adapters.js +1 -0
- package/packages/cli/dist/commands/init/config.d.ts +10 -0
- package/packages/cli/dist/commands/init/config.js +3 -0
- package/packages/cli/dist/commands/init/constants.d.ts +41 -0
- package/packages/cli/dist/commands/init/constants.js +1 -0
- package/packages/cli/dist/commands/init/curated.d.ts +7 -0
- package/packages/cli/dist/commands/init/curated.js +1 -0
- package/packages/cli/dist/commands/init/frontmatter.d.ts +54 -0
- package/packages/cli/dist/commands/init/frontmatter.js +2 -0
- package/packages/cli/dist/commands/init/index.d.ts +36 -0
- package/packages/cli/dist/commands/init/index.js +5 -0
- package/packages/cli/dist/commands/init/manifest.d.ts +71 -0
- package/packages/cli/dist/commands/init/manifest.js +1 -0
- package/packages/cli/dist/commands/init/scaffold.d.ts +46 -0
- package/packages/cli/dist/commands/init/scaffold.js +1 -0
- package/packages/cli/dist/commands/init/templates.d.ts +9 -0
- package/packages/cli/dist/commands/init/templates.js +194 -0
- package/packages/cli/dist/commands/init/user.d.ts +61 -0
- package/packages/cli/dist/commands/init/user.js +5 -0
- package/packages/cli/dist/commands/knowledge.d.ts +6 -0
- package/packages/cli/dist/commands/knowledge.js +1 -0
- package/packages/cli/dist/commands/search.d.ts +6 -0
- package/packages/cli/dist/commands/search.js +1 -0
- package/packages/cli/dist/commands/system.d.ts +6 -0
- package/packages/cli/dist/commands/system.js +4 -0
- package/packages/cli/dist/commands/upgrade.d.ts +6 -0
- package/packages/cli/dist/commands/upgrade.js +1 -0
- package/packages/cli/dist/commands/workspace.d.ts +6 -0
- package/packages/cli/dist/commands/workspace.js +1 -0
- package/packages/cli/dist/context.d.ts +7 -0
- package/packages/cli/dist/context.js +1 -0
- package/packages/cli/dist/helpers.d.ts +55 -0
- package/packages/cli/dist/helpers.js +5 -0
- package/packages/cli/dist/index.d.ts +10 -0
- package/packages/cli/dist/index.js +3 -0
- package/packages/cli/dist/types.d.ts +9 -0
- package/packages/cli/dist/types.js +1 -0
- package/packages/core/dist/constants.d.ts +74 -0
- package/packages/core/dist/constants.js +1 -0
- package/packages/core/dist/content-detector.d.ts +13 -0
- package/packages/core/dist/content-detector.js +1 -0
- package/packages/core/dist/errors.d.ts +20 -0
- package/packages/core/dist/errors.js +1 -0
- package/packages/core/dist/global-registry.d.ts +63 -0
- package/packages/core/dist/global-registry.js +1 -0
- package/packages/core/dist/index.d.ts +7 -0
- package/packages/core/dist/index.js +1 -0
- package/packages/core/dist/logger.d.ts +32 -0
- package/packages/core/dist/logger.js +1 -0
- package/packages/core/dist/types.d.ts +133 -0
- package/packages/core/dist/types.js +1 -0
- package/packages/dashboard/dist/assets/index-BjA4YODs.js +21 -0
- package/packages/dashboard/dist/assets/index-BjA4YODs.js.map +1 -0
- package/packages/dashboard/dist/assets/index-CHpVij2M.css +1 -0
- package/packages/dashboard/dist/index.html +18 -0
- package/packages/elicitation/dist/build.d.ts +14 -0
- package/packages/elicitation/dist/build.js +1 -0
- package/packages/elicitation/dist/fields.d.ts +32 -0
- package/packages/elicitation/dist/fields.js +1 -0
- package/packages/elicitation/dist/index.d.ts +5 -0
- package/packages/elicitation/dist/index.js +1 -0
- package/packages/elicitation/dist/normalize.d.ts +15 -0
- package/packages/elicitation/dist/normalize.js +1 -0
- package/packages/elicitation/dist/types.d.ts +88 -0
- package/packages/elicitation/dist/types.js +1 -0
- package/packages/embeddings/dist/embedder.interface.d.ts +26 -0
- package/packages/embeddings/dist/embedder.interface.js +1 -0
- package/packages/embeddings/dist/index.d.ts +3 -0
- package/packages/embeddings/dist/index.js +1 -0
- package/packages/embeddings/dist/onnx-embedder.d.ts +22 -0
- package/packages/embeddings/dist/onnx-embedder.js +1 -0
- package/packages/enterprise-bridge/dist/cache.d.ts +28 -0
- package/packages/enterprise-bridge/dist/cache.js +1 -0
- package/packages/enterprise-bridge/dist/er-client.d.ts +37 -0
- package/packages/enterprise-bridge/dist/er-client.js +1 -0
- package/packages/enterprise-bridge/dist/evolution-collector.d.ts +62 -0
- package/packages/enterprise-bridge/dist/evolution-collector.js +1 -0
- package/packages/enterprise-bridge/dist/index.d.ts +8 -0
- package/packages/enterprise-bridge/dist/index.js +1 -0
- package/packages/enterprise-bridge/dist/policy-store.d.ts +45 -0
- package/packages/enterprise-bridge/dist/policy-store.js +1 -0
- package/packages/enterprise-bridge/dist/push-adapter.d.ts +23 -0
- package/packages/enterprise-bridge/dist/push-adapter.js +1 -0
- package/packages/enterprise-bridge/dist/result-merger.d.ts +14 -0
- package/packages/enterprise-bridge/dist/result-merger.js +1 -0
- package/packages/enterprise-bridge/dist/types.d.ts +81 -0
- package/packages/enterprise-bridge/dist/types.js +1 -0
- package/packages/flows/dist/adapters/claude-plugin.d.ts +12 -0
- package/packages/flows/dist/adapters/claude-plugin.js +1 -0
- package/packages/flows/dist/adapters/copilot.d.ts +10 -0
- package/packages/flows/dist/adapters/copilot.js +1 -0
- package/packages/flows/dist/adapters/index.d.ts +11 -0
- package/packages/flows/dist/adapters/index.js +1 -0
- package/packages/flows/dist/adapters/native.d.ts +10 -0
- package/packages/flows/dist/adapters/native.js +1 -0
- package/packages/flows/dist/builtins.d.ts +16 -0
- package/packages/flows/dist/builtins.js +1 -0
- package/packages/flows/dist/foundation.d.ts +20 -0
- package/packages/flows/dist/foundation.js +11 -0
- package/packages/flows/dist/git.d.ts +34 -0
- package/packages/flows/dist/git.js +1 -0
- package/packages/flows/dist/index.d.ts +12 -0
- package/packages/flows/dist/index.js +1 -0
- package/packages/flows/dist/loader.d.ts +13 -0
- package/packages/flows/dist/loader.js +2 -0
- package/packages/flows/dist/registry.d.ts +23 -0
- package/packages/flows/dist/registry.js +1 -0
- package/packages/flows/dist/state-machine.d.ts +23 -0
- package/packages/flows/dist/state-machine.js +1 -0
- package/packages/flows/dist/symlinks.d.ts +17 -0
- package/packages/flows/dist/symlinks.js +1 -0
- package/packages/flows/dist/types.d.ts +112 -0
- package/packages/flows/dist/types.js +1 -0
- package/packages/indexer/dist/file-hasher.d.ts +13 -0
- package/packages/indexer/dist/file-hasher.js +1 -0
- package/packages/indexer/dist/filesystem-crawler.d.ts +29 -0
- package/packages/indexer/dist/filesystem-crawler.js +1 -0
- package/packages/indexer/dist/graph-extractor.d.ts +18 -0
- package/packages/indexer/dist/graph-extractor.js +1 -0
- package/packages/indexer/dist/hash-cache.d.ts +24 -0
- package/packages/indexer/dist/hash-cache.js +1 -0
- package/packages/indexer/dist/incremental-indexer.d.ts +56 -0
- package/packages/indexer/dist/incremental-indexer.js +1 -0
- package/packages/indexer/dist/index.d.ts +6 -0
- package/packages/indexer/dist/index.js +1 -0
- package/packages/present/dist/index.html +709 -0
- package/packages/server/dist/api.d.ts +3 -0
- package/packages/server/dist/api.js +1 -0
- package/packages/server/dist/auto-gc.d.ts +30 -0
- package/packages/server/dist/auto-gc.js +1 -0
- package/packages/server/dist/completions.d.ts +14 -0
- package/packages/server/dist/completions.js +1 -0
- package/packages/server/dist/config.d.ts +14 -0
- package/packages/server/dist/config.js +1 -0
- package/packages/server/dist/cross-workspace.d.ts +43 -0
- package/packages/server/dist/cross-workspace.js +1 -0
- package/packages/server/dist/curated-manager.d.ts +92 -0
- package/packages/server/dist/curated-manager.js +5 -0
- package/packages/server/dist/dashboard-static.d.ts +27 -0
- package/packages/server/dist/dashboard-static.js +1 -0
- package/packages/server/dist/elicitor.d.ts +18 -0
- package/packages/server/dist/elicitor.js +1 -0
- package/packages/server/dist/index.d.ts +1 -0
- package/packages/server/dist/index.js +1 -0
- package/packages/server/dist/mcp-logging.d.ts +11 -0
- package/packages/server/dist/mcp-logging.js +1 -0
- package/packages/server/dist/output-schemas.d.ts +242 -0
- package/packages/server/dist/output-schemas.js +1 -0
- package/packages/server/dist/prompts.d.ts +13 -0
- package/packages/server/dist/prompts.js +13 -0
- package/packages/server/dist/replay-interceptor.d.ts +23 -0
- package/packages/server/dist/replay-interceptor.js +1 -0
- package/packages/server/dist/resource-links.d.ts +34 -0
- package/packages/server/dist/resource-links.js +1 -0
- package/packages/server/dist/resources/curated-resources.d.ts +13 -0
- package/packages/server/dist/resources/curated-resources.js +2 -0
- package/packages/server/dist/resources/resource-notifier.d.ts +45 -0
- package/packages/server/dist/resources/resource-notifier.js +1 -0
- package/packages/server/dist/resources/resources.d.ts +8 -0
- package/packages/server/dist/resources/resources.js +2 -0
- package/packages/server/dist/sampling.d.ts +41 -0
- package/packages/server/dist/sampling.js +2 -0
- package/packages/server/dist/server.d.ts +47 -0
- package/packages/server/dist/server.js +3 -0
- package/packages/server/dist/structured-content-guard.d.ts +26 -0
- package/packages/server/dist/structured-content-guard.js +1 -0
- package/packages/server/dist/task-manager.d.ts +40 -0
- package/packages/server/dist/task-manager.js +1 -0
- package/packages/server/dist/tool-metadata.d.ts +38 -0
- package/packages/server/dist/tool-metadata.js +1 -0
- package/packages/server/dist/tool-prefix.d.ts +12 -0
- package/packages/server/dist/tool-prefix.js +1 -0
- package/packages/server/dist/tools/analyze.tools.d.ts +14 -0
- package/packages/server/dist/tools/analyze.tools.js +8 -0
- package/packages/server/dist/tools/audit.tool.d.ts +8 -0
- package/packages/server/dist/tools/audit.tool.js +1 -0
- package/packages/server/dist/tools/brainstorm.tool.d.ts +7 -0
- package/packages/server/dist/tools/brainstorm.tool.js +9 -0
- package/packages/server/dist/tools/bridge.tools.d.ts +34 -0
- package/packages/server/dist/tools/bridge.tools.js +15 -0
- package/packages/server/dist/tools/context.tools.d.ts +15 -0
- package/packages/server/dist/tools/context.tools.js +10 -0
- package/packages/server/dist/tools/evolution.tools.d.ts +7 -0
- package/packages/server/dist/tools/evolution.tools.js +5 -0
- package/packages/server/dist/tools/execution.tools.d.ts +14 -0
- package/packages/server/dist/tools/execution.tools.js +4 -0
- package/packages/server/dist/tools/flow.tools.d.ts +7 -0
- package/packages/server/dist/tools/flow.tools.js +1 -0
- package/packages/server/dist/tools/forge.tools.d.ts +13 -0
- package/packages/server/dist/tools/forge.tools.js +10 -0
- package/packages/server/dist/tools/forget.tool.d.ts +8 -0
- package/packages/server/dist/tools/forget.tool.js +1 -0
- package/packages/server/dist/tools/graph.tool.d.ts +7 -0
- package/packages/server/dist/tools/graph.tool.js +5 -0
- package/packages/server/dist/tools/infra.tools.d.ts +10 -0
- package/packages/server/dist/tools/infra.tools.js +5 -0
- package/packages/server/dist/tools/list.tool.d.ts +7 -0
- package/packages/server/dist/tools/list.tool.js +2 -0
- package/packages/server/dist/tools/lookup.tool.d.ts +7 -0
- package/packages/server/dist/tools/lookup.tool.js +3 -0
- package/packages/server/dist/tools/manipulation.tools.d.ts +10 -0
- package/packages/server/dist/tools/manipulation.tools.js +4 -0
- package/packages/server/dist/tools/onboard.tool.d.ts +9 -0
- package/packages/server/dist/tools/onboard.tool.js +2 -0
- package/packages/server/dist/tools/persistence.tools.d.ts +10 -0
- package/packages/server/dist/tools/persistence.tools.js +5 -0
- package/packages/server/dist/tools/policy.tools.d.ts +7 -0
- package/packages/server/dist/tools/policy.tools.js +3 -0
- package/packages/server/dist/tools/present/browser.d.ts +4 -0
- package/packages/server/dist/tools/present/browser.js +93 -0
- package/packages/server/dist/tools/present/helpers.d.ts +18 -0
- package/packages/server/dist/tools/present/helpers.js +1 -0
- package/packages/server/dist/tools/present/html.d.ts +18 -0
- package/packages/server/dist/tools/present/html.js +5 -0
- package/packages/server/dist/tools/present/index.d.ts +2 -0
- package/packages/server/dist/tools/present/index.js +1 -0
- package/packages/server/dist/tools/present/markdown.d.ts +17 -0
- package/packages/server/dist/tools/present/markdown.js +8 -0
- package/packages/server/dist/tools/present/templates.d.ts +14 -0
- package/packages/server/dist/tools/present/templates.js +472 -0
- package/packages/server/dist/tools/present/tool.d.ts +27 -0
- package/packages/server/dist/tools/present/tool.js +19 -0
- package/packages/server/dist/tools/present-blocks.d.ts +46 -0
- package/packages/server/dist/tools/present-blocks.js +27 -0
- package/packages/server/dist/tools/present-charts.d.ts +31 -0
- package/packages/server/dist/tools/present-charts.js +34 -0
- package/packages/server/dist/tools/present-theme.d.ts +14 -0
- package/packages/server/dist/tools/present-theme.js +395 -0
- package/packages/server/dist/tools/present-utils.d.ts +11 -0
- package/packages/server/dist/tools/present-utils.js +1 -0
- package/packages/server/dist/tools/present.tool.d.ts +2 -0
- package/packages/server/dist/tools/present.tool.js +1 -0
- package/packages/server/dist/tools/produce.tool.d.ts +7 -0
- package/packages/server/dist/tools/produce.tool.js +4 -0
- package/packages/server/dist/tools/read.tool.d.ts +7 -0
- package/packages/server/dist/tools/read.tool.js +2 -0
- package/packages/server/dist/tools/reindex.tool.d.ts +11 -0
- package/packages/server/dist/tools/reindex.tool.js +3 -0
- package/packages/server/dist/tools/remember.tool.d.ts +9 -0
- package/packages/server/dist/tools/remember.tool.js +4 -0
- package/packages/server/dist/tools/replay.tool.d.ts +6 -0
- package/packages/server/dist/tools/replay.tool.js +3 -0
- package/packages/server/dist/tools/restore.tool.d.ts +6 -0
- package/packages/server/dist/tools/restore.tool.js +3 -0
- package/packages/server/dist/tools/search.tool.d.ts +11 -0
- package/packages/server/dist/tools/search.tool.js +10 -0
- package/packages/server/dist/tools/status.tool.d.ts +20 -0
- package/packages/server/dist/tools/status.tool.js +3 -0
- package/packages/server/dist/tools/update.tool.d.ts +8 -0
- package/packages/server/dist/tools/update.tool.js +1 -0
- package/packages/server/dist/tools/utility.tools.d.ts +15 -0
- package/packages/server/dist/tools/utility.tools.js +13 -0
- package/packages/server/dist/version-check.d.ts +32 -0
- package/packages/server/dist/version-check.js +1 -0
- package/packages/store/dist/graph-store.interface.d.ts +118 -0
- package/packages/store/dist/graph-store.interface.js +1 -0
- package/packages/store/dist/index.d.ts +6 -0
- package/packages/store/dist/index.js +1 -0
- package/packages/store/dist/lance-store.d.ts +44 -0
- package/packages/store/dist/lance-store.js +1 -0
- package/packages/store/dist/sqlite-graph-store.d.ts +45 -0
- package/packages/store/dist/sqlite-graph-store.js +58 -0
- package/packages/store/dist/store-factory.d.ts +12 -0
- package/packages/store/dist/store-factory.js +1 -0
- package/packages/store/dist/store.interface.d.ts +54 -0
- package/packages/store/dist/store.interface.js +1 -0
- package/packages/tools/dist/audit.d.ts +65 -0
- package/packages/tools/dist/audit.js +6 -0
- package/packages/tools/dist/batch.d.ts +23 -0
- package/packages/tools/dist/batch.js +1 -0
- package/packages/tools/dist/changelog.d.ts +36 -0
- package/packages/tools/dist/changelog.js +2 -0
- package/packages/tools/dist/check.d.ts +48 -0
- package/packages/tools/dist/check.js +2 -0
- package/packages/tools/dist/checkpoint.d.ts +19 -0
- package/packages/tools/dist/checkpoint.js +1 -0
- package/packages/tools/dist/codemod.d.ts +39 -0
- package/packages/tools/dist/codemod.js +2 -0
- package/packages/tools/dist/compact.d.ts +41 -0
- package/packages/tools/dist/compact.js +3 -0
- package/packages/tools/dist/config-extractor.d.ts +9 -0
- package/packages/tools/dist/config-extractor.js +7 -0
- package/packages/tools/dist/data-transform.d.ts +12 -0
- package/packages/tools/dist/data-transform.js +1 -0
- package/packages/tools/dist/dead-symbols.d.ts +28 -0
- package/packages/tools/dist/dead-symbols.js +2 -0
- package/packages/tools/dist/delegate.d.ts +36 -0
- package/packages/tools/dist/delegate.js +1 -0
- package/packages/tools/dist/diagram-builder.d.ts +9 -0
- package/packages/tools/dist/diagram-builder.js +9 -0
- package/packages/tools/dist/diff-parse.d.ts +28 -0
- package/packages/tools/dist/diff-parse.js +3 -0
- package/packages/tools/dist/digest.d.ts +50 -0
- package/packages/tools/dist/digest.js +6 -0
- package/packages/tools/dist/dogfood-log.d.ts +49 -0
- package/packages/tools/dist/dogfood-log.js +2 -0
- package/packages/tools/dist/encode.d.ts +16 -0
- package/packages/tools/dist/encode.js +1 -0
- package/packages/tools/dist/env-info.d.ts +30 -0
- package/packages/tools/dist/env-info.js +1 -0
- package/packages/tools/dist/eval.d.ts +15 -0
- package/packages/tools/dist/eval.js +2 -0
- package/packages/tools/dist/evidence-map.d.ts +92 -0
- package/packages/tools/dist/evidence-map.js +2 -0
- package/packages/tools/dist/file-cache.d.ts +41 -0
- package/packages/tools/dist/file-cache.js +3 -0
- package/packages/tools/dist/file-summary.d.ts +52 -0
- package/packages/tools/dist/file-summary.js +2 -0
- package/packages/tools/dist/file-walk.d.ts +6 -0
- package/packages/tools/dist/file-walk.js +1 -0
- package/packages/tools/dist/find-examples.d.ts +29 -0
- package/packages/tools/dist/find-examples.js +3 -0
- package/packages/tools/dist/find.d.ts +49 -0
- package/packages/tools/dist/find.js +1 -0
- package/packages/tools/dist/forge-classify.d.ts +44 -0
- package/packages/tools/dist/forge-classify.js +2 -0
- package/packages/tools/dist/forge-ground.d.ts +61 -0
- package/packages/tools/dist/forge-ground.js +1 -0
- package/packages/tools/dist/git-context.d.ts +25 -0
- package/packages/tools/dist/git-context.js +3 -0
- package/packages/tools/dist/graph-query.d.ts +86 -0
- package/packages/tools/dist/graph-query.js +1 -0
- package/packages/tools/dist/guide.d.ts +25 -0
- package/packages/tools/dist/guide.js +1 -0
- package/packages/tools/dist/health.d.ts +16 -0
- package/packages/tools/dist/health.js +2 -0
- package/packages/tools/dist/http-request.d.ts +25 -0
- package/packages/tools/dist/http-request.js +1 -0
- package/packages/tools/dist/index.d.ts +57 -0
- package/packages/tools/dist/index.js +1 -0
- package/packages/tools/dist/lane.d.ts +41 -0
- package/packages/tools/dist/lane.js +6 -0
- package/packages/tools/dist/measure.d.ts +42 -0
- package/packages/tools/dist/measure.js +2 -0
- package/packages/tools/dist/onboard-utils.d.ts +12 -0
- package/packages/tools/dist/onboard-utils.js +1 -0
- package/packages/tools/dist/onboard.d.ts +50 -0
- package/packages/tools/dist/onboard.js +18 -0
- package/packages/tools/dist/parse-output.d.ts +82 -0
- package/packages/tools/dist/parse-output.js +2 -0
- package/packages/tools/dist/path-resolver.d.ts +14 -0
- package/packages/tools/dist/path-resolver.js +1 -0
- package/packages/tools/dist/process-manager.d.ts +20 -0
- package/packages/tools/dist/process-manager.js +1 -0
- package/packages/tools/dist/queue.d.ts +40 -0
- package/packages/tools/dist/queue.js +1 -0
- package/packages/tools/dist/regex-test.d.ts +33 -0
- package/packages/tools/dist/regex-test.js +1 -0
- package/packages/tools/dist/regex-utils.d.ts +8 -0
- package/packages/tools/dist/regex-utils.js +1 -0
- package/packages/tools/dist/rename.d.ts +31 -0
- package/packages/tools/dist/rename.js +2 -0
- package/packages/tools/dist/replay.d.ts +59 -0
- package/packages/tools/dist/replay.js +4 -0
- package/packages/tools/dist/response-envelope.d.ts +43 -0
- package/packages/tools/dist/response-envelope.js +1 -0
- package/packages/tools/dist/restore-points.d.ts +22 -0
- package/packages/tools/dist/restore-points.js +1 -0
- package/packages/tools/dist/schema-validate.d.ts +25 -0
- package/packages/tools/dist/schema-validate.js +1 -0
- package/packages/tools/dist/scope-map.d.ts +51 -0
- package/packages/tools/dist/scope-map.js +1 -0
- package/packages/tools/dist/snippet.d.ts +35 -0
- package/packages/tools/dist/snippet.js +1 -0
- package/packages/tools/dist/stash.d.ts +14 -0
- package/packages/tools/dist/stash.js +1 -0
- package/packages/tools/dist/stratum-card.d.ts +30 -0
- package/packages/tools/dist/stratum-card.js +4 -0
- package/packages/tools/dist/symbol.d.ts +45 -0
- package/packages/tools/dist/symbol.js +3 -0
- package/packages/tools/dist/synthesis-engine.d.ts +13 -0
- package/packages/tools/dist/synthesis-engine.js +6 -0
- package/packages/tools/dist/test-run.d.ts +28 -0
- package/packages/tools/dist/test-run.js +2 -0
- package/packages/tools/dist/text-utils.d.ts +24 -0
- package/packages/tools/dist/text-utils.js +2 -0
- package/packages/tools/dist/time-utils.d.ts +20 -0
- package/packages/tools/dist/time-utils.js +1 -0
- package/packages/tools/dist/trace.d.ts +29 -0
- package/packages/tools/dist/trace.js +2 -0
- package/packages/tools/dist/truncation.d.ts +33 -0
- package/packages/tools/dist/truncation.js +7 -0
- package/packages/tools/dist/watch.d.ts +32 -0
- package/packages/tools/dist/watch.js +1 -0
- package/packages/tools/dist/web-fetch.d.ts +47 -0
- package/packages/tools/dist/web-fetch.js +8 -0
- package/packages/tools/dist/web-search.d.ts +25 -0
- package/packages/tools/dist/web-search.js +1 -0
- package/packages/tools/dist/workset.d.ts +47 -0
- package/packages/tools/dist/workset.js +1 -0
- package/packages/tui/dist/App-DU2KEylW.js +2 -0
- package/packages/tui/dist/App.d.ts +13 -0
- package/packages/tui/dist/App.js +2 -0
- package/packages/tui/dist/CuratedPanel-BIamXLNy.js +2 -0
- package/packages/tui/dist/LogPanel-Bo8a8QXB.js +3 -0
- package/packages/tui/dist/SearchPanel-CpJGczAc.js +2 -0
- package/packages/tui/dist/StatusPanel-BAbUxyqQ.js +2 -0
- package/packages/tui/dist/chunk-D6axbAb-.js +2 -0
- package/packages/tui/dist/devtools-DMOZMn70.js +7 -0
- package/packages/tui/dist/hooks/useKBClient.d.ts +9 -0
- package/packages/tui/dist/hooks/useKBClient.js +2 -0
- package/packages/tui/dist/hooks/usePolling.d.ts +8 -0
- package/packages/tui/dist/hooks/usePolling.js +2 -0
- package/packages/tui/dist/index-BXafekwr.d.ts +64 -0
- package/packages/tui/dist/index.d.ts +7 -0
- package/packages/tui/dist/index.js +2 -0
- package/packages/tui/dist/jsx-runtime-y6Gdq5PZ.js +294 -0
- package/packages/tui/dist/panels/CuratedPanel.d.ts +7 -0
- package/packages/tui/dist/panels/CuratedPanel.js +2 -0
- package/packages/tui/dist/panels/LogPanel.d.ts +7 -0
- package/packages/tui/dist/panels/LogPanel.js +2 -0
- package/packages/tui/dist/panels/SearchPanel.d.ts +7 -0
- package/packages/tui/dist/panels/SearchPanel.js +2 -0
- package/packages/tui/dist/panels/StatusPanel.d.ts +7 -0
- package/packages/tui/dist/panels/StatusPanel.js +2 -0
- package/packages/tui/dist/react-D__J1GQe.js +24 -0
- package/packages/tui/dist/useKBClient-C35iA4uG.js +2 -0
- package/packages/tui/dist/usePolling-BbjnRWgx.js +2 -0
- package/scaffold/README.md +192 -0
- package/scaffold/adapters/claude-code.mjs +56 -0
- package/scaffold/adapters/copilot.mjs +270 -0
- package/scaffold/definitions/agents.mjs +189 -0
- package/scaffold/definitions/bodies.mjs +487 -0
- package/scaffold/definitions/hooks.mjs +43 -0
- package/scaffold/definitions/models.mjs +56 -0
- package/scaffold/definitions/plugins.mjs +38 -0
- package/scaffold/definitions/prompts.mjs +145 -0
- package/scaffold/definitions/protocols.mjs +679 -0
- package/scaffold/definitions/tools.mjs +229 -0
- package/scaffold/flows/aikit-advanced/flow.json +60 -0
- package/scaffold/flows/aikit-advanced/skills/execute/SKILL.md +124 -0
- package/scaffold/flows/aikit-advanced/skills/plan/SKILL.md +100 -0
- package/scaffold/flows/aikit-advanced/skills/spec/SKILL.md +100 -0
- package/scaffold/flows/aikit-advanced/skills/task/SKILL.md +99 -0
- package/scaffold/flows/aikit-advanced/skills/verify/SKILL.md +122 -0
- package/scaffold/flows/aikit-basic/flow.json +36 -0
- package/scaffold/flows/aikit-basic/skills/assess/SKILL.md +82 -0
- package/scaffold/flows/aikit-basic/skills/implement/SKILL.md +105 -0
- package/scaffold/flows/aikit-basic/skills/verify/SKILL.md +96 -0
- package/scaffold/general/agents/Architect-Reviewer-Alpha.agent.md +21 -0
- package/scaffold/general/agents/Architect-Reviewer-Beta.agent.md +21 -0
- package/scaffold/general/agents/Code-Reviewer-Alpha.agent.md +12 -0
- package/scaffold/general/agents/Code-Reviewer-Beta.agent.md +12 -0
- package/scaffold/general/agents/Debugger.agent.md +34 -0
- package/scaffold/general/agents/Documenter.agent.md +53 -0
- package/scaffold/general/agents/Explorer.agent.md +63 -0
- package/scaffold/general/agents/Frontend.agent.md +29 -0
- package/scaffold/general/agents/Implementer.agent.md +33 -0
- package/scaffold/general/agents/Orchestrator.agent.md +149 -0
- package/scaffold/general/agents/Planner.agent.md +79 -0
- package/scaffold/general/agents/README.md +57 -0
- package/scaffold/general/agents/Refactor.agent.md +36 -0
- package/scaffold/general/agents/Researcher-Alpha.agent.md +20 -0
- package/scaffold/general/agents/Researcher-Beta.agent.md +20 -0
- package/scaffold/general/agents/Researcher-Delta.agent.md +20 -0
- package/scaffold/general/agents/Researcher-Gamma.agent.md +20 -0
- package/scaffold/general/agents/Security.agent.md +55 -0
- package/scaffold/general/agents/_shared/architect-reviewer-base.md +60 -0
- package/scaffold/general/agents/_shared/code-agent-base.md +262 -0
- package/scaffold/general/agents/_shared/code-reviewer-base.md +64 -0
- package/scaffold/general/agents/_shared/decision-protocol.md +27 -0
- package/scaffold/general/agents/_shared/forge-protocol.md +90 -0
- package/scaffold/general/agents/_shared/researcher-base.md +101 -0
- package/scaffold/general/agents/templates/adr-template.md +28 -0
- package/scaffold/general/agents/templates/execution-state.md +26 -0
- package/scaffold/general/prompts/ask.prompt.md +21 -0
- package/scaffold/general/prompts/debug.prompt.md +25 -0
- package/scaffold/general/prompts/design.prompt.md +23 -0
- package/scaffold/general/prompts/implement.prompt.md +26 -0
- package/scaffold/general/prompts/plan.prompt.md +25 -0
- package/scaffold/general/prompts/review.prompt.md +32 -0
- package/scaffold/general/skills/adr-skill/SKILL.md +329 -0
- package/scaffold/general/skills/adr-skill/assets/templates/adr-madr.md +89 -0
- package/scaffold/general/skills/adr-skill/assets/templates/adr-readme.md +20 -0
- package/scaffold/general/skills/adr-skill/assets/templates/adr-simple.md +46 -0
- package/scaffold/general/skills/adr-skill/references/adr-conventions.md +95 -0
- package/scaffold/general/skills/adr-skill/references/examples.md +193 -0
- package/scaffold/general/skills/adr-skill/references/review-checklist.md +77 -0
- package/scaffold/general/skills/adr-skill/references/template-variants.md +52 -0
- package/scaffold/general/skills/adr-skill/scripts/bootstrap_adr.js +259 -0
- package/scaffold/general/skills/adr-skill/scripts/new_adr.js +391 -0
- package/scaffold/general/skills/adr-skill/scripts/set_adr_status.js +169 -0
- package/scaffold/general/skills/aikit/SKILL.md +521 -0
- package/scaffold/general/skills/brainstorming/SKILL.md +259 -0
- package/scaffold/general/skills/brainstorming/scripts/frame-template.html +365 -0
- package/scaffold/general/skills/brainstorming/scripts/helper.js +216 -0
- package/scaffold/general/skills/brainstorming/scripts/server.cjs +9 -0
- package/scaffold/general/skills/brainstorming/scripts/server.src.cjs +249 -0
- package/scaffold/general/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/scaffold/general/skills/brainstorming/visual-companion.md +430 -0
- package/scaffold/general/skills/c4-architecture/SKILL.md +295 -0
- package/scaffold/general/skills/c4-architecture/references/advanced-patterns.md +552 -0
- package/scaffold/general/skills/c4-architecture/references/c4-syntax.md +492 -0
- package/scaffold/general/skills/c4-architecture/references/common-mistakes.md +437 -0
- package/scaffold/general/skills/lesson-learned/SKILL.md +105 -0
- package/scaffold/general/skills/lesson-learned/references/anti-patterns.md +55 -0
- package/scaffold/general/skills/lesson-learned/references/se-principles.md +109 -0
- package/scaffold/general/skills/multi-agents-development/SKILL.md +435 -0
- package/scaffold/general/skills/multi-agents-development/architecture-review-prompt.md +81 -0
- package/scaffold/general/skills/multi-agents-development/code-quality-review-prompt.md +91 -0
- package/scaffold/general/skills/multi-agents-development/implementer-prompt.md +93 -0
- package/scaffold/general/skills/multi-agents-development/parallel-dispatch-example.md +167 -0
- package/scaffold/general/skills/multi-agents-development/spec-review-prompt.md +81 -0
- package/scaffold/general/skills/present/SKILL.md +424 -0
- package/scaffold/general/skills/requirements-clarity/SKILL.md +324 -0
- package/scaffold/general/skills/session-handoff/SKILL.md +189 -0
- package/scaffold/general/skills/session-handoff/references/handoff-template.md +139 -0
- package/scaffold/general/skills/session-handoff/references/resume-checklist.md +80 -0
- package/scaffold/general/skills/session-handoff/scripts/check_staleness.js +269 -0
- package/scaffold/general/skills/session-handoff/scripts/create_handoff.js +299 -0
- package/scaffold/general/skills/session-handoff/scripts/list_handoffs.js +113 -0
- package/scaffold/general/skills/session-handoff/scripts/validate_handoff.js +241 -0
- package/scaffold/generate.mjs +82 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { IEmbedder } from "../../embeddings/dist/index.js";
|
|
2
|
+
|
|
3
|
+
//#region packages/tools/src/digest.d.ts
|
|
4
|
+
interface DigestSource {
|
|
5
|
+
/** Unique identifier for this source */
|
|
6
|
+
id: string;
|
|
7
|
+
/** The text to compress */
|
|
8
|
+
text: string;
|
|
9
|
+
/** Priority weight (default: 1). Higher = more budget share */
|
|
10
|
+
weight?: number;
|
|
11
|
+
}
|
|
12
|
+
interface DigestOptions {
|
|
13
|
+
/** Source texts to compress */
|
|
14
|
+
sources: DigestSource[];
|
|
15
|
+
/** Focus query — what matters for the next step? */
|
|
16
|
+
query: string;
|
|
17
|
+
/** Target budget in characters (default: 4000) */
|
|
18
|
+
maxChars?: number;
|
|
19
|
+
/** Key fields to always extract via keyword matching */
|
|
20
|
+
pinFields?: string[];
|
|
21
|
+
/** Segmentation strategy (default: 'paragraph') */
|
|
22
|
+
segmentation?: 'paragraph' | 'sentence' | 'line';
|
|
23
|
+
}
|
|
24
|
+
interface DigestFieldEntry {
|
|
25
|
+
sourceId: string;
|
|
26
|
+
value: string;
|
|
27
|
+
}
|
|
28
|
+
interface DigestResult {
|
|
29
|
+
/** Compressed narrative (all sources merged, reading order maintained) */
|
|
30
|
+
text: string;
|
|
31
|
+
/** Extracted structured fields */
|
|
32
|
+
fields: Record<string, DigestFieldEntry[]>;
|
|
33
|
+
/** Per-source compression stats */
|
|
34
|
+
sourceStats: Array<{
|
|
35
|
+
id: string;
|
|
36
|
+
originalChars: number;
|
|
37
|
+
keptChars: number;
|
|
38
|
+
segmentsKept: number;
|
|
39
|
+
segmentsTotal: number;
|
|
40
|
+
}>;
|
|
41
|
+
totalOriginalChars: number;
|
|
42
|
+
totalCompressedChars: number;
|
|
43
|
+
ratio: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Compress multiple text sources into a single digest.
|
|
47
|
+
*/
|
|
48
|
+
declare function digest(embedder: IEmbedder, options: DigestOptions): Promise<DigestResult>;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { DigestFieldEntry, DigestOptions, DigestResult, DigestSource, digest };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{cosineSimilarity as e,estimateTokens as t,segment as n}from"./text-utils.js";const r=[`status`,`files`,`decisions`,`blockers`,`artifacts`,`next`],i={status:/\b(?:status|result)\s*[:=]/i,files:/\b(?:files?|modified|created|deleted)\s*[:=]/i,artifacts:/\b(?:artifacts?)\s*[:=]/i,decisions:/\b(?:decisions?|decided|chose|selected)\s*[:=]/i,blockers:/\b(?:blockers?|blocked|blocking)\s*[:=]/i,next:/\b(?:next\s*(?:steps?|actions?)|todo|follow.up)\s*[:=]/i},a={status:/(?:^|\b)(?:status|result)\s*[:=]\s*(.+)$/i,files:/(?:^|\b)(?:files?|modified|created|deleted)\s*[:=]\s*(.+)$/i,artifacts:/(?:^|\b)(?:artifacts?)\s*[:=]\s*(.+)$/i,decisions:/(?:^|\b)(?:decisions?|decided|chose|selected)\s*[:=]\s*(.+)$/i,blockers:/(?:^|\b)(?:blockers?|blocked|blocking)\s*[:=]\s*(.+)$/i,next:/(?:^|\b)(?:next\s*(?:steps?|actions?)|todo|follow.up)\s*[:=]\s*(.+)$/i},o=/\b(?:APPROVED|NEEDS_REVISION|BLOCKED|SUCCESS|PARTIAL|FAILED|ESCALATE)\b/i,s=.01;function c(e){let t=e??[...r];return[...new Set(t.map(e=>e.toLowerCase()))]}function l(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?1:e}function u(e,t){let n=new Set;for(let r of t)i[r]?.test(e)&&n.add(r);return t.includes(`status`)&&o.test(e)&&n.add(`status`),[...n]}function d(e,t){let n=t.split(`
|
|
2
|
+
`).map(e=>e.trim()).filter(e=>e.length>0);for(let t of n){let n=a[e]?.exec(t);if(n?.[1])return n[1].trim();if(e===`status`){let e=t.match(o);if(e)return e[0]}}return t.trim()}function f(e,t,n,r){e[t]||(e[t]=[]),e[t].push({sourceId:n,value:r})}function p(e,t,r,i){return e.map(e=>{let a=n(e.text,t).map((t,n)=>{let a=u(t,r);for(let n of a)f(i,n,e.id,d(n,t));return{index:n,text:t,pinnedFields:a,score:0}}),o=a.filter(e=>e.pinnedFields.length>0).reduce((e,t)=>e+t.text.length,0),s=a.filter(e=>e.pinnedFields.length===0).reduce((e,t)=>e+t.text.length,0);return{id:e.id,originalText:e.text,weight:l(e.weight),segments:a,pinnedChars:o,nonPinnedChars:s}})}function m(e,t){let n=new Map(e.map(e=>[e.id,0])),r=Math.max(0,t),i=e.filter(e=>e.nonPinnedChars>0);for(;r>s&&i.length>0;){let e=i.reduce((e,t)=>e+t.weight,0),t=0,a=[];for(let o of i){let i=n.get(o.id)??0,c=o.nonPinnedChars-i;if(c<=s)continue;let l=r*(o.weight/e),u=Math.min(l,c);n.set(o.id,i+u),t+=u,c-u>s&&a.push(o)}if(t<=s)break;r-=t,i=a}return n}function h(e){return e.map(e=>`[${e.id}]\n${e.text}`).join(`
|
|
3
|
+
|
|
4
|
+
`)}function g(e,t){return e===0?0:t/e}async function _(n,r){let{sources:i,query:a,maxChars:o=4e3,pinFields:l,segmentation:u=`paragraph`}=r,d={},f=p(i,u,c(l),d),_=i.reduce((e,t)=>e+t.text.length,0);if(_<=o){let e=f.filter(e=>e.originalText.trim().length>0).map(e=>({id:e.id,text:e.originalText})),t=f.map(e=>({id:e.id,originalChars:e.originalText.length,keptChars:e.originalText.length,segmentsKept:e.segments.length,segmentsTotal:e.segments.length}));return{text:h(e),fields:d,sourceStats:t,totalOriginalChars:_,totalCompressedChars:_,ratio:_===0?0:1}}let v=await n.embedQuery(a);for(let t of f)for(let r of t.segments)r.pinnedFields.length>0||(r.score=e(v,await n.embed(r.text)));let y=m(f,o-f.reduce((e,t)=>e+t.pinnedChars,0)),b=[],x=[],S=0;for(let e of f){let n=y.get(e.id)??0,r=new Map,i=0,a=e.segments.filter(e=>e.pinnedFields.length===0).sort((e,n)=>n.score-e.score||t(e.text)-t(n.text)||e.index-n.index),o;for(let e of a){let t=n-i;if(t<=s)break;if(e.text.length<=t+s){r.set(e.index,e.text),i+=e.text.length;continue}o||=e}let c=Math.floor(n-i);if(o&&c>0){let e=o.text.slice(0,c).trimEnd();e.length>0&&(r.set(o.index,e),i+=e.length)}let l=e.segments.filter(e=>e.pinnedFields.length>0||r.has(e.index)).map(e=>({index:e.index,text:r.get(e.index)??e.text})),u=l.reduce((e,t)=>e+t.text.length,0);b.push({id:e.id,originalChars:e.originalText.length,keptChars:u,segmentsKept:l.length,segmentsTotal:e.segments.length}),S+=u,l.length!==0&&x.push({id:e.id,text:l.map(e=>e.text).join(`
|
|
5
|
+
|
|
6
|
+
`)})}return{text:h(x),fields:d,sourceStats:b,totalOriginalChars:_,totalCompressedChars:S,ratio:g(_,S)}}export{_ as digest};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region packages/tools/src/dogfood-log.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* aikit_dogfood — Review persistent warn/error logs for dogfooding.
|
|
4
|
+
*
|
|
5
|
+
* Reads daily JSONL log files from .aikit-state/logs/ and returns a
|
|
6
|
+
* summarized or detailed view of recent issues. Useful for periodic
|
|
7
|
+
* review cycles to identify and fix recurring problems.
|
|
8
|
+
*/
|
|
9
|
+
interface DogfoodLogEntry {
|
|
10
|
+
ts: string;
|
|
11
|
+
level: 'warn' | 'error';
|
|
12
|
+
component: string;
|
|
13
|
+
msg: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
interface DogfoodLogOptions {
|
|
17
|
+
/** Number of days to look back (default: 7) */
|
|
18
|
+
days?: number;
|
|
19
|
+
/** Filter by level */
|
|
20
|
+
level?: 'warn' | 'error';
|
|
21
|
+
/** Filter by component name */
|
|
22
|
+
component?: string;
|
|
23
|
+
/** Maximum entries to return in detail (default: 50) */
|
|
24
|
+
limit?: number;
|
|
25
|
+
}
|
|
26
|
+
interface DogfoodLogGroupedEntry {
|
|
27
|
+
component: string;
|
|
28
|
+
msg: string;
|
|
29
|
+
level: 'warn' | 'error';
|
|
30
|
+
count: number;
|
|
31
|
+
firstSeen: string;
|
|
32
|
+
lastSeen: string;
|
|
33
|
+
}
|
|
34
|
+
interface DogfoodLogResult {
|
|
35
|
+
/** Total entries found matching filters */
|
|
36
|
+
totalEntries: number;
|
|
37
|
+
/** Unique issue groups (by component + message) */
|
|
38
|
+
groups: DogfoodLogGroupedEntry[];
|
|
39
|
+
/** Most recent entries (up to limit) */
|
|
40
|
+
recent: DogfoodLogEntry[];
|
|
41
|
+
/** Date range covered */
|
|
42
|
+
dateRange: {
|
|
43
|
+
from: string;
|
|
44
|
+
to: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
declare function dogfoodLog(options?: DogfoodLogOptions): DogfoodLogResult;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { DogfoodLogEntry, DogfoodLogGroupedEntry, DogfoodLogOptions, DogfoodLogResult, dogfoodLog };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{join as e,resolve as t}from"node:path";import{readFileSync as n,readdirSync as r}from"node:fs";import{AIKIT_PATHS as i}from"../../core/dist/index.js";function a(){return t(process.cwd(),i.logs)}function o(t={}){let{days:i=7,level:o,component:s,limit:c=50}=t,l=a(),u=new Date,d=new Date(u.getTime()-i*864e5).toISOString().slice(0,10),f=u.toISOString().slice(0,10),p;try{p=r(l).filter(e=>e.endsWith(`.jsonl`)&&e.slice(0,10)>=d).sort()}catch{return{totalEntries:0,groups:[],recent:[],dateRange:{from:d,to:f}}}let m=[];for(let t of p)try{let r=n(e(l,t),`utf-8`);for(let e of r.trim().split(`
|
|
2
|
+
`))if(e)try{let t=JSON.parse(e);if(o&&t.level!==o||s&&t.component!==s)continue;m.push(t)}catch{}}catch{}let h=new Map;for(let e of m){let t=`${e.component}::${e.msg}`,n=h.get(t);n?(n.count++,e.ts<n.firstSeen&&(n.firstSeen=e.ts),e.ts>n.lastSeen&&(n.lastSeen=e.ts)):h.set(t,{component:e.component,msg:e.msg,level:e.level,count:1,firstSeen:e.ts,lastSeen:e.ts})}let g=[...h.values()].sort((e,t)=>t.count-e.count),_=m.slice(-c);return{totalEntries:m.length,groups:g,recent:_,dateRange:{from:p.length>0?p[0].slice(0,10):d,to:f}}}export{o as dogfoodLog};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region packages/tools/src/encode.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* aikit_encode — Encoding, decoding, and hashing utilities.
|
|
4
|
+
*/
|
|
5
|
+
type EncodeOperation = 'base64_encode' | 'base64_decode' | 'url_encode' | 'url_decode' | 'sha256' | 'md5' | 'jwt_decode' | 'hex_encode' | 'hex_decode';
|
|
6
|
+
interface EncodeOptions {
|
|
7
|
+
operation: EncodeOperation;
|
|
8
|
+
input: string;
|
|
9
|
+
}
|
|
10
|
+
interface EncodeResult {
|
|
11
|
+
output: string;
|
|
12
|
+
operation: string;
|
|
13
|
+
}
|
|
14
|
+
declare function encode(options: EncodeOptions): EncodeResult;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { EncodeOperation, EncodeOptions, EncodeResult, encode };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash as e}from"node:crypto";function t(t){let{operation:n,input:r}=t,i;switch(n){case`base64_encode`:i=Buffer.from(r).toString(`base64`);break;case`base64_decode`:i=Buffer.from(r,`base64`).toString(`utf8`);break;case`url_encode`:i=encodeURIComponent(r);break;case`url_decode`:i=decodeURIComponent(r);break;case`sha256`:i=e(`sha256`).update(r).digest(`hex`);break;case`md5`:i=e(`md5`).update(r).digest(`hex`);break;case`jwt_decode`:{let e=r.split(`.`);if(e.length!==3)throw Error(`Invalid JWT: expected 3 dot-separated parts`);let t,n;try{t=JSON.parse(Buffer.from(e[0],`base64url`).toString()),n=JSON.parse(Buffer.from(e[1],`base64url`).toString())}catch{throw Error(`Invalid JWT: header or payload is not valid JSON`)}i=JSON.stringify({header:t,payload:n},null,2);break}case`hex_encode`:i=Buffer.from(r).toString(`hex`);break;case`hex_decode`:i=Buffer.from(r,`hex`).toString(`utf8`);break;default:throw Error(`Unknown operation: ${n}`)}return{output:i,operation:n}}export{t as encode};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region packages/tools/src/env-info.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* aikit_env — System environment and runtime information.
|
|
4
|
+
*/
|
|
5
|
+
interface EnvInfoOptions {
|
|
6
|
+
includeEnv?: boolean;
|
|
7
|
+
filterEnv?: string;
|
|
8
|
+
showSensitive?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface EnvInfoResult {
|
|
11
|
+
system: {
|
|
12
|
+
platform: string;
|
|
13
|
+
arch: string;
|
|
14
|
+
release: string;
|
|
15
|
+
hostname: string;
|
|
16
|
+
type: string;
|
|
17
|
+
cpus: number;
|
|
18
|
+
memoryTotalGb: number;
|
|
19
|
+
memoryFreeGb: number;
|
|
20
|
+
};
|
|
21
|
+
runtime: {
|
|
22
|
+
node: string;
|
|
23
|
+
v8: string;
|
|
24
|
+
};
|
|
25
|
+
cwd: string;
|
|
26
|
+
env?: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
declare function envInfo(options?: EnvInfoOptions): EnvInfoResult;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { EnvInfoOptions, EnvInfoResult, envInfo };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{arch as e,cpus as t,freemem as n,hostname as r,platform as i,release as a,totalmem as o,type as s}from"node:os";const c=[/key/i,/secret/i,/token/i,/password/i,/passwd/i,/credential/i,/private/i,/certificate/i];function l(l={}){let{includeEnv:u=!1,filterEnv:d,showSensitive:f=!1}=l,p={system:{platform:i(),arch:e(),release:a(),hostname:r(),type:s(),cpus:t().length,memoryTotalGb:Math.round(o()/1024**3*10)/10,memoryFreeGb:Math.round(n()/1024**3*10)/10},runtime:{node:process.versions.node,v8:process.versions.v8},cwd:process.cwd()};if(u){let e={};for(let[t,n]of Object.entries(process.env))n&&(d&&!t.toLowerCase().includes(d.toLowerCase())||(!f&&c.some(e=>e.test(t))?e[t]=`[REDACTED]`:e[t]=n));p.env=e}return p}export{l as envInfo};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region packages/tools/src/eval.d.ts
|
|
2
|
+
interface EvalOptions {
|
|
3
|
+
code: string;
|
|
4
|
+
lang?: 'js' | 'ts';
|
|
5
|
+
timeout?: number;
|
|
6
|
+
}
|
|
7
|
+
interface EvalResult {
|
|
8
|
+
success: boolean;
|
|
9
|
+
output: string;
|
|
10
|
+
error?: string;
|
|
11
|
+
durationMs: number;
|
|
12
|
+
}
|
|
13
|
+
declare function evaluate(options: EvalOptions): EvalResult;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { EvalOptions, EvalResult, evaluate };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import e from"node:vm";function t(t){let{code:i,lang:a=`js`,timeout:o=5e3}=t,s=Math.min(Math.max(o,100),1e4),c=Date.now();try{let t=a===`ts`?r(i):i,o=[],l={console:{log:(...e)=>o.push(e.map(String).join(` `)),error:(...e)=>o.push(`[error] ${e.map(String).join(` `)}`),warn:(...e)=>o.push(`[warn] ${e.map(String).join(` `)}`)},setTimeout:void 0,setInterval:void 0,setImmediate:void 0,fetch:void 0,process:void 0,require:void 0,JSON,Math,Date,Array,Object,String,Number,Boolean,Map,Set,RegExp,Error,Promise,parseInt,parseFloat,isNaN,isFinite},u=e.createContext(l,{codeGeneration:{strings:!1,wasm:!1}}),d=e.runInContext(t,u,{timeout:s});return{success:!0,output:o.length>0?o.join(`
|
|
2
|
+
`)+(d===void 0?``:`\n→ ${n(d)}`):d===void 0?`(no output)`:n(d),durationMs:Date.now()-c}}catch(e){return{success:!1,output:``,error:e.message,durationMs:Date.now()-c}}}function n(e){if(e===void 0)return`undefined`;if(e===null)return`null`;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function r(e){return e.replace(/^\s*import\s+type\s+.*?;\s*$/gm,``).replace(/^\s*(?:export\s+)?interface\s+\w+[^{]*\{[\s\S]*?^\s*}\s*$/gm,``).replace(/^\s*(?:export\s+)?type\s+\w+\s*=.*?;\s*$/gm,``).replace(/([,(]\s*[A-Za-z_$][\w$]*)\s*:\s*[^,)=\n]+/g,`$1`).replace(/\)\s*:\s*[^={\n]+(?=\s*(?:=>|\{))/g,`)`).replace(/\s+as\s+[A-Za-z_$][\w$<>,[\]|&\s.]*/g,``).replace(/<(?:[A-Za-z_$][\w$]*\s*,?\s*)+>(?=\s*\()/g,``)}export{t as evaluate};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region packages/tools/src/evidence-map.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* aikit_evidence_map — FORGE Evidence Map CRUD + Gate evaluator.
|
|
4
|
+
*
|
|
5
|
+
* Structured storage, validation, and gate evaluation for FORGE Evidence Map entries.
|
|
6
|
+
* Persisted in .aikit-state/evidence-maps.json.
|
|
7
|
+
*/
|
|
8
|
+
type EvidenceStatus = 'V' | 'A' | 'U';
|
|
9
|
+
type UnknownType = 'contract' | 'convention' | 'freshness' | 'runtime' | 'data-flow' | 'impact';
|
|
10
|
+
type GateDecision = 'YIELD' | 'HOLD' | 'HARD_BLOCK' | 'FORCED_DELIVERY';
|
|
11
|
+
type ForgeTier = 'floor' | 'standard' | 'critical';
|
|
12
|
+
type SafetyGate = 'provenance' | 'commitment' | 'coverage';
|
|
13
|
+
interface EvidenceEntry {
|
|
14
|
+
id: number;
|
|
15
|
+
claim: string;
|
|
16
|
+
status: EvidenceStatus;
|
|
17
|
+
receipt: string;
|
|
18
|
+
criticalPath: boolean;
|
|
19
|
+
unknownType?: UnknownType;
|
|
20
|
+
safetyGate?: SafetyGate;
|
|
21
|
+
}
|
|
22
|
+
interface EvidenceMapState {
|
|
23
|
+
taskId: string;
|
|
24
|
+
tier: ForgeTier;
|
|
25
|
+
entries: EvidenceEntry[];
|
|
26
|
+
createdAt: string;
|
|
27
|
+
updatedAt: string;
|
|
28
|
+
}
|
|
29
|
+
interface SafetyGateResult {
|
|
30
|
+
provenance: 'pass' | 'fail';
|
|
31
|
+
commitment: 'pass' | 'fail';
|
|
32
|
+
coverage: 'pass' | 'fail';
|
|
33
|
+
failures: string[];
|
|
34
|
+
}
|
|
35
|
+
interface GateResult {
|
|
36
|
+
decision: GateDecision;
|
|
37
|
+
reason: string;
|
|
38
|
+
unresolvedCritical: EvidenceEntry[];
|
|
39
|
+
warnings: string[];
|
|
40
|
+
stats: {
|
|
41
|
+
total: number;
|
|
42
|
+
verified: number;
|
|
43
|
+
assumed: number;
|
|
44
|
+
unresolved: number;
|
|
45
|
+
};
|
|
46
|
+
safetyGates?: SafetyGateResult;
|
|
47
|
+
annotation?: string;
|
|
48
|
+
}
|
|
49
|
+
type EvidenceMapAction = {
|
|
50
|
+
action: 'create';
|
|
51
|
+
taskId: string;
|
|
52
|
+
tier: ForgeTier;
|
|
53
|
+
} | {
|
|
54
|
+
action: 'add';
|
|
55
|
+
taskId: string;
|
|
56
|
+
claim: string;
|
|
57
|
+
status: EvidenceStatus;
|
|
58
|
+
receipt: string;
|
|
59
|
+
criticalPath?: boolean;
|
|
60
|
+
unknownType?: UnknownType;
|
|
61
|
+
safetyGate?: SafetyGate;
|
|
62
|
+
} | {
|
|
63
|
+
action: 'update';
|
|
64
|
+
taskId: string;
|
|
65
|
+
id: number;
|
|
66
|
+
status: EvidenceStatus;
|
|
67
|
+
receipt: string;
|
|
68
|
+
} | {
|
|
69
|
+
action: 'get';
|
|
70
|
+
taskId: string;
|
|
71
|
+
} | {
|
|
72
|
+
action: 'gate';
|
|
73
|
+
taskId: string;
|
|
74
|
+
retryCount?: number;
|
|
75
|
+
} | {
|
|
76
|
+
action: 'list';
|
|
77
|
+
} | {
|
|
78
|
+
action: 'delete';
|
|
79
|
+
taskId: string;
|
|
80
|
+
};
|
|
81
|
+
interface EvidenceMapResult {
|
|
82
|
+
state?: EvidenceMapState;
|
|
83
|
+
states?: EvidenceMapState[];
|
|
84
|
+
entry?: EvidenceEntry;
|
|
85
|
+
gate?: GateResult;
|
|
86
|
+
deleted?: boolean;
|
|
87
|
+
formattedMap?: string;
|
|
88
|
+
}
|
|
89
|
+
declare function evidenceMap(action: EvidenceMapAction, cwd?: string): EvidenceMapResult;
|
|
90
|
+
declare function autoClaimTestFailures(taskId: string, failures: string[], cwd?: string): EvidenceEntry[];
|
|
91
|
+
//#endregion
|
|
92
|
+
export { EvidenceEntry, EvidenceMapAction, EvidenceMapResult, EvidenceMapState, EvidenceStatus, ForgeTier, GateDecision, GateResult, SafetyGate, SafetyGateResult, UnknownType, autoClaimTestFailures, evidenceMap };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{dirname as e,resolve as t}from"node:path";import{existsSync as n,mkdirSync as r,readFileSync as i,writeFileSync as a}from"node:fs";import{AIKIT_PATHS as o}from"../../core/dist/index.js";const s=o.state;function c(e){return t(e??process.cwd(),s,`evidence-maps.json`)}function l(e){let t=c(e);if(!n(t))return{};try{let e=i(t,`utf-8`);return JSON.parse(e)}catch{return{}}}function u(t,i){let o=c(i),s=e(o);n(s)||r(s,{recursive:!0}),a(o,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function d(e,t){let n=l(t),r=n[e];if(!r)throw Error(`Evidence map not found: ${e}`);return{maps:n,state:r}}function f(e){return e.reduce((e,t)=>Math.max(e,t.id),0)+1}function p(e){let t=e.trim();if(!t)throw Error(`Claim is required`);if(/\r?\n/.test(t))throw Error(`Claim must be a single line`);return t}function m(e){return(e??``).replace(/\r?\n/g,` `).replace(/\|/g,`\\|`)}function h(e){let t=[`| # | Claim | Status | Receipt | Critical | Type | Safety |`,`|---|-------|--------|---------|----------|------|--------|`];for(let n of e.entries)t.push(`| ${n.id} | ${m(n.claim)} | ${n.status} | ${m(n.receipt)} | ${n.criticalPath?`yes`:`no`} | ${m(n.unknownType)} | ${m(n.safetyGate)} |`);return t.join(`
|
|
2
|
+
`)}function g(e){return{total:e.length,verified:e.filter(e=>e.status===`V`).length,assumed:e.filter(e=>e.status===`A`).length,unresolved:e.filter(e=>e.status===`U`).length}}function _(e){let t=[];for(let n of e.entries)n.status===`V`&&n.receipt.trim()===``&&t.push(`V entry without receipt`),n.status===`A`&&e.tier===`critical`&&n.unknownType===`contract`&&t.push(`Assumed contract at Critical tier — should be Verified`);return t}function v(e){return`FORCED DELIVERY annotation: unresolved entries remain -> ${e.filter(e=>e.status===`U`).map(e=>`#${e.id} ${e.claim}`).join(`; `)}`}function y(e){let t=[],n=e.entries.filter(e=>e.status===`V`&&!e.receipt.trim());n.length>0&&t.push(`Provenance: ${n.length} verified claim(s) lack receipts`);let r=e.entries.filter(e=>e.safetyGate===`commitment`&&e.status!==`V`);r.length>0&&t.push(`Commitment: ${r.length} commitment(s) not verified`);let i=e.entries.some(e=>e.safetyGate===`coverage`&&e.status===`U`);return i&&t.push(`Coverage: unresolved coverage entries remain`),{provenance:n.length>0?`fail`:`pass`,commitment:r.length>0?`fail`:`pass`,coverage:i?`fail`:`pass`,failures:t}}function b(e,t=0){let n=e.entries.filter(e=>e.criticalPath&&e.status===`U`),r=_(e),i=g(e.entries);return n.find(e=>e.unknownType===`contract`)?{decision:`HARD_BLOCK`,reason:`Unresolved contract unknown on critical path`,unresolvedCritical:n,warnings:r,stats:i}:n.length>0&&t===0?{decision:`HOLD`,reason:`Unresolved critical-path unknown — retry available`,unresolvedCritical:n,warnings:r,stats:i}:n.length>0&&t>=1?{decision:`FORCED_DELIVERY`,reason:`Unresolved critical-path unknown after retry`,unresolvedCritical:n,warnings:r,stats:i,annotation:v(e.entries)}:{decision:`YIELD`,reason:`All critical-path claims satisfy gate rules`,unresolvedCritical:[],warnings:r,stats:i,...x(e,r,i)}}function x(e,t,n){if(!e.entries.some(e=>e.safetyGate)||e.tier===`floor`)return{};let r=y(e);return r.failures.length>0?{safetyGates:r,decision:`HOLD`,reason:`Safety gate failure: ${r.failures.join(`; `)}`,warnings:[...t,...r.failures]}:{safetyGates:r}}function S(e,t){switch(e.action){case`create`:{let n=l(t),r=new Date().toISOString(),i={taskId:e.taskId,tier:e.tier,entries:[],createdAt:r,updatedAt:r};return n[e.taskId]=i,u(n,t),{state:i,formattedMap:h(i)}}case`add`:{let{maps:n,state:r}=d(e.taskId,t),i={id:f(r.entries),claim:p(e.claim),status:e.status,receipt:e.receipt,criticalPath:e.criticalPath??!1,unknownType:e.unknownType,safetyGate:e.safetyGate};return r.entries.push(i),r.updatedAt=new Date().toISOString(),n[e.taskId]=r,u(n,t),{state:r,entry:i,formattedMap:h(r)}}case`update`:{let{maps:n,state:r}=d(e.taskId,t),i=r.entries.find(t=>t.id===e.id);if(!i)throw Error(`Evidence entry not found: ${e.id}`);return i.status=e.status,i.receipt=e.receipt,r.updatedAt=new Date().toISOString(),n[e.taskId]=r,u(n,t),{state:r,entry:i,formattedMap:h(r)}}case`get`:{let{state:n}=d(e.taskId,t);return{state:n,formattedMap:h(n)}}case`gate`:{let{state:n}=d(e.taskId,t);return{state:n,gate:b(n,e.retryCount??0),formattedMap:h(n)}}case`list`:return{states:Object.values(l(t)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt))};case`delete`:{let n=l(t);return e.taskId in n?(delete n[e.taskId],u(n,t),{deleted:!0}):{deleted:!1}}}}function C(e,t,n){let r=[];for(let i of t){let t=S({action:`add`,taskId:e,claim:`Test failure: ${i}`,status:`U`,receipt:``,criticalPath:!0},n);t.entry&&r.push(t.entry)}return r}export{C as autoClaimTestFailures,S as evidenceMap};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region packages/tools/src/file-cache.d.ts
|
|
2
|
+
interface FileCacheEntry {
|
|
3
|
+
/** Full file content */
|
|
4
|
+
content: string;
|
|
5
|
+
/** SHA-256 hash of content */
|
|
6
|
+
hash: string;
|
|
7
|
+
/** Line count */
|
|
8
|
+
lines: number;
|
|
9
|
+
/** Estimated token count (~chars/4) */
|
|
10
|
+
estimatedTokens: number;
|
|
11
|
+
/** How many times this file has been requested */
|
|
12
|
+
hitCount: number;
|
|
13
|
+
/** Whether content changed since last read (false on cache hit) */
|
|
14
|
+
changed: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface FileCacheStats {
|
|
17
|
+
totalReads: number;
|
|
18
|
+
cacheHits: number;
|
|
19
|
+
filesTracked: number;
|
|
20
|
+
}
|
|
21
|
+
declare class FileCache {
|
|
22
|
+
private cache;
|
|
23
|
+
private totalReads;
|
|
24
|
+
private cacheHits;
|
|
25
|
+
private static readonly MAX_ENTRIES;
|
|
26
|
+
/**
|
|
27
|
+
* Get file content with deduplication.
|
|
28
|
+
* First call: reads from disk, hashes, caches.
|
|
29
|
+
* Subsequent calls: checks mtime → if unchanged, cache hit (skip read).
|
|
30
|
+
* If mtime changed: re-reads, re-hashes, checks if content actually changed.
|
|
31
|
+
*/
|
|
32
|
+
get(filePath: string): Promise<FileCacheEntry>;
|
|
33
|
+
/** Remove a single file from cache. Returns true if it was cached. */
|
|
34
|
+
invalidate(filePath: string): boolean;
|
|
35
|
+
/** Clear all cached files. Returns how many were cleared. */
|
|
36
|
+
clear(): number;
|
|
37
|
+
/** Get cache statistics. */
|
|
38
|
+
stats(): FileCacheStats;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { FileCache, FileCacheEntry, FileCacheStats };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{estimateTokens as e}from"./text-utils.js";import{readFile as t,stat as n}from"node:fs/promises";import{resolve as r}from"node:path";import{createHash as i}from"node:crypto";var a=class i{cache=new Map;totalReads=0;cacheHits=0;static MAX_ENTRIES=500;async get(a){let s=r(a);this.totalReads++;let c=await n(s);if(c.isDirectory())throw Error(`Path is a directory: ${a}. Expected a file path, not a directory. Use analyze_structure or find to explore directories.`);let l=c.mtimeMs,u=this.cache.get(s);if(u){if(u.mtimeMs===l)return this.cacheHits++,u.hitCount++,{content:u.content,hash:u.hash,lines:u.lines,estimatedTokens:u.estimatedTokens,hitCount:u.hitCount,changed:!1};let n=await t(s,`utf-8`),r=o(n);if(r===u.hash)return this.cacheHits++,u.hitCount++,u.mtimeMs=l,{content:u.content,hash:u.hash,lines:u.lines,estimatedTokens:u.estimatedTokens,hitCount:u.hitCount,changed:!1};let i=n.split(`
|
|
2
|
+
`).length,a=e(n);return u.content=n,u.hash=r,u.lines=i,u.estimatedTokens=a,u.hitCount++,u.mtimeMs=l,{content:n,hash:r,lines:i,estimatedTokens:a,hitCount:u.hitCount,changed:!0}}let d=await t(s,`utf-8`),f=o(d),p=d.split(`
|
|
3
|
+
`).length,m=e(d);if(this.cache.set(s,{content:d,hash:f,lines:p,estimatedTokens:m,hitCount:1,mtimeMs:l}),this.cache.size>i.MAX_ENTRIES){let e=this.cache.keys().next().value;e&&this.cache.delete(e)}return{content:d,hash:f,lines:p,estimatedTokens:m,hitCount:1,changed:!0}}invalidate(e){return this.cache.delete(r(e))}clear(){let e=this.cache.size;return this.cache.clear(),e}stats(){return{totalReads:this.totalReads,cacheHits:this.cacheHits,filesTracked:this.cache.size}}};function o(e){return i(`sha256`).update(e).digest(`hex`)}export{a as FileCache};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region packages/tools/src/file-summary.d.ts
|
|
2
|
+
interface FileSummaryOptions {
|
|
3
|
+
path: string;
|
|
4
|
+
/** Pre-loaded content — skip readFile when provided (e.g., from FileCache) */
|
|
5
|
+
content?: string;
|
|
6
|
+
previewLines?: number;
|
|
7
|
+
}
|
|
8
|
+
interface FileSummaryResult {
|
|
9
|
+
path: string;
|
|
10
|
+
lines: number;
|
|
11
|
+
language: string;
|
|
12
|
+
imports: string[];
|
|
13
|
+
exports: string[];
|
|
14
|
+
functions: Array<{
|
|
15
|
+
name: string;
|
|
16
|
+
line: number;
|
|
17
|
+
exported: boolean;
|
|
18
|
+
signature?: string;
|
|
19
|
+
}>;
|
|
20
|
+
classes: Array<{
|
|
21
|
+
name: string;
|
|
22
|
+
line: number;
|
|
23
|
+
exported: boolean;
|
|
24
|
+
signature?: string;
|
|
25
|
+
}>;
|
|
26
|
+
interfaces: Array<{
|
|
27
|
+
name: string;
|
|
28
|
+
line: number;
|
|
29
|
+
exported: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
types: Array<{
|
|
32
|
+
name: string;
|
|
33
|
+
line: number;
|
|
34
|
+
exported: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
/** Import details with external/internal classification (AST-powered) */
|
|
37
|
+
importDetails?: Array<{
|
|
38
|
+
source: string;
|
|
39
|
+
specifiers: string[];
|
|
40
|
+
isExternal: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
/** Intra-file call edges showing which functions call which (AST-powered) */
|
|
43
|
+
callEdges?: Array<{
|
|
44
|
+
caller: string;
|
|
45
|
+
callee: string;
|
|
46
|
+
line: number;
|
|
47
|
+
}>;
|
|
48
|
+
estimatedTokens: number;
|
|
49
|
+
}
|
|
50
|
+
declare function fileSummary(options: FileSummaryOptions): Promise<FileSummaryResult>;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { FileSummaryOptions, FileSummaryResult, fileSummary };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{readFile as e,stat as t}from"node:fs/promises";import{extname as n}from"node:path";import{SUPPORTED_EXTENSIONS as r,WasmRuntime as i,extractCalls as a,extractImports as o,extractSymbols as s}from"../../chunker/dist/index.js";async function c(a){let{path:o,previewLines:s=3}=a;if(!a.content){let e;try{e=await t(o)}catch(e){let t=e.code;throw t===`ENOENT`?Error(`File not found: ${o}. Check the path and try again.`):t===`EACCES`||t===`EPERM`?Error(`Permission denied reading ${o}. The file exists but is not accessible.`):e}if(e.isDirectory())throw Error(`Path is a directory: ${o}. file_summary requires a file path, not a directory. Use analyze_structure or find to explore directories.`);if(e.size>1e7)throw Error(`File too large (${(e.size/1e6).toFixed(1)}MB). file_summary supports files up to 10MB. Use search or compact with a query instead.`)}let c=a.content??await e(o,`utf-8`),d=c.split(`
|
|
2
|
+
`),f=o.split(`.`).pop()??``,p=n(o);return i.get()&&r.has(p)?l(o,c,d,f,p):u(o,c,d,f)}async function l(e,t,n,r,i){let[c,l,u]=await Promise.all([s(t,i,e),o(t,i,e),a(t,i,e).catch(()=>[])]),f=l.map(e=>`import ${e.specifiers.length>0?`{ ${e.specifiers.join(`, `)} }`:`*`} from '${e.source}'`),p=[],m=[],h=[],g=[],_=[];for(let e of c)switch(e.exported&&p.push(e.name),e.kind){case`function`:case`method`:m.push({name:e.name,line:e.line,exported:e.exported,signature:e.signature});break;case`class`:h.push({name:e.name,line:e.line,exported:e.exported,signature:e.signature});break;case`interface`:g.push({name:e.name,line:e.line,exported:e.exported});break;case`type`:_.push({name:e.name,line:e.line,exported:e.exported});break}let v=l.map(e=>({source:e.source,specifiers:e.specifiers,isExternal:e.isExternal})),y=u.map(e=>({caller:e.callerName,callee:e.calleeName,line:e.line}));return{path:e,lines:n.length,language:d(r),imports:f,exports:p,functions:m,classes:h,interfaces:g,types:_,importDetails:v,callEdges:y.length>0?y:void 0,estimatedTokens:Math.ceil(t.length/4)}}function u(e,t,n,r){let i=[],a=[],o=[],s=[],c=[],l=[];for(let e=0;e<n.length;e+=1){let t=n[e],r=e+1;if(/^import\s+.+/.test(t)){i.push(t.trim());continue}let u=t.match(/^export\s+(?:async\s+)?function\s+(\w+)/);if(u){o.push({name:u[1],line:r,exported:!0}),a.push(u[1]);continue}let d=t.match(/^(?:async\s+)?function\s+(\w+)/);if(d){o.push({name:d[1],line:r,exported:!1});continue}let f=t.match(/^(export\s+)?const\s+(\w+)\s*=.*(?:=>|\bfunction\b)/);if(f){let e=!!f[1];o.push({name:f[2],line:r,exported:e}),e&&a.push(f[2]);continue}let p=t.match(/^export\s+const\s+(\w+)\s*=/);if(p){a.push(p[1]);continue}let m=t.match(/^(export\s+)?(?:abstract\s+)?class\s+(\w+)/);if(m){let e=!!m[1];s.push({name:m[2],line:r,exported:e}),e&&a.push(m[2]);continue}let h=t.match(/^(export\s+)?interface\s+(\w+)/);if(h){let e=!!h[1];c.push({name:h[2],line:r,exported:e}),e&&a.push(h[2]);continue}let g=t.match(/^(export\s+)?type\s+(\w+)/);if(g){let e=!!g[1];l.push({name:g[2],line:r,exported:e}),e&&a.push(g[2]);continue}let _=t.match(/^export\s+\{(.+)\}/);if(_){let e=_[1].split(`,`).map(e=>e.trim().split(/\s+as\s+/).pop()?.trim()??``).filter(Boolean);a.push(...e)}}return{path:e,lines:n.length,language:d(r),imports:i,exports:a,functions:o,classes:s,interfaces:c,types:l,estimatedTokens:Math.ceil(t.length/4)}}function d(e){return{ts:`typescript`,tsx:`typescript-jsx`,js:`javascript`,jsx:`javascript-jsx`,py:`python`,rs:`rust`,go:`go`,java:`java`,rb:`ruby`,md:`markdown`,json:`json`,yaml:`yaml`,yml:`yaml`,css:`css`,html:`html`,sh:`shell`,bash:`shell`}[e]??e}export{c as fileSummary};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region packages/tools/src/file-walk.d.ts
|
|
2
|
+
declare const DEFAULT_TOOL_EXTENSIONS: string[];
|
|
3
|
+
declare function matchesGlobPattern(path: string, pattern: string): boolean;
|
|
4
|
+
declare function walkFiles(rootPath: string, extensions: string[], exclude: string[]): Promise<string[]>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { DEFAULT_TOOL_EXTENSIONS, matchesGlobPattern, walkFiles };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readdir as e,stat as t}from"node:fs/promises";import{extname as n,join as r,relative as i}from"node:path";import{AIKIT_PATHS as a}from"../../core/dist/index.js";const o=[`.ts`,`.tsx`,`.js`,`.jsx`],s=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,a.state]);function c(e){return e.replace(/\\/g,`/`)}function l(e){return e.replace(/[.+^${}()|[\]\\]/g,`\\$&`)}function u(e,t){let n=c(e),r=c(t).trim();if(!r)return!1;let i=l(r).replace(/\*\*/g,`::DOUBLE_STAR::`).replace(/\*/g,`[^/]*`).replace(/\?/g,`[^/]`).replace(/::DOUBLE_STAR::/g,`.*`);return RegExp(`^${i}$`).test(n)}function d(e,t,n){return t.some(t=>u(e,t)?!0:n?u(`${e}/`,t):!1)}async function f(a,o,l){let u=[],f=o.map(e=>e.toLowerCase());async function p(o){let m=await e(o);for(let e of m){if(s.has(e))continue;let m=r(o,e),h=await t(m),g=c(i(a,m));if(h.isDirectory()){d(g,l,!0)||await p(m);continue}d(g,l,!1)||f.includes(n(e).toLowerCase())&&u.push(m)}}return await p(a),u.sort((e,t)=>e.localeCompare(t)),u}export{o as DEFAULT_TOOL_EXTENSIONS,u as matchesGlobPattern,f as walkFiles};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ContentType } from "../../core/dist/index.js";
|
|
2
|
+
import { IEmbedder } from "../../embeddings/dist/index.js";
|
|
3
|
+
import { IKnowledgeStore } from "../../store/dist/index.js";
|
|
4
|
+
|
|
5
|
+
//#region packages/tools/src/find-examples.d.ts
|
|
6
|
+
interface FindExamplesOptions {
|
|
7
|
+
/** Symbol or pattern to find examples of */
|
|
8
|
+
query: string;
|
|
9
|
+
/** Max examples to return (default: 5) */
|
|
10
|
+
limit?: number;
|
|
11
|
+
/** Filter by content type */
|
|
12
|
+
contentType?: ContentType;
|
|
13
|
+
}
|
|
14
|
+
interface Example {
|
|
15
|
+
path: string;
|
|
16
|
+
startLine: number;
|
|
17
|
+
endLine: number;
|
|
18
|
+
content: string;
|
|
19
|
+
relevance: number;
|
|
20
|
+
context: string;
|
|
21
|
+
}
|
|
22
|
+
interface FindExamplesResult {
|
|
23
|
+
query: string;
|
|
24
|
+
examples: Example[];
|
|
25
|
+
totalFound: number;
|
|
26
|
+
}
|
|
27
|
+
declare function findExamples(embedder: IEmbedder, store: IKnowledgeStore, options: FindExamplesOptions): Promise<FindExamplesResult>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { Example, FindExamplesOptions, FindExamplesResult, findExamples };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{escapeRegExp as e}from"./regex-utils.js";async function t(t,n,r){let{query:i,limit:a=5,contentType:o}=r,s=`usage example of ${i}`,c=await t.embed(s),l=await n.search(c,{limit:a*3,contentType:o}),u=RegExp(`\\b${e(i)}\\b`,`i`),d=l.filter(e=>u.test(e.record.content));return{query:i,examples:d.map(e=>{let t=e.record.content,n=/export\s+(?:async\s+)?(?:function|class|const|interface|type)\s/.test(t),r=/^\s*import\s/m.test(t),i=/(?:^|[\\/])(test|tests|__tests__|spec)(?:[\\/]|$)/i.test(e.record.sourcePath)||/\.(test|spec)\.[jt]sx?$/i.test(e.record.sourcePath),a=0;n||(a+=.1),r||(a+=.05),i&&(a+=.05);let o=t.split(`
|
|
2
|
+
`),s=o.findIndex(e=>u.test(e)),c=Math.max(0,s-2),l=Math.min(o.length,s+5),d=o.slice(c,l).join(`
|
|
3
|
+
`);return{path:e.record.sourcePath,startLine:e.record.startLine,endLine:e.record.endLine,content:d||t.slice(0,300),relevance:Math.min(1,e.score+a),context:i?`test`:n?`definition`:`usage`}}).sort((e,t)=>t.relevance-e.relevance).slice(0,a),totalFound:d.length}}export{t as findExamples};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ContentType } from "../../core/dist/index.js";
|
|
2
|
+
import { IEmbedder } from "../../embeddings/dist/index.js";
|
|
3
|
+
import { IKnowledgeStore } from "../../store/dist/index.js";
|
|
4
|
+
|
|
5
|
+
//#region packages/tools/src/find.d.ts
|
|
6
|
+
interface FindOptions {
|
|
7
|
+
/** Semantic search query (optional) */
|
|
8
|
+
query?: string;
|
|
9
|
+
/** File glob pattern (optional) */
|
|
10
|
+
glob?: string;
|
|
11
|
+
/** Keyword/regex pattern for text search (optional) */
|
|
12
|
+
pattern?: string;
|
|
13
|
+
/** Max results per strategy (default: 10) */
|
|
14
|
+
limit?: number;
|
|
15
|
+
/** Filter by content type */
|
|
16
|
+
contentType?: ContentType;
|
|
17
|
+
/** Working directory for glob resolution (default: cwd) */
|
|
18
|
+
cwd?: string;
|
|
19
|
+
}
|
|
20
|
+
interface FindResult {
|
|
21
|
+
/** File path (relative to cwd) */
|
|
22
|
+
path: string;
|
|
23
|
+
/** How this result was found */
|
|
24
|
+
source: 'vector' | 'keyword' | 'glob' | 'pattern';
|
|
25
|
+
/** Relevance score (0-1 for vector/keyword, 1 for glob/pattern matches) */
|
|
26
|
+
score: number;
|
|
27
|
+
/** Line range if from KB search */
|
|
28
|
+
lineRange?: {
|
|
29
|
+
start: number;
|
|
30
|
+
end: number;
|
|
31
|
+
};
|
|
32
|
+
/** Content preview */
|
|
33
|
+
preview?: string;
|
|
34
|
+
}
|
|
35
|
+
interface FindResults {
|
|
36
|
+
results: FindResult[];
|
|
37
|
+
strategies: string[];
|
|
38
|
+
totalFound: number;
|
|
39
|
+
failedStrategies?: Array<{
|
|
40
|
+
strategy: string;
|
|
41
|
+
reason: string;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Run federated search across multiple strategies.
|
|
46
|
+
*/
|
|
47
|
+
declare function find(embedder: IEmbedder, store: IKnowledgeStore, options: FindOptions): Promise<FindResults>;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { FindOptions, FindResult, FindResults, find };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AIKIT_PATHS as e}from"../../core/dist/index.js";async function t(t,n,r){let{query:i,glob:a,pattern:o,limit:s=10,contentType:c,cwd:l=process.cwd()}=r,u=[],d=[],f=new Set,p=[];if(i){u.push(`vector`);let e=await t.embed(i),r={limit:s,contentType:c},a=await n.search(e,r);for(let e of a){let t=`${e.record.sourcePath}:${e.record.startLine}`;f.has(t)||(f.add(t),d.push({path:e.record.sourcePath,source:`vector`,score:e.score,lineRange:{start:e.record.startLine,end:e.record.endLine},preview:e.record.content.slice(0,200)}))}}if(i){u.push(`keyword`);try{let e=await n.ftsSearch(i,{limit:s,contentType:c});for(let t of e){let e=`${t.record.sourcePath}:${t.record.startLine}`;f.has(e)||(f.add(e),d.push({path:t.record.sourcePath,source:`keyword`,score:t.score,lineRange:{start:t.record.startLine,end:t.record.endLine},preview:t.record.content.slice(0,200)}))}}catch(e){p.push({strategy:`keyword`,reason:e instanceof Error?e.message:String(e)})}}if(a){u.push(`glob`);try{let{globSync:t}=await import(`node:fs`),n=t(a,{cwd:l,withFileTypes:!1}),r=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,e.state,e.data]),i=n.filter(e=>!e.replace(/\\/g,`/`).split(`/`).some(e=>r.has(e)));for(let e of i.slice(0,s)){let t=`glob:${e}`;f.has(t)||(f.add(t),d.push({path:e,source:`glob`,score:1}))}}catch(e){p.push({strategy:`glob`,reason:e instanceof Error?e.message:String(e)})}}if(o){u.push(`pattern`);try{let e=new RegExp(o,`i`),t=await n.ftsSearch(o,{limit:s*2,contentType:c});for(let n of t)if(e.test(n.record.content)){let e=`${n.record.sourcePath}:${n.record.startLine}`;f.has(e)||(f.add(e),d.push({path:n.record.sourcePath,source:`pattern`,score:n.score,lineRange:{start:n.record.startLine,end:n.record.endLine},preview:n.record.content.slice(0,200)}))}}catch(e){p.push({strategy:`pattern`,reason:e instanceof Error?e.message:String(e)})}}return d.sort((e,t)=>t.score-e.score),{results:d.slice(0,s),strategies:u,totalFound:d.length,...p.length>0&&{failedStrategies:p}}}export{t as find};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ForgeTier } from "./evidence-map.js";
|
|
2
|
+
|
|
3
|
+
//#region packages/tools/src/forge-classify.d.ts
|
|
4
|
+
interface ForgeClassifyOptions {
|
|
5
|
+
/** Files being modified (absolute or relative paths) */
|
|
6
|
+
files: string[];
|
|
7
|
+
/** Task description for keyword detection */
|
|
8
|
+
task: string;
|
|
9
|
+
/** Root path for package boundary detection */
|
|
10
|
+
rootPath: string;
|
|
11
|
+
}
|
|
12
|
+
interface ClassifyTrigger {
|
|
13
|
+
rule: string;
|
|
14
|
+
detail: string;
|
|
15
|
+
source: 'blast_radius' | 'cross_package' | 'schema_contract' | 'security_auth' | 'task_hint' | 'default';
|
|
16
|
+
}
|
|
17
|
+
interface TypedUnknownSeed {
|
|
18
|
+
description: string;
|
|
19
|
+
type: 'contract' | 'convention' | 'freshness' | 'runtime' | 'data-flow' | 'impact';
|
|
20
|
+
suggestedTool: string;
|
|
21
|
+
}
|
|
22
|
+
interface ForgeClassifyCeremony {
|
|
23
|
+
ground: string;
|
|
24
|
+
build: string;
|
|
25
|
+
break: string;
|
|
26
|
+
evidenceMap: string;
|
|
27
|
+
gate: string;
|
|
28
|
+
}
|
|
29
|
+
interface ForgeClassifyResult {
|
|
30
|
+
tier: ForgeTier;
|
|
31
|
+
triggers: ClassifyTrigger[];
|
|
32
|
+
packagesCrossed: string[];
|
|
33
|
+
hasSchemaChange: boolean;
|
|
34
|
+
hasSecurityPath: boolean;
|
|
35
|
+
typedUnknownSeeds: TypedUnknownSeed[];
|
|
36
|
+
ceremony: ForgeClassifyCeremony;
|
|
37
|
+
reclassifyHint?: {
|
|
38
|
+
suggestedTier: ForgeTier;
|
|
39
|
+
reason: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
declare function forgeClassify(options: ForgeClassifyOptions): Promise<ForgeClassifyResult>;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { ClassifyTrigger, ForgeClassifyCeremony, ForgeClassifyOptions, ForgeClassifyResult, TypedUnknownSeed, forgeClassify };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{fileSummary as e}from"./file-summary.js";import{dirname as t,extname as n,relative as r,resolve as i}from"node:path";import{existsSync as a,readFileSync as o,readdirSync as s,statSync as c}from"node:fs";import{AIKIT_PATHS as l}from"../../core/dist/index.js";const u=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.mts`,`.cts`,`.mjs`,`.cjs`]),d=new Set([`.git`,l.data,l.state,`.turbo`,`.yarn`,`build`,`coverage`,`dist`,`node_modules`]),f=/auth|token|permission|acl|encrypt|secret|credential|jwt|oauth|password/i,p=/\b(hash|sign|verify|bcrypt|jwt|decrypt|secret|password)\b/i,m=/auth|security|permission|encrypt|secret|credential/i,h=/types\.ts$|schema\.ts$|contract\.ts$|\.proto$|openapi|swagger|\.graphql$/i,g=/(?:^|\/)(events|contracts|shared)(?:\/|$)/i,_=/export\s+interface\b|export\s+type\b|export\s+const\s+\w*Schema\w*\s*=\s*z\./i,v=/schema|contract|migration|breaking.change|api.change/i,y=/migration|data.?model|multi.?service|breaking|backward.?compat/i,b={floor:{ground:`Parasitic — read target file only`,build:`Implement directly`,break:`Skip`,evidenceMap:`Not required`,gate:`Self-certify`},standard:{ground:`Scope map + blast radius + constraint seed`,build:`TDD — test first, then implement`,break:`Error paths + edge cases`,evidenceMap:`3-8 critical-path entries`,gate:`YIELD/HOLD evaluation`},critical:{ground:`Full scope map + blast radius + trace + patterns + constraint pack`,build:`TDD + contract verification + cross-service validation`,break:`Error paths + edge cases + security dimensions + data-flow verification`,evidenceMap:`Comprehensive — all critical-path claims with receipts`,gate:`Strict YIELD/HOLD/HARD_BLOCK evaluation`}};async function x(e){let t=i(e.rootPath),n=e.task.trim(),r=e.files.map(e=>i(t,e)),a=[],o=!1,s=!1;for(let e of r){let r=C(e,t),i=T(e);(f.test(r)||p.test(i)||m.test(n))&&(o=!0),(h.test(r)||g.test(r)||v.test(n)||_.test(i)||await E(e))&&(s=!0)}o&&S(a,{rule:`security-path`,detail:`Security/auth path, task, or content matched security heuristics`,source:`security_auth`}),s&&S(a,{rule:`schema-contract`,detail:`Schema or contract path, task, or export shape matched contract heuristics`,source:`schema_contract`});let c=D(r,t);c.affectedFiles>5&&S(a,{rule:`blast-radius-importers`,detail:`${c.affectedFiles} affected files via direct import scanning`,source:`blast_radius`});let l=[...new Set(r.map(e=>M(e,t)).filter(e=>!!e))].sort();l.length>=2&&S(a,{rule:`cross-package-boundary`,detail:`Files span ${l.length} packages: ${l.join(`, `)}`,source:`cross_package`}),y.test(n)&&S(a,{rule:`task-hint-critical`,detail:`Task description matched migration or compatibility criticality hints`,source:`task_hint`});let u=a.length>0?`critical`:r.length===1?`floor`:`standard`;u===`floor`&&(o||s)&&(u=`standard`);let d=j(a),x=u===`floor`&&d.some(e=>e.type===`contract`)?{suggestedTier:`standard`,reason:`Contract-type unknowns detected — Floor may be insufficient`}:void 0;return{tier:u,triggers:a,packagesCrossed:l,hasSchemaChange:s,hasSecurityPath:o,typedUnknownSeeds:d,ceremony:b[u],reclassifyHint:x}}function S(e,t){e.some(e=>e.rule===t.rule&&e.source===t.source)||e.push(t)}function C(e,t){let n=i(t,e),a=r(t,n);return(a&&!a.startsWith(`..`)?a:n).replace(/\\/g,`/`)}function w(e){if(!a(e))return!1;try{return c(e).size<=1e5}catch{return!1}}function T(e){if(!w(e))return``;try{return o(e,`utf-8`).split(/\r?\n/).slice(0,200).join(`
|
|
2
|
+
`)}catch{return``}}async function E(t){if(!w(t))return!1;try{let n=await e({path:t}),r=new Set(n.exports);return n.interfaces.some(e=>r.has(e.name))||n.types.some(e=>r.has(e.name))}catch{return!1}}function D(e,t){let n=new Set(e.filter(e=>a(e)));if(n.size===0)return{affectedFiles:e.length,importers:[]};let i=new Set;for(let e of O(t)){if(n.has(e)||!w(e))continue;let t=T(e);t&&k(t).some(t=>A(t,e,n))&&i.add(e)}return{affectedFiles:e.length+i.size,importers:[...i].map(e=>r(t,e).replace(/\\/g,`/`))}}function O(e){let t=[];function r(e){let a=[];try{a=s(e)}catch{return}for(let o of a){if(d.has(o))continue;let a=i(e,o),s;try{s=c(a)}catch{continue}if(s.isDirectory()){r(a);continue}u.has(n(o).toLowerCase())&&t.push(a)}}return r(e),t}function k(e){let t=new Set;for(let n of e.matchAll(/(?:from\s+['"]([^'"]+)['"]|import\s+['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\))/g)){let e=n[1]??n[2]??n[3];e&&t.add(e)}return[...t]}function A(e,n,r){if(!e.startsWith(`.`))return!1;let a=i(t(n),e);return[a,`${a}.ts`,`${a}.tsx`,`${a}.js`,`${a}.jsx`,`${a}.mts`,`${a}.cts`,`${a}.mjs`,`${a}.cjs`,i(a,`index.ts`),i(a,`index.tsx`),i(a,`index.js`),i(a,`index.jsx`)].some(e=>r.has(e))}function j(e){return e.map(e=>{switch(e.source){case`security_auth`:return{description:`Verify auth and security assumptions before yielding`,type:`contract`,suggestedTool:`aikit_search`};case`schema_contract`:return{description:`Confirm schema and contract compatibility`,type:`contract`,suggestedTool:`aikit_schema_validate`};case`blast_radius`:return{description:`Inspect affected importers before delivery`,type:`impact`,suggestedTool:`aikit_blast_radius`};case`cross_package`:return{description:`Assess downstream package impact across boundaries`,type:`impact`,suggestedTool:`aikit_blast_radius`};case`task_hint`:return{description:`Check established conventions for migrations or compatibility work`,type:`convention`,suggestedTool:`aikit_find`};default:return{description:`No explicit unknown routing required`,type:`freshness`,suggestedTool:`aikit_lookup`}}})}function M(e,n){let s=t(i(n,e)),c=i(n);for(;s.length>=c.length;){let e=i(s,`package.json`);if(a(e))try{return JSON.parse(o(e,`utf-8`)).name??r(c,s).replace(/\\/g,`/`)}catch{return r(c,s).replace(/\\/g,`/`)}let n=t(s);if(n===s)break;s=n}}export{x as forgeClassify};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ForgeTier } from "./evidence-map.js";
|
|
2
|
+
import { ClassifyTrigger, TypedUnknownSeed } from "./forge-classify.js";
|
|
3
|
+
import { ScopeMapResult } from "./scope-map.js";
|
|
4
|
+
import { IEmbedder } from "../../embeddings/dist/index.js";
|
|
5
|
+
import { IKnowledgeStore } from "../../store/dist/index.js";
|
|
6
|
+
|
|
7
|
+
//#region packages/tools/src/forge-ground.d.ts
|
|
8
|
+
interface ForgeGroundOptions {
|
|
9
|
+
/** Task description */
|
|
10
|
+
task: string;
|
|
11
|
+
/** Target files being modified (absolute paths) */
|
|
12
|
+
files: string[];
|
|
13
|
+
/** Root path of the codebase */
|
|
14
|
+
rootPath: string;
|
|
15
|
+
/** Max constraint entries to load (default: 3) */
|
|
16
|
+
maxConstraints?: number;
|
|
17
|
+
/** Force a specific tier (skip auto-classify) */
|
|
18
|
+
forceTier?: ForgeTier;
|
|
19
|
+
/** Task ID for evidence map creation (default: auto-generated from task) */
|
|
20
|
+
taskId?: string;
|
|
21
|
+
}
|
|
22
|
+
interface ConstraintRef {
|
|
23
|
+
source: string;
|
|
24
|
+
snippet: string;
|
|
25
|
+
relevance: number;
|
|
26
|
+
}
|
|
27
|
+
interface ForgeGroundResult {
|
|
28
|
+
/** Computed or forced tier */
|
|
29
|
+
tier: ForgeTier;
|
|
30
|
+
/** Classification triggers (empty if tier was forced) */
|
|
31
|
+
classifyTriggers: ClassifyTrigger[];
|
|
32
|
+
/** Scope map (relevant files with focus ranges) — null for Floor tier */
|
|
33
|
+
scopeMap: ScopeMapResult | null;
|
|
34
|
+
/** Typed Unknown Queue seeds */
|
|
35
|
+
typedUnknownSeeds: TypedUnknownSeed[];
|
|
36
|
+
/** Constraint seed — relevant KB entries from decisions/patterns */
|
|
37
|
+
constraints: ConstraintRef[];
|
|
38
|
+
/** File summaries for target files */
|
|
39
|
+
fileSummaries: Array<{
|
|
40
|
+
path: string;
|
|
41
|
+
exports: string[];
|
|
42
|
+
functions: string[];
|
|
43
|
+
lines: number;
|
|
44
|
+
error?: string;
|
|
45
|
+
}>;
|
|
46
|
+
/** Evidence map task ID (created if Standard or Critical) */
|
|
47
|
+
evidenceMapTaskId: string | null;
|
|
48
|
+
/** Total estimated tokens for this Ground output */
|
|
49
|
+
estimatedTokens: number;
|
|
50
|
+
/** Ceremony recommendations for this tier */
|
|
51
|
+
ceremony: {
|
|
52
|
+
ground: string;
|
|
53
|
+
build: string;
|
|
54
|
+
break: string;
|
|
55
|
+
evidenceMap: string;
|
|
56
|
+
gate: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
declare function forgeGround(embedder: IEmbedder, store: IKnowledgeStore, options: ForgeGroundOptions): Promise<ForgeGroundResult>;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { ConstraintRef, ForgeGroundOptions, ForgeGroundResult, forgeGround };
|