token-pilot 0.30.5 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/agents/tp-api-surface-tracker.md +10 -2
  4. package/agents/tp-audit-scanner.md +10 -2
  5. package/agents/tp-commit-writer.md +10 -2
  6. package/agents/tp-context-engineer.md +10 -2
  7. package/agents/tp-dead-code-finder.md +10 -2
  8. package/agents/tp-debugger.md +10 -2
  9. package/agents/tp-dep-health.md +10 -2
  10. package/agents/tp-doc-writer.md +10 -2
  11. package/agents/tp-history-explorer.md +10 -2
  12. package/agents/tp-impact-analyzer.md +10 -2
  13. package/agents/tp-incident-timeline.md +10 -2
  14. package/agents/tp-incremental-builder.md +10 -2
  15. package/agents/tp-migration-scout.md +10 -2
  16. package/agents/tp-onboard.md +10 -2
  17. package/agents/tp-performance-profiler.md +10 -2
  18. package/agents/tp-pr-reviewer.md +10 -2
  19. package/agents/tp-refactor-planner.md +10 -2
  20. package/agents/tp-review-impact.md +10 -2
  21. package/agents/tp-run.md +10 -2
  22. package/agents/tp-session-restorer.md +10 -2
  23. package/agents/tp-ship-coordinator.md +10 -2
  24. package/agents/tp-spec-writer.md +10 -2
  25. package/agents/tp-test-coverage-gapper.md +10 -2
  26. package/agents/tp-test-triage.md +10 -2
  27. package/agents/tp-test-writer.md +10 -2
  28. package/dist/cli/stats.d.ts +2 -0
  29. package/dist/cli/stats.js +46 -1
  30. package/dist/core/agent-matcher.d.ts +115 -0
  31. package/dist/core/agent-matcher.js +326 -0
  32. package/dist/core/event-log.d.ts +14 -1
  33. package/dist/core/validation.d.ts +13 -9
  34. package/dist/core/validation.js +180 -134
  35. package/dist/handlers/call-tree.d.ts +35 -0
  36. package/dist/handlers/call-tree.js +70 -0
  37. package/dist/hooks/installer.js +9 -0
  38. package/dist/hooks/post-task.d.ts +15 -0
  39. package/dist/hooks/post-task.js +102 -19
  40. package/dist/hooks/pre-task.d.ts +71 -0
  41. package/dist/hooks/pre-task.js +125 -0
  42. package/dist/hooks/session-start.d.ts +2 -0
  43. package/dist/hooks/session-start.js +49 -0
  44. package/dist/index.js +29 -0
  45. package/dist/server/tool-definitions.d.ts +65 -0
  46. package/dist/server/tool-definitions.js +18 -0
  47. package/dist/server.js +36 -1
  48. package/hooks/hooks.json +9 -0
  49. package/package.json +1 -1
@@ -977,6 +977,71 @@ export declare const TOOL_DEFINITIONS: ({
977
977
  };
978
978
  required?: undefined;
979
979
  };
