Commit Graph
22 Commits
Author SHA1 Message Date
L4XB a3ced7db06 fix(hooks): keep no structured tool result in activity history
The tracker serialized any structured result with JSON.stringify before
redaction, so an encoding nested in it, such as a double-escaped JSON
token, reached tool-usage.jsonl whole, and Claude Code's Bash stdout went
in as text. Keep text only from the adapter's tool_output, as main did,
and from Claude Code's tool_response only the sizes of stdout and stderr
and its interrupted and image flags. Any other structure is left out.
2026-11-05 11:35:43 +01:00
L4XB 6b9ff09542 Merge remote-tracking branch 'origin/main' into fix/hooks-read-tool-response
# Conflicts:
#	scripts/hooks/hook-input.js
#	tests/hooks/hook-input.test.js
2026-11-05 11:33:26 +01:00
haelyra 3dca6e2e88 fix(hooks): preserve provider conversation identity under inherited environments
Restore the shipped payload-first contract from #3464/#3495 and the explicit source #3755 scope clarification. Two provider conversations must retain distinct IDs despite an inherited registered ECC parent ID. Normal and ambient producer24 tests, canonical resolver10 and independent differential review pass. Keep native importer guards; explicit provider/native correlation is queued separately.
2026-10-29 18:57:29 -07:00
haelyra 6cd41995f4 fix(hooks): attribute native activity to the registered ECC session
Verify review discussion4419348312 against actual native producer/importer behavior. Prefer the independently sanitized ECC_SESSION_ID for the ECC-owned metrics feed, retain payload then legacy fallback for standalone hooks, and leave sibling hooks unchanged.

Actual Node producer plus read-only cached native binary reproduces zero imported metrics before the fix and exactly one tool/file/log after repeated sessions/status commands. Four producer regression controls and normal/adversarial inherited-env suites pass22/22. Focused coverage96.47percent lines and91.47percent branches; parent independent source review passed.
2026-10-29 17:43:55 -07:00
L4XB 08f605eed0 fix(hooks): check whole credential names and redact shell values to the next space
The bounded name parts (64 characters around the credential word) let a longer name such as API_KEY_ plus 65 characters go unredacted, and the field-bound bare value left `,beta` of CLIENT_SECRET=alpha,beta in the summary.

Find each name and separator first, starting a name only where a run of name characters starts, so every run is scanned once whatever its length, and test the whole name for the credential word. A bare value after a quoted JSON key still ends at the next field; any other runs to the next space.
2026-10-23 00:01:03 +02:00
L4XB abff545aa8 fix(hooks): redact Docker's auth values in activity summaries
A raw Docker configuration, as `cat ~/.docker/config.json` prints it, keeps its credential under `"auth":`, which only the auth_config name matched. Count `auth` as a credential word when it ends the word, so `"auth":`, `AUTH=` and `oauth=` are redacted while `author` and `auth_method` are not.
2026-10-22 23:13:01 +02:00
L4XB bc5a38a1a0 fix(hooks): keep credential redaction linear, field-bound and escape-aware
Three review findings on the generic credential rule:

