@dv.nghiem/flowdeck 0.4.1 → 0.4.3

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 (103) hide show
  1. package/README.md +3 -0
  2. package/dist/agents/index.d.ts +13 -0
  3. package/dist/agents/index.d.ts.map +1 -1
  4. package/dist/config/schema.d.ts +19 -0
  5. package/dist/config/schema.d.ts.map +1 -1
  6. package/dist/hooks/compaction-hook.d.ts +6 -1
  7. package/dist/hooks/compaction-hook.d.ts.map +1 -1
  8. package/dist/hooks/shell-env-hook.d.ts.map +1 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +1246 -321
  11. package/dist/mcp/index.d.ts +2 -3
  12. package/dist/mcp/index.d.ts.map +1 -1
  13. package/dist/services/artifact-store.d.ts +39 -0
  14. package/dist/services/artifact-store.d.ts.map +1 -0
  15. package/dist/services/artifact-store.test.d.ts +2 -0
  16. package/dist/services/artifact-store.test.d.ts.map +1 -0
  17. package/dist/services/context-assembler.d.ts +29 -0
  18. package/dist/services/context-assembler.d.ts.map +1 -0
  19. package/dist/services/context-assembler.test.d.ts +2 -0
  20. package/dist/services/context-assembler.test.d.ts.map +1 -0
  21. package/dist/services/cost-budget.d.ts +53 -0
  22. package/dist/services/cost-budget.d.ts.map +1 -0
  23. package/dist/services/cost-budget.test.d.ts +2 -0
  24. package/dist/services/cost-budget.test.d.ts.map +1 -0
  25. package/dist/services/cost-estimator.d.ts +103 -0
  26. package/dist/services/cost-estimator.d.ts.map +1 -0
  27. package/dist/services/cost-estimator.test.d.ts +2 -0
  28. package/dist/services/cost-estimator.test.d.ts.map +1 -0
  29. package/dist/services/draft-verifier.d.ts +48 -0
  30. package/dist/services/draft-verifier.d.ts.map +1 -0
  31. package/dist/services/draft-verifier.test.d.ts +2 -0
  32. package/dist/services/draft-verifier.test.d.ts.map +1 -0
  33. package/dist/services/index.d.ts +13 -0
  34. package/dist/services/index.d.ts.map +1 -1
  35. package/dist/services/lazy-rule-loader.d.ts +104 -0
  36. package/dist/services/lazy-rule-loader.d.ts.map +1 -0
  37. package/dist/services/lazy-rule-loader.test.d.ts +23 -0
  38. package/dist/services/lazy-rule-loader.test.d.ts.map +1 -0
  39. package/dist/services/model-router-ext.test.d.ts +2 -0
  40. package/dist/services/model-router-ext.test.d.ts.map +1 -0
  41. package/dist/services/model-router.d.ts +52 -0
  42. package/dist/services/model-router.d.ts.map +1 -0
  43. package/dist/services/model-router.test.d.ts +2 -0
  44. package/dist/services/model-router.test.d.ts.map +1 -0
  45. package/dist/services/prompt-cache-ext.test.d.ts +2 -0
  46. package/dist/services/prompt-cache-ext.test.d.ts.map +1 -0
  47. package/dist/services/prompt-cache.d.ts +61 -0
  48. package/dist/services/prompt-cache.d.ts.map +1 -0
  49. package/dist/services/prompt-cache.test.d.ts +2 -0
  50. package/dist/services/prompt-cache.test.d.ts.map +1 -0
  51. package/dist/services/rtk-manager.d.ts +80 -0
  52. package/dist/services/rtk-manager.d.ts.map +1 -0
  53. package/dist/services/rtk-manager.test.d.ts +2 -0
  54. package/dist/services/rtk-manager.test.d.ts.map +1 -0
  55. package/dist/services/rtk-policy.d.ts +26 -0
  56. package/dist/services/rtk-policy.d.ts.map +1 -0
  57. package/dist/services/rtk-policy.test.d.ts +2 -0
  58. package/dist/services/rtk-policy.test.d.ts.map +1 -0
  59. package/dist/services/rule-engine.d.ts +29 -0
  60. package/dist/services/rule-engine.d.ts.map +1 -0
  61. package/dist/services/rule-engine.test.d.ts +2 -0
  62. package/dist/services/rule-engine.test.d.ts.map +1 -0
  63. package/dist/services/task-batcher.d.ts +48 -0
  64. package/dist/services/task-batcher.d.ts.map +1 -0
  65. package/dist/services/task-batcher.test.d.ts +2 -0
  66. package/dist/services/task-batcher.test.d.ts.map +1 -0
  67. package/dist/services/telemetry.d.ts +6 -0
  68. package/dist/services/telemetry.d.ts.map +1 -1
  69. package/dist/services/token-budget.d.ts +44 -0
  70. package/dist/services/token-budget.d.ts.map +1 -0
  71. package/dist/services/token-budget.test.d.ts +2 -0
  72. package/dist/services/token-budget.test.d.ts.map +1 -0
  73. package/dist/services/token-metrics-ext.test.d.ts +2 -0
  74. package/dist/services/token-metrics-ext.test.d.ts.map +1 -0
  75. package/dist/services/token-metrics.d.ts +97 -0
  76. package/dist/services/token-metrics.d.ts.map +1 -0
  77. package/dist/services/token-metrics.test.d.ts +2 -0
  78. package/dist/services/token-metrics.test.d.ts.map +1 -0
  79. package/dist/tools/codegraph-tool.d.ts.map +1 -1
  80. package/dist/tools/council.d.ts.map +1 -1
  81. package/dist/tools/delegate.d.ts.map +1 -1
  82. package/dist/tools/load-rules.d.ts +25 -0
  83. package/dist/tools/load-rules.d.ts.map +1 -0
  84. package/dist/tools/rtk-setup.d.ts +22 -0
  85. package/dist/tools/rtk-setup.d.ts.map +1 -0
  86. package/dist/tools/run-pipeline.d.ts.map +1 -1
  87. package/docs/commands/fd-map-codebase.md +2 -1
  88. package/docs/configuration/index.md +26 -0
  89. package/docs/getting-started/installation.md +20 -0
  90. package/docs/reference/hooks.md +16 -1
  91. package/docs/reference/rtk.md +162 -0
  92. package/package.json +1 -1
  93. package/src/rules/common/agent-orchestration.md +7 -0
  94. package/src/rules/common/behavioral.md +7 -0
  95. package/src/rules/common/coding-style.md +7 -0
  96. package/src/rules/common/git-workflow.md +7 -0
  97. package/src/rules/common/security.md +7 -0
  98. package/src/rules/common/testing.md +7 -0
  99. package/src/rules/golang/patterns.md +7 -0
  100. package/src/rules/java/patterns.md +7 -0
  101. package/src/rules/python/patterns.md +7 -0
  102. package/src/rules/rust/patterns.md +7 -0
  103. package/src/rules/typescript/patterns.md +7 -0