980
+ } | {
981
+ name: string;
982
+ description: string;
983
+ inputSchema: {
984
+ type: "object";
985
+ properties: {
986
+ symbol: {
987
+ type: string;
988
+ description: string;
989
+ };
990
+ depth: {
991
+ type: string;
992
+ description: string;
993
+ };
994
+ path?: undefined;
995
+ show_imports?: undefined;
996
+ show_docs?: undefined;
997
+ scope?: undefined;
998
+ max_tokens?: undefined;
999
+ session_id?: undefined;
1000
+ force?: undefined;
1001
+ context_before?: undefined;
1002
+ context_after?: undefined;
1003
+ show?: undefined;
1004
+ include_edit_context?: undefined;
1005
+ symbols?: undefined;
1006
+ start_line?: undefined;
1007
+ end_line?: undefined;
1008
+ heading?: undefined;
1009
+ context_lines?: undefined;
1010
+ line?: undefined;
1011
+ context?: undefined;
1012
+ include_callers?: undefined;
1013
+ include_tests?: undefined;
1014
+ include_changes?: undefined;
1015
+ section?: undefined;
1016
+ paths?: undefined;
1017
+ kind?: undefined;
1018
+ limit?: undefined;
1019
+ lang?: undefined;
1020
+ mode?: undefined;
1021
+ include?: undefined;
1022
+ recursive?: undefined;
1023
+ max_depth?: undefined;
1024
+ verbose?: undefined;
1025
+ module?: undefined;
1026
+ export_only?: undefined;
1027
+ check?: undefined;
1028
+ pattern?: undefined;
1029
+ name?: undefined;
1030
+ ref?: undefined;
1031
+ count?: undefined;
1032
+ command?: undefined;
1033
+ runner?: undefined;
1034
+ timeout?: undefined;
1035
+ goal?: undefined;
1036
+ decisions?: undefined;
1037
+ confirmed?: undefined;
1038
+ files?: undefined;
1039
+ blocked?: undefined;
1040
+ next?: undefined;
1041
+ sessionId?: undefined;
1042
+ };
1043
+ required: string[];
1044
+ };
980
1045
  } | {
981
1046
  name: string;
982
1047
  description: string;
@@ -502,6 +502,24 @@ export const TOOL_DEFINITIONS = [
502
502
  },
503
503
  },
504
504
  // --- Analysis ---
505
+ {
506
+ name: "call_tree",
507
+ description: "Recursive depth-N call hierarchy for a function. Shows who calls who transitively — complements find_usages (flat one-level refs) by revealing full chains from leaf helpers to entry points. Use for debugging, refactor impact, and verifying reachability.",
508
+ inputSchema: {
509
+ type: "object",
510
+ properties: {
511
+ symbol: {
512
+ type: "string",
513
+ description: "Function / method name, unqualified (e.g. `fetchUser`).",
514
+ },
515
+ depth: {
516
+ type: "number",
517
+ description: "Walk-up depth. Default 3, max 6.",
518
+ },
519
+ },
520
+ required: ["symbol"],
521
+ },
522
+ },
505
523
  {
506
524
  name: "find_unused",
507
525
  description: "Find dead code — functions, classes, and variables with no references across the project. Use for cleanup and refactoring.",
package/dist/server.js CHANGED
@@ -28,6 +28,7 @@ import { handleSmartReadMany } from "./handlers/smart-read-many.js";
28
28
  import { handleProjectOverview } from "./handlers/project-overview.js";
29
29
  import { handleNonCodeRead, isNonCodeStructured } from "./handlers/non-code.js";
30
30
  import { handleFindUnused } from "./handlers/find-unused.js";
31
+ import { handleCallTree } from "./handlers/call-tree.js";
31
32
  import { handleReadForEdit } from "./handlers/read-for-edit.js";
32
33
  import { handleRelatedFiles } from "./handlers/related-files.js";
33
34
  import { handleOutline } from "./handlers/outline.js";
@@ -49,7 +50,7 @@ import { getMcpInstructions, TOOL_DEFINITIONS, } from "./server/tool-definitions
49
50
  import { filterToolsByProfile, parseProfileEnv, } from "./server/tool-profiles.js";
50
51
  import { STRICT_SMART_READ_MAX_TOKENS, STRICT_EXPLORE_AREA_INCLUDE, } from "./server/enforcement-mode.js";
51
52
  import { createTokenEstimates } from "./server/token-estimates.js";
52
- import { validateSmartReadArgs, validateReadSymbolArgs, validateReadSymbolsArgs, validateReadRangeArgs, validateReadDiffArgs, validateFindUsagesArgs, validateSmartReadManyArgs, validateReadForEditArgs, validateRelatedFilesArgs, validateOutlineArgs, validateFindUnusedArgs, validateCodeAuditArgs, validateProjectOverviewArgs, validateModuleInfoArgs, validateSmartDiffArgs, validateExploreAreaArgs, validateSmartLogArgs, validateTestSummaryArgs, validateReadSectionArgs, } from "./core/validation.js";
53
+ import { validateSmartReadArgs, validateReadSymbolArgs, validateReadSymbolsArgs, validateReadRangeArgs, validateReadDiffArgs, validateFindUsagesArgs, validateSmartReadManyArgs, validateReadForEditArgs, validateRelatedFilesArgs, validateOutlineArgs, validateFindUnusedArgs, validateCallTreeArgs, validateCodeAuditArgs, validateProjectOverviewArgs, validateModuleInfoArgs, validateSmartDiffArgs, validateExploreAreaArgs, validateSmartLogArgs, validateTestSummaryArgs, validateReadSectionArgs, } from "./core/validation.js";
53
54
  export async function createServer(projectRoot, options) {
54
55
  const mode = options?.enforcementMode ?? "deny";
55
56
  const config = await loadConfig(projectRoot);
@@ -726,6 +727,40 @@ export async function createServer(projectRoot, options) {
726
727
  ],
727
728
  };
728
729
  }
