devflow-kit 1.7.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/README.md +31 -1
- package/dist/cli.js +3 -1
- package/dist/commands/hud.d.ts +22 -0
- package/dist/commands/hud.js +180 -0
- package/dist/commands/init.d.ts +2 -12
- package/dist/commands/init.js +362 -181
- package/dist/commands/list.js +1 -0
- package/dist/commands/uninstall.js +9 -16
- package/dist/hud/cache.d.ts +14 -0
- package/dist/hud/cache.js +54 -0
- package/dist/hud/colors.d.ts +23 -0
- package/dist/hud/colors.js +62 -0
- package/dist/hud/components/config-counts.d.ts +8 -0
- package/dist/hud/components/config-counts.js +91 -0
- package/dist/hud/components/context-usage.d.ts +8 -0
- package/dist/hud/components/context-usage.js +49 -0
- package/dist/hud/components/diff-stats.d.ts +3 -0
- package/dist/hud/components/diff-stats.js +36 -0
- package/dist/hud/components/directory.d.ts +3 -0
- package/dist/hud/components/directory.js +10 -0
- package/dist/hud/components/git-ahead-behind.d.ts +3 -0
- package/dist/hud/components/git-ahead-behind.js +16 -0
- package/dist/hud/components/git-branch.d.ts +3 -0
- package/dist/hud/components/git-branch.js +14 -0
- package/dist/hud/components/model.d.ts +3 -0
- package/dist/hud/components/model.js +21 -0
- package/dist/hud/components/release-info.d.ts +3 -0
- package/dist/hud/components/release-info.js +9 -0
- package/dist/hud/components/session-cost.d.ts +3 -0
- package/dist/hud/components/session-cost.js +9 -0
- package/dist/hud/components/session-duration.d.ts +3 -0
- package/dist/hud/components/session-duration.js +18 -0
- package/dist/hud/components/todo-progress.d.ts +3 -0
- package/dist/hud/components/todo-progress.js +11 -0
- package/dist/hud/components/usage-quota.d.ts +3 -0
- package/dist/hud/components/usage-quota.js +45 -0
- package/dist/hud/components/version-badge.d.ts +3 -0
- package/dist/hud/components/version-badge.js +80 -0
- package/dist/hud/components/worktree-count.d.ts +3 -0
- package/dist/hud/components/worktree-count.js +8 -0
- package/dist/hud/config.d.ts +10 -0
- package/dist/hud/config.js +55 -0
- package/dist/hud/credentials.d.ts +17 -0
- package/dist/hud/credentials.js +99 -0
- package/dist/hud/git.d.ts +7 -0
- package/dist/hud/git.js +153 -0
- package/dist/hud/index.d.ts +2 -0
- package/dist/hud/index.js +81 -0
- package/dist/hud/render.d.ts +7 -0
- package/dist/hud/render.js +111 -0
- package/dist/hud/stdin.d.ts +6 -0
- package/dist/hud/stdin.js +25 -0
- package/dist/hud/transcript.d.ts +7 -0
- package/dist/hud/transcript.js +130 -0
- package/dist/hud/types.d.ts +116 -0
- package/dist/hud/types.js +2 -0
- package/dist/hud/usage-api.d.ts +7 -0
- package/dist/hud/usage-api.js +84 -0
- package/dist/utils/manifest.d.ts +1 -0
- package/dist/utils/post-install.d.ts +8 -1
- package/dist/utils/post-install.js +41 -0
- package/package.json +5 -2
- package/plugins/devflow-accessibility/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-ambient/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-ambient/agents/scrutinizer.md +6 -4
- package/plugins/devflow-ambient/agents/shepherd.md +26 -12
- package/plugins/devflow-ambient/agents/simplifier.md +24 -15
- package/plugins/devflow-audit-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-code-review/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-core-skills/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-debug/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-frontend-design/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-go/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-implement/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-implement/agents/scrutinizer.md +6 -4
- package/plugins/devflow-implement/agents/shepherd.md +26 -12
- package/plugins/devflow-implement/agents/simplifier.md +24 -15
- package/plugins/devflow-implement/skills/self-review/references/stub-detection.md +135 -0
- package/plugins/devflow-java/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-python/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-react/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-resolve/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-resolve/agents/simplifier.md +24 -15
- package/plugins/devflow-rust/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-self-review/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-self-review/agents/scrutinizer.md +6 -4
- package/plugins/devflow-self-review/agents/simplifier.md +24 -15
- package/plugins/devflow-self-review/skills/self-review/references/stub-detection.md +135 -0
- package/plugins/devflow-specify/.claude-plugin/plugin.json +1 -1
- package/plugins/devflow-typescript/.claude-plugin/plugin.json +1 -1
- package/scripts/hud/cache.d.ts +14 -0
- package/scripts/hud/cache.d.ts.map +1 -0
- package/scripts/hud/cache.js +54 -0
- package/scripts/hud/cache.js.map +1 -0
- package/scripts/hud/colors.d.ts +23 -0
- package/scripts/hud/colors.d.ts.map +1 -0
- package/scripts/hud/colors.js +62 -0
- package/scripts/hud/colors.js.map +1 -0
- package/scripts/hud/components/config-counts.d.ts +8 -0
- package/scripts/hud/components/config-counts.d.ts.map +1 -0
- package/scripts/hud/components/config-counts.js +91 -0
- package/scripts/hud/components/config-counts.js.map +1 -0
- package/scripts/hud/components/context-usage.d.ts +8 -0
- package/scripts/hud/components/context-usage.d.ts.map +1 -0
- package/scripts/hud/components/context-usage.js +49 -0
- package/scripts/hud/components/context-usage.js.map +1 -0
- package/scripts/hud/components/diff-stats.d.ts +3 -0
- package/scripts/hud/components/diff-stats.d.ts.map +1 -0
- package/scripts/hud/components/diff-stats.js +36 -0
- package/scripts/hud/components/diff-stats.js.map +1 -0
- package/scripts/hud/components/directory.d.ts +3 -0
- package/scripts/hud/components/directory.d.ts.map +1 -0
- package/scripts/hud/components/directory.js +10 -0
- package/scripts/hud/components/directory.js.map +1 -0
- package/scripts/hud/components/git-ahead-behind.d.ts +3 -0
- package/scripts/hud/components/git-ahead-behind.d.ts.map +1 -0
- package/scripts/hud/components/git-ahead-behind.js +16 -0
- package/scripts/hud/components/git-ahead-behind.js.map +1 -0
- package/scripts/hud/components/git-branch.d.ts +3 -0
- package/scripts/hud/components/git-branch.d.ts.map +1 -0
- package/scripts/hud/components/git-branch.js +14 -0
- package/scripts/hud/components/git-branch.js.map +1 -0
- package/scripts/hud/components/model.d.ts +3 -0
- package/scripts/hud/components/model.d.ts.map +1 -0
- package/scripts/hud/components/model.js +21 -0
- package/scripts/hud/components/model.js.map +1 -0
- package/scripts/hud/components/release-info.d.ts +3 -0
- package/scripts/hud/components/release-info.d.ts.map +1 -0
- package/scripts/hud/components/release-info.js +9 -0
- package/scripts/hud/components/release-info.js.map +1 -0
- package/scripts/hud/components/session-cost.d.ts +3 -0
- package/scripts/hud/components/session-cost.d.ts.map +1 -0
- package/scripts/hud/components/session-cost.js +9 -0
- package/scripts/hud/components/session-cost.js.map +1 -0
- package/scripts/hud/components/session-duration.d.ts +3 -0
- package/scripts/hud/components/session-duration.d.ts.map +1 -0
- package/scripts/hud/components/session-duration.js +18 -0
- package/scripts/hud/components/session-duration.js.map +1 -0
- package/scripts/hud/components/todo-progress.d.ts +3 -0
- package/scripts/hud/components/todo-progress.d.ts.map +1 -0
- package/scripts/hud/components/todo-progress.js +11 -0
- package/scripts/hud/components/todo-progress.js.map +1 -0
- package/scripts/hud/components/usage-quota.d.ts +3 -0
- package/scripts/hud/components/usage-quota.d.ts.map +1 -0
- package/scripts/hud/components/usage-quota.js +45 -0
- package/scripts/hud/components/usage-quota.js.map +1 -0
- package/scripts/hud/components/version-badge.d.ts +3 -0
- package/scripts/hud/components/version-badge.d.ts.map +1 -0
- package/scripts/hud/components/version-badge.js +80 -0
- package/scripts/hud/components/version-badge.js.map +1 -0
- package/scripts/hud/components/worktree-count.d.ts +3 -0
- package/scripts/hud/components/worktree-count.d.ts.map +1 -0
- package/scripts/hud/components/worktree-count.js +8 -0
- package/scripts/hud/components/worktree-count.js.map +1 -0
- package/scripts/hud/config.d.ts +10 -0
- package/scripts/hud/config.d.ts.map +1 -0
- package/scripts/hud/config.js +55 -0
- package/scripts/hud/config.js.map +1 -0
- package/scripts/hud/credentials.d.ts +17 -0
- package/scripts/hud/credentials.d.ts.map +1 -0
- package/scripts/hud/credentials.js +99 -0
- package/scripts/hud/credentials.js.map +1 -0
- package/scripts/hud/git.d.ts +7 -0
- package/scripts/hud/git.d.ts.map +1 -0
- package/scripts/hud/git.js +153 -0
- package/scripts/hud/git.js.map +1 -0
- package/scripts/hud/index.d.ts +2 -0
- package/scripts/hud/index.d.ts.map +1 -0
- package/scripts/hud/index.js +81 -0
- package/scripts/hud/index.js.map +1 -0
- package/scripts/hud/render.d.ts +7 -0
- package/scripts/hud/render.d.ts.map +1 -0
- package/scripts/hud/render.js +111 -0
- package/scripts/hud/render.js.map +1 -0
- package/scripts/hud/stdin.d.ts +6 -0
- package/scripts/hud/stdin.d.ts.map +1 -0
- package/scripts/hud/stdin.js +25 -0
- package/scripts/hud/stdin.js.map +1 -0
- package/scripts/hud/transcript.d.ts +7 -0
- package/scripts/hud/transcript.d.ts.map +1 -0
- package/scripts/hud/transcript.js +130 -0
- package/scripts/hud/transcript.js.map +1 -0
- package/scripts/hud/types.d.ts +116 -0
- package/scripts/hud/types.d.ts.map +1 -0
- package/scripts/hud/types.js +2 -0
- package/scripts/hud/types.js.map +1 -0
- package/scripts/hud/usage-api.d.ts +7 -0
- package/scripts/hud/usage-api.d.ts.map +1 -0
- package/scripts/hud/usage-api.js +84 -0
- package/scripts/hud/usage-api.js.map +1 -0
- package/scripts/hud.sh +5 -0
- package/shared/agents/scrutinizer.md +6 -4
- package/shared/agents/shepherd.md +26 -12
- package/shared/agents/simplifier.md +24 -15
- package/shared/skills/self-review/references/stub-detection.md +135 -0
- package/src/templates/settings.json +1 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StdinData — the JSON that Claude Code pipes to statusLine commands.
|
|
3
|
+
*/
|
|
4
|
+
export interface StdinData {
|
|
5
|
+
model?: {
|
|
6
|
+
display_name?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
};
|
|
9
|
+
cwd?: string;
|
|
10
|
+
context_window?: {
|
|
11
|
+
context_window_size?: number;
|
|
12
|
+
current_usage?: {
|
|
13
|
+
input_tokens?: number;
|
|
14
|
+
output_tokens?: number;
|
|
15
|
+
};
|
|
16
|
+
used_percentage?: number;
|
|
17
|
+
};
|
|
18
|
+
cost?: {
|
|
19
|
+
total_cost_usd?: number;
|
|
20
|
+
};
|
|
21
|
+
session_id?: string;
|
|
22
|
+
transcript_path?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Component IDs — the 14 HUD components.
|
|
26
|
+
*/
|
|
27
|
+
export type ComponentId = 'directory' | 'gitBranch' | 'gitAheadBehind' | 'diffStats' | 'model' | 'contextUsage' | 'versionBadge' | 'sessionDuration' | 'usageQuota' | 'todoProgress' | 'configCounts' | 'sessionCost' | 'releaseInfo' | 'worktreeCount';
|
|
28
|
+
/**
|
|
29
|
+
* HUD config persisted to ~/.devflow/hud.json.
|
|
30
|
+
*/
|
|
31
|
+
export interface HudConfig {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
detail: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Component render result.
|
|
37
|
+
*/
|
|
38
|
+
export interface ComponentResult {
|
|
39
|
+
text: string;
|
|
40
|
+
raw: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Component function signature.
|
|
44
|
+
*/
|
|
45
|
+
export type ComponentFn = (ctx: GatherContext) => Promise<ComponentResult | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Git status data gathered from the working directory.
|
|
48
|
+
*/
|
|
49
|
+
export interface GitStatus {
|
|
50
|
+
branch: string;
|
|
51
|
+
dirty: boolean;
|
|
52
|
+
staged: boolean;
|
|
53
|
+
ahead: number;
|
|
54
|
+
behind: number;
|
|
55
|
+
filesChanged: number;
|
|
56
|
+
additions: number;
|
|
57
|
+
deletions: number;
|
|
58
|
+
lastTag: string | null;
|
|
59
|
+
commitsSinceTag: number;
|
|
60
|
+
worktreeCount: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Transcript data parsed from session JSONL.
|
|
64
|
+
*/
|
|
65
|
+
export interface TranscriptData {
|
|
66
|
+
tools: Array<{
|
|
67
|
+
name: string;
|
|
68
|
+
status: 'running' | 'completed';
|
|
69
|
+
target?: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
}>;
|
|
72
|
+
agents: Array<{
|
|
73
|
+
name: string;
|
|
74
|
+
model?: string;
|
|
75
|
+
status: 'running' | 'completed';
|
|
76
|
+
description?: string;
|
|
77
|
+
}>;
|
|
78
|
+
todos: {
|
|
79
|
+
completed: number;
|
|
80
|
+
total: number;
|
|
81
|
+
};
|
|
82
|
+
skills: string[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Usage API data.
|
|
86
|
+
*/
|
|
87
|
+
export interface UsageData {
|
|
88
|
+
fiveHourPercent: number | null;
|
|
89
|
+
sevenDayPercent: number | null;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Config counts data for the configCounts component.
|
|
93
|
+
*/
|
|
94
|
+
export interface ConfigCountsData {
|
|
95
|
+
claudeMdFiles: number;
|
|
96
|
+
rules: number;
|
|
97
|
+
mcpServers: number;
|
|
98
|
+
hooks: number;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Gather context passed to all component render functions.
|
|
102
|
+
*/
|
|
103
|
+
export interface GatherContext {
|
|
104
|
+
stdin: StdinData;
|
|
105
|
+
git: GitStatus | null;
|
|
106
|
+
transcript: TranscriptData | null;
|
|
107
|
+
usage: UsageData | null;
|
|
108
|
+
configCounts: ConfigCountsData | null;
|
|
109
|
+
config: HudConfig & {
|
|
110
|
+
components: ComponentId[];
|
|
111
|
+
};
|
|
112
|
+
devflowDir: string;
|
|
113
|
+
sessionStartTime: number | null;
|
|
114
|
+
terminalWidth: number;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cli/hud/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE;QACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,aAAa,CAAC,EAAE;YAAE,YAAY,CAAC,EAAE,MAAM,CAAC;YAAC,aAAa,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAClE,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,IAAI,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GACnB,WAAW,GACX,WAAW,GACX,gBAAgB,GAChB,WAAW,GACX,OAAO,GACP,cAAc,GACd,cAAc,GACd,iBAAiB,GACjB,YAAY,GACZ,cAAc,GACd,cAAc,GACd,aAAa,GACb,aAAa,GACb,eAAe,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,aAAa,KAAK,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;AA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;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,SAAS,CAAC;IACjB,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;IAClC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACtC,MAAM,EAAE,SAAS,GAAG;QAAE,UAAU,EAAE,WAAW,EAAE,CAAA;KAAE,CAAC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/cli/hud/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UsageData } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Fetch usage quota data from the Anthropic API.
|
|
4
|
+
* Uses caching with backoff for rate limiting. Returns null on failure.
|
|
5
|
+
*/
|
|
6
|
+
export declare function fetchUsageData(): Promise<UsageData | null>;
|
|
7
|
+
//# sourceMappingURL=usage-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-api.d.ts","sourceRoot":"","sources":["../../src/cli/hud/usage-api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAqB5C;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAiFhE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import { readCache, writeCache, readCacheStale } from './cache.js';
|
|
3
|
+
import { getCredentials } from './credentials.js';
|
|
4
|
+
const USAGE_CACHE_KEY = 'usage';
|
|
5
|
+
const USAGE_CACHE_TTL = 5 * 60 * 1000; // 5 minutes
|
|
6
|
+
const USAGE_FAIL_TTL = 15 * 1000; // 15 seconds
|
|
7
|
+
const API_TIMEOUT = 1_500; // Must fit within 2s overall HUD timeout
|
|
8
|
+
const BACKOFF_CACHE_KEY = 'usage-backoff';
|
|
9
|
+
const DEBUG = !!process.env.DEVFLOW_HUD_DEBUG;
|
|
10
|
+
function debugLog(msg, data) {
|
|
11
|
+
if (!DEBUG)
|
|
12
|
+
return;
|
|
13
|
+
const entry = { ts: new Date().toISOString(), source: 'usage-api', msg, ...data };
|
|
14
|
+
fs.appendFileSync('/tmp/hud-debug.log', JSON.stringify(entry) + '\n');
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Fetch usage quota data from the Anthropic API.
|
|
18
|
+
* Uses caching with backoff for rate limiting. Returns null on failure.
|
|
19
|
+
*/
|
|
20
|
+
export async function fetchUsageData() {
|
|
21
|
+
// Check backoff
|
|
22
|
+
const backoff = readCache(BACKOFF_CACHE_KEY);
|
|
23
|
+
if (backoff && Date.now() < backoff.retryAfter) {
|
|
24
|
+
debugLog('skipped: backoff active', { retryAfter: backoff.retryAfter });
|
|
25
|
+
return readCacheStale(USAGE_CACHE_KEY);
|
|
26
|
+
}
|
|
27
|
+
// Check cache
|
|
28
|
+
const cached = readCache(USAGE_CACHE_KEY);
|
|
29
|
+
if (cached)
|
|
30
|
+
return cached;
|
|
31
|
+
const creds = await getCredentials();
|
|
32
|
+
if (!creds) {
|
|
33
|
+
debugLog('no OAuth credentials found');
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const token = creds.accessToken;
|
|
37
|
+
try {
|
|
38
|
+
const controller = new AbortController();
|
|
39
|
+
const timeout = setTimeout(() => controller.abort(), API_TIMEOUT);
|
|
40
|
+
debugLog('fetching usage', { timeout: API_TIMEOUT });
|
|
41
|
+
const response = await fetch('https://api.anthropic.com/api/oauth/usage', {
|
|
42
|
+
headers: {
|
|
43
|
+
Authorization: `Bearer ${token}`,
|
|
44
|
+
'Content-Type': 'application/json',
|
|
45
|
+
'anthropic-beta': 'oauth-2025-04-20',
|
|
46
|
+
},
|
|
47
|
+
signal: controller.signal,
|
|
48
|
+
});
|
|
49
|
+
clearTimeout(timeout);
|
|
50
|
+
if (response.status === 429) {
|
|
51
|
+
const retryAfter = parseInt(response.headers.get('Retry-After') || '60', 10);
|
|
52
|
+
const delay = Math.min(retryAfter * 1000, 5 * 60 * 1000);
|
|
53
|
+
writeCache(BACKOFF_CACHE_KEY, { retryAfter: Date.now() + delay, delay }, delay);
|
|
54
|
+
debugLog('rate limited (429)', { retryAfter, delay });
|
|
55
|
+
return readCacheStale(USAGE_CACHE_KEY);
|
|
56
|
+
}
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
debugLog('non-200 response', { status: response.status, statusText: response.statusText });
|
|
59
|
+
writeCache(USAGE_CACHE_KEY, null, USAGE_FAIL_TTL);
|
|
60
|
+
return readCacheStale(USAGE_CACHE_KEY);
|
|
61
|
+
}
|
|
62
|
+
const body = (await response.json());
|
|
63
|
+
const fiveHour = body.five_hour;
|
|
64
|
+
const sevenDay = body.seven_day;
|
|
65
|
+
const data = {
|
|
66
|
+
fiveHourPercent: typeof fiveHour?.utilization === 'number'
|
|
67
|
+
? Math.round(Math.max(0, Math.min(100, fiveHour.utilization)))
|
|
68
|
+
: null,
|
|
69
|
+
sevenDayPercent: typeof sevenDay?.utilization === 'number'
|
|
70
|
+
? Math.round(Math.max(0, Math.min(100, sevenDay.utilization)))
|
|
71
|
+
: null,
|
|
72
|
+
};
|
|
73
|
+
debugLog('usage fetched', { fiveHour: data.fiveHourPercent, sevenDay: data.sevenDayPercent });
|
|
74
|
+
writeCache(USAGE_CACHE_KEY, data, USAGE_CACHE_TTL);
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
79
|
+
debugLog('fetch failed', { error: message });
|
|
80
|
+
writeCache(USAGE_CACHE_KEY, null, USAGE_FAIL_TTL);
|
|
81
|
+
return readCacheStale(USAGE_CACHE_KEY);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=usage-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-api.js","sourceRoot":"","sources":["../../src/cli/hud/usage-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,eAAe,GAAG,OAAO,CAAC;AAChC,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;AACnD,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAC/C,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,yCAAyC;AACpE,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAO1C,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;AAE9C,SAAS,QAAQ,CAAC,GAAW,EAAE,IAA8B;IAC3D,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,MAAM,KAAK,GAAG,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IAClF,EAAE,CAAC,cAAc,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;AACxE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,gBAAgB;IAChB,MAAM,OAAO,GAAG,SAAS,CAAe,iBAAiB,CAAC,CAAC;IAC3D,IAAI,OAAO,IAAI,IAAI,C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AQ,CAAC,WAAW,CAAC,CAAC,CAAC;gBAC9D,CAAC,CAAC,IAAI;SACX,CAAC;QAEF,QAAQ,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;QAC9F,UAAU,CAAC,eAAe,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,QAAQ,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAC7C,UAAU,CAAmB,eAAe,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QACpE,OAAO,cAAc,CAAY,eAAe,CAAC,CAAC;IACpD,CAAC;AACH,CAAC"}
|
package/scripts/hud.sh
ADDED
|
@@ -21,13 +21,15 @@ You receive from orchestrator:
|
|
|
21
21
|
|
|
22
22
|
2. **Evaluate P0 pillars** (Design, Functionality, Security): These MUST pass. Fix all issues found.
|
|
23
23
|
|
|
24
|
-
3. **
|
|
24
|
+
3. **Detect stubs and wiring gaps**: Check for placeholder implementations that compile but don't deliver real functionality. See `references/stub-detection.md` for patterns. Flag as P0-Functionality issues.
|
|
25
25
|
|
|
26
|
-
4. **Evaluate
|
|
26
|
+
4. **Evaluate P1 pillars** (Complexity, Error Handling, Tests): These SHOULD pass. Fix all issues found.
|
|
27
27
|
|
|
28
|
-
5. **
|
|
28
|
+
5. **Evaluate P2 pillars** (Naming, Consistency, Documentation): Report as suggestions. Fix if straightforward.
|
|
29
29
|
|
|
30
|
-
6. **
|
|
30
|
+
6. **Commit fixes**: If any changes were made, create a commit with message "fix: address self-review issues".
|
|
31
|
+
|
|
32
|
+
7. **Report status**: Return structured report with pillar evaluations and changes made.
|
|
31
33
|
|
|
32
34
|
## Principles
|
|
33
35
|
|
|
@@ -21,9 +21,19 @@ You receive from orchestrator:
|
|
|
21
21
|
|
|
22
22
|
1. **Understand intent**: Read ORIGINAL_REQUEST and EXECUTION_PLAN to understand what was requested
|
|
23
23
|
2. **Review implementation**: Read FILES_CHANGED to understand what was built
|
|
24
|
-
3. **
|
|
25
|
-
4. **Check
|
|
26
|
-
|
|
24
|
+
3. **Goal-backward verification**: Start from the user's observable goals. For each goal: trace backward through the implementation — is it wired into the running app → does it contain substantive logic → does the file/function exist? Report any goal failing at any depth.
|
|
25
|
+
4. **Check artifact depth**: Classify each deliverable using this scale:
|
|
26
|
+
|
|
27
|
+
| Depth | Meaning | Example |
|
|
28
|
+
|-------|---------|---------|
|
|
29
|
+
| Exists | File/function created | Route file exists |
|
|
30
|
+
| Substantive | Contains real logic | Route has validation + DB call |
|
|
31
|
+
| Wired | Connected to running app | Route registered, imported, reachable |
|
|
32
|
+
|
|
33
|
+
Flag anything at "Exists" without reaching "Wired" as `incomplete`.
|
|
34
|
+
5. **Check completeness**: Verify all plan steps implemented, all acceptance criteria met
|
|
35
|
+
6. **Check scope**: Identify out-of-scope additions not justified by design improvements
|
|
36
|
+
7. **Report misalignments**: Document issues with sufficient detail for Coder to fix
|
|
27
37
|
|
|
28
38
|
## Principles
|
|
29
39
|
|
|
@@ -51,6 +61,11 @@ Return structured alignment status:
|
|
|
51
61
|
- Implementation solves: {1-sentence summary}
|
|
52
62
|
- Alignment: aligned | drifted
|
|
53
63
|
|
|
64
|
+
### Artifact Depth
|
|
65
|
+
| Deliverable | Exists | Substantive | Wired | Status |
|
|
66
|
+
|-------------|--------|-------------|-------|--------|
|
|
67
|
+
| {feature} | Y/N | Y/N | Y/N | complete/incomplete/stub |
|
|
68
|
+
|
|
54
69
|
### Misalignments Found (if MISALIGNED)
|
|
55
70
|
|
|
56
71
|
| Type | Description | Files | Suggested Fix |
|
|
@@ -59,20 +74,17 @@ Return structured alignment status:
|
|
|
59
74
|
| scope_creep | {what's out of scope} | {file paths} | {remove or justify} |
|
|
60
75
|
| incomplete | {what's partially done} | {file paths} | {what remains} |
|
|
61
76
|
| intent_drift | {how intent drifted} | {file paths} | {how to realign} |
|
|
77
|
+
| stub | {placeholder, not real logic} | {file paths} | {what real implementation needs} |
|
|
62
78
|
|
|
63
79
|
### Scope Check
|
|
64
80
|
- Out-of-scope additions: {list or "None"}
|
|
65
81
|
- Justification: {if additions found, are they justified design improvements?}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Misalignment Types
|
|
69
82
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
|
74
|
-
|
|
75
|
-
| `intent_drift` | Implementation solves different problem | "Built password reset instead of login flow" |
|
|
83
|
+
### Re-verification (if applicable)
|
|
84
|
+
| Previously Failed | Status | Notes |
|
|
85
|
+
|-------------------|--------|-------|
|
|
86
|
+
| {item} | RESOLVED/STILL_FAILING | {details} |
|
|
87
|
+
```
|
|
76
88
|
|
|
77
89
|
## Boundaries
|
|
78
90
|
|
|
@@ -81,12 +93,14 @@ Return structured alignment status:
|
|
|
81
93
|
- Out-of-scope additions not justified by design
|
|
82
94
|
- Partial implementations
|
|
83
95
|
- Intent drift
|
|
96
|
+
- Stubs or placeholders passing as real implementations
|
|
84
97
|
|
|
85
98
|
**Report as ALIGNED:**
|
|
86
99
|
- All plan steps implemented
|
|
87
100
|
- All acceptance criteria met
|
|
88
101
|
- No unjustified scope additions
|
|
89
102
|
- Implementation matches original intent
|
|
103
|
+
- All deliverables reach "Wired" depth
|
|
90
104
|
|
|
91
105
|
**Never:**
|
|
92
106
|
- Modify code or create commits
|
|
@@ -30,31 +30,39 @@ Analyze recently modified code and apply refinements that:
|
|
|
30
30
|
- Use proper error handling patterns (avoid try/catch when possible)
|
|
31
31
|
- Maintain consistent naming conventions
|
|
32
32
|
|
|
33
|
-
3. **
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
-
|
|
33
|
+
3. **Remove Slop**: Detect and remove these categories:
|
|
34
|
+
|
|
35
|
+
| Category | Pattern |
|
|
36
|
+
|----------|---------|
|
|
37
|
+
| Language-behavior tests | Tests verifying built-in language features work as documented |
|
|
38
|
+
| Redundant type checks | Runtime checks for types TypeScript already enforces |
|
|
39
|
+
| Over-defensive handling | try/catch around code that cannot throw |
|
|
40
|
+
| Debug remnants | console.log, debugger, alert() left behind |
|
|
41
|
+
| Commented-out code | Dead code preserved in comments |
|
|
42
|
+
| Unused imports | Imports not referenced anywhere in file |
|
|
43
|
+
| Verbose names | Unnecessarily long names (`currentUserDataObject` → `user`) |
|
|
44
|
+
| Unnecessary intermediates | Variables used once, immediately after assignment |
|
|
45
|
+
|
|
46
|
+
4. **Enhance Clarity**: Simplify code structure by:
|
|
47
|
+
|
|
48
|
+
- Reducing unnecessary nesting (early returns, guard clauses)
|
|
38
49
|
- Consolidating related logic
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
- Choose clarity over brevity - explicit code is often better than overly compact code
|
|
50
|
+
- Avoiding nested ternary operators — prefer switch or if/else
|
|
51
|
+
- Choosing clarity over brevity — explicit code beats compact code
|
|
42
52
|
|
|
43
|
-
|
|
53
|
+
5. **Maintain Balance**: Avoid over-simplification that could:
|
|
44
54
|
|
|
45
|
-
- Reduce code clarity or maintainability
|
|
46
55
|
- Create overly clever solutions that are hard to understand
|
|
47
56
|
- Combine too many concerns into single functions or components
|
|
48
57
|
- Remove helpful abstractions that improve code organization
|
|
49
|
-
- Prioritize "fewer lines" over readability (e.g., nested ternaries, dense one-liners)
|
|
50
58
|
- Make the code harder to debug or extend
|
|
51
59
|
|
|
52
|
-
|
|
60
|
+
6. **Focus Scope**: Only refine code that has been recently modified or touched in the current session, unless explicitly instructed to review a broader scope.
|
|
53
61
|
|
|
54
62
|
Your refinement process:
|
|
55
63
|
|
|
56
64
|
1. Identify the recently modified code sections
|
|
57
|
-
2. Analyze for
|
|
65
|
+
2. Analyze for slop categories and clarity improvements
|
|
58
66
|
3. Apply project-specific best practices and coding standards
|
|
59
67
|
4. Ensure all functionality remains unchanged
|
|
60
68
|
5. Verify the refined code is simpler and more maintainable
|
|
@@ -87,7 +95,8 @@ Return structured completion status:
|
|
|
87
95
|
- Files outside the recently modified scope (unless instructed)
|
|
88
96
|
|
|
89
97
|
**Handle autonomously:**
|
|
90
|
-
-
|
|
98
|
+
- Slop removal (all 8 categories)
|
|
99
|
+
- Naming improvements, nesting reduction
|
|
91
100
|
- Import sorting and organization
|
|
92
101
|
- Redundant abstraction elimination
|
|
93
|
-
- Comment cleanup (remove obvious, keep non-obvious)
|
|
102
|
+
- Comment cleanup (remove obvious, keep non-obvious)
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Stub Detection Patterns
|
|
2
|
+
|
|
3
|
+
Placeholder implementations that compile but don't deliver real functionality. Flag as **P0-Functionality** issues.
|
|
4
|
+
|
|
5
|
+
Cross-reference: `core-patterns/references/code-smell-violations.md` covers hardcoded data and fake functionality labeling. This file focuses on structural stub patterns.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Component Stubs
|
|
10
|
+
|
|
11
|
+
Render nothing meaningful or return placeholder markup.
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
// STUB — returns static text, no real rendering
|
|
15
|
+
function UserProfile({ userId }: Props) {
|
|
16
|
+
return <div>Name</div>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// REAL — fetches and renders actual data
|
|
20
|
+
function UserProfile({ userId }: Props) {
|
|
21
|
+
const user = useUser(userId);
|
|
22
|
+
if (!user) return <Skeleton />;
|
|
23
|
+
return <div><h2>{user.name}</h2><p>{user.email}</p></div>;
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Patterns to flag:**
|
|
28
|
+
- `return null` / `return <></>` in components that should render content
|
|
29
|
+
- Empty function bodies (`{}`) for handlers or lifecycle methods
|
|
30
|
+
- Components returning only hardcoded strings with no data binding
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 2. API / Service Stubs
|
|
35
|
+
|
|
36
|
+
Functions that exist in signature but throw, return hardcoded values, or do nothing.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// STUB — throws instead of implementing
|
|
40
|
+
async function createOrder(items: CartItem[]): Promise<Order> {
|
|
41
|
+
throw new Error("TODO: implement");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// STUB — hardcoded return, no real logic
|
|
45
|
+
async function getUser(id: string): Promise<User> {
|
|
46
|
+
return { id, name: "Test User", email: "test@test.com" };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// REAL — actual implementation
|
|
50
|
+
async function createOrder(items: CartItem[]): Promise<Result<Order, OrderError>> {
|
|
51
|
+
const validated = validateItems(items);
|
|
52
|
+
if (!validated.ok) return validated;
|
|
53
|
+
const order = await db.orders.create({ items: validated.value });
|
|
54
|
+
await queue.publish("order.created", order);
|
|
55
|
+
return { ok: true, value: order };
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Patterns to flag:**
|
|
60
|
+
- `throw new Error("TODO")` / `throw new Error("Not implemented")`
|
|
61
|
+
- Functions returning hardcoded objects (no DB/API/computation)
|
|
62
|
+
- `"Not implemented"` strings in response bodies
|
|
63
|
+
- Empty async functions (`async function foo() {}`)
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 3. Hook / Effect Stubs
|
|
68
|
+
|
|
69
|
+
State and effects declared but not wired to behavior.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
// STUB — effect does nothing
|
|
73
|
+
useEffect(() => {}, [userId]);
|
|
74
|
+
|
|
75
|
+
// STUB — state declared, setter never called
|
|
76
|
+
const [items, setItems] = useState<Item[]>([]);
|
|
77
|
+
// ... setItems never appears in the component
|
|
78
|
+
|
|
79
|
+
// STUB — custom hook returns static value
|
|
80
|
+
function usePermissions(): Permissions {
|
|
81
|
+
return { canEdit: true, canDelete: false };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// REAL — custom hook with actual logic
|
|
85
|
+
function usePermissions(): Permissions {
|
|
86
|
+
const { user } = useAuth();
|
|
87
|
+
const { data } = useQuery(["permissions", user.role], fetchPermissions);
|
|
88
|
+
return data ?? DEFAULT_PERMISSIONS;
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Patterns to flag:**
|
|
93
|
+
- `useEffect(() => {}, [...])` — empty effect body
|
|
94
|
+
- `useState` where the setter is never called in the component
|
|
95
|
+
- Custom hooks returning static/hardcoded values
|
|
96
|
+
- `useMemo`/`useCallback` wrapping static values
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 4. Wiring Gaps
|
|
101
|
+
|
|
102
|
+
Individual pieces exist but aren't connected to the running application. **Highest-value detection** — these pass compilation and individual tests but the feature doesn't work end-to-end.
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
// GAP — fetch without await (result discarded)
|
|
106
|
+
function loadDashboard() {
|
|
107
|
+
fetchMetrics(); // Promise floats, never awaited
|
|
108
|
+
return <Dashboard />;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// GAP — state declared but never rendered
|
|
112
|
+
const [error, setError] = useState<string | null>(null);
|
|
113
|
+
// ... error never appears in JSX
|
|
114
|
+
|
|
115
|
+
// GAP — handler defined but not bound
|
|
116
|
+
function handleSubmit(data: FormData) { /* real logic */ }
|
|
117
|
+
// ... <form onSubmit={handleSubmit}> never appears
|
|
118
|
+
|
|
119
|
+
// GAP — route defined with no-op handler
|
|
120
|
+
app.post("/api/orders", (_req, res) => {
|
|
121
|
+
res.status(200).json({ ok: true });
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// GAP — env var read but unused
|
|
125
|
+
const API_KEY = process.env.STRIPE_API_KEY;
|
|
126
|
+
// ... API_KEY never passed to any client or fetch call
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Patterns to flag:**
|
|
130
|
+
- `fetch`/`axios`/API call without `await` or `.then` (result discarded)
|
|
131
|
+
- State variable (`useState`, `useRef`) never rendered or read in output
|
|
132
|
+
- Event handler defined but not bound to any element/listener
|
|
133
|
+
- Route/endpoint registered with empty or no-op handler
|
|
134
|
+
- Environment variable or config read but never used downstream
|
|
135
|
+
- Import used only in type position but imported as value (in non-type-only import)
|