@ictechgy/context-guard 0.4.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 +49 -0
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.ko.md +353 -0
- package/README.md +353 -0
- package/context-guard-kit/README.md +76 -0
- package/context-guard-kit/benchmark_runner.py +1898 -0
- package/context-guard-kit/claude_transcript_cost_audit.py +1591 -0
- package/context-guard-kit/context_compress.py +543 -0
- package/context-guard-kit/context_escrow.py +919 -0
- package/context-guard-kit/context_guard_cli.py +149 -0
- package/context-guard-kit/context_guard_diet.py +1036 -0
- package/context-guard-kit/context_pack.py +929 -0
- package/context-guard-kit/failed_attempt_nudge.py +567 -0
- package/context-guard-kit/guard_large_read.py +690 -0
- package/context-guard-kit/hook_secret_patterns.py +43 -0
- package/context-guard-kit/read_symbol.py +483 -0
- package/context-guard-kit/rewrite_bash_for_token_budget.py +501 -0
- package/context-guard-kit/sanitize_output.py +725 -0
- package/context-guard-kit/settings.example.json +67 -0
- package/context-guard-kit/setup_wizard.py +1724 -0
- package/context-guard-kit/statusline.sh +362 -0
- package/context-guard-kit/statusline_merged.sh +157 -0
- package/context-guard-kit/tool_schema_pruner.py +837 -0
- package/context-guard-kit/trim_command_output.py +1098 -0
- package/docs/distribution.md +55 -0
- package/package.json +70 -0
- package/packaging/homebrew/context-guard.rb.template +34 -0
- package/plugins/context-guard/.claude-plugin/plugin.json +41 -0
- package/plugins/context-guard/LICENSE +201 -0
- package/plugins/context-guard/NOTICE +4 -0
- package/plugins/context-guard/README.ko.md +135 -0
- package/plugins/context-guard/README.md +135 -0
- package/plugins/context-guard/bin/claude-read-symbol +6 -0
- package/plugins/context-guard/bin/claude-sanitize-output +6 -0
- package/plugins/context-guard/bin/claude-token-artifact +6 -0
- package/plugins/context-guard/bin/claude-token-audit +6 -0
- package/plugins/context-guard/bin/claude-token-bench +6 -0
- package/plugins/context-guard/bin/claude-token-diet +6 -0
- package/plugins/context-guard/bin/claude-token-failed-nudge +6 -0
- package/plugins/context-guard/bin/claude-token-guard-read +6 -0
- package/plugins/context-guard/bin/claude-token-rewrite-bash +6 -0
- package/plugins/context-guard/bin/claude-token-setup +6 -0
- package/plugins/context-guard/bin/claude-token-statusline +6 -0
- package/plugins/context-guard/bin/claude-token-statusline-merged +6 -0
- package/plugins/context-guard/bin/claude-trim-output +6 -0
- package/plugins/context-guard/bin/context-guard +149 -0
- package/plugins/context-guard/bin/context-guard-artifact +919 -0
- package/plugins/context-guard/bin/context-guard-audit +1591 -0
- package/plugins/context-guard/bin/context-guard-bench +1898 -0
- package/plugins/context-guard/bin/context-guard-compress +543 -0
- package/plugins/context-guard/bin/context-guard-diet +1036 -0
- package/plugins/context-guard/bin/context-guard-failed-nudge +567 -0
- package/plugins/context-guard/bin/context-guard-guard-read +690 -0
- package/plugins/context-guard/bin/context-guard-pack +929 -0
- package/plugins/context-guard/bin/context-guard-read-symbol +483 -0
- package/plugins/context-guard/bin/context-guard-rewrite-bash +501 -0
- package/plugins/context-guard/bin/context-guard-sanitize-output +725 -0
- package/plugins/context-guard/bin/context-guard-setup +1724 -0
- package/plugins/context-guard/bin/context-guard-statusline +362 -0
- package/plugins/context-guard/bin/context-guard-statusline-merged +157 -0
- package/plugins/context-guard/bin/context-guard-tool-prune +837 -0
- package/plugins/context-guard/bin/context-guard-trim-output +1098 -0
- package/plugins/context-guard/brief/README.md +65 -0
- package/plugins/context-guard/brief/brief-mode.lite.md +29 -0
- package/plugins/context-guard/brief/brief-mode.standard.md +31 -0
- package/plugins/context-guard/brief/brief-mode.ultra.md +32 -0
- package/plugins/context-guard/lib/hook_secret_patterns.py +43 -0
- package/plugins/context-guard/skills/audit/SKILL.md +39 -0
- package/plugins/context-guard/skills/optimize/SKILL.md +48 -0
- package/plugins/context-guard/skills/setup/SKILL.md +40 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# ContextGuard distribution plan
|
|
2
|
+
|
|
3
|
+
ContextGuard separates **install** from **activation**.
|
|
4
|
+
|
|
5
|
+
- Install exposes local commands or Claude Code plugin skills.
|
|
6
|
+
- Activation is explicit and scoped through `context-guard setup` or `/context-guard:setup`.
|
|
7
|
+
- Package installation must not write project or user configuration.
|
|
8
|
+
|
|
9
|
+
## Supported install paths
|
|
10
|
+
|
|
11
|
+
| Path | Status | Command | Notes |
|
|
12
|
+
| --- | --- | --- | --- |
|
|
13
|
+
| Claude Code plugin | shipped | `/plugin marketplace add ictechgy/context-guard` then `/plugin install context-guard@context-guard` | Best native Claude Code workflow. |
|
|
14
|
+
| npm global | added | `npm install -g @ictechgy/context-guard` | Installs `context-guard` and helper aliases on PATH. |
|
|
15
|
+
| npx/npm exec | added | `npx @ictechgy/context-guard --version` | One-off usage; activation still requires explicit setup. |
|
|
16
|
+
| Homebrew | draft | `brew tap ictechgy/contextguard && brew install context-guard` | Formula template exists under `packaging/homebrew/`; publish after release artifact SHA is known. |
|
|
17
|
+
|
|
18
|
+
## Activation examples
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
context-guard setup --agent codex --scope project --with-init --with-skill --plan
|
|
22
|
+
context-guard setup --agent codex --scope project --with-init --with-skill --yes
|
|
23
|
+
context-guard setup --agent claude --scope user --plan
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Project scope is the default. 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.
|
|
27
|
+
|
|
28
|
+
## Runtime requirements
|
|
29
|
+
|
|
30
|
+
The helpers are Python/shell scripts packaged through npm and Homebrew. Supported machines need:
|
|
31
|
+
|
|
32
|
+
- macOS or Linux
|
|
33
|
+
- Python 3 available as `python3`
|
|
34
|
+
- POSIX no-follow file operations for setup writes
|
|
35
|
+
- Node/npm only for npm/npx install paths
|
|
36
|
+
|
|
37
|
+
## Non-goals for this release
|
|
38
|
+
|
|
39
|
+
- No install-time `postinstall` configuration writes.
|
|
40
|
+
- No sudo/root/system configuration writes.
|
|
41
|
+
- No claim of native activation for agents whose current safe user-level path has not been verified.
|
|
42
|
+
- No fixed token or cost savings claim from packaging alone.
|
|
43
|
+
|
|
44
|
+
## Homebrew formula release checks
|
|
45
|
+
|
|
46
|
+
Before publishing the Homebrew tap, run the formula-specific checks locally or in CI when Homebrew is available:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
brew style packaging/homebrew/context-guard.rb
|
|
50
|
+
brew audit --strict --new packaging/homebrew/context-guard.rb
|
|
51
|
+
brew install --build-from-source packaging/homebrew/context-guard.rb
|
|
52
|
+
brew test context-guard
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The formula should rewrite Python shebangs to the declared Homebrew Python dependency and expose both `context-guard` and legacy compatibility wrappers from `plugins/context-guard/bin`.
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ictechgy/context-guard",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "ContextGuard CLI helpers for keeping AI coding agent context focused and local-first.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://github.com/ictechgy/context-guard#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/ictechgy/context-guard.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/ictechgy/context-guard/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "commonjs",
|
|
15
|
+
"bin": {
|
|
16
|
+
"context-guard": "plugins/context-guard/bin/context-guard",
|
|
17
|
+
"context-guard-setup": "plugins/context-guard/bin/context-guard-setup",
|
|
18
|
+
"context-guard-diet": "plugins/context-guard/bin/context-guard-diet",
|
|
19
|
+
"context-guard-audit": "plugins/context-guard/bin/context-guard-audit",
|
|
20
|
+
"context-guard-trim-output": "plugins/context-guard/bin/context-guard-trim-output",
|
|
21
|
+
"context-guard-sanitize-output": "plugins/context-guard/bin/context-guard-sanitize-output",
|
|
22
|
+
"context-guard-artifact": "plugins/context-guard/bin/context-guard-artifact",
|
|
23
|
+
"context-guard-pack": "plugins/context-guard/bin/context-guard-pack",
|
|
24
|
+
"context-guard-tool-prune": "plugins/context-guard/bin/context-guard-tool-prune",
|
|
25
|
+
"context-guard-compress": "plugins/context-guard/bin/context-guard-compress",
|
|
26
|
+
"context-guard-bench": "plugins/context-guard/bin/context-guard-bench",
|
|
27
|
+
"context-guard-read-symbol": "plugins/context-guard/bin/context-guard-read-symbol",
|
|
28
|
+
"context-guard-rewrite-bash": "plugins/context-guard/bin/context-guard-rewrite-bash",
|
|
29
|
+
"context-guard-guard-read": "plugins/context-guard/bin/context-guard-guard-read",
|
|
30
|
+
"context-guard-failed-nudge": "plugins/context-guard/bin/context-guard-failed-nudge",
|
|
31
|
+
"context-guard-statusline": "plugins/context-guard/bin/context-guard-statusline",
|
|
32
|
+
"context-guard-statusline-merged": "plugins/context-guard/bin/context-guard-statusline-merged"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"CHANGELOG.md",
|
|
36
|
+
"LICENSE",
|
|
37
|
+
"NOTICE",
|
|
38
|
+
"README.md",
|
|
39
|
+
"README.ko.md",
|
|
40
|
+
"context-guard-kit/*.py",
|
|
41
|
+
"context-guard-kit/*.sh",
|
|
42
|
+
"context-guard-kit/README.md",
|
|
43
|
+
"context-guard-kit/settings.example.json",
|
|
44
|
+
"plugins/context-guard/.claude-plugin/plugin.json",
|
|
45
|
+
"plugins/context-guard/README.md",
|
|
46
|
+
"plugins/context-guard/README.ko.md",
|
|
47
|
+
"plugins/context-guard/LICENSE",
|
|
48
|
+
"plugins/context-guard/bin/**",
|
|
49
|
+
"plugins/context-guard/brief/**",
|
|
50
|
+
"plugins/context-guard/lib/**",
|
|
51
|
+
"plugins/context-guard/skills/**",
|
|
52
|
+
"docs/distribution.md",
|
|
53
|
+
"packaging/homebrew/context-guard.rb.template"
|
|
54
|
+
],
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=18"
|
|
57
|
+
},
|
|
58
|
+
"os": [
|
|
59
|
+
"darwin",
|
|
60
|
+
"linux"
|
|
61
|
+
],
|
|
62
|
+
"keywords": [
|
|
63
|
+
"ai",
|
|
64
|
+
"codex",
|
|
65
|
+
"claude-code",
|
|
66
|
+
"context",
|
|
67
|
+
"token-budget",
|
|
68
|
+
"cli"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Homebrew formula draft for ContextGuard.
|
|
2
|
+
# Replace URL/SHA/tag during release packaging; do not publish with SHA placeholder.
|
|
3
|
+
class ContextGuard < Formula
|
|
4
|
+
include Language::Python::Shebang
|
|
5
|
+
|
|
6
|
+
desc "Local-first context guardrails for AI coding agents"
|
|
7
|
+
homepage "https://github.com/ictechgy/context-guard"
|
|
8
|
+
url "https://github.com/ictechgy/context-guard/archive/refs/tags/v0.4.0.tar.gz"
|
|
9
|
+
sha256 "REPLACE_WITH_RELEASE_TARBALL_SHA256"
|
|
10
|
+
license "Apache-2.0"
|
|
11
|
+
|
|
12
|
+
depends_on "python@3.12"
|
|
13
|
+
|
|
14
|
+
def install
|
|
15
|
+
libexec.install "CHANGELOG.md", "LICENSE", "NOTICE", "README.md", "README.ko.md"
|
|
16
|
+
libexec.install "context-guard-kit"
|
|
17
|
+
libexec.install "plugins"
|
|
18
|
+
|
|
19
|
+
python_shebang = detected_python_shebang
|
|
20
|
+
Dir[libexec/"plugins/context-guard/bin/*"].each do |command|
|
|
21
|
+
next unless command.file?
|
|
22
|
+
|
|
23
|
+
first_line = command.open { |file| file.gets.to_s }
|
|
24
|
+
rewrite_shebang python_shebang, command if first_line.include?("python")
|
|
25
|
+
bin.write_exec_script command
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
test do
|
|
30
|
+
assert_match version.to_s, shell_output("#{bin}/context-guard --version")
|
|
31
|
+
mkdir testpath/"project"
|
|
32
|
+
system bin/"context-guard", "setup", "--root", testpath/"project", "--agent", "codex", "--scope", "project", "--plan"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "context-guard",
|
|
3
|
+
"description": "ContextGuard keeps AI coding-agent context lean, safe, and auditable with project-local setup, scans, large-read guards, output trimming/sanitizing, queryable log artifacts, budgeted context packs, tool/MCP schema pruning, statusline visibility, and usage audits.",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "jinhongan"
|
|
6
|
+
},
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"context-safety",
|
|
10
|
+
"context-hygiene",
|
|
11
|
+
"context-guard",
|
|
12
|
+
"claude-code",
|
|
13
|
+
"tokens",
|
|
14
|
+
"cost",
|
|
15
|
+
"context",
|
|
16
|
+
"settings",
|
|
17
|
+
"diet",
|
|
18
|
+
"read-symbol",
|
|
19
|
+
"large-read-guard",
|
|
20
|
+
"statusline",
|
|
21
|
+
"hooks",
|
|
22
|
+
"sanitize-output",
|
|
23
|
+
"grep-sanitizer",
|
|
24
|
+
"diff-sanitizer",
|
|
25
|
+
"secret-redaction",
|
|
26
|
+
"setup-wizard",
|
|
27
|
+
"interactive-setup",
|
|
28
|
+
"artifact-escrow",
|
|
29
|
+
"context-escrow",
|
|
30
|
+
"queryable-logs",
|
|
31
|
+
"tool-schema",
|
|
32
|
+
"mcp",
|
|
33
|
+
"schema-pruning",
|
|
34
|
+
"context-pack",
|
|
35
|
+
"research-radar",
|
|
36
|
+
"experimental-roadmap",
|
|
37
|
+
"gated-experiments",
|
|
38
|
+
"future-roadmap"
|
|
39
|
+
],
|
|
40
|
+
"version": "0.4.0"
|
|
41
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# ContextGuard
|
|
2
|
+
|
|
3
|
+
ContextGuard는 AI 코딩·도구 에이전트를 위한 로컬 우선 컨텍스트 관리 도구 모음입니다. Claude Code 플러그인으로 가장 먼저 제공되며, 같은 프로젝트 로컬 가드레일을 일반 로컬 헬퍼 명령과 안내용 brief 모드 규칙 스니펫으로 다른 에이전트에도 확장합니다.
|
|
4
|
+
|
|
5
|
+
가장 먼저 `/context-guard:setup`을 실행하세요. 설정은 명시적이며, 프로젝트 단위로 적용되고, 되돌릴 수 있습니다. 권장 프로젝트 설정을 병합하고, 읽기 전용 컨텍스트 관리 검사 요약을 출력하며, 전역 Claude 설정은 변경하지 않습니다. 외부 AI에 작업을 넘기거나 대신 실행하도록 설정하지도 않습니다.
|
|
6
|
+
|
|
7
|
+
## 줄이려는 토큰 낭비 경로
|
|
8
|
+
|
|
9
|
+
ContextGuard는 provider prompt cache나 semantic answer cache가 아니라 로컬 컨텍스트 관리 계층입니다. 에이전트 대화에 들어가기 전에 큰 파일은 검색·심볼·줄 범위 읽기로 좁히고, 긴 명령 출력은 축약하거나 요약하며, 큰 로그는 로컬 보관 요약 기록으로 남깁니다. 또한 민감 정보처럼 보이는 값과 경로를 최대한 가리고, Bash 실패가 반복되면 전략을 바꾸도록 알리며, 제한된 가림 처리된 segment hash로 캐시 친화적 프롬프트 배치를 감사하고, 감사·벤치마크로 실제 작업의 전후 비교 근거를 남기도록 돕습니다.
|
|
10
|
+
|
|
11
|
+
## 리브랜딩 참고
|
|
12
|
+
|
|
13
|
+
Claude Code는 예전 `/claude-token-optimizer:*` 플러그인 슬래시 명령을 별칭으로 제공하지 않습니다. 설치 후에는 `/context-guard:*`를 사용하세요.
|
|
14
|
+
|
|
15
|
+
기존 자동화가 바로 깨지지 않도록 로컬 CLI 호환 래퍼(`claude-token-*`, `claude-read-symbol`, `claude-trim-output`, `claude-sanitize-output`)는 `bin/`에 계속 포함합니다.
|
|
16
|
+
|
|
17
|
+
## 스킬
|
|
18
|
+
|
|
19
|
+
설치 후 Claude Code 안에서 다음 스킬을 사용할 수 있습니다.
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
/context-guard:setup
|
|
23
|
+
/context-guard:optimize
|
|
24
|
+
/context-guard:audit
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| 스킬 | 용도 |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| `/context-guard:setup` | 처음 적용할 때 쓰는 프로젝트 설정 마법사입니다. |
|
|
30
|
+
| `/context-guard:optimize` | 컨텍스트 가드레일을 점검하고 조정합니다. |
|
|
31
|
+
| `/context-guard:audit` | 로컬 Claude 대화 기록의 토큰·비용 집중 지점을 확인합니다. |
|
|
32
|
+
|
|
33
|
+
## 헬퍼 명령과 PATH
|
|
34
|
+
|
|
35
|
+
대표 명령은 `context-guard`이고, 기존 호환 헬퍼는 `context-guard-*` 접두사를 유지합니다. Claude Code 플러그인 스킬은 패키지에 포함된 헬퍼를 호출할 수 있지만, 일반 셸의 `PATH`에 플러그인 `bin/` 디렉터리가 자동으로 추가된다고 보장할 수는 없습니다.
|
|
36
|
+
|
|
37
|
+
Codex나 다른 터미널 기반 에이전트에서는 npm 패키지를 설치하거나 npx로 한 번만 실행할 수 있습니다. 설치 자체는 설정 파일을 쓰지 않는 수동적 단계입니다.
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install -g @ictechgy/context-guard
|
|
41
|
+
context-guard setup --agent codex --scope project --with-init --with-skill --plan
|
|
42
|
+
npx @ictechgy/context-guard --version
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
이 저장소 루트에서는 경로를 직접 지정해 실행하세요.
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
./plugins/context-guard/bin/context-guard-setup --plan
|
|
49
|
+
./plugins/context-guard/bin/context-guard-diet scan . --json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
로컬 개발 중 짧은 명령으로 실행하려면 현재 셸에 플러그인 bin 경로를 추가하세요.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
export PATH="$PWD/plugins/context-guard/bin:$PATH"
|
|
56
|
+
context-guard-setup --plan
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
자주 쓰는 헬퍼는 다음과 같습니다.
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
context-guard-audit ~/.claude/projects --top 20 --recommend
|
|
63
|
+
context-guard-setup
|
|
64
|
+
context-guard-diet scan . --json
|
|
65
|
+
context-guard-artifact store --command "long-command" --json < large.log
|
|
66
|
+
context-guard-artifact get <artifact_id> --lines 1:80
|
|
67
|
+
context-guard-compress --json < large-output.txt
|
|
68
|
+
context-guard-trim-output --max-lines 120 -- npm test
|
|
69
|
+
context-guard-read-symbol path/to/file.py TargetSymbol
|
|
70
|
+
context-guard-sanitize-output -- rg -n "TOKEN|SECRET" .
|
|
71
|
+
context-guard-sanitize-output -- git diff
|
|
72
|
+
context-guard-pack build --root . --source 'path=README.md,priority=100,lines=1:80' --budget-bytes 12000 --json
|
|
73
|
+
context-guard-pack slice --root . --path README.md --lines 1:40 --json
|
|
74
|
+
context-guard-tool-prune select --catalog tools.json --query "review failing tests" --top 5 --budget-bytes 12000 --json
|
|
75
|
+
context-guard-tool-prune get <receipt_id> --tool read_file --json
|
|
76
|
+
context-guard-statusline
|
|
77
|
+
context-guard-statusline-merged
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 헬퍼가 하는 일
|
|
81
|
+
|
|
82
|
+
- **설정 마법사**는 `.claude/settings.json`을 덮어쓰지 않고 병합한 뒤, 읽기 전용 `context-guard-diet scan` 요약을 출력합니다. 자동화에서 적용 후 검사 요약이 필요 없으면 `--no-diet-scan`을 사용하세요.
|
|
83
|
+
- **컨텍스트 관리 스캐너**는 누락된 `permissions.deny` 가드레일, Bash 출력 축약 훅, 상태표시줄 설정, 넓은 읽기 허용, 비용이 큰 기본 모델/추론 강도, 많은 MCP 서버, 크거나 민감해 보이는 에이전트 규칙 파일, bulky/sensitive 로컬 경로에 대한 자문형 context-exclusion 추천을 확인합니다.
|
|
84
|
+
- **대용량 읽기 가드와 심볼 리더**는 파일 전체 읽기 전에 검색, 심볼 구간, 작은 줄 범위 읽기 순서로 에이전트를 안내합니다. Python, JavaScript/TypeScript, Go, Rust 소스 구간 읽기를 지원합니다.
|
|
85
|
+
- **로컬 로그 보관소**는 큰 명령 출력을 기본적으로 `.context-guard/artifacts`에 가림 처리해 저장하고, 줄 번호가 있는 top error, 중복 라인 그룹, 가림 처리된 bounded suggested query가 담긴 요약 기록이나 요청한 정확한 줄 범위만 반환합니다. `get`과 `list`는 리브랜딩 이전의 `.claude-token-optimizer/artifacts` 요약 기록도 읽을 수 있습니다.
|
|
86
|
+
- **예산 기반 컨텍스트 패커**는 우선순위가 있는 로컬 파일 근거를 렌더링된 바이트 예산 안의 Markdown pack으로 조립하고, 포함·부분 포함·누락 source 메타데이터, bounded `.context-guard/packs` 요약 기록, 안전할 때만 정확한 가림 처리 `slice` 명령, 안전하지 않을 때의 `retrieval_omitted_reason`을 남깁니다. 토큰 수는 측정된 provider token 절감이 아니라 추정 `chars_div_4` proxy입니다.
|
|
87
|
+
- **Tool/MCP schema pruner**는 로컬 tool catalog를 bounded top-k 자문 리포트로 순위화하고, compact 요약 기록과 payload integrity check로 전체 가림 처리된 schema 재조회를 보존합니다.
|
|
88
|
+
- **보수적 압축기**는 가림 처리된 stdin을 JSON, diff, 로그, 검색 출력, 코드, 산문으로 분류하고, 관측 바이트 근거와 추정 토큰 proxy를 함께 노출합니다.
|
|
89
|
+
- **출력 축약기**는 감싼 명령의 종료 코드를 보존하면서 긴 로그를 줄이고, `--digest markdown` 또는 `--digest json`으로 실행기 실패 정보, 가림 처리된 failure signature, 중복 라인 그룹, 다음 조회 제안이 담긴 요약을 만들 수 있습니다.
|
|
90
|
+
- **민감정보 가림 도구**는 검색, diff, 로그 출력에서 자격 증명 패턴, 비공개 키 블록, 인증 헤더, 자격 증명이 포함된 URL, 민감해 보이는 경로를 가립니다.
|
|
91
|
+
- **상태표시줄**은 모델, 컨텍스트, 비용 신호를 짧게 보여주고, 대화 기록 데이터가 있으면 캐시 읽기와 캐시 재사용 신호도 함께 표시합니다.
|
|
92
|
+
- **대화 기록 감사**는 usage/cost/cache bucket을 집계하고, 토큰 집중 지점과 `cache_friendliness` 프롬프트 배치 신호를 제한된 가림 처리된 segment hash로 보고합니다. 원문 프롬프트는 출력하지 않습니다.
|
|
93
|
+
- **반복 실패 알림**은 Bash 실패가 반복될 때 같은 경로를 계속 재시도하지 않고 전략을 바꾸도록 안내합니다.
|
|
94
|
+
- **벤치마크 헬퍼**는 기준/변형 실행을 대응해 실제 토큰·비용 필드, 별도의 바이트 감소 간접 증거, 진단용 `wall_time_seconds`, `provider_cached_tokens`, provider-cache 사용 가능성 텔레메트리로 기록합니다.
|
|
95
|
+
|
|
96
|
+
## brief 모드 (권고)
|
|
97
|
+
|
|
98
|
+
brief 모드는 코딩 에이전트가 군더더기를 줄이되 증거(파일 경로, 명령, 명령 출력과 오류, 코드 블록, 검증 상태, 변경 파일, 남은 과제, 주의사항)는 유지하도록 요청하는 에이전트 중립·안내용 규칙 스니펫을 제공합니다. 강제가 아니라 최선 노력 안내이며, 토큰·비용 절감을 **보장하지 않습니다.**
|
|
99
|
+
|
|
100
|
+
세 가지 결정적 레벨(`lite`, `standard`, `ultra`)이 [`brief/`](brief/)에 있습니다. 각 레벨은 마커로 구분된 하나의 블록이며, 에이전트의 규칙·지시 파일(`AGENTS.md`, `CLAUDE.md`, Cursor 규칙 파일, Copilot 지시 등)에 설치하고 블록을 지워서 제거합니다. 자세한 내용은 [`brief/README.md`](brief/README.md)를 참고하세요.
|
|
101
|
+
|
|
102
|
+
## 절감 수치를 과장하지 않습니다
|
|
103
|
+
|
|
104
|
+
이 헬퍼들은 흔히 컨텍스트를 불필요하게 키우는 원인을 줄이지만, 고정된 절감률을 보장하지 않습니다. 실제 전후 비교 증거가 필요하면 `context-guard-bench --ledger-jsonl ... --report-json ...`로 본인 작업에서 측정하세요. 토큰 절감 주장은 대응 태스크 양쪽 모두에 `primary_tokens_measured`가 있을 때만 계산하며, wall-time과 provider-cache 필드는 진단용 텔레메트리이지 단독 절감 증거가 아닙니다. 감사의 `cache_friendliness`는 휴리스틱 배치 신호이며 청구 기준이 아닙니다. 벤치마크 CSV 스키마는 엄격하므로 헬퍼 업그레이드 후에는 새 CSV를 시작하거나 헤더를 마이그레이션하세요.
|
|
105
|
+
|
|
106
|
+
ContextGuard는 모델 토큰을 줄이기 위해 작업을 외부 AI 서비스로 전송하지 않습니다. 모든 헬퍼 명령은 로컬에서 동작합니다.
|
|
107
|
+
|
|
108
|
+
미래 learned, multimodal, self-hosted 최적화 아이디어는 [`../../research/experimental-token-reduction-radar.md`](../../research/experimental-token-reduction-radar.md)에만 gated experiment로 기록합니다. 이 radar는 제공 중인 runtime 기능이 아니며, provider가 측정한 matched-task 근거 없이 hosted API 절감을 주장하지 않습니다.
|
|
109
|
+
|
|
110
|
+
교차 에이전트 규칙 스니펫은 권고 사항입니다. 대상 에이전트가 반드시 따른다고 보장할 수 없으므로, 절감 주장이 필요하면 실제 전후 동작을 직접 측정하세요.
|
|
111
|
+
|
|
112
|
+
## 로컬 배포 테스트
|
|
113
|
+
|
|
114
|
+
마켓플레이스 저장소 루트에서 실행합니다.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
claude --plugin-dir ./plugins/context-guard
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
그다음 Claude Code 안에서 실행합니다.
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
/context-guard:setup
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
마켓플레이스 설치 테스트:
|
|
127
|
+
|
|
128
|
+
```text
|
|
129
|
+
/plugin marketplace add ./
|
|
130
|
+
/plugin install context-guard@context-guard
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## 라이선스
|
|
134
|
+
|
|
135
|
+
Copyright 2026 jinhongan. Apache License 2.0으로 배포됩니다. [LICENSE](LICENSE)와 [NOTICE](NOTICE)를 참고하세요.
|