730
+ case "call_tree": {
731
+ const callTreeArgs = validateCallTreeArgs(args);
732
+ const cachedTree = sessionCache?.get("call_tree", callTreeArgs);
733
+ if (cachedTree) {
734
+ recordWithTrace({
735
+ tool: "call_tree",
736
+ path: callTreeArgs.symbol,
737
+ tokensReturned: cachedTree.tokenEstimate,
738
+ tokensWouldBe: cachedTree.tokensWouldBe ?? cachedTree.tokenEstimate,
739
+ timestamp: Date.now(),
740
+ sessionCacheHit: true,
741
+ savingsCategory: "cache",
742
+ args: callTreeArgs,
743
+ });
744
+ return cachedTree.result;
745
+ }
746
+ const treeResult = await handleCallTree(callTreeArgs, astIndex);
747
+ const treeText = treeResult.content[0]?.text ?? "";
748
+ const treeTokens = estimateTokens(treeText);
749
+ // No good "wouldBe" baseline for call_tree (you'd otherwise
750
+ // run find_usages in a loop). Use a conservative N× multiplier.
751
+ const treeWouldBe = treeTokens * 3;
752
+ sessionCache?.set("call_tree", callTreeArgs, treeResult, { dependsOnAst: true }, treeTokens, treeWouldBe);
753
+ recordWithTrace({
754
+ tool: "call_tree",
755
+ path: callTreeArgs.symbol,
756
+ tokensReturned: treeTokens,
757
+ tokensWouldBe: treeWouldBe,
758
+ timestamp: Date.now(),
759
+ savingsCategory: "compression",
760
+ args: callTreeArgs,
761
+ });
762
+ return treeResult;
763
+ }
729
764
  case "find_unused": {
730
765
  const unusedArgs = validateFindUnusedArgs(args);
731
766
  const cachedUnused = sessionCache?.get("find_unused", unusedArgs);
package/hooks/hooks.json CHANGED
@@ -45,6 +45,15 @@
45
45
  "command": "node ${CLAUDE_PLUGIN_ROOT}/dist/index.js hook-pre-grep"
46
46
  }
47
47
  ]
48
+ },
49
+ {
50
+ "matcher": "Task",
51
+ "hooks": [
52
+ {
53
+ "type": "command",
54
+ "command": "node ${CLAUDE_PLUGIN_ROOT}/dist/index.js hook-pre-task"
55
+ }
56
+ ]
48
57
  }
49
58
  ],
50
59
  "SessionStart": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "token-pilot",
3
- "version": "0.30.5",
3
+ "version": "0.32.0",
4
4
  "description": "Save up to 80% tokens when AI reads code — MCP server for token-efficient code navigation, AST-aware structural reading instead of dumping full files into context window",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",