- The unbounded name parts around the credential word made the expression rescan the rest of the text after each dot or hyphen. 128,000 characters of `a.` took about 8 seconds, and 256,000 ran past the hook timeout. The name parts are now bounded to 64 characters each, which brings the same input down to about 30 ms.
- A bare value ran to the next whitespace, so `{"token":null,"status":"failed","exit_code":1}` lost its status and exit code. A bare value now ends at the next comma, brace, bracket, semicolon or quote. A JSON object or array value is still redacted to the end.
- A quoted value stopped at an escaped quote, so `{"api_key":"part1\\" part2"}` kept `part2`. Quoted values now skip escaped characters.
2026-10-22 23:06:47 +02:00
L4XB f5a3ab3745 fix(hooks): redact a credential's JSON value that holds spaces
An unquoted value ran to the next whitespace, so `DOCKER_AUTH_CONFIG={"auths": {"registry": {"auth": "..."}}}` kept everything after its first space, the auth value included. A value that opens with { or [ is now redacted to the end of the summary.
2026-10-22 22:46:36 +02:00
L4XB 3494e114bb fix(hooks): redact credential variable names that carry the word inside
The generic redaction matched a credential word only right before the separator, so `AWS_SECRET_ACCESS_KEY=...` or `DOCKER_AUTH_CONFIG=...` kept its value in the activity summary. Match a name that contains secret, token, password, api_key, access_key, private_key, credential or auth_config anywhere, and take an unquoted value up to the next whitespace. `max_tokens`, `tokenizer` and `author` stay as they are.
2026-10-22 22:34:03 +02:00
L4XB 7adb98b7e9 fix(hooks): redact the secrets governance-capture detects in activity summaries
With Claude Code's tool_response read, command output such as `cat .env` now reaches the activity log's output_summary. Its redaction covered a few token forms, not the ones governance-capture detects: generic key, secret and token assignments (`api_key = "..."`, `OPENAI_API_KEY=...`, `"token": "..."`), JWTs, private keys, and ghu_/ghr_ tokens. Redact those too.
2026-10-22 22:06:08 +02:00
L4XB 2aee3e4588 fix(hooks): read the tool result Claude Code sends as tool_response
Claude Code passes a PostToolUse hook the result of its tool as tool_response. For Bash, that is an object with stdout, stderr, interrupted and isImage. Three hooks read only tool_output, the shape that the Cursor adapter builds, so under Claude Code they never saw any output:

- post-bash-pr-created never printed the PR URL and the review command after `gh pr create`;
- governance-capture never ran its secret detection on command output, such as that of `cat .env`;
- session-activity-tracker logged an empty output_summary for every tool.

Add getToolResult and getToolResultText to hook-input.js. They read tool_response first, then tool_output. Use them in the three hooks. governance-capture now also reads the adapter's { output }, where it used to accept only a string.
2026-10-22 21:35:25 +02:00
Clovis 3f8b31dcb8 fix: also fix hook_event_name env-var bug found by pre-merge review; sanitize session_id
Same class of bug as the session_id fix, one field over, found by code-reviewer
before merge: CLAUDE_HOOK_EVENT_NAME is never set for hook subprocesses either
(currently a harmless no-op since the dispatcher only ever calls this hook under
PostToolUse, but a real latent bug if that wiring ever changes). Also runs the
stdin-derived session_id through sanitizeSessionId(), matching the established
pattern already used in cost-tracker.js, ecc-context-monitor.js,
ecc-metrics-bridge.js, and gateguard-fact-force.js.
2026-09-05 17:08:47 -07:00
Clovis cfca5c8153 fix: session-activity-tracker never records (CLAUDE_SESSION_ID unset)
session-activity-tracker.js is correctly registered in
posttooluse-dispatcher.js's SYNC_HOOKS and fires on every tool call --
but buildActivityRow() only ever read the session id from
ECC_SESSION_ID/CLAUDE_SESSION_ID environment variables, which Claude
Code does not actually set for hook subprocesses. Every row silently
came back null and nothing was ever written to
~/.claude/metrics/tool-usage.jsonl, with no error anywhere.

The session id is available in the hook's own stdin JSON payload
(input.session_id) in real invocations. This prefers that, keeping the
env vars as a fallback. New test added; all 18 existing + new tests
pass.

Also adds a live Activity view to the capabilities dashboard
(scripts/dashboard-web.js) reading that same metrics file, so Skill
vs. Agent vs. raw-tool usage is visible in real time instead of
requiring a manual tail+jq -- verified live against a real session
before this commit. Documents the loopback-only, no-auth design and
the standard SSH-port-forwarding pattern for viewing it from another
device you control.
2026-09-05 16:58:17 -07:00
Affaan Mustafa 2b09308224 Merge pull request #1384 from KeWang0622/fix/lint-md028-eqeqeq
fix: resolve markdownlint MD028 + ESLint eqeqeq lint failures
2026-04-12 23:03:19 -07:00
Affaan Mustafa fc5921a521 fix: detach ecc2 background session runners (#1387)
* fix: detach ecc2 background session runners

* fix: stabilize windows ci portability

* fix: persist detached runner startup stderr

* fix: prefer repo-relative hook file paths

* fix: make npm pack test shell-safe on windows
2026-04-12 22:29:05 -07:00
Ke Wang 6a247d4c43 fix: resolve markdownlint MD028 and ESLint eqeqeq warnings
Fix two lint issues that cause `npm run lint` to exit non-zero:

1. README.md (MD028): Two consecutive blockquotes separated by a bare
   blank line. Markdownlint treats this as one blockquote with an
   illegal blank line inside. Replace the blank line with a `>`
   continuation so both paragraphs stay in the same blockquote.

2. session-activity-tracker.js (eqeqeq): Three instances of `== null`
   replaced with explicit `=== null || === undefined` guards to satisfy
   the repo's `eqeqeq: warn` ESLint rule.

Closes #1366
2026-04-12 16:00:55 -05:00
Affaan Mustafa b01a300c31 feat(ecc2): persist tool log params and trigger context 2026-04-09 08:04:18 -07:00
Affaan Mustafa 31f672275e feat(ecc2): infer tracked write modifications 2026-04-09 07:48:29 -07:00
Affaan Mustafa eee9768cd8 feat(ecc2): persist file activity patch previews 2026-04-09 07:45:37 -07:00
Affaan Mustafa c395b42d2c feat(ecc2): persist file activity diff previews 2026-04-09 07:40:28 -07:00
Affaan Mustafa edd027edd4 feat(ecc2): classify typed file activity 2026-04-09 07:33:42 -07:00
Affaan Mustafa 48fd68115e feat(ecc2): sync hook activity into session metrics 2026-04-09 07:02:24 -07:00