docks-kit 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/README.md +6 -4
- package/cli/docs/install.md +9 -11
- package/cli/docs/overview.md +3 -0
- package/cli/docs/platforms.md +3 -5
- package/cli/src/engine-native/DESIGN.md +4 -0
- package/cli/src/engine-native/claudeSync.ts +23 -25
- package/cli/src/engine-native/codexSync.ts +42 -36
- package/cli/src/engine-native/exec.ts +8 -23
- package/cli/src/engine-native/index.ts +3 -4
- package/cli/src/engine-native/models.ts +14 -16
- package/cli/src/engine-native/modes.ts +13 -4
- package/cli/src/engine-native/skillsSync.ts +7 -10
- package/cli/src/engine-native/toolchain.ts +6 -6
- package/cli/src/generated/sotPayload.ts +41 -0
- package/cli/src/kitHome.ts +15 -11
- package/cli/src/manifests.ts +17 -15
- package/cli/src/payload.ts +28 -0
- package/docks-kit +6 -6
- package/package.json +2 -3
- package/SoT/.agents/skills.txt +0 -14
- package/SoT/.claude/CLAUDE.md +0 -146
- package/SoT/.claude/fetch-usage.sh +0 -66
- package/SoT/.claude/hooks/notify.sh +0 -14
- package/SoT/.claude/mcp-servers.json +0 -10
- package/SoT/.claude/settings.json +0 -235
- package/SoT/.claude/statusline.sh +0 -175
- package/SoT/.codex/AGENTS.md +0 -75
- package/SoT/.codex/agents/.gitkeep +0 -1
- package/SoT/.codex/config.toml +0 -45
- package/SoT/.codex/plugins/marketplace.json +0 -50
- package/SoT/.codex/rules/docks.rules +0 -116
- package/SoT/models.json +0 -31
- package/SoT/toolchain.json +0 -27
- package/notification.mp3 +0 -0
package/docks-kit
CHANGED
|
@@ -7,6 +7,10 @@ set -euo pipefail
|
|
|
7
7
|
|
|
8
8
|
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
9
9
|
|
|
10
|
+
# BEGIN GENERATED BUN PIN
|
|
11
|
+
BUN_PIN="1.3.14"
|
|
12
|
+
# END GENERATED BUN PIN
|
|
13
|
+
|
|
10
14
|
case "$(uname -s)-$(uname -m)" in
|
|
11
15
|
Linux-x86_64) KIT_BIN="docks-kit-linux-x64" ;;
|
|
12
16
|
Linux-aarch64) KIT_BIN="docks-kit-linux-arm64" ;;
|
|
@@ -39,12 +43,8 @@ if ! BUN="$(find_bun)"; then
|
|
|
39
43
|
echo "[docks-kit] curl missing too. Install Bun manually (https://bun.sh) or download a docks-kit release binary." >&2
|
|
40
44
|
exit 1
|
|
41
45
|
fi
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
BUN_PIN=""
|
|
45
|
-
if command -v jq >/dev/null 2>&1; then
|
|
46
|
-
BUN_PIN="$(jq -r '.tools.bun.verified // empty' "$REPO_DIR/SoT/toolchain.json" 2>/dev/null || true)"
|
|
47
|
-
fi
|
|
46
|
+
# The installer takes a bun-vX.Y.Z release tag as $1. BUN_PIN is generated
|
|
47
|
+
# from the authoring toolchain manifest alongside the embedded payload.
|
|
48
48
|
tmp_installer=$(mktemp 2>/dev/null || echo "/tmp/bun-install-$$.sh")
|
|
49
49
|
curl -fsSL https://bun.sh/install -o "$tmp_installer" && bash "$tmp_installer" ${BUN_PIN:+"bun-v$BUN_PIN"} >/dev/null 2>&1 || true
|
|
50
50
|
rm -f "$tmp_installer"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docks-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Portable AI coding agent config kit — SoT sync engine + typed CLI for Claude Code, Codex, and universal agent skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
"cli/src",
|
|
16
16
|
"cli/docs",
|
|
17
17
|
"cli/tsconfig.json",
|
|
18
|
-
"SoT",
|
|
19
|
-
"notification.mp3",
|
|
20
18
|
"docks-kit",
|
|
21
19
|
"AGENTS.md",
|
|
22
20
|
"README.md"
|
|
@@ -24,6 +22,7 @@
|
|
|
24
22
|
"scripts": {
|
|
25
23
|
"typecheck": "tsc --noEmit -p cli",
|
|
26
24
|
"build:binaries": "bash cli/build-binaries.sh",
|
|
25
|
+
"prepack": "bun cli/scripts/generate-sot-payload.ts --check",
|
|
27
26
|
"golden:dryrun": "bun cli/test/golden-dryrun.ts",
|
|
28
27
|
"golden:mutation": "bun cli/test/golden-mutation.ts",
|
|
29
28
|
"test:unit": "vitest run"
|
package/SoT/.agents/skills.txt
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Universal AI-agent skills (agentskills.io standard).
|
|
2
|
-
# Bootstrapped to ~/.agents/skills/ by cli/src/engine-native/skillsSync.ts during ./docks-kit sync.
|
|
3
|
-
# One slug per line: <owner>/<repo>. Lines starting with # are comments.
|
|
4
|
-
# Each skill's canonical SKILL.md lands in ~/.agents/skills/<name>/ — Codex
|
|
5
|
-
# reads that path natively; Claude Code gets a ~/.claude/skills/<name>
|
|
6
|
-
# symlink to it. The skills sync names both agents the kit supports
|
|
7
|
-
# (-a claude-code codex) so the CLI keeps the shared canonical copy.
|
|
8
|
-
|
|
9
|
-
# Browser automation CLI — reaches JS-rendered, auth-walled, login-gated pages
|
|
10
|
-
# (x.com, LinkedIn, Confluence) that built-in WebFetch can't. The skills sync
|
|
11
|
-
# auto-installs the `agent-browser` npm package + downloads Chrome for Testing
|
|
12
|
-
# (~175 MB) on first sync; Linux runs `agent-browser install --with-deps` which
|
|
13
|
-
# may prompt for sudo to install system libs (libnss3, libatk, ...).
|
|
14
|
-
vercel-labs/agent-browser
|
package/SoT/.claude/CLAUDE.md
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
@RTK.md
|
|
2
|
-
|
|
3
|
-
## Research Before Implementation
|
|
4
|
-
|
|
5
|
-
Before writing or modifying code that uses an API, hook, method, or config surface you have not verified in this session, research current documentation first.
|
|
6
|
-
|
|
7
|
-
**Research workflow:**
|
|
8
|
-
1. Use `resolve-library-id` → `query-docs` (context7) to fetch up-to-date docs for the specific library/framework
|
|
9
|
-
2. If context7 doesn't cover it, read the official docs with `agent-browser` (it reaches JS-rendered, auth-walled, and login-gated pages); fall back to `WebFetch` for a simple static page
|
|
10
|
-
3. Only then proceed to implementation
|
|
11
|
-
|
|
12
|
-
**When to research:**
|
|
13
|
-
- Installing or configuring a dependency
|
|
14
|
-
- Using an API, hook, method, or pattern you haven't verified in this session
|
|
15
|
-
- Upgrading or migrating between versions
|
|
16
|
-
- Any task where you'd otherwise rely on training data for syntax/behavior
|
|
17
|
-
|
|
18
|
-
**Do NOT:**
|
|
19
|
-
- Assume API signatures, method names, or config options from memory
|
|
20
|
-
- Generate framework code without checking current docs first
|
|
21
|
-
- Skip research because the library "seems familiar"
|
|
22
|
-
|
|
23
|
-
<constraint>
|
|
24
|
-
Research the codebase before editing. Never change code you haven't read.
|
|
25
|
-
</constraint>
|
|
26
|
-
|
|
27
|
-
## Agentic Harness Heuristics
|
|
28
|
-
|
|
29
|
-
**1. Persistence.** Keep going until the user's query is completely resolved. Only yield when sure the problem is solved. Before ending a turn, check the last paragraph: if it is a plan, a question you can answer yourself, or a promise of work not done ("I'll…"), do that work now.
|
|
30
|
-
|
|
31
|
-
**2. Default to parallel.** Whenever you have multiple independent operations (reads, greps, web fetches, independent edits), invoke them in a single response with multiple tool-use blocks. Sequential calls only when output of one operation is required as input to the next.
|
|
32
|
-
|
|
33
|
-
**3. Multi-pass search.** First-pass search often misses — vary the wording (colleague-questions over keywords) before concluding something doesn't exist.
|
|
34
|
-
|
|
35
|
-
**4. Trace symbols.** Before modifying a symbol, trace it to its definitions and all usages. Don't assume a function's behavior or a type's shape from the call site alone.
|
|
36
|
-
|
|
37
|
-
**5. Linter-loop 3-strike rule.** Don't loop more than 3 times fixing linter errors on the same file. On the third attempt, stop and ask the user — repeated failure usually means the diagnosis is wrong, not the code.
|
|
38
|
-
|
|
39
|
-
**6. Read-before-Edit TTL.** If you haven't read a file with the Read tool in the last ~5 messages, re-read it before editing. Cached file content goes stale silently when the user edits between turns.
|
|
40
|
-
|
|
41
|
-
**7. Big-file rule.** For files >1000 lines, prefer Grep + scoped Read (`offset` + `limit`) over reading the entire file. Whole-file reads bloat context; targeted reads keep the working set small.
|
|
42
|
-
|
|
43
|
-
**8. Todo hygiene.** Use TaskCreate for items with meaningful outcome (≥5 min, distinct deliverable). Never include operational sub-actions (linting, testing, searching, examining the codebase) as their own todos — those are sub-steps in service of higher-level tasks. Mark complete immediately when done, never in batches.
|
|
44
|
-
|
|
45
|
-
**9. Literal-instruction rule.** Current frontier models follow instructions literally — they do not silently generalize from intent. Phrase requirements as explicit checklists with success criteria, not narrative.
|
|
46
|
-
|
|
47
|
-
**10. Context hygiene.** Prefer `/clear` at task boundaries and `/rewind` for wrong-path detours over carrying rot forward (corrections accumulate noise; rewinds preserve the prefix and discard the bad branch). On a continuing task, run `/compact` with steering before context quality degrades. Never stop, summarize, or suggest a new session on account of context limits.
|
|
48
|
-
|
|
49
|
-
**11. Autonomy calibration.** For minor choices (naming, formatting, default values, which of two equivalent approaches), pick a reasonable option and note it — don't ask. Ask first only for scope changes, destructive actions, or decisions that change the deliverable. When the user is describing a problem or asking a question rather than requesting a change, the deliverable is your assessment — report findings and stop; don't apply fixes until asked. Don't close a finished task with "Want me to also…?" — run the obvious verification, then stop cleanly.
|
|
50
|
-
|
|
51
|
-
**12. Capability triggering.** When the answer depends on current or version-specific information, search or fetch before answering — never answer from memory. When work fans out across independent items (many files to read, many tests to run, many candidates to check), delegate to parallel subagents; never spawn one for work you can complete directly. For verification, prefer a fresh-context subagent over self-critique. On tasks longer than a few turns, keep a running notes file and re-read it before each phase.
|
|
52
|
-
|
|
53
|
-
<constraint>
|
|
54
|
-
Treat the 12 heuristics above as protocol, not preference. If a turn ends without honoring an applicable one (e.g., lint-loop guard not respected, edit without re-read), self-correct in the next turn before continuing.
|
|
55
|
-
</constraint>
|
|
56
|
-
|
|
57
|
-
## Project Skills
|
|
58
|
-
|
|
59
|
-
Projects may have a `.claude/skills/` directory with Tool Wrapper skills managed by `/docs`. Claude Code auto-discovers these at session start — only descriptions are loaded, full content loads on demand via the Skill tool.
|
|
60
|
-
|
|
61
|
-
Skills follow the [agentskills.io](https://agentskills.io) open standard:
|
|
62
|
-
- **SKILL.md**: frontmatter (`name`, `description`, `user-invocable: false`, `metadata`) + body (≤500 lines)
|
|
63
|
-
- **references/**: on-demand detail files (30-150 lines each), loaded when the skill instructs Claude to read them
|
|
64
|
-
- **Discovery**: Claude Code scans `.claude/skills/*/SKILL.md` at session start, loads only `name` + `description` (~100 tokens per skill)
|
|
65
|
-
- **Triggering**: Claude semantically matches descriptions against user tasks, invokes via `Skill` tool — no `@import` or pointer tables needed
|
|
66
|
-
- **CSO (Claude Search Optimization)**: descriptions MUST start with "Use when..." and describe trigger conditions, not capabilities
|
|
67
|
-
- **Third-party / vendored skills**: add an `upstream:` frontmatter block (`source`, `license`, `vendored_at: "YYYY-MM-DD"`) when vendoring a skill from an external repo. The block marks the skill as vendored so kit-specific checks (CSO start-prefix, `user-invocable`, `metadata.updated`) are relaxed and the skill's body is preserved verbatim from upstream. Universal structural checks (fenced frontmatter, name matches directory, description length, 500-line body cap) still apply.
|
|
68
|
-
|
|
69
|
-
<constraint>
|
|
70
|
-
After any code change affecting documented patterns, update the relevant skill in `.claude/skills/` and its `metadata.updated` frontmatter field. When introducing something new, create a skill or add a `references/` file to an existing skill.
|
|
71
|
-
</constraint>
|
|
72
|
-
|
|
73
|
-
## Project Agents
|
|
74
|
-
|
|
75
|
-
Projects and the global kit may have a `.claude/agents/` directory containing subagent definitions. Each agent file declares its `model` (`sonnet`/`opus`/`haiku`/`inherit`/full model ID), `tools`, and system prompt. Claude Code auto-discovers them at session start and delegates when a `subagent_type` matches or when a slash command explicitly invokes them.
|
|
76
|
-
|
|
77
|
-
Agent files follow this structure:
|
|
78
|
-
- **Frontmatter**: `name` (kebab-case, matches filename), `description` (CSO — starts "Use when…" with a "Not for…" exclusion clause), `tools`, `model`
|
|
79
|
-
- **Body** (≤500 lines): `<constraint>` blocks for non-negotiable rules, `## Workflow` with context-acknowledgment as step 1, `## Output Format`, `## Anti-Hallucination Checks`, `## Success Criteria`
|
|
80
|
-
- **Model-selection resolution** (per Claude Code docs): `CLAUDE_CODE_SUBAGENT_MODEL` env var → per-invocation `model` param → agent frontmatter `model:` → parent conversation. The env var is NOT set in this kit, so per-agent frontmatter controls selection.
|
|
81
|
-
|
|
82
|
-
<constraint>
|
|
83
|
-
When adding a new agent: use kebab-case name matching filename, CSO-compliant description (starts "Use when…", contains a "Not" exclusion clause), explicit `model` and `tools`.
|
|
84
|
-
</constraint>
|
|
85
|
-
|
|
86
|
-
## Picking the right models for workflows and subagents
|
|
87
|
-
|
|
88
|
-
Rankings, higher = better. Intelligence is how hard a problem the model can be handed unsupervised. Taste covers UI/UX, code quality, API design, and copy. Cost is relative spend — a tie-breaker only.
|
|
89
|
-
|
|
90
|
-
| model | cost | intelligence | taste |
|
|
91
|
-
|----------|------|--------------|-------|
|
|
92
|
-
| gpt-5.5 | 9 | 8 | 5 |
|
|
93
|
-
| opus-4.8 | 4 | 7 | 8 |
|
|
94
|
-
| sonnet-5 | 5 | 5 | 7 |
|
|
95
|
-
|
|
96
|
-
Fable 5 outranks all three on intelligence and taste, but its limits are spent for now — treat opus-4.8 as the ceiling until Fable access returns, then Fable takes the top intelligence+taste slot.
|
|
97
|
-
|
|
98
|
-
How to apply:
|
|
99
|
-
- These are defaults, not limits. Standing permission to override: if a cheaper model's output misses the bar, rerun with a smarter one without asking. Judge the output, not the price tag — escalating costs less than shipping mediocre work.
|
|
100
|
-
- Cost is a tie-breaker only; when axes conflict for anything that ships, intelligence > taste > cost.
|
|
101
|
-
- Bulk/mechanical work (clear-spec implementation, data analysis, migrations): gpt-5.5.
|
|
102
|
-
- Anything user-facing (UI, copy, API design) needs taste ≥ 7 → opus-4.8 (sonnet-5 when Opus is saturated).
|
|
103
|
-
- Reviews of plans/implementations: opus-4.8, optionally gpt-5.5 as a second independent perspective.
|
|
104
|
-
- Never use Haiku.
|
|
105
|
-
- gpt-5.5 is reachable only through the Codex CLI (`~/.codex/config.toml` defaults to gpt-5.5): `codex exec` for headless implementation/analysis, `codex review` for diff review, `codex exec -s read-only` with a self-contained prompt for ad-hoc investigation, UI verification, or data analysis. Codex is more efficient than Claude on well-specced execution and stronger at computer-use and UI/UX verification — offload those and report results back.
|
|
106
|
-
- Claude models run via the Agent/Workflow `model` parameter (`opus`, `sonnet`).
|
|
107
|
-
|
|
108
|
-
Using gpt-5.5 inside workflows and subagents (the `model` parameter takes only Claude models, so wrap it):
|
|
109
|
-
- Spawn a thin Claude wrapper agent with `model: 'sonnet', effort: 'low'` whose prompt tells it to write a self-contained Codex prompt, run `codex exec` via Bash, and return Codex's output verbatim. The wrapper only shuttles the prompt and result — gpt-5.5 does the work.
|
|
110
|
-
|
|
111
|
-
Reaching gpt-5.5 (or a full-context worker in another project) as a persistent session — the `session-relay` skill (shared bus + `relay` CLI, Claude ⇄ Codex):
|
|
112
|
-
- `codex exec` is one-shot and stateless. When the offload must be resumable, span several turns, or run in another project with that project's own config, spawn a real session instead: `relay spawn <dir> --tool codex --model gpt-5.5 --effort xhigh` (or `--tool claude --model opus` for a Claude worker), then continue it with `send` / `wake`.
|
|
113
|
-
- Two independent perspectives on a plan = the red-team pair spawn: a gpt-5.5 worker and an opus worker debate over the bus, orchestrator writes the verdict — the concrete form of the "second independent perspective" review above.
|
|
114
|
-
- Pin `--model`/`--effort` on every spawn/wake; never leave an unattended relay child on a top interactive default (e.g. Fable). Each spawn/wake bills the target's subscription — spawn deliberately, never in loops.
|
|
115
|
-
|
|
116
|
-
## Agentic Engineering Discipline
|
|
117
|
-
|
|
118
|
-
1. **State assumptions; push back when warranted.** If a requirement is ambiguous in a way that changes the deliverable, surface the ambiguity and propose 1–2 concrete interpretations in your first message — do not silently pick one and run with it. Surface inconsistencies and confusion instead of guessing past them; present tradeoffs when approaches genuinely differ; push back when the request looks wrong. Agreeable-but-wrong is the failure mode, not disagreement.
|
|
119
|
-
2. **Minimum code that solves the stated problem.** Each named pattern below is a defect — catch it during generation, not after:
|
|
120
|
-
|
|
121
|
-
**Code slop**
|
|
122
|
-
- **Defensive guards** around internally-trusted calls (`try`, `if x != null`). Validate at system boundaries only.
|
|
123
|
-
- **Speculative abstraction.** No helper for one caller; no interface for one implementer. Three similar lines beats premature DRY.
|
|
124
|
-
- **Backwards-compat shims** without a caller — re-exports, deprecation aliases, untoggled feature flags. Just change the code.
|
|
125
|
-
- **Half-finished stubs.** `TODO handle later`, `throw new Error('not implemented')`. Implement or remove the path.
|
|
126
|
-
- **Underscore-rename of unused vars.** Delete the var.
|
|
127
|
-
- **Dead code left behind.** After a refactor, delete the paths, helpers, and imports the change made unreachable.
|
|
128
|
-
|
|
129
|
-
**Comment slop**
|
|
130
|
-
- **Restate-the-code.** `// increment i`. The identifier already says it.
|
|
131
|
-
- **Provenance.** `// added for ticket X`, `// used by Y`. Belongs in the PR description; rots in code.
|
|
132
|
-
- **Tombstones.** `// removed Z`, `// previously did W`. Git remembers.
|
|
133
|
-
- **Docstring bloat** on self-evident functions. One line, only when the WHY isn't obvious from the name.
|
|
134
|
-
|
|
135
|
-
**Output slop**
|
|
136
|
-
- **End-of-turn diff-restatement.** One or two sentences: what changed, what's next. Don't recap what's in the diff.
|
|
137
|
-
- **Narration tics.** "Now I'll…", "Let me check…", play-by-play between tool calls. Terse working shorthand between tool calls is fine; play-by-play is not — write a sentence when something load-bearing happens (a finding, a direction change, a blocker).
|
|
138
|
-
- **Compressed final summaries.** The final message is for a reader who didn't watch the work: outcome first, complete sentences. Shorten by dropping detail, never by compressing into fragments or arrow chains.
|
|
139
|
-
3. **Surgical changes only.** Do not modify code, comments, or formatting outside the explicit scope of the request. Surface unrelated issues as follow-ups — do not fix inline.
|
|
140
|
-
4. **State how success will be verified before implementing.** Name the test, build, smoke check, or diff inspection that will prove the change works. Prefer executable criteria — a test that fails before and passes after, a command with expected output — over judgment calls, and keep each change small enough that its diff is reviewable in one sitting.
|
|
141
|
-
5. **Review scope follows the pipeline.** In pipeline reviews with a downstream filter (multi-agent scans, verification phases), report every issue found with confidence and severity — filtering happens downstream. In ad-hoc reviews, flag only gaps that affect correctness or the stated requirements; treat the rest as optional.
|
|
142
|
-
6. **Ground every progress claim in evidence.** Before reporting progress or completion, audit each claim against a tool result from this session — show the test output, the command and what it returned. If something is unverified, say so explicitly; if tests fail, say so with the output.
|
|
143
|
-
|
|
144
|
-
<constraint>
|
|
145
|
-
Treat the six rules above as preventive (during generation), not remedial (after the fact). Self-correct if a turn drifts.
|
|
146
|
-
</constraint>
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Async Stop hook: refreshes the /oauth/usage stats the statusline reads.
|
|
3
|
-
|
|
4
|
-
exec 2>/dev/null
|
|
5
|
-
|
|
6
|
-
CACHE_FILE="/tmp/.claude_usage_cache"
|
|
7
|
-
TOKEN_CACHE="/tmp/.claude_token_cache"
|
|
8
|
-
CREDS_FILE="$HOME/.claude/.credentials.json"
|
|
9
|
-
TOKEN_MAX_AGE=900 # 15 minutes
|
|
10
|
-
|
|
11
|
-
file_mtime() {
|
|
12
|
-
if [ "$(uname)" = "Darwin" ]; then
|
|
13
|
-
stat -f %m "$1" 2>/dev/null || echo 0
|
|
14
|
-
else
|
|
15
|
-
stat -c %Y "$1" 2>/dev/null || echo 0
|
|
16
|
-
fi
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
# Newer credentials than the usage cache => possible account switch; drop it to avoid showing the previous account.
|
|
20
|
-
if [ -f "$CACHE_FILE" ] && [ -f "$CREDS_FILE" ] \
|
|
21
|
-
&& [ "$(file_mtime "$CREDS_FILE")" -ge "$(file_mtime "$CACHE_FILE")" ]; then
|
|
22
|
-
rm -f "$CACHE_FILE"
|
|
23
|
-
fi
|
|
24
|
-
|
|
25
|
-
token=""
|
|
26
|
-
if [ -f "$TOKEN_CACHE" ]; then
|
|
27
|
-
cache_mtime=$(file_mtime "$TOKEN_CACHE")
|
|
28
|
-
age=$(( $(date +%s) - cache_mtime ))
|
|
29
|
-
creds_mtime=0
|
|
30
|
-
[ -f "$CREDS_FILE" ] && creds_mtime=$(file_mtime "$CREDS_FILE")
|
|
31
|
-
if [ "$age" -lt "$TOKEN_MAX_AGE" ] && [ "$creds_mtime" -lt "$cache_mtime" ]; then
|
|
32
|
-
token=$(cat "$TOKEN_CACHE")
|
|
33
|
-
fi
|
|
34
|
-
fi
|
|
35
|
-
|
|
36
|
-
if [ -z "$token" ]; then
|
|
37
|
-
if [ -f "$CREDS_FILE" ]; then
|
|
38
|
-
token=$(jq -r '.claudeAiOauth.accessToken // empty' "$CREDS_FILE")
|
|
39
|
-
fi
|
|
40
|
-
# macOS Keychain fallback
|
|
41
|
-
if [ -z "$token" ] && command -v security >/dev/null 2>&1; then
|
|
42
|
-
creds=$(security find-generic-password -s "Claude Code-credentials" -w 2>/dev/null)
|
|
43
|
-
[ -n "$creds" ] && token=$(echo "$creds" | jq -r '.claudeAiOauth.accessToken // empty')
|
|
44
|
-
fi
|
|
45
|
-
[ -z "$token" ] && exit 0
|
|
46
|
-
echo "$token" > "$TOKEN_CACHE"
|
|
47
|
-
fi
|
|
48
|
-
|
|
49
|
-
response=$(curl -s --max-time 3 \
|
|
50
|
-
-H "Authorization: Bearer $token" \
|
|
51
|
-
-H "anthropic-beta: oauth-2025-04-20" \
|
|
52
|
-
"https://api.anthropic.com/oauth/usage")
|
|
53
|
-
|
|
54
|
-
[ -z "$response" ] && exit 0
|
|
55
|
-
|
|
56
|
-
five_h=$(echo "$response" | jq -r '.five_hour.utilization // empty' | awk '{printf "%.0f", $1}')
|
|
57
|
-
seven_d=$(echo "$response" | jq -r '.seven_day.utilization // empty' | awk '{printf "%.0f", $1}')
|
|
58
|
-
five_h_reset=$(echo "$response" | jq -r '.five_hour.resets_at // empty')
|
|
59
|
-
seven_d_reset=$(echo "$response" | jq -r '.seven_day.resets_at // empty')
|
|
60
|
-
|
|
61
|
-
# Numeric-range guard: a schema change would otherwise poison the cache silently.
|
|
62
|
-
if [ -n "$five_h" ] && [ -n "$seven_d" ] \
|
|
63
|
-
&& echo "$five_h" | grep -qE '^[0-9]+$' && [ "$five_h" -ge 0 ] && [ "$five_h" -le 100 ] 2>/dev/null \
|
|
64
|
-
&& echo "$seven_d" | grep -qE '^[0-9]+$' && [ "$seven_d" -ge 0 ] && [ "$seven_d" -le 100 ] 2>/dev/null; then
|
|
65
|
-
printf '%s\n%s\n%s\n%s\n' "$five_h" "$seven_d" "$five_h_reset" "$seven_d_reset" > "$CACHE_FILE"
|
|
66
|
-
fi
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
|
|
4
|
-
SOUND="$HOME/.claude/notification.mp3"
|
|
5
|
-
[ -f "$SOUND" ] || exit 0
|
|
6
|
-
|
|
7
|
-
if [ "$(uname)" = "Darwin" ]; then
|
|
8
|
-
command -v afplay >/dev/null 2>&1 && exec afplay "$SOUND"
|
|
9
|
-
fi
|
|
10
|
-
|
|
11
|
-
command -v ffplay >/dev/null 2>&1 && exec ffplay -nodisp -autoexit -loglevel quiet "$SOUND"
|
|
12
|
-
command -v paplay >/dev/null 2>&1 && exec paplay "$SOUND"
|
|
13
|
-
command -v aplay >/dev/null 2>&1 && exec aplay -q "$SOUND"
|
|
14
|
-
exit 0
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/claude-code-settings.json",
|
|
3
|
-
"minimumVersion": "2.1.170",
|
|
4
|
-
"model": "opus",
|
|
5
|
-
"advisorModel": "fable",
|
|
6
|
-
"effortLevel": "xhigh",
|
|
7
|
-
"autoMemoryEnabled": true,
|
|
8
|
-
"skillListingMaxDescChars": 2048,
|
|
9
|
-
"respectGitignore": true,
|
|
10
|
-
"cleanupPeriodDays": 14,
|
|
11
|
-
"skillListingBudgetFraction": 0.05,
|
|
12
|
-
"env": {
|
|
13
|
-
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "64000",
|
|
14
|
-
"CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR": "1",
|
|
15
|
-
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "468000",
|
|
16
|
-
"CLAUDE_CODE_NO_FLICKER": "1"
|
|
17
|
-
},
|
|
18
|
-
"permissions": {
|
|
19
|
-
"defaultMode": "auto",
|
|
20
|
-
"allow": [
|
|
21
|
-
"Read",
|
|
22
|
-
"Glob",
|
|
23
|
-
"Grep",
|
|
24
|
-
"WebFetch",
|
|
25
|
-
"WebSearch",
|
|
26
|
-
"Edit(./)",
|
|
27
|
-
"Write(./)",
|
|
28
|
-
"Bash(git *)",
|
|
29
|
-
"Bash(git add *)",
|
|
30
|
-
"Bash(git commit *)",
|
|
31
|
-
"Bash(git status *)",
|
|
32
|
-
"Bash(git diff *)",
|
|
33
|
-
"Bash(git log *)",
|
|
34
|
-
"Bash(git branch *)",
|
|
35
|
-
"Bash(git checkout *)",
|
|
36
|
-
"Bash(git switch *)",
|
|
37
|
-
"Bash(git stash *)",
|
|
38
|
-
"Bash(git fetch *)",
|
|
39
|
-
"Bash(git pull *)",
|
|
40
|
-
"Bash(git tag *)",
|
|
41
|
-
"Bash(git show *)",
|
|
42
|
-
"Bash(git blame *)",
|
|
43
|
-
"Bash(git worktree *)",
|
|
44
|
-
"Bash(gh *)",
|
|
45
|
-
"Bash(pnpm *)",
|
|
46
|
-
"Bash(npm *)",
|
|
47
|
-
"Bash(npx *)",
|
|
48
|
-
"Bash(node *)",
|
|
49
|
-
"Bash(docker *)",
|
|
50
|
-
"Bash(docker-compose *)",
|
|
51
|
-
"Bash(rtk *)",
|
|
52
|
-
"Bash(ls *)",
|
|
53
|
-
"Bash(cat *)",
|
|
54
|
-
"Bash(find *)",
|
|
55
|
-
"Bash(grep *)",
|
|
56
|
-
"Bash(head *)",
|
|
57
|
-
"Bash(tail *)",
|
|
58
|
-
"Bash(wc *)",
|
|
59
|
-
"Bash(sort *)",
|
|
60
|
-
"Bash(uniq *)",
|
|
61
|
-
"Bash(diff *)",
|
|
62
|
-
"Bash(which *)",
|
|
63
|
-
"Bash(pwd *)",
|
|
64
|
-
"Bash(date *)",
|
|
65
|
-
"Bash(mkdir *)",
|
|
66
|
-
"Bash(basename *)",
|
|
67
|
-
"Bash(dirname *)",
|
|
68
|
-
"Bash(realpath *)",
|
|
69
|
-
"Bash(jq *)",
|
|
70
|
-
"Bash(curl *)",
|
|
71
|
-
"Bash(tree *)",
|
|
72
|
-
"Bash(sed *)",
|
|
73
|
-
"Bash(awk *)",
|
|
74
|
-
"Bash(cut *)",
|
|
75
|
-
"Bash(tr *)",
|
|
76
|
-
"Bash(tee *)",
|
|
77
|
-
"Bash(echo *)",
|
|
78
|
-
"Bash(printf *)",
|
|
79
|
-
"Bash(env *)",
|
|
80
|
-
"Bash(printenv *)",
|
|
81
|
-
"Bash(uname *)",
|
|
82
|
-
"Bash(file *)",
|
|
83
|
-
"Bash(stat *)",
|
|
84
|
-
"Bash(du *)",
|
|
85
|
-
"Bash(id *)",
|
|
86
|
-
"Bash(whoami *)",
|
|
87
|
-
"Bash(php *)",
|
|
88
|
-
"Bash(composer *)",
|
|
89
|
-
"Bash(python3 *)",
|
|
90
|
-
"Bash(python *)",
|
|
91
|
-
"Bash(pip *)",
|
|
92
|
-
"Bash(pip3 *)"
|
|
93
|
-
],
|
|
94
|
-
"deny": [
|
|
95
|
-
"Read(**/.env)",
|
|
96
|
-
"Read(**/.env.local)",
|
|
97
|
-
"Read(**/secrets/**)",
|
|
98
|
-
"Read(**/*.key)",
|
|
99
|
-
"Read(**/*.pem)",
|
|
100
|
-
"Read(**/*.p12)",
|
|
101
|
-
"Read(**/.credentials*)",
|
|
102
|
-
"Edit(**/.env)",
|
|
103
|
-
"Edit(**/.env.local)",
|
|
104
|
-
"Edit(**/secrets/**)",
|
|
105
|
-
"Write(**/.env)",
|
|
106
|
-
"Write(**/.env.local)",
|
|
107
|
-
"Write(**/secrets/**)",
|
|
108
|
-
"Bash(sudo *)",
|
|
109
|
-
"Bash(rm -rf /)",
|
|
110
|
-
"Bash(rm -rf / *)",
|
|
111
|
-
"Bash(rm -rf ~)",
|
|
112
|
-
"Bash(rm -rf ~ *)",
|
|
113
|
-
"Bash(rm -rf $HOME)",
|
|
114
|
-
"Bash(rm -rf $HOME *)",
|
|
115
|
-
"Bash(> /dev *)",
|
|
116
|
-
"Bash(dd if= *)",
|
|
117
|
-
"Bash(mkfs *)",
|
|
118
|
-
"Bash(eval *)",
|
|
119
|
-
"Bash(chmod 777 *)",
|
|
120
|
-
"Bash(chmod -R 777 *)",
|
|
121
|
-
"Bash(git push --force origin main *)",
|
|
122
|
-
"Bash(git push --force origin master *)",
|
|
123
|
-
"Bash(git push -f origin main *)",
|
|
124
|
-
"Bash(git push -f origin master *)"
|
|
125
|
-
],
|
|
126
|
-
"ask": [
|
|
127
|
-
"Bash(git clean *)",
|
|
128
|
-
"Bash(docker volume rm *)",
|
|
129
|
-
"Bash(docker system prune *)"
|
|
130
|
-
]
|
|
131
|
-
},
|
|
132
|
-
"hooks": {
|
|
133
|
-
"SessionStart": [
|
|
134
|
-
{
|
|
135
|
-
"hooks": [
|
|
136
|
-
{
|
|
137
|
-
"type": "command",
|
|
138
|
-
"command": "echo \"[CONTEXT] Current date: $(date '+%A, %Y-%m-%d %H:%M:%S %Z')\"",
|
|
139
|
-
"timeout": 5
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
"type": "command",
|
|
143
|
-
"command": "echo \"[CONFIG] Context: $([ \\\"${CLAUDE_CODE_DISABLE_1M_CONTEXT:-0}\\\" = \\\"1\\\" ] && echo '200K' || echo '1M') | Compact-window: ${CLAUDE_CODE_AUTO_COMPACT_WINDOW:-full} | Effort: ${CLAUDE_CODE_EFFORT_LEVEL:-$(jq -r .effortLevel $HOME/.claude/settings.json 2>/dev/null || echo default)} | Thinking: adaptive | Subagent: ${CLAUDE_CODE_SUBAGENT_MODEL:-default}\"",
|
|
144
|
-
"timeout": 5
|
|
145
|
-
}
|
|
146
|
-
]
|
|
147
|
-
}
|
|
148
|
-
],
|
|
149
|
-
"Notification": [
|
|
150
|
-
{
|
|
151
|
-
"hooks": [
|
|
152
|
-
{
|
|
153
|
-
"type": "command",
|
|
154
|
-
"command": "[ -x \"$HOME/.claude/hooks/notify.sh\" ] && \"$HOME/.claude/hooks/notify.sh\" || true",
|
|
155
|
-
"timeout": 10,
|
|
156
|
-
"async": true
|
|
157
|
-
}
|
|
158
|
-
]
|
|
159
|
-
}
|
|
160
|
-
],
|
|
161
|
-
"PreToolUse": [
|
|
162
|
-
{
|
|
163
|
-
"matcher": "Bash",
|
|
164
|
-
"hooks": [
|
|
165
|
-
{
|
|
166
|
-
"type": "command",
|
|
167
|
-
"command": "rtk hook claude"
|
|
168
|
-
}
|
|
169
|
-
]
|
|
170
|
-
}
|
|
171
|
-
],
|
|
172
|
-
"PostToolUseFailure": [
|
|
173
|
-
{
|
|
174
|
-
"matcher": "Bash",
|
|
175
|
-
"hooks": [
|
|
176
|
-
{
|
|
177
|
-
"type": "command",
|
|
178
|
-
"command": "echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PostToolUseFailure\",\"additionalContext\":\"Last bash command failed. Repository / file state may have shifted \u2014 re-read affected files before retrying. If the failure is a missing dependency or env mismatch, surface it to the user rather than retrying blindly.\"}}'",
|
|
179
|
-
"timeout": 5
|
|
180
|
-
}
|
|
181
|
-
]
|
|
182
|
-
}
|
|
183
|
-
],
|
|
184
|
-
"Stop": [
|
|
185
|
-
{
|
|
186
|
-
"hooks": [
|
|
187
|
-
{
|
|
188
|
-
"type": "command",
|
|
189
|
-
"command": "bash $HOME/.claude/fetch-usage.sh",
|
|
190
|
-
"timeout": 5,
|
|
191
|
-
"async": true
|
|
192
|
-
}
|
|
193
|
-
]
|
|
194
|
-
}
|
|
195
|
-
],
|
|
196
|
-
"SubagentStop": [
|
|
197
|
-
{
|
|
198
|
-
"hooks": [
|
|
199
|
-
{
|
|
200
|
-
"type": "prompt",
|
|
201
|
-
"prompt": "You are a quality gate for subagent outputs in a multi-agent code-analysis pipeline.\n\nEvaluate the subagent's `last_assistant_message` field (in the JSON below) against these requirements:\n\n1. ALLOW (return `{}`): Mode-selection or no-issues responses. Examples: \"Which mode do you prefer\", \"select an option\", \"no issues / problems / violations / blockers found\".\n\n2. ALLOW (return `{}`): Output contains at least one concrete file:line citation \u2014 e.g. `src/auth.ts:42`, `lib/db.ts:100-115`, or path references that include line numbers.\n\n3. BLOCK (return `{\"decision\":\"block\",\"reason\":\"<one-line explanation>\"}`): Output claims about code or findings WITHOUT concrete file:line citations. Vague references like \"the auth handler\" or \"near the database code\" are not acceptable as the only evidence.\n\nSubagent invocation JSON:\n$ARGUMENTS\n\nReturn ONLY the JSON decision (no commentary, no markdown fences).",
|
|
202
|
-
"timeout": 30
|
|
203
|
-
}
|
|
204
|
-
]
|
|
205
|
-
}
|
|
206
|
-
]
|
|
207
|
-
},
|
|
208
|
-
"statusLine": {
|
|
209
|
-
"type": "command",
|
|
210
|
-
"command": "~/.claude/statusline.sh",
|
|
211
|
-
"refreshInterval": 5
|
|
212
|
-
},
|
|
213
|
-
"enabledPlugins": {
|
|
214
|
-
"context7@claude-plugins-official": true,
|
|
215
|
-
"frontend-design@claude-plugins-official": true,
|
|
216
|
-
"php-lsp@claude-plugins-official": true,
|
|
217
|
-
"typescript-lsp@claude-plugins-official": true,
|
|
218
|
-
"docks@docks": true,
|
|
219
|
-
"session-relay@docks": true,
|
|
220
|
-
"effect-kit@docks": true
|
|
221
|
-
},
|
|
222
|
-
"extraKnownMarketplaces": {
|
|
223
|
-
"docks": {
|
|
224
|
-
"source": {
|
|
225
|
-
"source": "github",
|
|
226
|
-
"repo": "DocksDocks/docks"
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
"alwaysThinkingEnabled": true,
|
|
231
|
-
"showThinkingSummaries": true,
|
|
232
|
-
"viewMode": "default",
|
|
233
|
-
"theme": "dark-daltonized",
|
|
234
|
-
"skipDangerousModePermissionPrompt": true
|
|
235
|
-
}
|