@@ -0,0 +1,61 @@
1
+ /** Agents that are safe to cache — pure read-only / idempotent analysis. */
2
+ export declare const CACHEABLE_AGENTS: Set<string>;
3
+ export interface CacheEntry {
4
+ key: string;
5
+ agent: string;
6
+ state_version: number;
7
+ index_version: number;
8
+ created_at: string;
9
+ ttl_ms: number;
10
+ response: string;
11
+ }
12
+ export interface CacheStats {
13
+ total_entries: number;
14
+ valid_entries: number;
15
+ expired_entries: number;
16
+ cache_size_bytes: number;
17
+ }
18
+ export declare function hashKey(agent: string, prompt: string, context: string, stateVersion: number, indexVersion: number): string;
19
+ /**
20
+ * Normalize a prompt for fuzzy cache lookup.
21
+ * Collapses multiple whitespace characters to single spaces and trims.
22
+ * Only whitespace is normalized — punctuation and case are preserved
23
+ * to avoid false cache hits across semantically different queries.
24
+ */
25
+ export declare function normalizeForCache(text: string): string;
26
+ /**
27
+ * Like hashKey but using whitespace-normalized prompt and context.
28
+ * Used as a fallback after the exact key misses.
29
+ */
30
+ export declare function hashKeyNormalized(agent: string, prompt: string, context: string, stateVersion: number, indexVersion: number): string;
31
+ /**
32
+ * Retrieve a cached response.
33
+ *
34
+ * Lookup order:
35
+ * 1. Exact key (prompt.trim() + context.trim())
36
+ * 2. Whitespace-normalized key (collapses multiple spaces/newlines)
37
+ *
38
+ * Returns null when:
39
+ * - Agent is not in CACHEABLE_AGENTS
40
+ * - No entry exists under either key
41
+ * - Entry is expired
42
+ * - stateVersion or indexVersion don't match (state changed since cached)
43
+ */
44
+ export declare function getCached(dir: string, agent: string, prompt: string, context: string, stateVersion: number, indexVersion: number, safe_to_cache?: boolean): string | null;
45
+ /**
46
+ * Store a response in the cache.
47
+ *
48
+ * No-ops silently when:
49
+ * - safe_to_cache is false
50
+ * - Agent is not in CACHEABLE_AGENTS
51
+ */
52
+ export declare function setCached(dir: string, agent: string, prompt: string, context: string, stateVersion: number, indexVersion: number, response: string, safe_to_cache?: boolean, ttl_ms?: number): void;
53
+ /**
54
+ * Remove expired entries and trim to MAX_CACHE_ENTRIES.
55
+ * Called automatically on setCached.
56
+ */
57
+ export declare function pruneExpired(dir: string): void;
58
+ export declare function getCacheStats(dir: string): CacheStats;
59
+ /** Force-invalidate all cache entries for a given directory (call after state writes). */
60
+ export declare function invalidateCache(dir: string): void;
61
+ //# sourceMappingURL=prompt-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-cache.d.ts","sourceRoot":"","sources":["../../src/services/prompt-cache.ts"],"names":[],"mappings":"AAmBA,4EAA4E;AAC5E,eAAO,MAAM,gBAAgB,aAQ3B,CAAA;AAMF,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;CACzB;AA+BD,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,GACnB,MAAM,CAGR;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,GACnB,MAAM,CASR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,aAAa,UAAQ,GACpB,MAAM,GAAG,IAAI,CAaf;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,aAAa,UAAQ,EACrB,MAAM,SAAiB,GACtB,IAAI,CAsBN;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAsC9C;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CA6BrD;AAED,0FAA0F;AAC1F,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAQjD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=prompt-cache.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-cache.test.d.ts","sourceRoot":"","sources":["../../src/services/prompt-cache.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * rtk-manager — runtime integration for https://github.com/rtk-ai/rtk
3
+ *
4
+ * rtk is a CLI proxy that compresses noisy terminal output (git, npm, test
5
+ * runners, linters, docker, etc.) by 60-90% before it reaches the model
6
+ * context. It works by prefixing supported commands: `rtk git status`.
7
+ *
8
+ * This manager provides:
9
+ * - Detection of an installed rtk binary
10
+ * - Optional agent-triggered initialization (rtk init -g)
11
+ * - Status reporting for diagnostics
12
+ * - wrapCommandArgs() for explicit wrapping in FlowDeck's own spawnSync calls
13
+ *
14
+ * DESIGN NOTES:
15
+ * - No auto-install: downloading + executing a remote shell script is a
16
+ * supply-chain risk. Users install rtk manually; this plugin detects it.
17
+ * - No startup mutation: init is agent-triggered via rtk-setup tool only.
18
+ * - Live detection: no state cache that goes stale across machines/reinstalls.
19
+ * - Bash hook caveat: `rtk init -g` writes to Claude Code / Copilot global
20
+ * config. Whether that hook fires in OpenCode's non-interactive bash sessions
21
+ * depends on the runtime. Explicit wrapping via wrapCommandArgs() is the
22
+ * reliable alternative.
23
+ */
24
+ export interface RtkDetection {
25
+ installed: boolean;
26
+ binPath?: string;
27
+ version?: string;
28
+ error?: string;
29
+ }
30
+ export interface RtkInitResult {
31
+ success: boolean;
32
+ log: string;
33
+ telemetryDisabled: boolean;
34
+ error?: string;
35
+ }
36
+ export interface RtkStatus {
37
+ installed: boolean;
38
+ binPath?: string;
39
+ version?: string;
40
+ initAttempted: boolean;
41
+ initSuccess: boolean;
42
+ telemetryDisabled: boolean;
43
+ installInstructions?: string;
44
+ }
45
+ /**
46
+ * Locate and verify the rtk binary. Checks PATH first, then known install
47
+ * locations. Returns the first working binary found.
48
+ */
49
+ export declare function detectRtk(): RtkDetection;
50
+ /**
51
+ * Run `rtk init -g` to install the bash hook for Claude Code / Copilot,
52
+ * then immediately run `rtk telemetry disable` to explicitly opt out.
53
+ *
54
+ * Telemetry is disabled by default per rtk docs, but we make it explicit
55
+ * and persistent so consent is never accidentally given in future versions.
56
+ * The `RTK_TELEMETRY_DISABLED=1` env var injected by shell-env-hook provides
57
+ * an additional belt-and-suspenders block at the session level.
58
+ *
59
+ * Note on bash hook: `rtk init -g` writes to Claude Code / Copilot global
60
+ * config. Whether that hook fires in OpenCode's non-interactive bash sessions
61
+ * depends on the runtime configuration. Use `$RTK_BIN <cmd>` explicitly as
62
+ * a reliable alternative when RTK_INSTALLED=true in the environment.
63
+ */
64
+ export declare function initRtk(binPath: string): RtkInitResult;
65
+ /**
66
+ * Return current rtk status. Always performs a live detection check.
67
+ */
68
+ export declare function getRtkStatus(opts?: {
69
+ runInit?: boolean;
70
+ }): RtkStatus;
71
+ /**
72
+ * Wrap a command with rtk if the binary is available and policy allows it.
73
+ * Returns `[cmd, ...args]` unchanged when rtk is unavailable or policy says no.
74
+ *
75
+ * Usage:
76
+ * const [c, ...a] = wrapCommandArgs("git", ["status"], "/home/user/.local/bin/rtk")
77
+ * spawnSync(c, a, { ... })
78
+ */
79
+ export declare function wrapCommandArgs(cmd: string, args: string[], binPath: string | undefined): [string, ...string[]];
80
+ //# sourceMappingURL=rtk-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rtk-manager.d.ts","sourceRoot":"","sources":["../../src/services/rtk-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAQH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,MAAM,CAAA;IACX,iBAAiB,EAAE,OAAO,CAAA;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,aAAa,EAAE,OAAO,CAAA;IACtB,WAAW,EAAE,OAAO,CAAA;IACpB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAYD;;;GAGG;AACH,wBAAgB,SAAS,IAAI,YAAY,CAsBxC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAsCtD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CA+BpE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAI/G"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=rtk-manager.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rtk-manager.test.d.ts","sourceRoot":"","sources":["../../src/services/rtk-manager.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * rtk-policy — command wrapping policy for rtk integration.
3
+ *
4
+ * Determines which commands benefit from rtk output compression and which
5
+ * should be passed through unchanged. The policy is intentionally conservative:
6
+ * when in doubt, don't wrap.
7
+ *
8
+ * Wrapping benefits:
9
+ * - Commands with large, repetitive, or progress-heavy output
10
+ * - Commands where compressed output preserves the signal
11
+ *
12
+ * Do NOT wrap:
13
+ * - Commands where raw output is required for correctness
14
+ * - Commands with already-compact output (git rev-parse, git diff --name-only)
15
+ * - Commands used for installing rtk itself (curl, sh)
16
+ * - Structured/programmatic output (codegraph, jq, etc.)
17
+ * - OS notification tools (notify-send, osascript, powershell)
18
+ */
19
+ /**
20
+ * Determine whether a command should be wrapped with rtk.
21
+ * Returns true only when compression is expected to improve signal quality.
22
+ */
23
+ export declare function shouldWrapWithRtk(cmd: string, args: string[]): boolean;
24
+ /** Returns the full list of supported commands for diagnostics/documentation. */
25
+ export declare function getSupportedCommands(): string[];
26
+ //# sourceMappingURL=rtk-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rtk-policy.d.ts","sourceRoot":"","sources":["../../src/services/rtk-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA4DH;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAatE;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAE/C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=rtk-policy.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rtk-policy.test.d.ts","sourceRoot":"","sources":["../../src/services/rtk-policy.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ export type CheckType = "file_exists" | "json_valid" | "detect_language" | "classify_command" | "is_nonempty" | "contains_keyword";
2
+ export interface CheckResult<T> {
3
+ type: CheckType;
4
+ value: T;
5
+ /** Always true — signals this result came from deterministic code, not a model. */
6
+ deterministic: true;
7
+ }
8
+ /** Check whether a file path exists on disk. */
9
+ export declare function checkFileExists(filePath: string): CheckResult<boolean>;
10
+ export interface JSONValidResult {
11
+ valid: boolean;
12
+ error?: string;
13
+ }
14
+ /** Check whether a string is valid JSON. */
15
+ export declare function checkJSONValid(text: string): CheckResult<JSONValidResult>;
16
+ /** Detect programming language from file extension. Returns null for unknown extensions. */
17
+ export declare function detectLanguage(filename: string): CheckResult<string | null>;
18
+ export type CommandClass = "read" | "write" | "delete" | "run" | "navigate" | "unknown";
19
+ /** Classify a tool/command name into its operational class. */
20
+ export declare function classifyCommandType(command: string): CheckResult<CommandClass>;
21
+ /** Check whether a string is non-empty after trimming. */
22
+ export declare function checkIsNonEmpty(text: string): CheckResult<boolean>;
23
+ export interface KeywordSearchResult {
24
+ found: boolean;
25
+ matched?: string;
26
+ }
27
+ /** Check whether a string contains any of the given keywords (case-insensitive). */
28
+ export declare function checkContainsKeyword(text: string, keywords: string[]): CheckResult<KeywordSearchResult>;
29
+ //# sourceMappingURL=rule-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-engine.d.ts","sourceRoot":"","sources":["../../src/services/rule-engine.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,SAAS,GACjB,aAAa,GACb,YAAY,GACZ,iBAAiB,GACjB,kBAAkB,GAClB,aAAa,GACb,kBAAkB,CAAA;AAEtB,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,IAAI,EAAE,SAAS,CAAA;IACf,KAAK,EAAE,CAAC,CAAA;IACR,mFAAmF;IACnF,aAAa,EAAE,IAAI,CAAA;CACpB;AAID,gDAAgD;AAChD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAEtE;AAID,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,4CAA4C;AAC5C,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,eAAe,CAAC,CAWzE;AA4BD,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,CAG3E;AAID,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,OAAO,GACP,QAAQ,GACR,KAAK,GACL,UAAU,GACV,SAAS,CAAA;AAUb,+DAA+D;AAC/D,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC,YAAY,CAAC,CAQ9E;AAID,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAElE;AAID,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,oFAAoF;AACpF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAAE,GACjB,WAAW,CAAC,mBAAmB,CAAC,CAQlC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=rule-engine.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-engine.test.d.ts","sourceRoot":"","sources":["../../src/services/rule-engine.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Task Batcher
3
+ *
4
+ * Coalesces multiple homogeneous cheap tasks into a single agent call.
5
+ * Reduces N session creations + system-prompt injections to 1 for
6
+ * classification/validation batches.
7
+ *
8
+ * SAFETY CONSTRAINTS:
9
+ * - Max 5 tasks per batch (avoid context contamination in large batches)
10
+ * - Each task must have a unique, non-empty id
11
+ * - Partial salvage: successfully parsed results are returned even if
12
+ * others fail — caller decides how to handle failures
13
+ * - The batcher builds prompts and parses responses; session creation
14
+ * is the caller's responsibility (use with `delegate`)
15
+ */
16
+ export declare const TASK_BATCHER_MAX_SIZE = 5;
17
+ export interface BatchTask {
18
+ id: string;
19
+ prompt: string;
20
+ }
21
+ export interface BatchResult {
22
+ id: string;
23
+ result: string;
24
+ success: boolean;
25
+ error?: string;
26
+ }
27
+ export interface BatchResponse {
28
+ results: BatchResult[];
29
+ success_count: number;
30
+ failure_count: number;
31
+ }
32
+ /**
33
+ * Build a single batched prompt from multiple tasks.
34
+ * The expected response is a JSON array with `id` and `result` fields.
35
+ */
36
+ export declare function buildBatchPrompt(tasks: BatchTask[]): string;
37
+ /**
38
+ * Parse a batched model response into per-task results.
39
+ * Returns partial results: tasks whose ids appear in the response are
40
+ * marked success, missing tasks are marked failure.
41
+ */
42
+ export declare function parseBatchResponse(tasks: BatchTask[], rawResponse: string): BatchResponse;
43
+ /**
44
+ * Validate that a batch is safe to send.
45
+ * Returns null if valid, or an error message if not.
46
+ */
47
+ export declare function validateBatch(tasks: BatchTask[]): string | null;
48
+ //# sourceMappingURL=task-batcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-batcher.d.ts","sourceRoot":"","sources":["../../src/services/task-batcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,qBAAqB,IAAI,CAAA;AAEtC,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,CAiB3D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CA0DzF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,GAAG,IAAI,CAY/D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=task-batcher.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-batcher.test.d.ts","sourceRoot":"","sources":["../../src/services/task-batcher.test.ts"],"names":[],"mappings":""}
@@ -15,6 +15,12 @@ export interface TelemetryEvent {
15
15
  files?: string[];
16
16
  cost_estimate?: number;
17
17
  error_category?: string;
18
+ /** Estimated input tokens (chars / 4) for this event. */
19
+ input_tokens?: number;
20
+ /** Estimated output tokens (chars / 4) for this event. */
21
+ output_tokens?: number;
22
+ /** Raw input character count before prompt was sent to the model. */
23
+ context_size_chars?: number;
18
24
  meta?: Record<string, unknown>;
19
25
  }
