@harness-forge/cli 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/token-budget-optimizer/SKILL.md +26 -0
- package/AGENTS.md +4 -1
- package/README.md +4 -3
- package/docs/agent-usage-playbook.md +22 -0
- package/docs/agents.md +5 -0
- package/docs/authoring/token-budget-optimizer-port.md +78 -0
- package/manifests/catalog/compatibility-matrix.json +35 -1
- package/manifests/catalog/index.json +1 -0
- package/manifests/catalog/package-surface.json +15 -0
- package/manifests/catalog/token-budget-optimizer-import-inventory.json +146 -0
- package/package.json +1 -1
- package/skills/README.md +6 -0
- package/skills/token-budget-optimizer/SKILL.md +56 -0
- package/skills/token-budget-optimizer/references/audit-dimensions.md +37 -0
- package/skills/token-budget-optimizer/references/promotion-ladder.md +44 -0
- package/skills/token-budget-optimizer/references/report-template.md +25 -0
- package/skills/token-budget-optimizer/references/scoring-model.md +43 -0
- package/skills/token-budget-optimizer/scripts/inspect_token_surfaces.py +68 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: token-budget-optimizer
|
|
3
|
+
description: Auto-discoverable wrapper for `.hforge/library/skills/token-budget-optimizer/SKILL.md`.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Token Budget Optimizer
|
|
7
|
+
|
|
8
|
+
## Activation
|
|
9
|
+
|
|
10
|
+
- trigger when context is getting large, repetitive, or expensive to keep in active prompt history
|
|
11
|
+
- trigger when the repo already has runtime summaries, task artifacts, decisions, or specs that can be reused instead of re-read
|
|
12
|
+
- trigger before broad repo rescans when the next safe answer may already exist in `.hforge/` or other authoritative guidance surfaces
|
|
13
|
+
|
|
14
|
+
## Use These Surfaces
|
|
15
|
+
|
|
16
|
+
- `.hforge/library/skills/token-budget-optimizer/SKILL.md`
|
|
17
|
+
- `.hforge/library/skills/token-budget-optimizer/references/`
|
|
18
|
+
- `.hforge/library/skills/token-budget-optimizer/scripts/inspect_token_surfaces.py`
|
|
19
|
+
- `.hforge/library/docs/authoring/token-budget-optimizer-port.md`
|
|
20
|
+
|
|
21
|
+
## Operating Rule
|
|
22
|
+
|
|
23
|
+
Use the canonical skill under `.hforge/library/skills/` for execution. Treat
|
|
24
|
+
this wrapper as a discovery entrypoint only, prefer the smallest authoritative
|
|
25
|
+
runtime surfaces first, and use the maintainer-facing port note only when the
|
|
26
|
+
import rationale or promotion intent matters.
|
package/AGENTS.md
CHANGED
|
@@ -60,6 +60,7 @@ Use the thin visible bridge surfaces first in installed workspaces:
|
|
|
60
60
|
|
|
61
61
|
- prefer `.hforge/library/skills/cloud-architect/` when the task is about deployment topology, distributed systems, reliability, observability, or cloud trade-offs across services
|
|
62
62
|
- prefer `.hforge/library/skills/engineering-assistant/` when the task needs architecture plus implementation orchestration, option framing, or explicit project-memory and change-discipline guidance in one surface
|
|
63
|
+
- prefer `.hforge/library/skills/token-budget-optimizer/` when prompt history is growing, repo context is being repeated, or existing runtime artifacts should be reused before broader rescans
|
|
63
64
|
- use `.hforge/library/manifests/catalog/framework-assets.json` and `.hforge/runtime/repo/recommendations.json` when framework or bundle matching is more reliable than guessing from file extensions
|
|
64
65
|
|
|
65
66
|
## Imported skill governance
|
|
@@ -67,8 +68,10 @@ Use the thin visible bridge surfaces first in installed workspaces:
|
|
|
67
68
|
- treat `.hforge/library/manifests/catalog/engineering-assistant-import-inventory.json` as the review ledger for the single-skill engineering-assistant port
|
|
68
69
|
- keep maintainer-facing provenance for that port in `.hforge/library/docs/authoring/engineering-assistant-port.md`
|
|
69
70
|
- treat `.hforge/library/manifests/catalog/enhanced-skill-import-inventory.json` as the review ledger for embedded skill packs and use it before changing imported skill surfaces
|
|
71
|
+
- treat `.hforge/library/manifests/catalog/token-budget-optimizer-import-inventory.json` as the review ledger for the token-budget-optimizer port and promotion rationale
|
|
70
72
|
- treat `.agents/skills/` as the discovery layer and `.hforge/library/skills/` as the canonical installed execution layer
|
|
71
73
|
- keep maintainer-facing provenance in `.hforge/library/docs/authoring/enhanced-skill-import.md`
|
|
74
|
+
- keep maintainer-facing provenance for token-budget optimization in `.hforge/library/docs/authoring/token-budget-optimizer-port.md`
|
|
72
75
|
- use `RESEARCH-SOURCES.md` and `VALIDATION.md` only as additional provenance, not as replacements for the canonical installed skill surfaces
|
|
73
76
|
- prefer the project-owned canonical `.hforge/library/skills/` surfaces over any raw imported archive layout
|
|
74
77
|
|
|
@@ -123,4 +126,4 @@ Use the thin visible bridge surfaces first in installed workspaces:
|
|
|
123
126
|
## Usage promotion
|
|
124
127
|
|
|
125
128
|
- if an operator wants stronger Harness Forge usage in day-to-day agent work, use `docs/agent-usage-playbook.md`
|
|
126
|
-
- prefer the playbook prompts when you want the agent to prove it is reading the installed guidance layer, use the command catalog, create task artifacts, write decision records, or escalate into recursive mode
|
|
129
|
+
- prefer the playbook prompts when you want the agent to prove it is reading the installed guidance layer, use the command catalog, compact context efficiently, create task artifacts, write decision records, or escalate into recursive mode
|
package/README.md
CHANGED
|
@@ -101,7 +101,7 @@ Instead of relying on one-off prompts or tribal setup knowledge, it gives you a
|
|
|
101
101
|
| 🎯 Runtime targets | 4 target surfaces: Codex, Claude Code, Cursor, OpenCode |
|
|
102
102
|
| 🧠 Knowledge system | 14 language packs total: 5 seeded + 9 structured |
|
|
103
103
|
| 🧩 Framework coverage | 12 framework packs including React, Next.js, Vite, Express, FastAPI, Django, ASP.NET Core, Spring Boot, Laravel, Symfony, Gin, and Ktor |
|
|
104
|
-
| 🛠 Skills |
|
|
104
|
+
| 🛠 Skills | 45 packaged skills across language engineering, workflow orchestration, operational helpers, and workload-specialized flows |
|
|
105
105
|
| 🔁 Flow support | `.specify/` spec → plan → tasks → implement flow plus flow-state recovery |
|
|
106
106
|
| 🔬 Intelligence | `scan`, `recommend`, `cartograph`, `classify-boundaries`, and `synthesize-instructions` |
|
|
107
107
|
| 📊 Local observability | Effectiveness summaries, recommendation acceptance, hook runs, maintenance traces, and runtime summaries |
|
|
@@ -267,6 +267,7 @@ Harness Forge can lower token burn because it gives the agent:
|
|
|
267
267
|
- focused runtime summaries
|
|
268
268
|
- machine-readable manifests
|
|
269
269
|
- curated skills
|
|
270
|
+
- a promoted token-budget-optimizer skill for context compaction and reuse-first work
|
|
270
271
|
- reusable task/state artifacts
|
|
271
272
|
- repo-aware recommendations
|
|
272
273
|
- structured entrypoints instead of blind exploration
|
|
@@ -418,7 +419,7 @@ Harness Forge is strongest with **Codex** and **Claude Code** today.
|
|
|
418
419
|
- structured language engineering skills
|
|
419
420
|
- Speckit workflow orchestration skills
|
|
420
421
|
- operational helper skills
|
|
421
|
-
- workload-specialized skills such as incident triage, dependency upgrade safety, profiling, API contract review, database migration review, release readiness, repo modernization, observability setup, and
|
|
422
|
+
- workload-specialized skills such as incident triage, dependency upgrade safety, profiling, API contract review, database migration review, release readiness, repo modernization, observability setup, cloud architecture, and token-budget optimization
|
|
422
423
|
|
|
423
424
|
---
|
|
424
425
|
|
|
@@ -724,7 +725,7 @@ That playbook includes:
|
|
|
724
725
|
|
|
725
726
|
- launcher-aware command resolution when `hforge` is not on `PATH`
|
|
726
727
|
- concrete operator prompts that tell agents to read the installed runtime
|
|
727
|
-
- examples for task artifacts, decision records, recursive mode, and
|
|
728
|
+
- examples for task artifacts, decision records, recursive mode, support verification, and token-budget compaction
|
|
728
729
|
|
|
729
730
|
In runtimes that expose packaged markdown commands, Harness Forge can also ship
|
|
730
731
|
triggerable command docs such as `/hforge-init`, `/hforge-analyze`,
|
|
@@ -50,6 +50,8 @@ following:
|
|
|
50
50
|
- uses `status`, `commands`, `recommend`, `review`, `task`, or `recursive` instead of inventing unsupported commands
|
|
51
51
|
- reads `.hforge/runtime/repo/repo-map.json` or `.hforge/runtime/repo/recommendations.json` before making support claims
|
|
52
52
|
- writes durable artifacts only when the workflow actually calls for them
|
|
53
|
+
- compacts context by reusing runtime summaries, task artifacts, and decision
|
|
54
|
+
records instead of rereading wide repo surfaces
|
|
53
55
|
|
|
54
56
|
## Important limitation
|
|
55
57
|
|
|
@@ -92,6 +94,15 @@ hforge recursive plan "investigate the issue" --task-id TASK-001 --root . --json
|
|
|
92
94
|
hforge recursive capabilities --root . --json
|
|
93
95
|
```
|
|
94
96
|
|
|
97
|
+
If the task is large or the prompt is getting expensive:
|
|
98
|
+
|
|
99
|
+
```text
|
|
100
|
+
Load .agents/skills/token-budget-optimizer/SKILL.md and use the installed
|
|
101
|
+
token-budget-optimizer skill before broad repo scanning. Reuse existing
|
|
102
|
+
runtime summaries, task artifacts, and decision records first, then tell me
|
|
103
|
+
which surfaces you will keep loaded and which ones you can compact away.
|
|
104
|
+
```
|
|
105
|
+
|
|
95
106
|
## Prompt patterns
|
|
96
107
|
|
|
97
108
|
### 1. Prove that the agent is using Harness Forge
|
|
@@ -165,6 +176,17 @@ output, before claiming that Claude Code, Codex, Cursor, or OpenCode supports a
|
|
|
165
176
|
behavior.
|
|
166
177
|
```
|
|
167
178
|
|
|
179
|
+
### 8. Force context compaction and reuse
|
|
180
|
+
|
|
181
|
+
Use this when the task is long-running or the agent is repeating repo scans:
|
|
182
|
+
|
|
183
|
+
```text
|
|
184
|
+
Use the installed Harness Forge token-budget-optimizer skill before you expand
|
|
185
|
+
context further. Reuse existing runtime summaries, task artifacts, and decision
|
|
186
|
+
records first. Tell me what you will keep loaded, what you will compact, and
|
|
187
|
+
what new evidence still requires a focused read.
|
|
188
|
+
```
|
|
189
|
+
|
|
168
190
|
## Claude-specific examples
|
|
169
191
|
|
|
170
192
|
```text
|
package/docs/agents.md
CHANGED
|
@@ -20,6 +20,7 @@ AI content into the hidden `.hforge/` layer.
|
|
|
20
20
|
- `docs/agent-usage-playbook.md` for copy-ready prompts and examples that make
|
|
21
21
|
agents use the installed Harness Forge runtime more explicitly
|
|
22
22
|
- `docs/authoring/enhanced-skill-import.md` for curated research and validation provenance behind imported skill upgrades
|
|
23
|
+
- `docs/authoring/token-budget-optimizer-port.md` for maintainer-facing provenance behind the promoted context-compaction skill
|
|
23
24
|
- `RESEARCH-SOURCES.md` and `VALIDATION.md` for optional pack-level provenance detail
|
|
24
25
|
|
|
25
26
|
## When agents should use Harness Forge
|
|
@@ -36,6 +37,8 @@ AI content into the hidden `.hforge/` layer.
|
|
|
36
37
|
an explicit recursive session instead of growing the prompt
|
|
37
38
|
- when a recursive session needs one bounded structured analysis step with a
|
|
38
39
|
durable run record instead of chat-only reasoning
|
|
40
|
+
- when prompt history is growing and the next safe answer may already exist in
|
|
41
|
+
`.hforge/runtime/`, task artifacts, or decision records
|
|
39
42
|
|
|
40
43
|
## Discovery rule
|
|
41
44
|
|
|
@@ -58,3 +61,5 @@ AI content into the hidden `.hforge/` layer.
|
|
|
58
61
|
`.hforge/agent-manifest.json` first and treat every surface it marks
|
|
59
62
|
`treatAsProductCode: false` as AI-layer content rather than application code
|
|
60
63
|
- use `docs/authoring/enhanced-skill-import.md`, `RESEARCH-SOURCES.md`, and `VALIDATION.md` only when provenance or import rationale matters
|
|
64
|
+
- use `.agents/skills/token-budget-optimizer/SKILL.md` when the next safe step
|
|
65
|
+
depends on compacting context and reusing authoritative runtime surfaces
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Token Budget Optimizer Port Governance
|
|
2
|
+
|
|
3
|
+
This document records how the March 2026 `hforge-token-budget-optimizer`
|
|
4
|
+
archive was ported into Harness Forge.
|
|
5
|
+
|
|
6
|
+
## Source pack
|
|
7
|
+
|
|
8
|
+
- Pack name: `Harness Forge Token Budget Optimizer Skill Pack`
|
|
9
|
+
- Inventory record: `manifests/catalog/token-budget-optimizer-import-inventory.json`
|
|
10
|
+
- Imported scope:
|
|
11
|
+
- context compaction and reuse-first operating guidance
|
|
12
|
+
- token-surface audit heuristics
|
|
13
|
+
- a promotion ladder for choosing what belongs in active context
|
|
14
|
+
- a deterministic helper script for identifying high-value low-cost surfaces
|
|
15
|
+
- OpenAI-oriented runtime metadata in `agents/openai.yaml`
|
|
16
|
+
|
|
17
|
+
## Canonical outcome
|
|
18
|
+
|
|
19
|
+
Harness Forge now owns one canonical token-budget optimization surface at
|
|
20
|
+
`skills/token-budget-optimizer/SKILL.md`.
|
|
21
|
+
|
|
22
|
+
The port preserves the imported pack's distinctive value:
|
|
23
|
+
|
|
24
|
+
- compact first, scan later
|
|
25
|
+
- prefer authoritative runtime summaries over repeated broad repo reads
|
|
26
|
+
- keep context costs explicit instead of relying on intuition alone
|
|
27
|
+
- reuse task artifacts, decision records, repo maps, and command catalogs before
|
|
28
|
+
re-deriving them in chat
|
|
29
|
+
|
|
30
|
+
## Artifact decisions
|
|
31
|
+
|
|
32
|
+
| Imported artifact | Outcome | Project-owned destination | Why |
|
|
33
|
+
| --- | --- | --- | --- |
|
|
34
|
+
| `hforge-token-budget-optimizer/SKILL.md` | embed | `skills/token-budget-optimizer/SKILL.md` | the responsibility is distinct and should be first-class in the skill library |
|
|
35
|
+
| `hforge-token-budget-optimizer/references/*.md` | embed | `skills/token-budget-optimizer/references/` | the audit dimensions, promotion ladder, scoring model, and report template are direct runtime guidance |
|
|
36
|
+
| `hforge-token-budget-optimizer/scripts/inspect_token_surfaces.py` | embed | `skills/token-budget-optimizer/scripts/inspect_token_surfaces.py` | the helper is deterministic and useful across supported runtimes |
|
|
37
|
+
| `hforge-token-budget-optimizer/agents/openai.yaml` | translate | this document plus the canonical wrapper | runtime-specific metadata becomes maintainer provenance instead of a universal contract |
|
|
38
|
+
|
|
39
|
+
## Imported metadata summary
|
|
40
|
+
|
|
41
|
+
The source pack carried one OpenAI-oriented descriptor under
|
|
42
|
+
`agents/openai.yaml`. Harness Forge treats that file as provenance only and
|
|
43
|
+
keeps cross-agent discovery in the project-owned wrapper under
|
|
44
|
+
`.agents/skills/token-budget-optimizer/SKILL.md`.
|
|
45
|
+
|
|
46
|
+
## Promotion intent
|
|
47
|
+
|
|
48
|
+
This skill is intentionally promoted because it improves one of Harness Forge's
|
|
49
|
+
core product promises: lower token burn through better reuse of installed
|
|
50
|
+
runtime knowledge.
|
|
51
|
+
|
|
52
|
+
The intended workflow is:
|
|
53
|
+
|
|
54
|
+
1. consult existing runtime and task artifacts first
|
|
55
|
+
2. keep only the smallest authoritative set of surfaces in active context
|
|
56
|
+
3. expand into focused code reads only when the compact context is not enough
|
|
57
|
+
|
|
58
|
+
## Runtime compatibility baseline
|
|
59
|
+
|
|
60
|
+
- Codex: translated support through canonical skill, wrapper, and packaged helper
|
|
61
|
+
script
|
|
62
|
+
- Claude Code: translated support through canonical skill, wrapper, and packaged
|
|
63
|
+
helper script
|
|
64
|
+
- Cursor: guidance-first support
|
|
65
|
+
- OpenCode: guidance-first support
|
|
66
|
+
|
|
67
|
+
This keeps support claims honest while still making the skill broadly usable.
|
|
68
|
+
|
|
69
|
+
## Acceptance rules for future updates
|
|
70
|
+
|
|
71
|
+
- keep `manifests/catalog/token-budget-optimizer-import-inventory.json` aligned
|
|
72
|
+
with every imported artifact and follow-up translation
|
|
73
|
+
- preserve one canonical `skills/token-budget-optimizer/` surface instead of
|
|
74
|
+
creating variants with overlapping responsibility
|
|
75
|
+
- do not promote compaction in ways that hide release gates, support posture,
|
|
76
|
+
migration steps, or other safety-critical details
|
|
77
|
+
- keep runtime-specific metadata maintainer-facing unless project-owned
|
|
78
|
+
cross-agent surfaces are explicitly added
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generatedAt": "2026-03-
|
|
2
|
+
"generatedAt": "2026-03-29T00:26:01.295Z",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
5
|
"subjectType": "language",
|
|
@@ -1264,6 +1264,14 @@
|
|
|
1264
1264
|
"relatedId": "test-strategy-and-coverage",
|
|
1265
1265
|
"supportLevel": "full"
|
|
1266
1266
|
},
|
|
1267
|
+
{
|
|
1268
|
+
"subjectType": "target",
|
|
1269
|
+
"subjectId": "claude-code",
|
|
1270
|
+
"relationType": "supports",
|
|
1271
|
+
"relatedType": "skill",
|
|
1272
|
+
"relatedId": "token-budget-optimizer",
|
|
1273
|
+
"supportLevel": "full"
|
|
1274
|
+
},
|
|
1267
1275
|
{
|
|
1268
1276
|
"subjectType": "target",
|
|
1269
1277
|
"subjectId": "claude-code",
|
|
@@ -2099,6 +2107,14 @@
|
|
|
2099
2107
|
"relatedId": "test-strategy-and-coverage",
|
|
2100
2108
|
"supportLevel": "full"
|
|
2101
2109
|
},
|
|
2110
|
+
{
|
|
2111
|
+
"subjectType": "target",
|
|
2112
|
+
"subjectId": "codex",
|
|
2113
|
+
"relationType": "supports",
|
|
2114
|
+
"relatedType": "skill",
|
|
2115
|
+
"relatedId": "token-budget-optimizer",
|
|
2116
|
+
"supportLevel": "full"
|
|
2117
|
+
},
|
|
2102
2118
|
{
|
|
2103
2119
|
"subjectType": "target",
|
|
2104
2120
|
"subjectId": "codex",
|
|
@@ -3019,6 +3035,15 @@
|
|
|
3019
3035
|
"supportLevel": "partial",
|
|
3020
3036
|
"notes": "Cursor only provides partial skill support for test-strategy-and-coverage."
|
|
3021
3037
|
},
|
|
3038
|
+
{
|
|
3039
|
+
"subjectType": "target",
|
|
3040
|
+
"subjectId": "cursor",
|
|
3041
|
+
"relationType": "supports",
|
|
3042
|
+
"relatedType": "skill",
|
|
3043
|
+
"relatedId": "token-budget-optimizer",
|
|
3044
|
+
"supportLevel": "partial",
|
|
3045
|
+
"notes": "Cursor only provides partial skill support for token-budget-optimizer."
|
|
3046
|
+
},
|
|
3022
3047
|
{
|
|
3023
3048
|
"subjectType": "target",
|
|
3024
3049
|
"subjectId": "cursor",
|
|
@@ -3940,6 +3965,15 @@
|
|
|
3940
3965
|
"supportLevel": "partial",
|
|
3941
3966
|
"notes": "OpenCode only provides partial skill support for test-strategy-and-coverage."
|
|
3942
3967
|
},
|
|
3968
|
+
{
|
|
3969
|
+
"subjectType": "target",
|
|
3970
|
+
"subjectId": "opencode",
|
|
3971
|
+
"relationType": "supports",
|
|
3972
|
+
"relatedType": "skill",
|
|
3973
|
+
"relatedId": "token-budget-optimizer",
|
|
3974
|
+
"supportLevel": "partial",
|
|
3975
|
+
"notes": "OpenCode only provides partial skill support for token-budget-optimizer."
|
|
3976
|
+
},
|
|
3943
3977
|
{
|
|
3944
3978
|
"subjectType": "target",
|
|
3945
3979
|
"subjectId": "opencode",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"manifests/catalog/flow-artifacts.json",
|
|
30
30
|
"manifests/catalog/engineering-assistant-import-inventory.json",
|
|
31
31
|
"manifests/catalog/enhanced-skill-import-inventory.json",
|
|
32
|
+
"manifests/catalog/token-budget-optimizer-import-inventory.json",
|
|
32
33
|
"manifests/catalog/package-surface.json",
|
|
33
34
|
"manifests/catalog/seeded-knowledge-files.json"
|
|
34
35
|
],
|
|
@@ -49,12 +49,14 @@
|
|
|
49
49
|
".agents/skills/javascript-engineering/SKILL.md",
|
|
50
50
|
".agents/skills/cloud-architect/SKILL.md",
|
|
51
51
|
".agents/skills/recursive-structured-analysis/SKILL.md",
|
|
52
|
+
".agents/skills/token-budget-optimizer/SKILL.md",
|
|
52
53
|
"docs/catalog/language-packs.md",
|
|
53
54
|
"docs/catalog/framework-packs.md",
|
|
54
55
|
"docs/templates/authoring.md",
|
|
55
56
|
"docs/authoring/skills.md",
|
|
56
57
|
"docs/authoring/engineering-assistant-port.md",
|
|
57
58
|
"docs/authoring/enhanced-skill-import.md",
|
|
59
|
+
"docs/authoring/token-budget-optimizer-port.md",
|
|
58
60
|
"docs/flow-orchestration.md",
|
|
59
61
|
"docs/generated-artifacts.md",
|
|
60
62
|
"docs/hooks/catalog.md",
|
|
@@ -100,6 +102,12 @@
|
|
|
100
102
|
"skills/javascript-engineering",
|
|
101
103
|
"skills/cloud-architect",
|
|
102
104
|
"skills/recursive-structured-analysis/SKILL.md",
|
|
105
|
+
"skills/token-budget-optimizer/SKILL.md",
|
|
106
|
+
"skills/token-budget-optimizer/references/audit-dimensions.md",
|
|
107
|
+
"skills/token-budget-optimizer/references/promotion-ladder.md",
|
|
108
|
+
"skills/token-budget-optimizer/references/scoring-model.md",
|
|
109
|
+
"skills/token-budget-optimizer/references/report-template.md",
|
|
110
|
+
"skills/token-budget-optimizer/scripts/inspect_token_surfaces.py",
|
|
103
111
|
"skills/repo-onboarding/SKILL.md",
|
|
104
112
|
"skills/documentation-lookup/SKILL.md",
|
|
105
113
|
"skills/security-scan/SKILL.md",
|
|
@@ -176,6 +184,7 @@
|
|
|
176
184
|
"manifests/catalog/flow-artifacts.json",
|
|
177
185
|
"manifests/catalog/engineering-assistant-import-inventory.json",
|
|
178
186
|
"manifests/catalog/enhanced-skill-import-inventory.json",
|
|
187
|
+
"manifests/catalog/token-budget-optimizer-import-inventory.json",
|
|
179
188
|
"manifests/catalog/seeded-knowledge-files.json",
|
|
180
189
|
"manifests/catalog/package-surface.json",
|
|
181
190
|
"manifests/hooks/index.json",
|
|
@@ -242,6 +251,7 @@
|
|
|
242
251
|
"docs/maintenance-lifecycle.md",
|
|
243
252
|
"docs/release-process.md",
|
|
244
253
|
"docs/authoring/engineering-assistant-port.md",
|
|
254
|
+
"docs/authoring/token-budget-optimizer-port.md",
|
|
245
255
|
"docs/observability.md",
|
|
246
256
|
"docs/benchmark-scenarios.md",
|
|
247
257
|
"docs/troubleshooting.md",
|
|
@@ -371,11 +381,14 @@
|
|
|
371
381
|
"paths": [
|
|
372
382
|
"manifests/catalog/engineering-assistant-import-inventory.json",
|
|
373
383
|
"docs/authoring/engineering-assistant-port.md",
|
|
384
|
+
"docs/authoring/token-budget-optimizer-port.md",
|
|
374
385
|
"skills/engineering-assistant/references/architecture.md",
|
|
375
386
|
"skills/engineering-assistant/references/project-notes.md",
|
|
376
387
|
"skills/engineering-assistant/references/change-discipline.md",
|
|
377
388
|
"manifests/catalog/enhanced-skill-import-inventory.json",
|
|
389
|
+
"manifests/catalog/token-budget-optimizer-import-inventory.json",
|
|
378
390
|
"docs/authoring/enhanced-skill-import.md",
|
|
391
|
+
"docs/authoring/token-budget-optimizer-port.md",
|
|
379
392
|
"skills/repo-onboarding/references/discovery-checklist.md",
|
|
380
393
|
"skills/architecture-decision-records/references/decision-rubric.md",
|
|
381
394
|
"skills/api-contract-review/references/review-template.md",
|
|
@@ -426,6 +439,7 @@
|
|
|
426
439
|
".agents/skills/javascript-engineering/SKILL.md",
|
|
427
440
|
".agents/skills/cloud-architect/SKILL.md",
|
|
428
441
|
".agents/skills/recursive-structured-analysis/SKILL.md",
|
|
442
|
+
".agents/skills/token-budget-optimizer/SKILL.md",
|
|
429
443
|
"targets/codex/adapter.json",
|
|
430
444
|
"targets/codex/runtime/.codex",
|
|
431
445
|
"scripts/codex/apply-home-config.mjs",
|
|
@@ -457,6 +471,7 @@
|
|
|
457
471
|
".agents/skills/javascript-engineering/SKILL.md",
|
|
458
472
|
".agents/skills/cloud-architect/SKILL.md",
|
|
459
473
|
".agents/skills/recursive-structured-analysis/SKILL.md",
|
|
474
|
+
".agents/skills/token-budget-optimizer/SKILL.md",
|
|
460
475
|
"targets/claude-code/adapter.json",
|
|
461
476
|
"targets/claude-code/runtime/.claude",
|
|
462
477
|
"hooks"
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
{
|
|
2
|
+
"packId": "token-budget-optimizer-2026-03",
|
|
3
|
+
"sourceName": "Harness Forge Token Budget Optimizer Skill Pack",
|
|
4
|
+
"sourceVersion": "2026-03-29-import",
|
|
5
|
+
"resourceRoots": [
|
|
6
|
+
"hforge-token-budget-optimizer/"
|
|
7
|
+
],
|
|
8
|
+
"summary": "Governed port record for the imported token-budget-optimizer skill, preserving its context-compaction and reuse-first intent while translating the pack into project-owned canonical skill, wrapper, references, and helper surfaces.",
|
|
9
|
+
"validationScope": "The port validates canonical skill ownership, wrapper discovery coverage, package-surface registration, and front-door promotion for token-efficient agent operation. Runtime-native slash commands are intentionally not required for this skill.",
|
|
10
|
+
"researchScope": "The imported pack contributes context-compaction guidance, reuse-first operating rules, token-surface audit dimensions, a scoring model, a promotion ladder, and a deterministic helper script for identifying high-value low-cost runtime surfaces.",
|
|
11
|
+
"entries": [
|
|
12
|
+
{
|
|
13
|
+
"artifactPath": "hforge-token-budget-optimizer/SKILL.md",
|
|
14
|
+
"artifactType": "skill",
|
|
15
|
+
"skillId": "token-budget-optimizer",
|
|
16
|
+
"existingProjectSurface": null,
|
|
17
|
+
"decision": "embed",
|
|
18
|
+
"decisionReason": "The imported pack owns a distinct runtime responsibility around context compaction and reuse-first navigation, so it should ship as one canonical skill rather than being folded into a broader helper.",
|
|
19
|
+
"destinationPath": "skills/token-budget-optimizer/SKILL.md",
|
|
20
|
+
"reviewStatus": "accepted"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"artifactPath": "hforge-token-budget-optimizer/references/audit-dimensions.md",
|
|
24
|
+
"artifactType": "reference",
|
|
25
|
+
"skillId": "token-budget-optimizer",
|
|
26
|
+
"existingProjectSurface": null,
|
|
27
|
+
"decision": "embed",
|
|
28
|
+
"decisionReason": "The audit dimensions are direct supporting guidance for deciding which surfaces deserve active prompt space.",
|
|
29
|
+
"destinationPath": "skills/token-budget-optimizer/references/audit-dimensions.md",
|
|
30
|
+
"reviewStatus": "accepted"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"artifactPath": "hforge-token-budget-optimizer/references/promotion-ladder.md",
|
|
34
|
+
"artifactType": "reference",
|
|
35
|
+
"skillId": "token-budget-optimizer",
|
|
36
|
+
"existingProjectSurface": null,
|
|
37
|
+
"decision": "embed",
|
|
38
|
+
"decisionReason": "The promotion ladder turns the imported context-reuse idea into a reusable operating model for agents in installed workspaces.",
|
|
39
|
+
"destinationPath": "skills/token-budget-optimizer/references/promotion-ladder.md",
|
|
40
|
+
"reviewStatus": "accepted"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"artifactPath": "hforge-token-budget-optimizer/references/scoring-model.md",
|
|
44
|
+
"artifactType": "reference",
|
|
45
|
+
"skillId": "token-budget-optimizer",
|
|
46
|
+
"existingProjectSurface": null,
|
|
47
|
+
"decision": "embed",
|
|
48
|
+
"decisionReason": "The scoring model is a direct supporting heuristic for choosing low-cost high-authority context surfaces.",
|
|
49
|
+
"destinationPath": "skills/token-budget-optimizer/references/scoring-model.md",
|
|
50
|
+
"reviewStatus": "accepted"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"artifactPath": "hforge-token-budget-optimizer/references/report-template.md",
|
|
54
|
+
"artifactType": "reference",
|
|
55
|
+
"skillId": "token-budget-optimizer",
|
|
56
|
+
"existingProjectSurface": null,
|
|
57
|
+
"decision": "embed",
|
|
58
|
+
"decisionReason": "The report template preserves the imported pack's goal of making compaction decisions explicit and reviewable.",
|
|
59
|
+
"destinationPath": "skills/token-budget-optimizer/references/report-template.md",
|
|
60
|
+
"reviewStatus": "accepted"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"artifactPath": "hforge-token-budget-optimizer/scripts/inspect_token_surfaces.py",
|
|
64
|
+
"artifactType": "script",
|
|
65
|
+
"skillId": "token-budget-optimizer",
|
|
66
|
+
"existingProjectSurface": null,
|
|
67
|
+
"decision": "embed",
|
|
68
|
+
"decisionReason": "The helper script is deterministic, package-owned, and directly useful for ranking reusable context surfaces before an agent expands prompt history.",
|
|
69
|
+
"destinationPath": "skills/token-budget-optimizer/scripts/inspect_token_surfaces.py",
|
|
70
|
+
"reviewStatus": "accepted"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"artifactPath": "hforge-token-budget-optimizer/agents/openai.yaml",
|
|
74
|
+
"artifactType": "metadata",
|
|
75
|
+
"skillId": "token-budget-optimizer",
|
|
76
|
+
"existingProjectSurface": null,
|
|
77
|
+
"decision": "translate",
|
|
78
|
+
"decisionReason": "The source runtime metadata is treated as pack provenance while the project expresses cross-agent discovery through the canonical wrapper and maintainer-facing port note.",
|
|
79
|
+
"destinationPath": "docs/authoring/token-budget-optimizer-port.md",
|
|
80
|
+
"reviewStatus": "accepted"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"artifactPath": "hforge-token-budget-optimizer/.agents-wrapper",
|
|
84
|
+
"artifactType": "wrapper",
|
|
85
|
+
"skillId": "token-budget-optimizer",
|
|
86
|
+
"existingProjectSurface": null,
|
|
87
|
+
"decision": "embed",
|
|
88
|
+
"decisionReason": "The imported skill needs a visible discovery wrapper so Codex and Claude Code can find the canonical token-optimization workflow quickly.",
|
|
89
|
+
"destinationPath": ".agents/skills/token-budget-optimizer/SKILL.md",
|
|
90
|
+
"reviewStatus": "accepted"
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"compatibilityProfiles": [
|
|
94
|
+
{
|
|
95
|
+
"targetId": "codex",
|
|
96
|
+
"supportLevel": "translated",
|
|
97
|
+
"metadataMode": "translated",
|
|
98
|
+
"helperMode": "packaged-script",
|
|
99
|
+
"notes": "Codex consumes the canonical skill and wrapper directly, and can optionally run the helper script when a deterministic token-surface audit is useful."
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"targetId": "claude-code",
|
|
103
|
+
"supportLevel": "translated",
|
|
104
|
+
"metadataMode": "translated",
|
|
105
|
+
"helperMode": "packaged-script",
|
|
106
|
+
"notes": "Claude Code consumes the same canonical skill and wrapper, with the helper script available when the operator wants explicit compaction evidence."
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"targetId": "cursor",
|
|
110
|
+
"supportLevel": "guidance-only",
|
|
111
|
+
"metadataMode": "unsupported",
|
|
112
|
+
"helperMode": "documentation-first",
|
|
113
|
+
"notes": "Cursor can follow the guidance surfaces, but the primary promotion path is still the canonical skill and maintainer note."
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"targetId": "opencode",
|
|
117
|
+
"supportLevel": "guidance-only",
|
|
118
|
+
"metadataMode": "unsupported",
|
|
119
|
+
"helperMode": "documentation-first",
|
|
120
|
+
"notes": "OpenCode receives the canonical guidance without overstating runtime-native metadata parity."
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
"portingRules": [
|
|
124
|
+
{
|
|
125
|
+
"ruleId": "promote-reuse-first-runtime-skills",
|
|
126
|
+
"matchCriteria": "An imported skill owns a distinct responsibility for context compaction, reuse-first reasoning, or token-cost discipline.",
|
|
127
|
+
"preferredOutcome": "embed",
|
|
128
|
+
"requiredFollowUps": [
|
|
129
|
+
"create the canonical skill under skills/",
|
|
130
|
+
"ship supporting references and helper surfaces under the same skill directory",
|
|
131
|
+
"add a discovery wrapper under .agents/skills/",
|
|
132
|
+
"register the skill in package-surface and front-door docs"
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"ruleId": "translate-runtime-specific-metadata",
|
|
137
|
+
"matchCriteria": "The imported artifact is runtime-specific metadata rather than canonical cross-agent guidance.",
|
|
138
|
+
"preferredOutcome": "translate",
|
|
139
|
+
"requiredFollowUps": [
|
|
140
|
+
"summarize the metadata in maintainer-facing provenance",
|
|
141
|
+
"avoid claiming universal runtime-native parity",
|
|
142
|
+
"keep the canonical wrapper and skill as the active discovery path"
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
}
|
package/package.json
CHANGED
package/skills/README.md
CHANGED
|
@@ -57,6 +57,7 @@ and modernization guidance sourced into project-owned `references/` directories.
|
|
|
57
57
|
- `skills/security-scan/`
|
|
58
58
|
- `skills/release-readiness/`
|
|
59
59
|
- `skills/architecture-decision-records/`
|
|
60
|
+
- `skills/token-budget-optimizer/`
|
|
60
61
|
|
|
61
62
|
## Workload-specialized skills
|
|
62
63
|
|
|
@@ -92,3 +93,8 @@ maintainer-facing provenance instead of shipping duplicate skill identities.
|
|
|
92
93
|
Single-skill ports such as `engineering-assistant` should preserve the same
|
|
93
94
|
discipline through `manifests/catalog/engineering-assistant-import-inventory.json`
|
|
94
95
|
and `docs/authoring/engineering-assistant-port.md`.
|
|
96
|
+
|
|
97
|
+
Context-compaction ports such as `token-budget-optimizer` should preserve the
|
|
98
|
+
same discipline through
|
|
99
|
+
`manifests/catalog/token-budget-optimizer-import-inventory.json` and
|
|
100
|
+
`docs/authoring/token-budget-optimizer-port.md`.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: token-budget-optimizer
|
|
3
|
+
description: compact context, reuse existing runtime artifacts, and choose the smallest authoritative surface before expanding prompt history. use when the task is growing large, when earlier repo intelligence already exists, or when repeated rescans would waste tokens without adding new evidence.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Token Budget Optimizer
|
|
7
|
+
|
|
8
|
+
## Trigger Signals
|
|
9
|
+
|
|
10
|
+
- the prompt is getting long and earlier repo context is being repeated
|
|
11
|
+
- the repo already has `AGENTS.md`, `.hforge/runtime/`, specs, plans, or review artifacts that can answer the next question
|
|
12
|
+
- the task is investigative or iterative enough that careless re-reading will waste tokens
|
|
13
|
+
- the agent is about to scan broad directory trees before checking existing runtime summaries
|
|
14
|
+
|
|
15
|
+
## Inspect First
|
|
16
|
+
|
|
17
|
+
- `.hforge/agent-manifest.json` and `.hforge/generated/agent-command-catalog.json`
|
|
18
|
+
- `.hforge/runtime/index.json`, `.hforge/runtime/repo/repo-map.json`, and `.hforge/runtime/repo/recommendations.json`
|
|
19
|
+
- active guidance bridges such as `AGENTS.md`, `CLAUDE.md`, and `.agents/skills/<skill>/SKILL.md`
|
|
20
|
+
- any existing `spec.md`, `plan.md`, `tasks.md`, review output, or decision record relevant to the current task
|
|
21
|
+
- `skills/token-budget-optimizer/scripts/inspect_token_surfaces.py` when a deterministic token-surface audit would help
|
|
22
|
+
|
|
23
|
+
## Workflow
|
|
24
|
+
|
|
25
|
+
1. identify the concrete question the agent must answer next and avoid reading more than that question requires
|
|
26
|
+
2. rank existing surfaces by authority, freshness, and cost, preferring hidden runtime summaries and durable artifacts before broad source scans
|
|
27
|
+
3. reuse prior findings, repo maps, decision records, and task artifacts instead of re-deriving them from scratch
|
|
28
|
+
4. compact the active context into a short working set: current goal, authoritative surfaces, open questions, and the next small evidence step
|
|
29
|
+
5. escalate to deeper reads only when the compacted working set cannot answer the task safely
|
|
30
|
+
|
|
31
|
+
## Output Contract
|
|
32
|
+
|
|
33
|
+
- a short context budget summary with the current goal and the smallest authoritative surfaces to keep loaded
|
|
34
|
+
- a reuse plan listing which runtime artifacts, docs, or task artifacts should be trusted instead of reread
|
|
35
|
+
- compaction candidates describing what can be summarized once and then dropped from active context
|
|
36
|
+
- unresolved gaps that still require new evidence or deeper file reads
|
|
37
|
+
|
|
38
|
+
## Failure Modes
|
|
39
|
+
|
|
40
|
+
- runtime artifacts are stale, missing, or do not cover the active question
|
|
41
|
+
- the task is genuinely novel and prior summaries are no longer trustworthy
|
|
42
|
+
- the agent mistakes low-cost summaries for high-authority truth and skips required verification
|
|
43
|
+
|
|
44
|
+
## Escalation
|
|
45
|
+
|
|
46
|
+
- escalate when the repo has conflicting guidance across `AGENTS.md`, runtime summaries, and product code
|
|
47
|
+
- escalate when token saving would hide a risky detail such as a release gate, migration step, or support constraint
|
|
48
|
+
- escalate when there is no reliable compact surface and the agent must build a new authoritative summary first
|
|
49
|
+
|
|
50
|
+
## References
|
|
51
|
+
|
|
52
|
+
- `skills/token-budget-optimizer/references/audit-dimensions.md`
|
|
53
|
+
- `skills/token-budget-optimizer/references/promotion-ladder.md`
|
|
54
|
+
- `skills/token-budget-optimizer/references/scoring-model.md`
|
|
55
|
+
- `skills/token-budget-optimizer/references/report-template.md`
|
|
56
|
+
- `skills/token-budget-optimizer/scripts/inspect_token_surfaces.py`
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Token Surface Audit Dimensions
|
|
2
|
+
|
|
3
|
+
Use these dimensions when deciding whether a surface deserves active context.
|
|
4
|
+
|
|
5
|
+
## Authority
|
|
6
|
+
|
|
7
|
+
- highest: generated or maintained runtime truth such as `.hforge/agent-manifest.json`, `.hforge/generated/agent-command-catalog.json`, and current runtime indexes
|
|
8
|
+
- medium: maintained docs and active skill contracts
|
|
9
|
+
- lower: old notes, ad-hoc chat summaries, or broad source scans without task focus
|
|
10
|
+
|
|
11
|
+
## Freshness
|
|
12
|
+
|
|
13
|
+
- prefer artifacts regenerated after the latest repo changes
|
|
14
|
+
- downgrade summaries that predate major install, refresh, or architecture changes
|
|
15
|
+
- if freshness is unclear, verify with `status`, `refresh`, or a targeted file read
|
|
16
|
+
|
|
17
|
+
## Reuse value
|
|
18
|
+
|
|
19
|
+
- high when the surface already answers the current question directly
|
|
20
|
+
- medium when the surface narrows the search space meaningfully
|
|
21
|
+
- low when the surface only restates generic repo facts or marketing prose
|
|
22
|
+
|
|
23
|
+
## Token cost
|
|
24
|
+
|
|
25
|
+
- very low: compact JSON summaries, short skill wrappers, direct command catalogs
|
|
26
|
+
- medium: short markdown guides and specific reference docs
|
|
27
|
+
- high: large source trees, broad recursive scans, or entire repo reviews with no focus
|
|
28
|
+
|
|
29
|
+
## Risk of omission
|
|
30
|
+
|
|
31
|
+
- high risk means the surface guards support claims, release gates, migrations, security rules, or architecture decisions
|
|
32
|
+
- low risk means the surface is descriptive but not safety-critical
|
|
33
|
+
|
|
34
|
+
## Recommended decision rule
|
|
35
|
+
|
|
36
|
+
Keep in active context only the smallest set of high-authority, sufficiently
|
|
37
|
+
fresh surfaces that answer the current question without hiding a known risk.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Context Promotion Ladder
|
|
2
|
+
|
|
3
|
+
Use this ladder to decide what belongs in active prompt context.
|
|
4
|
+
|
|
5
|
+
## Level 1: Discovery only
|
|
6
|
+
|
|
7
|
+
- wrappers in `.agents/skills/`
|
|
8
|
+
- short command docs
|
|
9
|
+
- repo root guidance bridges
|
|
10
|
+
|
|
11
|
+
Use these to choose the next canonical surface quickly.
|
|
12
|
+
|
|
13
|
+
## Level 2: Canonical operating surfaces
|
|
14
|
+
|
|
15
|
+
- `.hforge/agent-manifest.json`
|
|
16
|
+
- `.hforge/generated/agent-command-catalog.json`
|
|
17
|
+
- canonical skill contracts under `.hforge/library/skills/`
|
|
18
|
+
- runtime indexes and repo summaries
|
|
19
|
+
|
|
20
|
+
Prefer these before reading broad product code.
|
|
21
|
+
|
|
22
|
+
## Level 3: Task-bound artifacts
|
|
23
|
+
|
|
24
|
+
- spec, plan, and task documents
|
|
25
|
+
- task-runtime artifacts
|
|
26
|
+
- decision records
|
|
27
|
+
- review summaries and validation outputs
|
|
28
|
+
|
|
29
|
+
Promote these when the work is already scoped and historical context matters.
|
|
30
|
+
|
|
31
|
+
## Level 4: Focused code evidence
|
|
32
|
+
|
|
33
|
+
- only the files needed to resolve an active question
|
|
34
|
+
- only the specific function, module, schema, or config block that matters
|
|
35
|
+
|
|
36
|
+
Do not jump here until the earlier levels stop being enough.
|
|
37
|
+
|
|
38
|
+
## Level 5: Broad exploratory scans
|
|
39
|
+
|
|
40
|
+
- full repo walks
|
|
41
|
+
- many-file comparisons
|
|
42
|
+
- recursive investigation sessions
|
|
43
|
+
|
|
44
|
+
Use these only when lower-cost surfaces cannot answer the question safely.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Token Budget Report Template
|
|
2
|
+
|
|
3
|
+
## Current goal
|
|
4
|
+
|
|
5
|
+
- What question must be answered next?
|
|
6
|
+
|
|
7
|
+
## Keep loaded
|
|
8
|
+
|
|
9
|
+
- Which 3-6 surfaces are authoritative enough to stay in active context?
|
|
10
|
+
|
|
11
|
+
## Reuse instead of reread
|
|
12
|
+
|
|
13
|
+
- Which runtime artifacts, prior summaries, or task docs already cover the needed context?
|
|
14
|
+
|
|
15
|
+
## Compact and drop
|
|
16
|
+
|
|
17
|
+
- Which broad notes, repeated chat summaries, or low-authority reads can be collapsed into one sentence and removed from active context?
|
|
18
|
+
|
|
19
|
+
## New evidence still required
|
|
20
|
+
|
|
21
|
+
- Which focused files or commands still need to be read or run?
|
|
22
|
+
|
|
23
|
+
## Risk notes
|
|
24
|
+
|
|
25
|
+
- What important detail would be dangerous to over-compress?
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Token Budget Scoring Model
|
|
2
|
+
|
|
3
|
+
Use a simple score to compare candidate context surfaces.
|
|
4
|
+
|
|
5
|
+
## Formula
|
|
6
|
+
|
|
7
|
+
`score = authority + freshness + reuseValue - tokenCost - ambiguityPenalty`
|
|
8
|
+
|
|
9
|
+
Each dimension can be scored from `0` to `3`.
|
|
10
|
+
|
|
11
|
+
## Guidance
|
|
12
|
+
|
|
13
|
+
- authority:
|
|
14
|
+
- `3` canonical machine-readable runtime truth
|
|
15
|
+
- `2` maintained human-readable canonical docs
|
|
16
|
+
- `1` narrow ad-hoc notes or inferred summaries
|
|
17
|
+
- `0` stale or untrusted context
|
|
18
|
+
- freshness:
|
|
19
|
+
- `3` generated or edited after the relevant change
|
|
20
|
+
- `2` likely current but not recently verified
|
|
21
|
+
- `1` possibly stale
|
|
22
|
+
- `0` known stale
|
|
23
|
+
- reuseValue:
|
|
24
|
+
- `3` directly answers the next question
|
|
25
|
+
- `2` sharply narrows what must be read next
|
|
26
|
+
- `1` weakly helpful
|
|
27
|
+
- `0` mostly decorative
|
|
28
|
+
- tokenCost:
|
|
29
|
+
- `3` large or diffuse
|
|
30
|
+
- `2` moderate
|
|
31
|
+
- `1` small
|
|
32
|
+
- `0` tiny
|
|
33
|
+
- ambiguityPenalty:
|
|
34
|
+
- `3` likely to mislead without verification
|
|
35
|
+
- `2` needs careful cross-checking
|
|
36
|
+
- `1` low ambiguity
|
|
37
|
+
- `0` explicit and stable
|
|
38
|
+
|
|
39
|
+
## Usage rule
|
|
40
|
+
|
|
41
|
+
Prefer the smallest set of surfaces with the highest positive score, then
|
|
42
|
+
validate any high-risk claim with one focused evidence read instead of a broad
|
|
43
|
+
context expansion.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Inspect likely high-value context surfaces for token-efficient agent work."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
SURFACES = [
|
|
12
|
+
("AGENTS.md", "guidance", 3, 3, 3, 1),
|
|
13
|
+
("CLAUDE.md", "guidance", 3, 3, 2, 1),
|
|
14
|
+
(".hforge/agent-manifest.json", "runtime", 3, 3, 3, 1),
|
|
15
|
+
(".hforge/generated/agent-command-catalog.json", "runtime", 3, 3, 3, 1),
|
|
16
|
+
(".hforge/runtime/index.json", "runtime", 3, 3, 2, 1),
|
|
17
|
+
(".hforge/runtime/repo/repo-map.json", "runtime", 3, 2, 3, 1),
|
|
18
|
+
(".hforge/runtime/repo/recommendations.json", "runtime", 3, 2, 3, 1),
|
|
19
|
+
(".hforge/runtime/repo/instruction-plan.json", "runtime", 3, 2, 2, 1),
|
|
20
|
+
("README.md", "docs", 2, 2, 1, 2),
|
|
21
|
+
(".specify/spec.md", "workflow", 2, 2, 3, 2),
|
|
22
|
+
(".specify/plan.md", "workflow", 2, 2, 3, 2),
|
|
23
|
+
(".specify/tasks.md", "workflow", 2, 2, 3, 2),
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def score(authority: int, freshness: int, reuse_value: int, token_cost: int) -> int:
|
|
28
|
+
return authority + freshness + reuse_value - token_cost
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def main() -> int:
|
|
32
|
+
root = Path(sys.argv[1]).resolve() if len(sys.argv) > 1 else Path.cwd().resolve()
|
|
33
|
+
found = []
|
|
34
|
+
missing = []
|
|
35
|
+
|
|
36
|
+
for relative_path, category, authority, freshness, reuse_value, token_cost in SURFACES:
|
|
37
|
+
absolute_path = root / relative_path
|
|
38
|
+
entry = {
|
|
39
|
+
"path": relative_path,
|
|
40
|
+
"category": category,
|
|
41
|
+
"score": score(authority, freshness, reuse_value, token_cost),
|
|
42
|
+
"authority": authority,
|
|
43
|
+
"freshness": freshness,
|
|
44
|
+
"reuseValue": reuse_value,
|
|
45
|
+
"tokenCost": token_cost,
|
|
46
|
+
}
|
|
47
|
+
if absolute_path.exists():
|
|
48
|
+
entry["sizeBytes"] = absolute_path.stat().st_size
|
|
49
|
+
found.append(entry)
|
|
50
|
+
else:
|
|
51
|
+
missing.append(entry)
|
|
52
|
+
|
|
53
|
+
found.sort(key=lambda item: (-item["score"], item["path"]))
|
|
54
|
+
missing.sort(key=lambda item: (-item["score"], item["path"]))
|
|
55
|
+
|
|
56
|
+
result = {
|
|
57
|
+
"workspaceRoot": str(root),
|
|
58
|
+
"recommendedKeepLoaded": found[:6],
|
|
59
|
+
"recommendedFallbackReads": found[6:10],
|
|
60
|
+
"missingButUseful": missing[:6],
|
|
61
|
+
}
|
|
62
|
+
json.dump(result, sys.stdout, indent=2)
|
|
63
|
+
sys.stdout.write("\n")
|
|
64
|
+
return 0
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if __name__ == "__main__":
|
|
68
|
+
raise SystemExit(main())
|