@dv.nghiem/flowdeck 0.4.2 → 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.
- package/README.md +3 -0
- package/dist/agents/index.d.ts +13 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/config/schema.d.ts +19 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/hooks/compaction-hook.d.ts +6 -1
- package/dist/hooks/compaction-hook.d.ts.map +1 -1
- package/dist/hooks/shell-env-hook.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1236 -318
- package/dist/services/artifact-store.d.ts +39 -0
- package/dist/services/artifact-store.d.ts.map +1 -0
- package/dist/services/artifact-store.test.d.ts +2 -0
- package/dist/services/artifact-store.test.d.ts.map +1 -0
- package/dist/services/context-assembler.d.ts +29 -0
- package/dist/services/context-assembler.d.ts.map +1 -0
- package/dist/services/context-assembler.test.d.ts +2 -0
- package/dist/services/context-assembler.test.d.ts.map +1 -0
- package/dist/services/cost-budget.d.ts +53 -0
- package/dist/services/cost-budget.d.ts.map +1 -0
- package/dist/services/cost-budget.test.d.ts +2 -0
- package/dist/services/cost-budget.test.d.ts.map +1 -0
- package/dist/services/cost-estimator.d.ts +103 -0
- package/dist/services/cost-estimator.d.ts.map +1 -0
- package/dist/services/cost-estimator.test.d.ts +2 -0
- package/dist/services/cost-estimator.test.d.ts.map +1 -0
- package/dist/services/draft-verifier.d.ts +48 -0
- package/dist/services/draft-verifier.d.ts.map +1 -0
- package/dist/services/draft-verifier.test.d.ts +2 -0
- package/dist/services/draft-verifier.test.d.ts.map +1 -0
- package/dist/services/index.d.ts +13 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/lazy-rule-loader.d.ts +104 -0
- package/dist/services/lazy-rule-loader.d.ts.map +1 -0
- package/dist/services/lazy-rule-loader.test.d.ts +23 -0
- package/dist/services/lazy-rule-loader.test.d.ts.map +1 -0
- package/dist/services/model-router-ext.test.d.ts +2 -0
- package/dist/services/model-router-ext.test.d.ts.map +1 -0
- package/dist/services/model-router.d.ts +52 -0
- package/dist/services/model-router.d.ts.map +1 -0
- package/dist/services/model-router.test.d.ts +2 -0
- package/dist/services/model-router.test.d.ts.map +1 -0
- package/dist/services/prompt-cache-ext.test.d.ts +2 -0
- package/dist/services/prompt-cache-ext.test.d.ts.map +1 -0
- package/dist/services/prompt-cache.d.ts +61 -0
- package/dist/services/prompt-cache.d.ts.map +1 -0
- package/dist/services/prompt-cache.test.d.ts +2 -0
- package/dist/services/prompt-cache.test.d.ts.map +1 -0
- package/dist/services/rtk-manager.d.ts +80 -0
- package/dist/services/rtk-manager.d.ts.map +1 -0
- package/dist/services/rtk-manager.test.d.ts +2 -0
- package/dist/services/rtk-manager.test.d.ts.map +1 -0
- package/dist/services/rtk-policy.d.ts +26 -0
- package/dist/services/rtk-policy.d.ts.map +1 -0
- package/dist/services/rtk-policy.test.d.ts +2 -0
- package/dist/services/rtk-policy.test.d.ts.map +1 -0
- package/dist/services/rule-engine.d.ts +29 -0
- package/dist/services/rule-engine.d.ts.map +1 -0
- package/dist/services/rule-engine.test.d.ts +2 -0
- package/dist/services/rule-engine.test.d.ts.map +1 -0
- package/dist/services/task-batcher.d.ts +48 -0
- package/dist/services/task-batcher.d.ts.map +1 -0
- package/dist/services/task-batcher.test.d.ts +2 -0
- package/dist/services/task-batcher.test.d.ts.map +1 -0
- package/dist/services/telemetry.d.ts +6 -0
- package/dist/services/telemetry.d.ts.map +1 -1
- package/dist/services/token-budget.d.ts +44 -0
- package/dist/services/token-budget.d.ts.map +1 -0
- package/dist/services/token-budget.test.d.ts +2 -0
- package/dist/services/token-budget.test.d.ts.map +1 -0
- package/dist/services/token-metrics-ext.test.d.ts +2 -0
- package/dist/services/token-metrics-ext.test.d.ts.map +1 -0
- package/dist/services/token-metrics.d.ts +97 -0
- package/dist/services/token-metrics.d.ts.map +1 -0
- package/dist/services/token-metrics.test.d.ts +2 -0
- package/dist/services/token-metrics.test.d.ts.map +1 -0
- package/dist/tools/council.d.ts.map +1 -1
- package/dist/tools/delegate.d.ts.map +1 -1
- package/dist/tools/load-rules.d.ts +25 -0
- package/dist/tools/load-rules.d.ts.map +1 -0
- package/dist/tools/rtk-setup.d.ts +22 -0
- package/dist/tools/rtk-setup.d.ts.map +1 -0
- package/dist/tools/run-pipeline.d.ts.map +1 -1
- package/docs/commands/fd-map-codebase.md +2 -1
- package/docs/configuration/index.md +26 -0
- package/docs/getting-started/installation.md +20 -0
- package/docs/reference/hooks.md +16 -1
- package/docs/reference/rtk.md +162 -0
- package/package.json +1 -1
- package/src/rules/common/agent-orchestration.md +7 -0
- package/src/rules/common/behavioral.md +7 -0
- package/src/rules/common/coding-style.md +7 -0
- package/src/rules/common/git-workflow.md +7 -0
- package/src/rules/common/security.md +7 -0
- package/src/rules/common/testing.md +7 -0
- package/src/rules/golang/patterns.md +7 -0
- package/src/rules/java/patterns.md +7 -0
- package/src/rules/python/patterns.md +7 -0
- package/src/rules/rust/patterns.md +7 -0
- package/src/rules/typescript/patterns.md +7 -0
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@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,CAAC,mBAAmB,CAAC,CAQlC"}
|
|
@@ -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 @@
|
|
|
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,qBAAqB,GAErB,mBAAmB,CAAA;AAEvB,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,kBAAkB,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,IAAI,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAA;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAA;I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,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 @@
|
|
|
1
|
+
{"version":3,"file":"token-budget.test.d.ts","sourceRoot":"","sources":["../../src/services/token-budget.test.ts"],"names":[],"mappings":""}
|
|
@@ -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,SA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,EACpB,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAYN;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,aAAa,EACpB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI,CAiBN;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,MAAM,EAClB,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 @@
|
|
|
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":"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;
|
|
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;
|
|
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;
|
|
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
|
|
@@ -138,6 +138,32 @@ Defines per-agent allowed/forbidden tools, required inputs, and success criteria
|
|
|
138
138
|
}
|
|
139
139
|
```
|
|
140
140
|
|
|
141
|
+
### `costBudget` — Per-Workflow Cost Enforcement
|
|
142
|
+
|
|
143
|
+
Limits estimated USD spend and token consumption per workflow run. When a limit is reached, FlowDeck can warn, stop, or escalate depending on `onExhaustion`.
|
|
144
|
+
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"governance": {
|
|
148
|
+
"costBudget": {
|
|
149
|
+
"maxEstimatedCostUSD": 1.0,
|
|
150
|
+
"maxInputTokens": 500000,
|
|
151
|
+
"maxOutputTokens": 100000,
|
|
152
|
+
"onExhaustion": "warn"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
| Field | Type | Default | Description |
|
|
159
|
+
|-------|------|---------|-------------|
|
|
160
|
+
| `maxEstimatedCostUSD` | number | (none) | Maximum estimated USD cost per workflow run |
|
|
161
|
+
| `maxInputTokens` | number | (none) | Maximum input tokens per workflow run |
|
|
162
|
+
| `maxOutputTokens` | number | (none) | Maximum output tokens per workflow run |
|
|
163
|
+
| `onExhaustion` | `"warn"` \| `"stop"` \| `"escalate"` | `"warn"` | Action taken when a limit is reached |
|
|
164
|
+
|
|
165
|
+
Budget state is persisted to `.codebase/COST_BUDGETS.json`.
|
|
166
|
+
|
|
141
167
|
---
|
|
142
168
|
|
|
143
169
|
## `model_profile` — Context Window Balance
|
|
@@ -44,6 +44,26 @@ which flowdeck
|
|
|
44
44
|
|
|
45
45
|
After installation, FlowDeck registers as an OpenCode plugin. Restart OpenCode to load the plugin and its commands.
|
|
46
46
|
|
|
47
|
+
## Optional: rtk Output Compression
|
|
48
|
+
|
|
49
|
+
[rtk](https://github.com/rtk-ai/rtk) is a CLI proxy that compresses noisy terminal output (git, npm, test runners, linters) by 60–90% before it reaches the model context. It is optional but recommended for token savings on command-heavy workflows.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Linux / macOS
|
|
53
|
+
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
FlowDeck detects rtk automatically. No configuration needed. Once installed:
|
|
57
|
+
|
|
58
|
+
- `RTK_INSTALLED=true` and `RTK_BIN=<path>` are injected into every bash session
|
|
59
|
+
- `RTK_TELEMETRY_DISABLED=1` is always set (FlowDeck disables rtk telemetry by default)
|
|
60
|
+
- Agents can use `$RTK_BIN git status`, `$RTK_BIN npm test`, etc. for compressed output
|
|
61
|
+
- Call `rtk-setup` (action: `"init"`) once to install the bash auto-rewrite hook
|
|
62
|
+
|
|
63
|
+
See [rtk Integration reference](../reference/rtk.md) for full setup, supported commands, and telemetry details.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
47
67
|
## Environment Variables
|
|
48
68
|
|
|
49
69
|
FlowDeck respects the following environment variables:
|
package/docs/reference/hooks.md
CHANGED
|
@@ -98,10 +98,25 @@ Injects the following environment variables into every bash tool execution:
|
|
|
98
98
|
| `DETECTED_LANGUAGES` | Marker files scan | Comma-separated list (e.g., `typescript,python`) |
|
|
99
99
|
| `PRIMARY_LANGUAGE` | Marker files scan | First detected language |
|
|
100
100
|
| `FLOWDECK_PHASE` | `STATE.md` phase field | Current FlowDeck planning phase |
|
|
101
|
+
| `RTK_INSTALLED` | Live `rtk --version` check | `"true"` if the rtk binary is found, `"false"` otherwise |
|
|
102
|
+
| `RTK_BIN` | rtk binary path | Full path to the rtk binary (only set when `RTK_INSTALLED=true`) |
|
|
103
|
+
| `RTK_TELEMETRY_DISABLED` | Set when rtk is installed | Always `"1"` when rtk is detected — blocks rtk telemetry regardless of consent state |
|
|
101
104
|
|
|
102
105
|
Language detection uses marker files: `tsconfig.json` (TypeScript), `go.mod` (Go), `pyproject.toml`/`requirements.txt` (Python), `Cargo.toml` (Rust), `build.gradle`/`pom.xml` (Java).
|
|
103
106
|
|
|
104
|
-
**
|
|
107
|
+
**rtk detection:** The binary is checked once at hook creation time (startup cost only) and cached for the session lifetime. Checks `PATH` first, then `~/.local/bin/rtk` and `/usr/local/bin/rtk`.
|
|
108
|
+
|
|
109
|
+
**Using rtk in bash commands:** When `RTK_INSTALLED=true`, agents can compress noisy CLI output by prefixing commands with `$RTK_BIN`:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
$RTK_BIN git status # compressed git status output
|
|
113
|
+
$RTK_BIN npm test # compressed test runner output
|
|
114
|
+
$RTK_BIN tsc --noEmit # compressed TypeScript compiler output
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
See [rtk Integration](rtk.md) for the full list of supported commands and setup instructions.
|
|
118
|
+
|
|
119
|
+
**State read:** `package.json`, lockfiles, marker files, `.planning/STATE.md`, `rtk` binary (PATH check)
|
|
105
120
|
|
|
106
121
|
---
|
|
107
122
|
|