20
26
  export declare function telemetryPath(dir: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/services/telemetry.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,kBAAkB,GAC1B,eAAe,GACf,aAAa,GACb,WAAW,GACX,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,GAClB,cAAc,GACd,UAAU,GACV,kBAAkB,GAClB,cAAc,GAEd,oBAAoB,GACpB,iBAAiB,GACjB,kBAAkB,GAClB,gBAAgB,GAChB,kBAAkB,GAClB,mBAAmB,GACnB,qB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,MAAM,CAAA;IACrB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG,cAAc,GAAG,IAAI,CAa1G;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,SAAM,GAAG,cAAc,EAAE,CAUrE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE,CAE1E;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,SAAM,GAAG,cAAc,EAAE,CAuBxE;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,cAAc,EAAE,CAI/E"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Token Budget Service
3
+ *
4
+ * Provides INPUT size budgets and soft response directives by workflow stage
5
+ * and task complexity. These are GUIDANCE values, not hard limits
6
+ * (OpenCode SDK does not expose a max_tokens parameter on session.prompt).
7
+ *
8
+ * Hard controls apply to INPUT: context_chars_limit and prompt_chars_limit
9
+ * cap carry-forward and total prompt size before sending.
10
+ *
11
+ * Soft controls: response_directive is a hint string appended to the prompt.
12
+ * It asks the model to be concise — not enforced at the API level.
13
+ */
14
+ import type { WorkflowStage } from "./token-metrics";
15
+ import type { TaskComplexity } from "./model-router";
16
+ export interface TokenBudget {
17
+ /** Hard cap on context/carry-forward chars (apply before sending). */
18
+ context_chars_limit: number;
19
+ /** Hard cap on total prompt chars including system instructions. */
20
+ prompt_chars_limit: number;
21
+ /**
22
+ * Soft directive to append to the prompt.
23
+ * Empty string = no constraint injected.
24
+ * This is guidance only — not API-enforced.
25
+ */
26
+ response_directive: string;
27
+ }
28
+ /**
29
+ * Get the token budget for a given workflow stage and task complexity.
30
+ * Cheap tasks receive ~40% of the base budget; expensive tasks receive ~150%.
31
+ */
32
+ export declare function getTokenBudget(stage: WorkflowStage, complexity: TaskComplexity): TokenBudget;
33
+ /**
34
+ * Truncate a carry-forward context to fit within budget.
35
+ * Preserves the most recent content (tail) when truncating.
36
+ * Attempts to trim to a line boundary to avoid mid-line cuts.
37
+ */
38
+ export declare function applyContextBudget(context: string, budget: TokenBudget): string;
39
+ /**
40
+ * Append the response directive to a prompt, if one is set for this budget.
41
+ * Returns the prompt unchanged when no directive applies.
42
+ */
43
+ export declare function applyResponseDirective(prompt: string, budget: TokenBudget): string;
44
+ //# sourceMappingURL=token-budget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-budget.d.ts","sourceRoot":"","sources":["../../src/services/token-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,WAAW;IAC1B,sEAAsE;IACtE,mBAAmB,EAAE,MAAM,CAAA;IAC3B,oEAAoE;IACpE,kBAAkB,EAAE,MAAM,CAAA;IAC1B;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,CAAA;CAC3B;AAyBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,GAAG,WAAW,CAY5F;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAK/E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAGlF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=token-budget.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-budget.test.d.ts","sourceRoot":"","sources":["../../src/services/token-budget.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=token-metrics-ext.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-metrics-ext.test.d.ts","sourceRoot":"","sources":["../../src/services/token-metrics-ext.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,97 @@
1
+ export type WorkflowStage = "discuss" | "plan" | "execute" | "verify" | "design" | "fix-bug" | "write-docs" | "council" | "delegate" | "pipeline" | "exploration" | "unknown";
2
+ export type MetricEventType = "model_call" | "cache_hit" | "duplicate_suppressed" | "rule_bypass" | "retry";
3
+ export interface MetricEvent {
4
+ ts: string;
5
+ workflow_id: string;
6
+ stage: WorkflowStage;
7
+ event: MetricEventType;
8
+ agent?: string;
9
+ /**
10
+ * Model identifier used for this call (e.g. "claude-sonnet-4.6").
11
+ * Enables cost estimation via cost-estimator.ts.
12
+ */
13
+ model?: string;
14
+ /** Estimated input tokens (chars / 4) */
15
+ est_input_tokens: number;
16
+ /** Estimated output tokens (chars / 4) */
17
+ est_output_tokens: number;
18
+ /** Raw input character count */
19
+ input_chars: number;
20
+ /** Raw output character count */
21
+ output_chars: number;
22
+ duration_ms?: number;
23
+ /** Estimated USD cost for this event (populated when model is known). */
24
+ est_cost_usd?: number;
25
+ }
26
+ export interface StageSummary {
27
+ stage: WorkflowStage;
28
+ model_calls: number;
29
+ cache_hits: number;
30
+ duplicates_suppressed: number;
31
+ rule_bypasses: number;
32
+ retries: number;
33
+ total_est_input_tokens: number;
34
+ total_est_output_tokens: number;
35
+ avg_input_chars: number;
36
+ avg_output_chars: number;
37
+ /** Estimated USD cost for this stage (requires model field on events). */
38
+ est_cost_usd: number;
39
+ }
40
+ export interface MetricsReport {
41
+ workflow_id: string;
42
+ by_stage: StageSummary[];
43
+ totals: {
44
+ model_calls: number;
45
+ cache_hits: number;
46
+ duplicates_suppressed: number;
47
+ rule_bypasses: number;
48
+ retries: number;
49
+ est_input_tokens: number;
50
+ est_output_tokens: number;
51
+ /** Estimated total USD cost across all model calls. 0 if no model info available. */
52
+ est_cost_usd: number;
53
+ /** Estimated USD wasted on retries. */
54
+ retry_cost_usd: number;
55
+ cache_hit_rate: number;
56
+ duplicate_suppression_rate: number;
57
+ rule_bypass_rate: number;
58
+ retry_rate: number;
59
+ };
60
+ efficiency: {
61
+ most_expensive_stage: string;
62
+ cache_effectiveness: "good" | "moderate" | "low";
63
+ avg_context_chars_by_stage: Record<string, number>;
64
+ };
65
+ /** Workflow-level timing if startWorkflowTimer was called. */
66
+ elapsed_ms?: number;
67
+ }
68
+ /** Rough token estimate: ~4 chars per token. */
69
+ export declare function estimateTokens(text: string): number;
70
+ export declare function recordModelCall(dir: string, workflow_id: string, stage: WorkflowStage, inputText: string, outputText: string, agent?: string, duration_ms?: number, model?: string, est_cost_usd?: number): void;
71
+ export declare function recordCacheHit(dir: string, workflow_id: string, stage: WorkflowStage, inputText: string, agent?: string, model?: string): void;
72
+ export declare function recordDuplicateSuppressed(dir: string, workflow_id: string, stage: WorkflowStage, agent?: string): void;
73
+ /**
74
+ * Record a retry model call.
75
+ * This is a model call that happened because the previous attempt failed transiently.
76
+ * Contributes to retry_cost_usd in the cost report.
77
+ */
78
+ export declare function recordRetryCall(dir: string, workflow_id: string, stage: WorkflowStage, inputText: string, outputText: string, agent?: string, duration_ms?: number, model?: string, est_cost_usd?: number): void;
79
+ /**
80
+ * Record a rule-based bypass — a check answered deterministically without a model call.
81
+ * `check_type` identifies which rule-engine check was used.
82
+ */
83
+ export declare function recordRuleBypass(dir: string, workflow_id: string, stage: WorkflowStage, check_type: string, agent?: string): void;
84
+ /**
85
+ * Mark the start of a workflow run for latency tracking.
86
+ * Call this before the first model call for a workflow.
87
+ */
88
+ export declare function startWorkflowTimer(workflow_id: string): void;
89
+ /**
90
+ * Get elapsed milliseconds since startWorkflowTimer was called.
91
+ * Returns undefined if the timer was not started.
92
+ */
93
+ export declare function getWorkflowElapsed(workflow_id: string): number | undefined;
94
+ export declare function getMetricsReport(dir: string, workflow_id: string): MetricsReport;
95
+ /** List all workflow IDs that have metric events. */
96
+ export declare function listTrackedWorkflows(dir: string): string[];
97
+ //# sourceMappingURL=token-metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-metrics.d.ts","sourceRoot":"","sources":["../../src/services/token-metrics.ts"],"names":[],"mappings":"AAeA,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,MAAM,GACN,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,SAAS,GACT,UAAU,GACV,UAAU,GACV,aAAa,GACb,SAAS,CAAA;AAEb,MAAM,MAAM,eAAe,GACvB,YAAY,GACZ,WAAW,GACX,sBAAsB,GACtB,aAAa,GACb,OAAO,CAAA;AAEX,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,aAAa,CAAA;IACpB,KAAK,EAAE,eAAe,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,yCAAyC;IACzC,gBAAgB,EAAE,MAAM,CAAA;IACxB,0CAA0C;IAC1C,iBAAiB,EAAE,MAAM,CAAA;IACzB,gCA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,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAYN;AAKD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG1E;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CAsHhF;AAED,qDAAqD;AACrD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAe1D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=token-metrics.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-metrics.test.d.ts","sourceRoot":"","sources":["../../src/services/token-metrics.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"codegraph-tool.d.ts","sourceRoot":"","sources":["../../src/tools/codegraph-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAa/D,eAAO,MAAM,aAAa,EAAE,cA6G1B,CAAA"}
1
+ {"version":3,"file":"codegraph-tool.d.ts","sourceRoot":"","sources":["../../src/tools/codegraph-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAa/D,eAAO,MAAM,aAAa,EAAE,cA2H1B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"council.d.ts","sourceRoot":"","sources":["../../src/tools/council.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAKtD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CA2ExE"}
1
+ {"version":3,"file":"council.d.ts","sourceRoot":"","sources":["../../src/tools/council.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAkDtD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAgHxE"}
@@ -1 +1 @@
1
- {"version":3,"file":"delegate.d.ts","sourceRoot":"","sources":["../../src/tools/delegate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAWtD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CA6HzE"}
1
+ {"version":3,"file":"delegate.d.ts","sourceRoot":"","sources":["../../src/tools/delegate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAmBtD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAmPzE"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Load Rules Tool
3
+ *
4
+ * On-demand rule loading for agents. Allows an agent to explicitly request
5
+ * the full content of rule modules that were not injected at startup (because
6
+ * they are stage-restricted and the stage was not known at plugin init time).
7
+ *
8
+ * Usage pattern:
9
+ * 1. At startup only always_on + language-matching rules are injected globally.
10
+ * 2. When an agent begins work (e.g. a coder starting the execute stage),
11
+ * it calls this tool to load coding-style, security, and testing rules.
12
+ * 3. The tool returns full rule content and logs which modules were loaded.
13
+ *
14
+ * This keeps the global instruction context minimal while ensuring agents get
15
+ * the right guidance when they actually need it.
16
+ */
17
+ import { type ToolDefinition } from "@opencode-ai/plugin";
18
+ /** Reset the loaded-paths cache (for testing). */
19
+ export declare function resetLoadedRulesCache(): void;
20
+ /** Return a copy of currently loaded paths (for testing/diagnostics). */
21
+ export declare function getLoadedRulePaths(): string[];
22
+ export declare const loadRulesTool: ToolDefinition;
23
+ /** Query-only tool: list all available rule modules with their metadata summaries. */
24
+ export declare const listRulesTool: ToolDefinition;
25
+ //# sourceMappingURL=load-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-rules.d.ts","sourceRoot":"","sources":["../../src/tools/load-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAgB/D,kDAAkD;AAClD,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED,yEAAyE;AACzE,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAE7C;AAED,eAAO,MAAM,aAAa,EAAE,cAsF1B,CAAA;AAUF,sFAAsF;AACtF,eAAO,MAAM,aAAa,EAAE,cAyB1B,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { type ToolDefinition } from "@opencode-ai/plugin";
2
+ /**
3
+ * rtk-setup tool — agent-callable tool for rtk lifecycle management.
4
+ *
5
+ * Provides:
6
+ * - Detection: is rtk installed and where?
7
+ * - Optional init: run `rtk init -g` to install the bash hook
8
+ * - Status report: for diagnostics in the current workflow
9
+ * - Supported commands list: which commands benefit from rtk wrapping
10
+ *
11
+ * Agents should call this tool when:
12
+ * - They want to verify rtk is available before running commands
13
+ * - The workflow involves heavy CLI usage (git, tests, linting, docker)
14
+ * - After a user has installed rtk and wants to activate it
15
+ *
16
+ * Note on bash hook: `rtk init -g` writes to Claude Code / Copilot global
17
+ * config. In OpenCode's non-interactive bash sessions the hook may not fire
18
+ * automatically. Use `$RTK_BIN <cmd>` explicitly as a reliable alternative
19
+ * when RTK_INSTALLED=true in the environment.
20
+ */
21
+ export declare const rtkSetupTool: ToolDefinition;
22
+ //# sourceMappingURL=rtk-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rtk-setup.d.ts","sourceRoot":"","sources":["../../src/tools/rtk-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAI/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY,EAAE,cA0EzB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"run-pipeline.d.ts","sourceRoot":"","sources":["../../src/tools/run-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AA4BtD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAuH5E"}
1
+ {"version":3,"file":"run-pipeline.d.ts","sourceRoot":"","sources":["../../src/tools/run-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AA8BtD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAkI5E"}
@@ -86,6 +86,7 @@ Report includes: codegraph install/index status, files created per mapper, key f
86
86
 
87
87
  ## Related Commands
88
88
 
89
+ - `/fd-new-feature` - Define a new feature, initialize feature context in the current phase directory
89
90
  - `/fd-doctor` — check environment health including codegraph status
90
91
  - `/fd-discuss` — uses codegraph for code intelligence during discussions
91
- - `/fd-plan` — uses codegraph for impact analysis during planning
92
+ - `/fd-plan` — uses codegraph for impact analysis during planning