@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
@@ -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:
@@ -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
- **State read:** `package.json`, lockfiles, marker files, `.planning/STATE.md`
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
 
@@ -0,0 +1,162 @@
1
+ # rtk Integration
2
+
3
+ FlowDeck integrates [rtk](https://github.com/rtk-ai/rtk) — a Rust CLI proxy that compresses noisy terminal output (git, npm, test runners, linters, Docker, and more) by 60–90% before it reaches the model context.
4
+
5
+ ---
6
+
7
+ ## What rtk does
8
+
9
+ rtk acts as a transparent proxy in front of supported CLI commands:
10
+
11
+ ```bash
12
+ rtk git status # same as git status, but output compressed 60-90%
13
+ rtk npm test # same as npm test, but noise filtered out
14
+ rtk tsc --noEmit # TypeScript compiler errors, signal-only
15
+ ```
16
+
17
+ This reduces the number of tokens consumed by verbose CLI output — lowering cost and improving signal quality for agents that read shell output.
18
+
19
+ ---
20
+
21
+ ## Detection
22
+
23
+ FlowDeck detects rtk automatically at session startup. No configuration is required.
24
+
25
+ Detection checks in order:
26
+ 1. `rtk --version` via `PATH`
27
+ 2. `~/.local/bin/rtk` (default install location on Linux/macOS)
28
+ 3. `/usr/local/bin/rtk`
29
+
30
+ Detection is performed once per session and cached (zero overhead per bash call).
31
+
32
+ ---
33
+
34
+ ## Environment Variables Injected
35
+
36
+ When rtk is detected, FlowDeck injects the following into **every bash tool execution** via the `shell.env` hook:
37
+
38
+ | Variable | Value | Description |
39
+ |----------|-------|-------------|
40
+ | `RTK_INSTALLED` | `"true"` / `"false"` | Whether rtk was found at session start |
41
+ | `RTK_BIN` | e.g. `/home/user/.local/bin/rtk` | Full path to the rtk binary (only when installed) |
42
+ | `RTK_TELEMETRY_DISABLED` | `"1"` | Always set when rtk is installed — blocks telemetry |
43
+
44
+ Agents can use these vars directly in bash commands:
45
+
46
+ ```bash
47
+ if [ "$RTK_INSTALLED" = "true" ]; then
48
+ $RTK_BIN git log --oneline -20
49
+ else
50
+ git log --oneline -20
51
+ fi
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Telemetry
57
+
58
+ FlowDeck **always disables rtk telemetry**. Two layers of protection:
59
+
60
+ 1. **`rtk telemetry disable`** — run automatically after every `rtk-setup init`. Stores an explicit opt-out in rtk's local config (`~/.local/share/rtk/`).
61
+ 2. **`RTK_TELEMETRY_DISABLED=1`** — injected into every bash session by FlowDeck's `shell.env` hook. Blocks telemetry at the env-var level regardless of stored consent state.
62
+
63
+ Both mechanisms are active independently. The env var alone is sufficient to suppress all telemetry pings even if the config opt-out is somehow lost.
64
+
65
+ See [rtk TELEMETRY.md](https://github.com/rtk-ai/rtk/blob/develop/docs/TELEMETRY.md) for what rtk would collect if telemetry were enabled.
66
+
67
+ ---
68
+
69
+ ## Supported Commands
70
+
71
+ The following commands benefit from rtk compression. FlowDeck's wrapping policy (`rtk-policy.ts`) uses this list:
72
+
73
+ | Command | What gets compressed |
74
+ |---------|----------------------|
75
+ | `git status` | Staged / unstaged file listing |
76
+ | `git log` | Commit history |
77
+ | `git diff` | Full diff output |
78
+ | `git show` | Commit show output |
79
+ | `npm test` / `bun test` | Test runner output and summaries |
80
+ | `tsc` | TypeScript compiler diagnostics |
81
+ | `eslint` / `biome` / `oxlint` | Lint output |
82
+ | `jest` / `vitest` / `pytest` | Test output |
83
+ | `cargo` | Rust build / test output |
84
+ | `docker` | Container and image listings |
85
+ | `kubectl` | Kubernetes resource listings |
86
+ | `gh` | GitHub CLI output |
87
+ | `pnpm` / `yarn` / `npx` | Package manager output |
88
+
89
+ **Commands that are never wrapped** (raw output required or already compact):
90
+
91
+ | Command | Reason |
92
+ |---------|--------|
93
+ | `git rev-parse` | Returns a single hash — already minimal |
94
+ | `git diff --name-only` / `--name-status` / `--stat` | Already compact listing |
95
+ | `git ls-files`, `git config`, `git symbolic-ref` | Compact structured output |
96
+ | `codegraph` | Programmatic structured output — must not be modified |
97
+ | `curl` | Used for downloads — raw output required |
98
+ | `sh`, `bash`, `node`, `python` | Shell interpreters — must not be intercepted |
99
+
100
+ ---
101
+
102
+ ## Setup Tool
103
+
104
+ Agents can check rtk status or trigger initialization via the `rtk-setup` tool:
105
+
106
+ ### Check status
107
+
108
+ ```
109
+ rtk-setup (action: "status")
110
+ ```
111
+
112
+ Returns current detection result, binary path, version, and instructions if rtk is not installed.
113
+
114
+ ### Initialize bash hook
115
+
116
+ ```
117
+ rtk-setup (action: "init")
118
+ ```
119
+
120
+ Runs `rtk init -g` to install the bash rewriting hook, then immediately runs `rtk telemetry disable`. Reports both outcomes.
121
+
122
+ **Bash hook caveat:** `rtk init -g` writes to Claude Code / Copilot global config. Whether the hook fires automatically in OpenCode's non-interactive bash sessions depends on the runtime. Using `$RTK_BIN <cmd>` explicitly is always reliable.
123
+
124
+ ---
125
+
126
+ ## Installing rtk
127
+
128
+ FlowDeck does **not** auto-install rtk. Auto-executing a remote shell script is a supply-chain risk. Install manually:
129
+
130
+ ```bash
131
+ # Linux / macOS
132
+ curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
133
+ ```
134
+
135
+ After installation, add `~/.local/bin` to your PATH if not already present, then verify:
136
+
137
+ ```bash
138
+ rtk --version
139
+ ```
140
+
141
+ FlowDeck will detect the binary automatically on the next session start.
142
+
143
+ ---
144
+
145
+ ## No rtk? No problem.
146
+
147
+ rtk is entirely optional. If rtk is not installed:
148
+ - `RTK_INSTALLED=false` is injected (no `RTK_BIN` or `RTK_TELEMETRY_DISABLED`)
149
+ - All commands run as normal — no change to behavior
150
+ - The `rtk-setup` tool returns install instructions instead of status
151
+ - All FlowDeck workflows remain fully functional
152
+
153
+ ---
154
+
155
+ ## Files
156
+
157
+ | File | Purpose |
158
+ |------|---------|
159
+ | `src/services/rtk-manager.ts` | Detection (`detectRtk`), init (`initRtk`), status (`getRtkStatus`), wrapping (`wrapCommandArgs`) |
160
+ | `src/services/rtk-policy.ts` | Command wrapping policy — supported list, compact-git exclusions, `shouldWrapWithRtk()` |
161
+ | `src/tools/rtk-setup.ts` | Agent-callable `rtk-setup` tool |
162
+ | `src/hooks/shell-env-hook.ts` | Injects `RTK_INSTALLED`, `RTK_BIN`, `RTK_TELEMETRY_DISABLED` into bash sessions |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dv.nghiem/flowdeck",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "FlowDeck — structured planning and execution workflows for OpenCode",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,3 +1,10 @@
1
+ ---
2
+ description: FlowDeck agent registry and orchestration rules — which agent to delegate to and when
3
+ always_on: true
4
+ stages: []
5
+ languages: []
6
+ ---
7
+
1
8
  # Agent Orchestration
2
9
 
3
10
  FlowDeck provides 23 specialist agents. Each has a specific role. Using the right agent gets better results faster.
@@ -1,3 +1,10 @@
1
+ ---
2
+ description: Core behavioral guidelines for all LLM agents — think before coding, simplicity, surgical changes, goal-driven execution
3
+ always_on: true
4
+ stages: []
5
+ languages: []
6
+ ---
7
+
1
8
  Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
2
9
 
3
10
  **Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
@@ -1,3 +1,10 @@
1
+ ---
2
+ description: Language-agnostic coding conventions — naming, simplicity, immutability, resource cleanup
3
+ always_on: false
4
+ stages: [execute, fix-bug, verify]
5
+ languages: []
6
+ ---
7
+
1
8
  # Coding Style
2
9
 
3
10
  Language-agnostic coding conventions followed by all FlowDeck agents.
@@ -1,3 +1,10 @@
1
+ ---
2
+ description: Conventional commit format, PR workflow, clean git history standards
3
+ always_on: false
4
+ stages: [execute, verify]
5
+ languages: []
6
+ ---
7
+
1
8
  # Git Workflow
2
9
 
3
10
  Conventional commits, clean history, and structured PR workflow.
@@ -1,3 +1,10 @@
1
+ ---
2
+ description: Security checklist for code changes — no hardcoded secrets, parameterized queries, input validation, auth middleware
3
+ always_on: false
4
+ stages: [execute, fix-bug, verify]
5
+ languages: []
6
+ ---
7
+
1
8
  # Security Standards
2
9
 
3
10
  Security requirements that apply to all code. These are checked before every merge and deployment.
@@ -1,3 +1,10 @@
1
+ ---
2
+ description: TDD and testing standards — 80% coverage, Red-Green-Refactor, regression tests required
3
+ always_on: false
4
+ stages: [execute, fix-bug, verify]
5
+ languages: []
6
+ ---
7
+
1
8
  # Testing Standards
2
9
 
3
10
  All code must meet these testing standards before being considered done.
@@ -1,3 +1,10 @@
1
+ ---
2
+ description: Go conventions — error handling, goroutines, interfaces, testing with t.Run
3
+ always_on: false
4
+ stages: [execute, fix-bug, verify]
5
+ languages: [go]
6
+ ---
7
+
1
8
  # Go Patterns
2
9
 
3
10
  Go conventions for FlowDeck projects.
@@ -1,3 +1,10 @@
1
+ ---
2
+ description: Java conventions — Java 17+ features, Spring Boot patterns, checked exceptions, testing with JUnit 5
3
+ always_on: false
4
+ stages: [execute, fix-bug, verify]
5
+ languages: [java]
6
+ ---
7
+
1
8
  # Java Patterns
2
9
 
3
10
  Java conventions for FlowDeck projects. Targets Java 17+.
@@ -1,3 +1,10 @@
1
+ ---
2
+ description: Python conventions — type hints, virtual environments, testing with pytest, PEP 8
3
+ always_on: false
4
+ stages: [execute, fix-bug, verify]
5
+ languages: [python]
6
+ ---
7
+
1
8
  # Python Patterns
2
9
 
3
10
  Python conventions for FlowDeck projects.
@@ -1,3 +1,10 @@
1
+ ---
2
+ description: Rust conventions — ownership, error handling with Result/Option, unsafe boundaries, testing
3
+ always_on: false
4
+ stages: [execute, fix-bug, verify]
5
+ languages: [rust]
6
+ ---
7
+
1
8
  # Rust Patterns
2
9
 
3
10
  Rust conventions for FlowDeck projects.
@@ -1,3 +1,10 @@
1
+ ---
2
+ description: TypeScript-specific conventions — strict mode, type safety, async patterns, error handling
3
+ always_on: false
4
+ stages: [execute, fix-bug, verify]
5
+ languages: [typescript]
6
+ ---
7
+
1
8
  # TypeScript Patterns
2
9
 
3
10
  TypeScript-specific conventions and patterns for FlowDeck projects.