@ictechgy/context-guard 0.4.16 → 0.6.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/CHANGELOG.md +74 -0
- package/README.ko.md +91 -1
- package/README.md +95 -1
- package/docs/distribution.md +100 -0
- package/package.json +5 -1
- package/plugins/context-guard/.claude-plugin/plugin.json +1 -1
- package/plugins/context-guard/README.ko.md +34 -1
- package/plugins/context-guard/README.md +36 -1
- package/plugins/context-guard/bin/bash_reference_policy.py +967 -0
- package/plugins/context-guard/bin/context-guard-artifact +1 -1
- package/plugins/context-guard/bin/context-guard-bench +4216 -103
- package/plugins/context-guard/bin/context-guard-failed-nudge +95 -23
- package/plugins/context-guard/bin/context-guard-guard-read +6 -2
- package/plugins/context-guard/bin/context-guard-mcp +2 -1
- package/plugins/context-guard/bin/context-guard-pack +2086 -142
- package/plugins/context-guard/bin/context-guard-rewrite-bash +497 -45
- package/plugins/context-guard/bin/context-guard-sanitize-output +178 -22
- package/plugins/context-guard/bin/context-guard-setup +901 -28
- package/plugins/context-guard/bin/context-guard-statusline +33 -2
- package/plugins/context-guard/bin/context-guard-statusline-merged +71 -20
- package/plugins/context-guard/bin/context-guard-task-memory +635 -0
- package/plugins/context-guard/bin/context-guard-trim-output +706 -35
- package/plugins/context-guard/lib/context_guard_commands.py +25 -1
- package/plugins/context-guard/lib/context_pack_git_boundary.py +19 -0
- package/plugins/context-guard/lib/context_pack_identity.py +115 -0
- package/plugins/context-guard/lib/context_pack_receipts.py +9 -0
- package/plugins/context-guard/lib/context_pack_rendering.py +12 -0
- package/plugins/context-guard/lib/context_pack_scanning.py +10 -0
- package/plugins/context-guard/lib/context_pack_selection.py +6 -0
- package/plugins/context-guard/lib/credential_policy.py +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,80 @@ All notable changes for the ContextGuard plugin are documented here.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.6.0] - 2026-08-21
|
|
8
|
+
|
|
9
|
+
- Added a provider-free `context-guard-receipt evaluate phase` surface with
|
|
10
|
+
closed P2-P6 input/result schemas. It computes shadow/canary/router/adjunct/
|
|
11
|
+
specialized-track readiness from bounded canonical local records while
|
|
12
|
+
keeping runtime activation, generalization, provider calls, and savings
|
|
13
|
+
claims disabled behind the existing sequential phase gates.
|
|
14
|
+
- Changed the discarded v2 Bash canary's fixed marker write from denied shell
|
|
15
|
+
output redirection to an existing MiniShell-v1-supported `python3 -c` route.
|
|
16
|
+
Both real hook modes now guard the exact command in provider-free tests, and
|
|
17
|
+
the offline fake host honors hook denials before creating any marker.
|
|
18
|
+
- Added an explicit `--study-v2-use-existing-login` gate for executable v2
|
|
19
|
+
provider actions. `prepare` now verifies and pseudonymously binds the exact
|
|
20
|
+
first-party Claude login plus its owned, non-writable HOME identity without
|
|
21
|
+
persisting email or organization text. Every provider reservation rechecks
|
|
22
|
+
that binding, keeps XDG/session paths isolated, excludes credential-shaped
|
|
23
|
+
environment variables, and omits `CLAUDE_CONFIG_DIR`; `analyze` remains
|
|
24
|
+
provider- and auth-independent.
|
|
25
|
+
- Bound both discarded v2 Bash-routing canary calls to the same hard `$0.75`
|
|
26
|
+
per-call Claude CLI budget as each analytic task. The value is part of the
|
|
27
|
+
immutable canary contract, so prepare/resume rejects drift; the frozen study's
|
|
28
|
+
218 consumed/reserved identities imply a `$163.50` arithmetic maximum. The
|
|
29
|
+
CLI enforces each process cap; there is no separate aggregate CLI limiter.
|
|
30
|
+
- Published the sanitized result of the first frozen 12-task live study. The
|
|
31
|
+
study is explicitly `inconclusive`: one arm-unit exhausted its fixed retry,
|
|
32
|
+
no favorable subset or correction assessment was analyzed, and no token or
|
|
33
|
+
cost savings claim is allowed.
|
|
34
|
+
|
|
35
|
+
## [0.5.1] - 2026-08-19
|
|
36
|
+
|
|
37
|
+
- Bounded context-pack source, diff, and non-Git traversal input before
|
|
38
|
+
allocation; made Markdown evidence fences content-derived; and reused one
|
|
39
|
+
immutable source snapshot across suggest/build so representative pack latency
|
|
40
|
+
falls from tens of seconds to sub-second without changing ordinary pack bytes.
|
|
41
|
+
- Pinned automatic hook and statusline runtimes instead of trusting ambient
|
|
42
|
+
`PATH`, Python startup variables, shell startup variables, or executable
|
|
43
|
+
overrides, while retaining setup-approved OMC integration.
|
|
44
|
+
- Added the backward-compatible Receipt external-approval v2 envelope whose
|
|
45
|
+
scope truthfully binds manual owner cleanup, plus bounded V4 authorization
|
|
46
|
+
lock waits, read-only ledger snapshots, cached immutable selection artifacts,
|
|
47
|
+
and shared V3/V4 failure conformance tests.
|
|
48
|
+
- Preserved sparse token availability in the Mac consumer and added the
|
|
49
|
+
provider-live test directory to the release gate.
|
|
50
|
+
|
|
51
|
+
## [0.5.0] - 2026-08-06
|
|
52
|
+
|
|
53
|
+
- Added the default-off Claude Code `PreToolUse:Bash` reference route. After
|
|
54
|
+
strong local sanitization, long merged command output can stay in a private
|
|
55
|
+
project-local Receipt store while the transcript receives a compact,
|
|
56
|
+
exact-retrieval handle and an executable `context-guard reference` command.
|
|
57
|
+
Retrieval derives private state internally and pages exact UTF-8 output in
|
|
58
|
+
fixed 20,000-byte-or-smaller chunks, so resolving a handle cannot replay the
|
|
59
|
+
complete 10 MB capture in one turn. The legacy trim route and unchanged route
|
|
60
|
+
remain deterministic fallbacks; source/plugin-only installs cannot enable
|
|
61
|
+
this npm-only mode.
|
|
62
|
+
- Added the independently versioned `@ictechgy/context-guard-receipt@0.2.0`
|
|
63
|
+
exact dependency, fixed seven-day reference expiry, bounded authenticated
|
|
64
|
+
import recovery journal, 10,000,000-byte merged capture ceiling, and
|
|
65
|
+
expired/revoked reference refusal. Installation and disablement never erase
|
|
66
|
+
stored artifacts automatically.
|
|
67
|
+
- Added an executable three-arm study across `host_unmodified`, `legacy_trim`,
|
|
68
|
+
and `bash_reference_v1`, with an explicit `prepare` → `canary` → `run`/`resume`
|
|
69
|
+
→ `analyze` lifecycle. `prepare` binds the CLI and runs local
|
|
70
|
+
`--version`/`--help` probes without a model request. Provider/model requests
|
|
71
|
+
occur only during canary and analytic execution. A separate provider-free
|
|
72
|
+
offline rehearsal exercises the lifecycle with a native fake CLI. The study
|
|
73
|
+
binds a fixed 12-task corpus and reports the legacy contrast diagnostically;
|
|
74
|
+
without an independent power model the result is descriptive-only and cannot
|
|
75
|
+
authorize a savings claim.
|
|
76
|
+
- Added build-once npm candidate manifests, exact cross-package hashes/SRI,
|
|
77
|
+
paired clean-install discovery smoke, separate trusted publication to
|
|
78
|
+
`next`, and preflight/rollback-aware promotion to `latest`. No package is
|
|
79
|
+
published or promoted automatically by this release.
|
|
80
|
+
|
|
7
81
|
## [0.4.16] - 2026-08-01
|
|
8
82
|
|
|
9
83
|
- Sanitizer output-scanning is now one monotonic left-to-right pass. All nine location-prefix consumers previously re-parsed the same optional `path:line:` fragment at every offset, which made lines with few colons quadratic: a single 82,015-byte line took 2.62 s and a 100,014-byte line took 3.98 s. The leading prefix is identified once and the seven unanchored consumers run as fragment-free twins, while the two `^`-anchored header consumers keep their original patterns because they were never a per-offset cost. The same lines now take 64.3 ms and 0.078 s, with doubling ratios of 1.84 to 2.01. Redaction output is byte-identical to the previous implementation, pinned by a differential oracle against a hash-frozen baseline across eleven corpora, three sanitization contexts, both path-display modes, and both shared-state and per-line runs.
|
package/README.ko.md
CHANGED
|
@@ -221,6 +221,62 @@ npm exec @ictechgy/context-guard -- --version
|
|
|
221
221
|
|
|
222
222
|
`--scope project`는 `AGENTS.md`, `.agents/skills/...`처럼 저장소 안 파일에 적용합니다. `--scope user`는 전체 사용자 환경에 적용하려는 경우에만 의도적으로 사용하세요. 실제 적용에는 `--yes`와 명시적인 `--agent`가 필요하며, 지원되는 쓰기는 되돌리기 기록을 남깁니다.
|
|
223
223
|
|
|
224
|
+
### Claude Code용 선택적 Bash reference
|
|
225
|
+
|
|
226
|
+
`bash_reference_v1` 경로는 정확한 프로젝트 로컬 npm 설치에서만 사용할 수
|
|
227
|
+
있습니다. 루트 패키지는 `@ictechgy/context-guard-receipt@0.2.1`을 정확히
|
|
228
|
+
고정합니다. global npm, `npx`, 소스 체크아웃, Homebrew, Claude marketplace
|
|
229
|
+
plugin 배치에서는 기존 Bash trim 동작을 유지하고 setup이 reference 경로를
|
|
230
|
+
사용할 수 없다고 알립니다.
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
npm install --save-exact @ictechgy/context-guard@0.6.0
|
|
234
|
+
./node_modules/.bin/context-guard setup --root . --agent claude --scope project --bash-reference-v1 --plan
|
|
235
|
+
./node_modules/.bin/context-guard setup --root . --agent claude --scope project --bash-reference-v1 --yes
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
기본 비활성인 이 `PreToolUse:Bash` 모드는 강하게 가림 처리된 긴 명령 출력을
|
|
239
|
+
프로젝트의 비공개 Receipt 저장소에 두고 digest에는 짧은 조회 handle만
|
|
240
|
+
넣습니다. Handle은 bearer와 비슷하고 Claude/provider에 보일 수 있으며 발급
|
|
241
|
+
후 정확히 7일 뒤 만료됩니다. Bash 실행 전에 wrapper는 소유자 전용 익명 캡처
|
|
242
|
+
descriptor와 검증된 Receipt broker 하나를 준비합니다. Broker는 코드 로드와
|
|
243
|
+
repository/store/expiry/journal 경계 고정을 끝낸 뒤에만 준비 완료를 알립니다.
|
|
244
|
+
따라서 8,192바이트 공개 임계값보다 작은 출력도 로컬 상태 축을 초기화할 수
|
|
245
|
+
있지만, 이 경우 `ABORT`하고 handle은 내보내지 않습니다. Strong sanitizer,
|
|
246
|
+
정확한 패키지 pin, 절대 Node runtime, broker 준비 또는 최종 등록을 사용할 수
|
|
247
|
+
없으면 감싼 명령의 exit status를 바꾸지 않고 legacy trim으로 돌아갑니다.
|
|
248
|
+
기존 `--artifact-receipt` 캡처와는 동시에 사용할 수 없습니다.
|
|
249
|
+
|
|
250
|
+
Digest는 handle을 실행 가능한 프로젝트 로컬 조회 명령으로 표시합니다.
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
./node_modules/.bin/context-guard reference <cgr1p-handle>
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Handle을 발급한 동일한 물리 프로젝트 root에서 실행하세요. 명령은 비공개
|
|
257
|
+
sibling state 위치를 내부에서 계산하고, 정확한 sanitized UTF-8 출력 중 최대
|
|
258
|
+
20,000바이트 한 페이지만 반환합니다. 남은 바이트가 있으면 diagnostic에 다음
|
|
259
|
+
연속 조회용 `--offset`을 표시하므로 전체 보관 출력을 한 번에 transcript로 쏟지
|
|
260
|
+
않습니다. 잘못되었거나 만료된 handle, 다른 root, stale source, 변경된 패키지,
|
|
261
|
+
잘못된 응답은 payload를 전혀 반환하지 않습니다.
|
|
262
|
+
|
|
263
|
+
패키지를 제거하기 전에 reference 경로를 먼저 끄세요.
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
./node_modules/.bin/context-guard setup --root . --agent claude --scope project --no-bash-reference-v1 --yes --no-diet-scan
|
|
267
|
+
npm uninstall @ictechgy/context-guard
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Receipt 상태는 저장소 밖의 비공개 sibling 디렉터리
|
|
271
|
+
`.context-guard-receipt-state-<root-selector-sha256>`에 둡니다. Selector는
|
|
272
|
+
정규화한 root 경로와 device/inode identity를 묶으므로 나란한 저장소끼리
|
|
273
|
+
authority를 공유하지 않습니다. 비활성화와 패키지 제거는 나중의 정확한 재설치나
|
|
274
|
+
별도 사용자 승인 artifact 정리를 위해 이 디렉터리를 보존합니다. 다만 `npm
|
|
275
|
+
uninstall`은 검증된 package-local code와 `node_modules/.bin/context-guard`를
|
|
276
|
+
제거하므로, 정확한 프로젝트 로컬 pair를 다시 설치하기 전에는 reference 조회를
|
|
277
|
+
할 수 없습니다. 이 메커니즘은 큰 Bash 출력의 transcript 입력을 줄일 수 있지만
|
|
278
|
+
고정된 provider token 또는 비용 절감을 보장하지 않습니다.
|
|
279
|
+
|
|
224
280
|
## Homebrew 배포 경로
|
|
225
281
|
|
|
226
282
|
Homebrew는 공유 `ictechgy/tap` tap을 통해 macOS 배포 경로로 사용할 수 있습니다.
|
|
@@ -281,6 +337,8 @@ long-command 2>&1 | ./plugins/context-guard/bin/context-guard-artifact store --c
|
|
|
281
337
|
./plugins/context-guard/bin/context-guard-artifact search "ERROR" --json
|
|
282
338
|
./plugins/context-guard/bin/context-guard-artifact receipt <artifact_id> --json
|
|
283
339
|
./plugins/context-guard/bin/context-guard-artifact get <artifact_id> --lines 1:80
|
|
340
|
+
./plugins/context-guard/bin/context-guard task-memory put --task issue-123 --source src/app.py --json < stable-context.txt
|
|
341
|
+
./plugins/context-guard/bin/context-guard task-memory get <opaque_handle> --task issue-123 --source src/app.py --max-bytes 65536
|
|
284
342
|
```
|
|
285
343
|
|
|
286
344
|
로컬 보관 모드는 캡처·sandbox 검색·조회 용도입니다. 기본 저장 위치는 `.context-guard/artifacts`이며, 리브랜딩 이전의 `.claude-token-optimizer/artifacts` 요약 기록도 계속 읽을 수 있습니다. JSON 요약 기록에는 줄 번호가 포함된 top-error 요약 기록, 중복 라인 그룹, 가림 처리된 범위 제한 `suggested_queries`, 안정적인 `contextguard-artifact:<id>` 핸들이 있는 `output_sandbox` envelope가 들어갑니다. `context-guard-artifact receipt <artifact_id> --json`으로 본문 없이 메타데이터/재조회 핸들만 다시 가져온 뒤, 전체 로그를 다시 넣지 않고 필요한 최소 범위만 정확하게 조회할 수 있습니다. `search`는 로컬 sanitized artifact sandbox를 literal substring으로 검색하고, bounded match/context record와 `context-guard-artifact get ... --lines START:END` 재조회 명령을 함께 반환합니다. custom `--dir` 값의 raw private path는 기본적으로 가림 처리되므로 같은 `--dir`로 다시 실행하거나, 직접 실행 가능한 local command가 꼭 필요할 때만 `search --show-paths`를 명시하세요. 이 검색 리포트는 local-only이며 hosted token/cost savings claim으로 해석하면 안 됩니다. 릴리스 확인처럼 종료 코드가 중요한 파이프라인에서는 원래 명령의 종료 코드를 직접 보존하세요. 종료 코드 보존이 핵심이면 `context-guard-trim-output -- ...`을 사용하는 편이 안전합니다.
|
|
@@ -295,6 +353,14 @@ long-command 2>&1 | ./plugins/context-guard/bin/context-guard-artifact store --c
|
|
|
295
353
|
--manifest-out suggested-pack.json \
|
|
296
354
|
--pack-out context-pack.md \
|
|
297
355
|
--budget-bytes 12000 --json --explain --adaptive-k --symbol-memory
|
|
356
|
+
# 안전한 direct import neighbor를 최대 4개까지 pack에 명시적으로 추가:
|
|
357
|
+
./plugins/context-guard/bin/context-guard-pack auto \
|
|
358
|
+
--root . --files src/app.py --query "entrypoint 검토" --top 1 \
|
|
359
|
+
--budget-bytes 12000 --json --no-artifact --apply-symbol-memory
|
|
360
|
+
# 로컬 품질 gate 통과 뒤 heuristic source를 명시적으로 축소:
|
|
361
|
+
./plugins/context-guard/bin/context-guard-pack auto \
|
|
362
|
+
--root . --query "실패 테스트 검토" --top 8 \
|
|
363
|
+
--budget-bytes 12000 --json --no-artifact --apply-adaptive-k
|
|
298
364
|
# 또는 명시적인 두 단계로 실행:
|
|
299
365
|
./plugins/context-guard/bin/context-guard-pack suggest \
|
|
300
366
|
--root . --query "failing tests review" --diff HEAD \
|
|
@@ -316,7 +382,16 @@ long-command 2>&1 | ./plugins/context-guard/bin/context-guard-artifact store --c
|
|
|
316
382
|
- JSON explain에는 bounded `repo_map`이 포함될 수 있습니다. 예시는 sampled byte/token-proxy tree, category-only secret risk count, signature-first hint, explain-only graph rank, 기존 `slice`/symbol 재조회 힌트입니다.
|
|
317
383
|
- repo-map은 manifest, pack 본문, receipt, byte budget을 바꾸지 않고 네트워크·모델 호출·임베딩을 쓰지 않습니다. 토큰 값은 provider-token이나 savings claim이 아닌 추정 `chars_div_4` proxy입니다.
|
|
318
384
|
- `suggest` 또는 `auto`에 `--adaptive-k`를 추가하면 로컬 score distribution, byte-budget fit, clamped score-mass 기반 recall/precision proxy에서 나온 advisory-only top-k shrink/expand metadata를 포함합니다. `--adaptive-k-policy balanced|recall|precision`과 선택적 `--adaptive-k-min-recall-proxy` / `--adaptive-k-min-precision-proxy` gate로 로컬 추천 정책을 고를 수 있고, gate 실패는 metadata-only(`pass|failed`)입니다. adaptive block은 capped selected/omitted evidence와 구조화된 source-verification hint를 포함하지만 추천값을 자동 적용하지 않으며 manifest, pack 본문, receipt, byte budget을 바꾸지 않습니다.
|
|
385
|
+
- `auto --apply-adaptive-k`는 명시적·기본 비활성 pruning 경로입니다. 회귀 gate가 통과할 때만 로컬 추천값을 적용하고, 호출자가 지정한 file/output/test-output 및 diff source는 항상 유지한 채 같은 byte budget으로 다시 build하며 `adaptive_k_application`을 기록합니다. `--adaptive-k`를 내포하지만 provider token/cost 절감 주장을 허용하지 않습니다.
|
|
319
386
|
- `auto`에 `--symbol-memory`를 추가하면 repo-map 기반 symbol/graph advisory metadata와 정확한 `slice` / `read-symbol` 검증 힌트를 포함합니다. 이는 source verification 안내일 뿐이며 manifest, pack 본문, receipt, byte budget을 바꾸지 않습니다.
|
|
387
|
+
- `--apply-symbol-memory`는 명시적·기본 비활성 Graphify식 적용 경로입니다. 일반 추천 뒤 안전한 direct import neighbor slice를 최대 4개 manifest에 추가하고 같은 byte budget으로 pack을 다시 만듭니다. explicit/query seed는 더 높은 우선순위를 유지하고 secret-risk neighbor는 제외하며 exact source/fallback receipt는 보존됩니다. 결과에는 닫힌 `graph_application` 블록이 기록되며 provider token/cost 절감 주장은 하지 않습니다.
|
|
388
|
+
- `--self-financing-selection`은 기본 비활성 조합 경로입니다. ordinary pack byte ceiling을 고정한 뒤 Adaptive, task-matching Symbol, bounded one-hop Graph 순서로 적용합니다. 각 후보는 frozen identity, secret-risk 판단, byte delta, exact fallback, 대체된 lower-value non-caller source를 기록하며 안전하게 맞지 않으면 정직한 no-op이 됩니다. 이는 로컬 byte-ceiling 정책이며 provider token/cost 절감 주장이 아닙니다.
|
|
389
|
+
- `auto --selection-plan --json`은 pack, manifest, receipt를 쓰지 않는 provider-free read-only content-addressed plan을 만듭니다. JSON을 명시적으로 저장한 뒤 같은 task 입력과 `--apply-selection-plan PATH --no-artifact`(또는 명시적인 output/artifact 옵션)를 사용해 적용합니다. apply는 출력 전에 closed plan과 source identity를 다시 검증하며 drift, incomplete scan, secret-risk 또는 scorer/private 입력, unsafe host/output boundary, exact recovery 누락을 fail-closed로 거부합니다.
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
context-guard-pack auto --root . --query "checkout retry 수정" --diff worktree --output logs/test.txt --json --selection-plan > selection-plan.json
|
|
393
|
+
context-guard-pack auto --root . --query "checkout retry 수정" --diff worktree --output logs/test.txt --json --apply-selection-plan selection-plan.json --no-artifact
|
|
394
|
+
```
|
|
320
395
|
- `--manifest-out`은 `build`가 읽을 수 있는 manifest를 저장하고, `--pack-out`은 렌더링된 팩 본문을 저장합니다.
|
|
321
396
|
- `context-guard-pack suggest`는 더 낮은 수준의 로컬 전용 준비 단계입니다. `--query`, `--diff`, 반복 `--files`, 그리고 `--root` 아래의 선택적 `--output` / `--test-output` 텍스트 파일을 가림 처리한 신호에서 후보 파일과 줄 범위를 순위화한 뒤 `build --manifest`가 바로 읽을 수 있는 manifest를 씁니다.
|
|
322
397
|
- `context-guard-pack build`는 우선순위가 있는 로컬 파일 근거를 렌더링된 UTF-8 바이트 기준 `--budget-bytes` 안의 Markdown 팩으로 조립합니다. JSON 출력은 포함·부분 포함·중복·unsafe·missing·예산 초과로 누락된 source를 기록합니다.
|
|
@@ -405,7 +480,7 @@ JSON 출력에는 여러 증거 surface가 포함될 수 있습니다.
|
|
|
405
480
|
[Sonnet] repo | main | ctx 86% ⚠ | cost $0.123 | cache 80% | reuse 8.0x
|
|
406
481
|
```
|
|
407
482
|
|
|
408
|
-
`cache N%`는 최근 일정 범위의 대화 기록에서 관찰된 입력 토큰 중 cache read가 차지하는 비율이며, cache read가 1회 이상 있을 때만 표시됩니다. `reuse X.Yx`는 `cache_read / cache_creation` 값이며, cache read가 양수이고 cache creation이 0이 아닐 때만 표시됩니다. `⚠` 표시는 컨텍스트 사용률이 경고 기준에 도달했을 때 나타나며 기본값은 80%입니다.
|
|
483
|
+
`cache N%`는 최근 일정 범위의 대화 기록에서 관찰된 입력 토큰 중 cache read가 차지하는 비율이며, cache read가 1회 이상 있을 때만 표시됩니다. `reuse X.Yx`는 `cache_read / cache_creation` 값이며, cache read가 양수이고 cache creation이 0이 아닐 때만 표시됩니다. `⚠` 표시는 컨텍스트 사용률이 경고 기준에 도달했을 때 나타나며 기본값은 80%입니다. 자동 훅은 격리된 환경에서 실행되므로 `CONTEXT_GUARD_STATUSLINE_CTX_WARN=90`을 설정한 뒤 setup을 다시 실행해 이 안전한 동작 설정을 설치 명령에 고정하세요. Python·shell loader 변수는 전달하지 않습니다.
|
|
409
484
|
|
|
410
485
|
### 반복 가능한 벤치마크 실행
|
|
411
486
|
|
|
@@ -545,6 +620,21 @@ context-guard-setup --plan
|
|
|
545
620
|
|
|
546
621
|
`context-guard mcp`(또는 `context-guard-mcp`)는 의존성 없는 로컬 stdio MCP 서버입니다. 프로세스 하나는 root와 namespace 하나에 고정되며 compression, sanitization된 artifact 조회, 로컬 통계만 제공합니다. HTTP, SSE, 네트워크, provider, model, proxy, 자동 client 설정 기능은 없습니다. 저장되는 fallback은 원문이 아닌 정확한 sanitization 완료 사본이고 다른 namespace의 artifact는 조회할 수 없습니다. 이 로컬 어댑터는 hosted token/cost 절감을 주장하지 않습니다.
|
|
547
622
|
|
|
623
|
+
반복 파일·로그 컨텍스트를 명시적으로 다루려면 함께 설치되는 Receipt
|
|
624
|
+
companion을 `context-guard-receipt-mcp --root /absolute/repository`로 실행할
|
|
625
|
+
수 있습니다. `receipt_context` 도구는 사용자가 `eligible`이라고 명시한
|
|
626
|
+
상대 경로만 읽고, byte-benefit router가 유리하다고 판단하면 compact exact
|
|
627
|
+
reference를 반환하며, 반복 조회에는 같은 live reference를 재사용하고 한 번에
|
|
628
|
+
최대 65,536바이트의 exact slice만 가져옵니다. 이 기능은 opt-in이며
|
|
629
|
+
process-local입니다. 선택적 task scope는 task 간 재사용을 막고, 명시적 release는
|
|
630
|
+
context GC를 수행하며, content-free history에는 process-keyed HMAC과 결정만
|
|
631
|
+
남습니다. `receipt_diagnose`는 파일 byte를 반환하지 않고 비적용 shadow
|
|
632
|
+
firewall/router와 prefix 재사용 기반 scout/surgeon 안내를 제공합니다. 명시적
|
|
633
|
+
private `--state-dir`로 같은 binary를 시작하면 action을 실행하지 않는
|
|
634
|
+
authenticated `receipt_twin` 근거 기록만 추가됩니다. 스스로 등록되거나 전체
|
|
635
|
+
prompt를 가로채지 않고, capability가 재시작을 넘어 유지되지 않으며, provider를
|
|
636
|
+
호출하거나 hosted 절감 효과를 주장하지 않습니다.
|
|
637
|
+
|
|
548
638
|
## 릴리스 확인
|
|
549
639
|
|
|
550
640
|
릴리스에 민감한 변경을 배포하거나 머지하기 전에는 동기화 확인과 두 게이트를 모두 실행하세요.
|
package/README.md
CHANGED
|
@@ -234,6 +234,66 @@ npm exec @ictechgy/context-guard -- --version
|
|
|
234
234
|
|
|
235
235
|
Use `--scope project` for repository files such as `AGENTS.md` and `.agents/skills/...`. Use `--scope user` only when you intentionally want a user-level path; applying user scope requires `--yes` plus an explicit `--agent`, and supported writes record rollback metadata.
|
|
236
236
|
|
|
237
|
+
### Opt-in Bash references for Claude Code
|
|
238
|
+
|
|
239
|
+
The `bash_reference_v1` route is available only from an exact, project-local npm
|
|
240
|
+
installation. The root package pins `@ictechgy/context-guard-receipt@0.2.1`; a
|
|
241
|
+
global, `npx`, source-checkout, Homebrew, or Claude marketplace-plugin layout
|
|
242
|
+
keeps the existing Bash trim behavior and setup reports the reference route as
|
|
243
|
+
unavailable.
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
npm install --save-exact @ictechgy/context-guard@0.6.0
|
|
247
|
+
./node_modules/.bin/context-guard setup --root . --agent claude --scope project --bash-reference-v1 --plan
|
|
248
|
+
./node_modules/.bin/context-guard setup --root . --agent claude --scope project --bash-reference-v1 --yes
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
This default-off `PreToolUse:Bash` mode keeps strongly sanitized long command
|
|
252
|
+
output in the private project-local Receipt store and puts only a compact
|
|
253
|
+
retrieval handle in the digest. The handle is bearer-like and can be visible to
|
|
254
|
+
Claude/the provider; it expires exactly seven days after issuance. Before Bash
|
|
255
|
+
starts, the wrapper creates an anonymous owner-only capture descriptor and one
|
|
256
|
+
verified Receipt broker, which preloads code and retains the repository, store,
|
|
257
|
+
expiry, and journal boundaries. Even output below the 8,192-byte disclosure
|
|
258
|
+
threshold can therefore initialize those local axes; it sends `ABORT` and emits
|
|
259
|
+
no handle. If strong sanitization, the exact package pin, the absolute Node
|
|
260
|
+
runtime, broker preparation, or final registration is unavailable, execution
|
|
261
|
+
falls back to legacy trimming without changing the wrapped command's exit
|
|
262
|
+
status. The mode is mutually exclusive with legacy `--artifact-receipt`
|
|
263
|
+
capture.
|
|
264
|
+
|
|
265
|
+
The digest renders the handle as an executable, project-local retrieval command:
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
./node_modules/.bin/context-guard reference <cgr1p-handle>
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Run it from the same physical project root that issued the handle. It derives
|
|
272
|
+
the private sibling state location internally and returns one exact sanitized
|
|
273
|
+
UTF-8 page, capped at 20,000 bytes. When more bytes remain, its diagnostic gives
|
|
274
|
+
the next continuation `--offset`; each page stays bounded, so retrieval cannot dump
|
|
275
|
+
the full retained output into the transcript in one step. Invalid, expired,
|
|
276
|
+
wrong-root, stale-source, changed-package, and malformed references return no
|
|
277
|
+
payload.
|
|
278
|
+
|
|
279
|
+
Disable the route before uninstalling:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
./node_modules/.bin/context-guard setup --root . --agent claude --scope project --no-bash-reference-v1 --yes --no-diet-scan
|
|
283
|
+
npm uninstall @ictechgy/context-guard
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Receipt state is kept outside the repository in a private sibling directory
|
|
287
|
+
named `.context-guard-receipt-state-<root-selector-sha256>`. The selector binds
|
|
288
|
+
the normalized root path and its device/inode identity so sibling repositories
|
|
289
|
+
do not share authority. Disablement and package removal preserve that directory
|
|
290
|
+
for a later exact reinstall or separately authorized artifact cleanup. `npm
|
|
291
|
+
uninstall` removes the verified package-local code and
|
|
292
|
+
`node_modules/.bin/context-guard`, so reference retrieval is unavailable until
|
|
293
|
+
the exact project-local pair is reinstalled. This mechanism can reduce
|
|
294
|
+
transcript input for large Bash output, but it does not guarantee a fixed
|
|
295
|
+
provider-token or cost reduction.
|
|
296
|
+
|
|
237
297
|
## Homebrew release path
|
|
238
298
|
|
|
239
299
|
Homebrew is available through the shared `ictechgy/tap` tap:
|
|
@@ -305,6 +365,8 @@ long-command 2>&1 | ./plugins/context-guard/bin/context-guard-artifact store --c
|
|
|
305
365
|
./plugins/context-guard/bin/context-guard-artifact search "ERROR" --json
|
|
306
366
|
./plugins/context-guard/bin/context-guard-artifact receipt <artifact_id> --json
|
|
307
367
|
./plugins/context-guard/bin/context-guard-artifact get <artifact_id> --lines 1:80
|
|
368
|
+
./plugins/context-guard/bin/context-guard task-memory put --task issue-123 --source src/app.py --json < stable-context.txt
|
|
369
|
+
./plugins/context-guard/bin/context-guard task-memory get <opaque_handle> --task issue-123 --source src/app.py --max-bytes 65536
|
|
308
370
|
```
|
|
309
371
|
|
|
310
372
|
Artifact mode is for capture, sandbox search, and retrieval. It stores sanitized output under `.context-guard/artifacts` by default and can still read legacy `.claude-token-optimizer/artifacts` receipts from before the rebrand. JSON receipts include line-numbered top-error receipts, duplicate-line groups, sanitized bounded `suggested_queries`, and an `output_sandbox` envelope with a stable `contextguard-artifact:<id>` handle. Use `context-guard-artifact receipt <artifact_id> --json` to rehydrate metadata-only handles without returning content, then fetch the smallest useful exact slice instead of replaying the full log. `search` scans the local sanitized artifact sandbox by literal substring, returns capped match/context records, and includes `context-guard-artifact get ... --lines START:END` rehydration commands for omitted detail. For custom `--dir` values, raw private paths stay redacted by default; rerun with the same `--dir`, or pass `search --show-paths` when you explicitly want a directly executable local command. The search report is local-only and does not make hosted token/cost savings claims. When `--max-lines` accompanies a `--lines START:END` selector, it caps lines returned within that range; it does not expand the selector. Preserve the producer command's exit code yourself when using shell pipelines in release checks, or use `context-guard-trim-output -- ...` when exit-code preservation is the primary requirement.
|
|
@@ -319,6 +381,14 @@ Artifact mode is for capture, sandbox search, and retrieval. It stores sanitized
|
|
|
319
381
|
--manifest-out suggested-pack.json \
|
|
320
382
|
--pack-out context-pack.md \
|
|
321
383
|
--budget-bytes 12000 --json --explain --adaptive-k --symbol-memory
|
|
384
|
+
# Explicitly add up to four safe direct import neighbors to the pack:
|
|
385
|
+
./plugins/context-guard/bin/context-guard-pack auto \
|
|
386
|
+
--root . --files src/app.py --query "review entrypoint" --top 1 \
|
|
387
|
+
--budget-bytes 12000 --json --no-artifact --apply-symbol-memory
|
|
388
|
+
# Explicitly prune heuristic sources after the local quality gates pass:
|
|
389
|
+
./plugins/context-guard/bin/context-guard-pack auto \
|
|
390
|
+
--root . --query "review failing tests" --top 8 \
|
|
391
|
+
--budget-bytes 12000 --json --no-artifact --apply-adaptive-k
|
|
322
392
|
# Or run the two explicit steps:
|
|
323
393
|
./plugins/context-guard/bin/context-guard-pack suggest \
|
|
324
394
|
--root . --query "review failing tests" --diff HEAD \
|
|
@@ -340,7 +410,16 @@ A few boundaries are intentional:
|
|
|
340
410
|
- `--explain` may include bounded `repo_map` metadata: sampled byte/token-proxy tree entries, category-only secret-risk counts, signature-first file hints, explain-only graph ranks, and exact `slice`/symbol retrieval hints.
|
|
341
411
|
- Explain metadata does not change the manifest, pack body, receipt, or byte budget. It does not use network/model/embedding calls, and token values remain local `chars_div_4` proxies rather than provider-token or savings claims.
|
|
342
412
|
- Add `--adaptive-k` to `suggest` or `auto` for advisory-only shrink/expand top-k metadata derived from local score distribution, byte-budget fit, and clamped score-mass recall/precision proxies. Use `--adaptive-k-policy balanced|recall|precision` plus optional `--adaptive-k-min-recall-proxy` / `--adaptive-k-min-precision-proxy` gates to choose a local recommendation policy; gate failures are metadata-only (`pass|failed`). The adaptive block includes capped selected/omitted evidence and structured source-verification hints, never applies the recommendation automatically, and does not change the manifest, pack body, receipt, or byte budget.
|
|
413
|
+
- Add `--apply-adaptive-k` to `auto` for an explicit, default-off pruning pass. It applies the local recommendation only when its regression gates pass, always retains caller-declared file/output/test-output and diff sources, rebuilds inside the same byte budget, and records `adaptive_k_application`. It implies `--adaptive-k` and does not authorize a provider-token or cost-savings claim.
|
|
343
414
|
- Add `--symbol-memory` to `auto` for repo-map-derived symbol/graph advisory metadata with exact `slice` / `read-symbol` verification hints. It is source-verification guidance only and does not change the manifest, pack body, receipt, or byte budget.
|
|
415
|
+
- Add `--apply-symbol-memory` for an explicit, default-off Graphify-style step: after the ordinary suggestion pass, it adds at most four direct import-neighbor slices to the manifest and rebuilds within the same byte budget. Explicit/query seeds keep higher priority, secret-risk neighbors are excluded, the exact source/fallback receipt remains available, and the result records a closed `graph_application` block. This implies symbol-memory output but makes no provider-token or cost claim.
|
|
416
|
+
- Add `--self-financing-selection` for the composed default-off path. It freezes the ordinary pack byte ceiling, applies Adaptive, then task-matching Symbol slices, then bounded one-hop Graph neighbors. Each candidate records its frozen identity, secret-risk decision, byte delta, exact fallback, and any lower-value non-caller source it replaces; candidates that cannot fit safely are recorded as no-ops. This is a local byte-ceiling policy, not a provider-token or cost-savings claim.
|
|
417
|
+
- Use `auto --selection-plan --json` to produce a provider-free, read-only, content-addressed plan without writing a pack, manifest, or receipt. Save that JSON deliberately, then use the same task inputs with `--apply-selection-plan PATH --no-artifact` (or explicitly choose output/artifact options) to apply it. Apply recomputes the closed plan and revalidates source identities before emitting anything; drift, incomplete scans, secret-risk or scorer/private inputs, unsafe host/output boundaries, and missing exact recovery fail closed.
|
|
418
|
+
|
|
419
|
+
```bash
|
|
420
|
+
context-guard-pack auto --root . --query "fix checkout retry" --diff worktree --output logs/test.txt --json --selection-plan > selection-plan.json
|
|
421
|
+
context-guard-pack auto --root . --query "fix checkout retry" --diff worktree --output logs/test.txt --json --apply-selection-plan selection-plan.json --no-artifact
|
|
422
|
+
```
|
|
344
423
|
- `--manifest-out` writes a build-compatible manifest; `--pack-out` saves the rendered pack.
|
|
345
424
|
- `context-guard-pack suggest` is the lower-level additive local-only planning step. It ranks candidate files and line ranges from `--query`, `--diff`, repeated `--files`, and optional sanitized `--output` / `--test-output` files under `--root`, then writes a manifest that `build --manifest` can consume.
|
|
346
425
|
- `context-guard-pack build` assembles prioritized local file evidence into a Markdown body whose rendered UTF-8 bytes stay within `--budget-bytes`. JSON output records included, partial, duplicate, unsafe, missing, and budget-omitted sources.
|
|
@@ -460,7 +539,7 @@ These fields can flag likely volatile content near the prompt prefix, stable-pre
|
|
|
460
539
|
[Sonnet] repo | main | ctx 86% ⚠ | cost $0.123 | cache 80% | reuse 8.0x
|
|
461
540
|
```
|
|
462
541
|
|
|
463
|
-
`cache N%` is the cache-read share of observed input-side tokens in the bounded transcript tail and stays hidden until at least one cache read is observed. `reuse X.Yx` is `cache_read / cache_creation` and is shown only when cache read is positive and cache creation is non-zero. The `⚠` marker appears when context usage reaches the warning threshold, defaulting to 80
|
|
542
|
+
`cache N%` is the cache-read share of observed input-side tokens in the bounded transcript tail and stays hidden until at least one cache read is observed. `reuse X.Yx` is `cache_read / cache_creation` and is shown only when cache read is positive and cache creation is non-zero. The `⚠` marker appears when context usage reaches the warning threshold, defaulting to 80%. Automatic hooks run with an isolated environment, so set `CONTEXT_GUARD_STATUSLINE_CTX_WARN=90` and rerun setup to pin that safe behavior setting into the installed command; Python and shell loader variables are never carried through.
|
|
464
543
|
|
|
465
544
|
### Run a repeatable benchmark
|
|
466
545
|
|
|
@@ -609,6 +688,21 @@ Do not rely on `PATH` lookup for generated hooks by default. The setup wizard re
|
|
|
609
688
|
|
|
610
689
|
`context-guard mcp` (or `context-guard-mcp`) is a dependency-free local stdio MCP server. Each process is fixed to one root and one namespace; it exposes only compression, sanitized artifact retrieval, and local statistics. It has no HTTP, SSE, network, provider, model, proxy, or automatic client-configuration surface. Stored fallback content is an exact sanitized copy, not raw input, and artifacts from another namespace are not retrievable. This local adapter makes no hosted token or cost-savings claim.
|
|
611
690
|
|
|
691
|
+
For explicit repeated file or log context, the bundled Receipt companion also
|
|
692
|
+
provides `context-guard-receipt-mcp --root /absolute/repository`. Its
|
|
693
|
+
`receipt_context` tool accepts an explicitly eligible relative path, returns a
|
|
694
|
+
compact exact reference when the byte-benefit router says deferral is useful,
|
|
695
|
+
reuses that live reference for repeated reads, and retrieves exact slices of at
|
|
696
|
+
most 65,536 bytes. Optional task scopes prevent cross-task reuse, explicit
|
|
697
|
+
release performs context GC, and the content-free history records only
|
|
698
|
+
process-keyed HMACs and decisions. `receipt_diagnose` adds non-applying shadow
|
|
699
|
+
firewall/router plus prefix-reuse scout/surgeon advice without returning file
|
|
700
|
+
bytes. Starting the same binary with an explicit private `--state-dir` enables
|
|
701
|
+
only `receipt_twin`, which records authenticated revalidation evidence but
|
|
702
|
+
executes no action. The flow remains opt-in: it does not register itself,
|
|
703
|
+
intercept whole prompts, survive capability restart, call a provider, or make a
|
|
704
|
+
hosted savings claim.
|
|
705
|
+
|
|
612
706
|
## Release checks
|
|
613
707
|
|
|
614
708
|
Before publishing or merging release-sensitive changes, run the copy check and both gates:
|
package/docs/distribution.md
CHANGED
|
@@ -27,6 +27,106 @@ context-guard setup --agent claude --scope user --plan
|
|
|
27
27
|
|
|
28
28
|
Project scope is the default. `context-guard doctor` and `context-guard setup --verify` are read-only health checks. User scope is opt-in and requires an explicit agent for writes. Supported user-scope writes record backups and rollback metadata under `.context-guard/rollback` in the user home directory. Setup resolves packaged/check-out helpers first; `PATH` helper fallback is default-off and requires `--allow-path-helper-fallback` for a trusted install after canonical executable and identity validation.
|
|
29
29
|
|
|
30
|
+
## Exact npm pair for Bash references
|
|
31
|
+
|
|
32
|
+
`bash_reference_v1` is a narrower distribution than the ordinary CLI/plugin.
|
|
33
|
+
It accepts only an exact project-local npm topology: root
|
|
34
|
+
`@ictechgy/context-guard@0.6.0` declares
|
|
35
|
+
`@ictechgy/context-guard-receipt: 0.2.1`, and the installed Receipt inventory
|
|
36
|
+
must match the SHA-256 trust anchor embedded in the root policy. Hoisted and
|
|
37
|
+
nested npm dependency layouts are supported; global npm, `npx`, Homebrew,
|
|
38
|
+
source-checkout, arbitrary `PATH`, and marketplace-plugin layouts are refused.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install --save-exact @ictechgy/context-guard@0.6.0
|
|
42
|
+
./node_modules/.bin/context-guard setup --root . --agent claude --scope project --bash-reference-v1 --plan
|
|
43
|
+
./node_modules/.bin/context-guard setup --root . --agent claude --scope project --bash-reference-v1 --yes
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Setup writes the opt-in flag only when the paired topology is present. Doctor
|
|
47
|
+
and source/plugin setup report it as unavailable otherwise and retain the
|
|
48
|
+
legacy Bash trim hook. Runtime discovery never launches Node by name from
|
|
49
|
+
`PATH`: it binds an absolute interpreter from fixed system locations, with a
|
|
50
|
+
GitHub Actions-only Node fallback restricted to fixed hosted-toolcache roots,
|
|
51
|
+
and rechecks the pinned Receipt files before starting one private broker. Before
|
|
52
|
+
Bash starts, every interpreter must be a regular, single-link executable owned
|
|
53
|
+
by root or the current user, executable, and not group- or world-writable. The
|
|
54
|
+
CI workflow validates the canonical hosted Python and Node locations, removes
|
|
55
|
+
group/world write permission from exactly those two ephemeral targets, and then
|
|
56
|
+
runs the same production preflight; `GITHUB_ACTIONS` never weakens this policy.
|
|
57
|
+
The broker has
|
|
58
|
+
already loaded its code and retained the repository, store, expiry, journal,
|
|
59
|
+
and anonymous owner-only capture descriptors. `COMMIT` therefore performs no
|
|
60
|
+
later package-path, interpreter, or Git lookup. Even a below-threshold command
|
|
61
|
+
can initialize the local state axes before the wrapper sends `ABORT`. A missing
|
|
62
|
+
strong sanitizer, changed package, invalid response, timeout, or unavailable
|
|
63
|
+
state yields legacy output, not a reference and not a changed child exit
|
|
64
|
+
status.
|
|
65
|
+
|
|
66
|
+
An issued digest contains the directly executable retrieval command below; it
|
|
67
|
+
must be run from the same physical project root:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
./node_modules/.bin/context-guard reference <cgr1p-handle>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The root command never accepts or reveals `--root` or `--state-dir`. It derives
|
|
74
|
+
the deterministic sibling state internally and returns at most one exact
|
|
75
|
+
20,000-byte sanitized UTF-8 page. If more content remains, a compact diagnostic
|
|
76
|
+
provides the next continuation `--offset`. Expansion rechecks the exact package,
|
|
77
|
+
root/source binding, and active seven-day registry entry; any failure emits no
|
|
78
|
+
payload.
|
|
79
|
+
|
|
80
|
+
The handle is provider-visible bearer material with an exact seven-day expiry.
|
|
81
|
+
State is placed outside the repository in a private sibling named
|
|
82
|
+
`.context-guard-receipt-state-<root-selector-sha256>`; the selector binds the
|
|
83
|
+
normalized root path and device/inode identity. This keeps Receipt state
|
|
84
|
+
physically disjoint from the repository snapshot and separates sibling roots.
|
|
85
|
+
Disablement removes only the hook flag, and npm uninstall removes package code
|
|
86
|
+
but deliberately leaves state/artifacts intact for a later exact reinstall or
|
|
87
|
+
separately authorized cleanup. After uninstall, the verified package-local code
|
|
88
|
+
and `node_modules/.bin/context-guard` are absent, so retrieval is unavailable
|
|
89
|
+
until the exact project-local pair is reinstalled:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
./node_modules/.bin/context-guard setup --root . --agent claude --scope project --no-bash-reference-v1 --yes --no-diet-scan
|
|
93
|
+
npm uninstall @ictechgy/context-guard
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Artifact deletion is not automated; it requires a separate, explicit
|
|
97
|
+
user-authorized retention decision. `--bash-reference-v1` and
|
|
98
|
+
`--artifact-receipt` are mutually exclusive.
|
|
99
|
+
|
|
100
|
+
## npm candidate, publication, and promotion gates
|
|
101
|
+
|
|
102
|
+
`.github/workflows/npm-candidate.yml` checks out one exact commit, runs both
|
|
103
|
+
package gates, packs each package exactly once offline, exercises the paired
|
|
104
|
+
tarballs in a clean install, and uploads immutable per-package artifacts. The
|
|
105
|
+
shared candidate manifest binds the commit, exact dependency, Receipt inventory
|
|
106
|
+
digest, policy digest, SHA-256, sha512 SRI, sizes, toolchain, and protocol. The
|
|
107
|
+
workflow refuses a requested commit that differs from its own workflow-source
|
|
108
|
+
commit so the later source and signer attestation digests bind the same revision.
|
|
109
|
+
|
|
110
|
+
`.github/workflows/npm-publish.yml` downloads an exact artifact by run and
|
|
111
|
+
artifact ID, revalidates the manifest and tarball, verifies GitHub build
|
|
112
|
+
provenance for both the candidate manifest and tarball against the candidate
|
|
113
|
+
source commit plus the exact trusted signer workflow revision, and publishes
|
|
114
|
+
only that tarball to `next`. Publishing the root also
|
|
115
|
+
requires the npm registry's Receipt `dist.integrity` to equal the Receipt bytes
|
|
116
|
+
bound in the same candidate manifest. Publication remains a manual,
|
|
117
|
+
environment-protected operation and is not performed by CI automatically.
|
|
118
|
+
|
|
119
|
+
`.github/workflows/npm-promote.yml` is a separate manual gate. Before changing
|
|
120
|
+
`latest`, it proves both requested versions are the current reviewed `next`
|
|
121
|
+
pair, verifies the root's exact Receipt dependency, and records the previous
|
|
122
|
+
tags for rollback. One manually approved `npm-pair-promote` environment exposes
|
|
123
|
+
the two package-scoped credentials only to the pair-mutation step. That same
|
|
124
|
+
shell moves Receipt then root and, on failure or ordinary cancellation, attempts
|
|
125
|
+
both compensating tag restores before it exits; no second environment approval
|
|
126
|
+
is needed for compensation. A force-cancel, unavailable npm registry, or
|
|
127
|
+
unavailable promotion credential can still prevent restoration; in that case
|
|
128
|
+
rerun the preflight and restore the recorded previous tags explicitly.
|
|
129
|
+
|
|
30
130
|
## Runtime requirements
|
|
31
131
|
|
|
32
132
|
The helpers are Python/shell scripts packaged through npm and Homebrew as plugin-local `plugins/context-guard/bin` entrypoints plus `plugins/context-guard/lib` helpers; checkout-only `context-guard-kit` sources are not duplicated in the npm tarball. Supported machines need:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ictechgy/context-guard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "ContextGuard CLI helpers for keeping AI coding agent context focused and local-first.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/ictechgy/context-guard#readme",
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
"url": "https://github.com/ictechgy/context-guard/issues"
|
|
13
13
|
},
|
|
14
14
|
"type": "commonjs",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@ictechgy/context-guard-receipt": "0.2.1"
|
|
17
|
+
},
|
|
15
18
|
"bin": {
|
|
16
19
|
"context-guard": "plugins/context-guard/bin/context-guard",
|
|
17
20
|
"context-guard-setup": "plugins/context-guard/bin/context-guard-setup",
|
|
@@ -22,6 +25,7 @@
|
|
|
22
25
|
"context-guard-sanitize-output": "plugins/context-guard/bin/context-guard-sanitize-output",
|
|
23
26
|
"context-guard-filter": "plugins/context-guard/bin/context-guard-filter",
|
|
24
27
|
"context-guard-artifact": "plugins/context-guard/bin/context-guard-artifact",
|
|
28
|
+
"context-guard-task-memory": "plugins/context-guard/bin/context-guard-task-memory",
|
|
25
29
|
"context-guard-pack": "plugins/context-guard/bin/context-guard-pack",
|
|
26
30
|
"context-guard-tool-prune": "plugins/context-guard/bin/context-guard-tool-prune",
|
|
27
31
|
"context-guard-compress": "plugins/context-guard/bin/context-guard-compress",
|
|
@@ -46,6 +46,15 @@ context-guard setup --agent codex --scope project --brief-mode standard --plan
|
|
|
46
46
|
npx @ictechgy/context-guard --version
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
짧은 `bash_reference_v1` Bash 출력 경로는 이 marketplace plugin/소스 배치에서
|
|
50
|
+
의도적으로 활성화되지 않습니다. 정확한 프로젝트 로컬
|
|
51
|
+
`@ictechgy/context-guard@0.6.0` npm 설치와
|
|
52
|
+
`@ictechgy/context-guard-receipt@0.2.1` 의존성이 필요하며, 그 뒤
|
|
53
|
+
`setup --agent claude --scope project --bash-reference-v1`로 명시적으로
|
|
54
|
+
활성화해야 합니다. Plugin setup은 동작하지 않는 reference flag를 설치하지 않고
|
|
55
|
+
legacy trim을 유지하며 경고합니다. 활성화·비활성화, 7일 handle, 상태 보존은
|
|
56
|
+
저장소의 배포 문서를 참고하세요.
|
|
57
|
+
|
|
49
58
|
이 저장소 루트에서는 경로를 직접 지정해 실행하세요.
|
|
50
59
|
|
|
51
60
|
```bash
|
|
@@ -69,6 +78,8 @@ context-guard-diet scan . --json
|
|
|
69
78
|
context-guard-artifact store --command "long-command" --json < large.log
|
|
70
79
|
context-guard-artifact receipt <artifact_id> --json
|
|
71
80
|
context-guard-artifact get <artifact_id> --lines 1:80
|
|
81
|
+
context-guard task-memory put --task issue-123 --source src/app.py --json < stable-context.txt
|
|
82
|
+
context-guard task-memory get <opaque_handle> --task issue-123 --source src/app.py --max-bytes 65536
|
|
72
83
|
context-guard-compress --json < large-output.txt
|
|
73
84
|
context-guard cost preflight --request request.json --budget-krw 3000 --json
|
|
74
85
|
context-guard cost observe --usage usage.json --json
|
|
@@ -78,6 +89,8 @@ context-guard-read-symbol path/to/file.py TargetSymbol
|
|
|
78
89
|
context-guard-sanitize-output -- rg -n "TOKEN|SECRET" .
|
|
79
90
|
context-guard-sanitize-output -- git diff
|
|
80
91
|
context-guard-pack auto --root . --query "failing tests review" --diff HEAD --manifest-out suggested-pack.json --pack-out context-pack.md --budget-bytes 12000 --json --explain --adaptive-k --adaptive-k-policy recall
|
|
92
|
+
context-guard-pack auto --root . --files src/app.py --query "entrypoint 검토" --top 1 --budget-bytes 12000 --json --no-artifact --apply-symbol-memory
|
|
93
|
+
context-guard-pack auto --root . --query "실패 테스트 검토" --top 8 --budget-bytes 12000 --json --no-artifact --apply-adaptive-k
|
|
81
94
|
context-guard-pack build --root . --manifest suggested-pack.json --budget-bytes 12000 --json
|
|
82
95
|
context-guard-pack build --root . --manifest suggested-pack.json --budget-bytes 12000 --json --no-artifact --delta-from-pack-id 0123456789abcdef0123
|
|
83
96
|
context-guard-pack slice --root . --path README.md --lines 1:40 --json
|
|
@@ -99,8 +112,16 @@ context-guard-statusline-merged
|
|
|
99
112
|
- **컨텍스트 관리 스캐너**는 누락된 `permissions.deny` 가드레일, Bash 출력 축약 훅, 상태표시줄 설정, 넓은 읽기 허용, 비용이 큰 기본 모델/추론 강도, 많은 MCP 서버, 크거나 민감해 보이는 에이전트 규칙 파일, 부피가 크거나 민감해 보이는 로컬 경로에 대한 자문형 context-exclusion 추천을 확인합니다.
|
|
100
113
|
- **대용량 읽기 가드와 심볼 리더**는 파일 전체 읽기 전에 검색, 심볼 구간, 작은 줄 범위 읽기 순서로 에이전트를 안내합니다. Python, JavaScript/TypeScript, Go, Rust 소스 구간 읽기를 지원합니다.
|
|
101
114
|
- **로컬 로그 보관소**는 큰 명령 출력을 기본적으로 `.context-guard/artifacts`에 가림 처리해 저장하고, 줄 번호가 있는 top error, 중복 라인 그룹, 가림 처리된 bounded suggested query, 안정적인 `contextguard-artifact:<id>` 핸들이 담긴 `output_sandbox` 요약 기록이나 요청한 정확한 줄 범위만 반환합니다. `receipt <artifact_id> --json`은 본문 없이 핸들과 재조회 명령만 다시 출력합니다. `get`과 `list`는 리브랜딩 이전의 `.claude-token-optimizer/artifacts` 요약 기록도 읽을 수 있습니다.
|
|
102
|
-
- **예산 기반 컨텍스트 패커**는 우선순위가 있는 로컬 파일 근거를 렌더링된 바이트 예산 안의 Markdown pack으로 조립하고, 포함·부분 포함·누락 source 메타데이터, bounded `.context-guard/packs` 요약 기록, 안전할 때만 정확한 가림 처리 `slice` 명령, 안전하지 않을 때의 `retrieval_omitted_reason`을 남깁니다. 추가된 `auto` 하위 명령은 추천과 pack build를 한 번에 실행하고, `auto --explain`은 manifest, pack 본문, receipt, byte budget을 바꾸지 않으면서 결정적 로컬 선택/build 이유를 짧게 추가합니다. JSON explain의 bounded repo-map은 sampled byte/token-proxy tree, category-only secret risk count, signature-first hint, explain-only graph rank, 기존 `slice`/symbol 재조회 힌트를 제공하지만 pack 선택이나 provider savings claim은 아닙니다. `suggest`는 로컬 query, diff, 명시 파일, 가림 처리된 output/test-output 신호를 `build`와 호환되는 manifest로 순위화하며 네트워크·모델 호출·임베딩·provider 비용 추정은 하지 않습니다. `suggest/auto --adaptive-k`는 `--adaptive-k-policy balanced|recall|precision` 및 선택적 recall/precision proxy gate, capped selected/omitted evidence, 구조화된 source-verification hint를 제공하지만 추천값을 자동 적용하거나 manifest/pack/receipt를 바꾸지 않습니다. 토큰 수는 측정된 provider token 절감이 아니라 추정 `chars_div_4` proxy입니다.
|
|
115
|
+
- **예산 기반 컨텍스트 패커**는 우선순위가 있는 로컬 파일 근거를 렌더링된 바이트 예산 안의 Markdown pack으로 조립하고, 포함·부분 포함·누락 source 메타데이터, bounded `.context-guard/packs` 요약 기록, 안전할 때만 정확한 가림 처리 `slice` 명령, 안전하지 않을 때의 `retrieval_omitted_reason`을 남깁니다. 추가된 `auto` 하위 명령은 추천과 pack build를 한 번에 실행하고, `auto --explain`은 manifest, pack 본문, receipt, byte budget을 바꾸지 않으면서 결정적 로컬 선택/build 이유를 짧게 추가합니다. JSON explain의 bounded repo-map은 sampled byte/token-proxy tree, category-only secret risk count, signature-first hint, explain-only graph rank, 기존 `slice`/symbol 재조회 힌트를 제공하지만 pack 선택이나 provider savings claim은 아닙니다. `suggest`는 로컬 query, diff, 명시 파일, 가림 처리된 output/test-output 신호를 `build`와 호환되는 manifest로 순위화하며 네트워크·모델 호출·임베딩·provider 비용 추정은 하지 않습니다. `suggest/auto --adaptive-k`는 `--adaptive-k-policy balanced|recall|precision` 및 선택적 recall/precision proxy gate, capped selected/omitted evidence, 구조화된 source-verification hint를 제공하지만 추천값을 자동 적용하거나 manifest/pack/receipt를 바꾸지 않습니다. 명시적 `auto --apply-symbol-memory`는 안전한 direct import neighbor slice를 최대 4개 manifest에 추가하고 동일 byte budget으로 다시 build합니다. explicit/query seed의 우선순위를 보존하고 secret-risk neighbor를 제외하며 exact fallback과 닫힌 `graph_application` 근거를 남깁니다. 토큰 수는 측정된 provider token 절감이 아니라 추정 `chars_div_4` proxy입니다.
|
|
116
|
+
- `auto --self-financing-selection`은 기본 비활성 조합 경로로 Adaptive, task-matching Symbol, bounded one-hop Graph 순서로 ordinary-pack byte ceiling 안에서 적용합니다. caller/critical source는 대체하지 않으며 각 후보의 frozen identity, secret 판단, byte delta, exact fallback, replacement removal 또는 정직한 no-op을 기록합니다. provider savings 주장은 하지 않습니다.
|
|
117
|
+
- `auto --selection-plan --json`은 query, diff, output/log, symbol, self-financing 입력에서 provider-free read-only closed plan만 출력합니다. 저장한 plan은 같은 입력에 `--apply-selection-plan PATH`를 별도로 지정해야 적용됩니다. apply는 출력 전에 plan과 source identity를 다시 검증하며 incomplete scan, secret-risk/scorer-private 입력, drift, unsafe output boundary, exact recovery 누락을 fail-closed로 거부합니다.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
context-guard-pack auto --root . --query "retry 수정" --diff worktree --output logs/test.txt --json --selection-plan > selection-plan.json
|
|
121
|
+
context-guard-pack auto --root . --query "retry 수정" --diff worktree --output logs/test.txt --json --apply-selection-plan selection-plan.json --no-artifact
|
|
122
|
+
```
|
|
103
123
|
- **Tool/MCP schema pruner**는 로컬 tool catalog를 bounded top-k 자문 리포트로 순위화하고, compact 요약 기록과 payload integrity check로 전체 가림 처리된 schema 재조회를 보존합니다. `defer-report`는 core inline tool과 deferred stub/namespace 요약을 나누고 gross deferred-schema 및 net initial-report `chars_div_4` proxy 회계를 보여주지만, deferred tool을 쓰기 전에는 전체 schema를 다시 조회해야 합니다.
|
|
124
|
+
- **적용형 adaptive breadth**는 명시적 `auto --apply-adaptive-k`에서만 동작합니다. 로컬 회귀 gate 통과 뒤 heuristic source를 줄이고 caller가 지정한 file/output/test-output 및 diff source는 항상 보존하며, 같은 byte budget으로 다시 build하고 `adaptive_k_application`을 기록합니다. 로컬 proxy는 provider token/cost 절감 주장을 허용하지 않습니다.
|
|
104
125
|
- **보수적 압축기**는 가림 처리된 stdin을 JSON, diff, 로그, 검색 출력, 코드, 산문으로 분류하고, 관측 바이트 근거와 추정 토큰 proxy를 함께 노출합니다.
|
|
105
126
|
- **정적 cache-score lint와 Anthropic 비용 가드/route advisor**는 `context-guard-cache-score`로 로컬 prompt/request cache layout과 사용자 제공 cache write/read multiplier 기반 amortization 위험을 안내하고, `context-guard cost preflight/observe/ledger/compile`로 호출 전 비용 추정, provider usage 대조, keyed-HMAC cache 위험 기록, 안정적인 prefix 배치 안내를 제공합니다. `context-guard route-advisor`는 caller가 제공한 workload JSON, provider feature 선언, usage telemetry, 외부·로컬 shifted cost를 읽는 local-only passive advisor이며 queue를 시작하거나 provider를 호출하거나 pricing 문서를 새로 가져오거나 provider feature 지식을 authoritative하게 취급하지 않고 total-cost accounting, batchability blocker, route 후보를 출력합니다. 원문 프롬프트를 저장하지 않고 Anthropic/provider prompt cache를 대체하지 않으며, 추천은 matched successful task, 비열등 quality evidence, shifted-cost accounting 없이는 hosted token/cost 절감 주장이 아닙니다.
|
|
106
127
|
- **출력 축약기**는 감싼 명령의 종료 코드를 보존하면서 긴 로그를 줄이고, `--digest markdown` 또는 `--digest json`으로 실행기 실패 정보, 가림 처리된 failure signature, 중복 라인 그룹, 다음 조회 제안이 담긴 요약을 만들 수 있습니다. `--artifact-receipt`를 digest mode와 함께 쓰면 sanitized 전체 출력을 로컬 artifact receipt로 저장하고 `contextguard-artifact:<id>` 핸들과 `context-guard-artifact receipt/get/search ...` 재조회 명령으로 누락된 slice를 다시 확장할 수 있습니다.
|
|
@@ -160,6 +181,18 @@ context-guard experiments verify proof-carrying-context --artifact-dir ./artifac
|
|
|
160
181
|
|
|
161
182
|
`context-guard mcp`와 `context-guard-mcp`는 의존성 없는 로컬 stdio MCP 자식 프로세스를 실행합니다. 프로세스는 root와 namespace 하나로 격리되고 sanitization된 compression, 정확한 sanitization artifact fallback, 로컬 통계만 제공합니다. HTTP, 네트워크, provider, model, proxy 통합이나 client 설정 변경은 없습니다. artifact는 namespace 사이에서 접근할 수 없고 hosted token/cost 절감도 주장하지 않습니다.
|
|
162
183
|
|
|
184
|
+
설치된 Receipt companion도
|
|
185
|
+
`context-guard-receipt-mcp --root /absolute/repository`로 명시적으로 실행할 수
|
|
186
|
+
있습니다. `receipt_context` 도구는 사용자가 `eligible`이라고 명시한 상대
|
|
187
|
+
파일·로그를 보수적 byte router가 유리하다고 판단할 때 compact process-local
|
|
188
|
+
exact reference로 저장하고, 같은 live reference를 재사용하며, 한 번에 최대
|
|
189
|
+
65,536바이트의 exact slice를 조회합니다. 선택적 task scope와 명시적 release는
|
|
190
|
+
process-local context GC를 제공하고, content-free history에는 keyed digest와
|
|
191
|
+
결정만 남습니다. `receipt_diagnose`는 비적용 firewall/router와 prefix 재사용
|
|
192
|
+
scout/surgeon 안내를 제공하며, 명시적 private `--state-dir`는 authenticated
|
|
193
|
+
advisory `receipt_twin`만 활성화합니다. 자동 등록, prompt 가로채기, capability의
|
|
194
|
+
재시작 후 지속 저장, provider 호출, hosted 절감 주장은 하지 않습니다.
|
|
195
|
+
|
|
163
196
|
## 로컬 배포 테스트
|
|
164
197
|
|
|
165
198
|
마켓플레이스 저장소 루트에서 실행합니다.
|