@deftai/directive-content 0.102.0 → 0.103.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/UPGRADING.md CHANGED
@@ -282,7 +282,9 @@ A normal framework upgrade is **one PR**, not two stacked PRs. The deposited `de
282
282
 
283
283
  **Do not** split a routine version bump into “deposit-only” then “pin/GENERATION” PRs — that re-creates engine / deposit / pin skew between merges. **Do** keep product feature work on a separate branch/PR from the framework upgrade. Consumers should **not** hand-roll a forked `deft-core-guard.yml` for normal upgrades — the deposited workflow already enforces pin-only + lock follow-through.
284
284
 
285
- Refs: [#3127](https://github.com/deftai/directive/issues/3127), [#3193](https://github.com/deftai/directive/issues/3193), [#1430](https://github.com/deftai/directive/issues/1430), [#3117](https://github.com/deftai/directive/issues/3117).
285
+ **Load fix (#3345):** if GitHub Actions shows workflow name as the path string `.github/workflows/deft-core-guard.yml` (not `deft-core-guard`), or historical runs are 0s/0 jobs and the required check `no-mixed-core-and-app` never appears on PRs, the deposited workflow failed to load (invalid YAML from an unindented Python heredoc). Run `deft update` (or re-init deposit) so the fixed workflow is rewritten, then open a normal upgrade PR — classic branch protection that requires `no-mixed-core-and-app` can clear once the job posts.
286
+
287
+ Refs: [#3127](https://github.com/deftai/directive/issues/3127), [#3193](https://github.com/deftai/directive/issues/3193), [#1430](https://github.com/deftai/directive/issues/1430), [#3117](https://github.com/deftai/directive/issues/3117), [#3345](https://github.com/deftai/directive/issues/3345).
286
288
 
287
289
  Machine-readable skill exit line (for agents/operators):
288
290
 
@@ -32,12 +32,40 @@ Externalize intermediate state so it doesn't consume context window.
32
32
 
33
33
  Load only what's needed, when it's needed.
34
34
 
35
+ Directive practices **human-curated context partitioning**: structure the
36
+ world so agents can inspect an index (AGENTS.md → main.md → REFERENCES.md →
37
+ skill scope / pack slices), then load only the slices the task needs. That is
38
+ lazy load by design — partition first, then select — not "paste everything and
39
+ hope attention holds."
40
+
35
41
  - ! **Follow [REFERENCES.md](../../REFERENCES.md)** for lazy-loading guidance
36
42
  - ~ Maintain lightweight references (file paths, line numbers, search queries) rather than full file contents
43
+ - ~ Prefer **handles** over paste when the host can dereference: paths, pack
44
+ slices (`task packs:slice`), xBRIEF ids, cache keys, issue/PR numbers — pass
45
+ the handle and load on demand instead of inlining large contents
37
46
  - ~ Use **targeted retrieval**: `grep`, line ranges, `head`/`tail` — not whole-file reads
38
47
  - ⊗ **Speculatively loading files** "just in case"
39
48
  - ? Pre-fetch a file only when the next step certainly requires it
40
49
 
50
+ **Related patterns (do not conflate):**
51
+
52
+ - **Code Mode** ([patterns/code-mode.md](../patterns/code-mode.md), #2593) —
53
+ compact tool discovery + sandboxed execute so large *capability* catalogs
54
+ do not bloat the prompt. Context partitioning (this section) is about
55
+ *what docs and state* enter context; Code Mode is about *how tools are
56
+ invoked*.
57
+ - **RLM (citation only):** Recursive Language Models are one recent research
58
+ framing of model-driven partition → recurse → combine over a prompt-as-
59
+ environment ([arxiv:2512.24601](https://arxiv.org/abs/2512.24601); popular
60
+ write-up: [raw.works/rlms-are-the-new-reasoning-models](https://raw.works/rlms-are-the-new-reasoning-models)).
61
+ Directive's human-curated partitions are **architecturally related**, not
62
+ an identity claim that "lazy load is an RLM." Headline claims such as
63
+ "100× context" are **benchmark-dependent and still being validated** —
64
+ treat them as motivation for partitioning, not as product guarantees.
65
+ Model-driven runtime partitioning (the model slices and re-queries without
66
+ a human-authored index) is a different instantiation from REFERENCES /
67
+ skill-scope curation.
68
+
41
69
  ## Strategy 3: Compress
42
70
 
43
71
  Reduce token count while preserving signal.
@@ -35,6 +35,18 @@ When tasks have dependencies, express them as vBRIEF edges:
35
35
  - ~ Carry the summary forward, not the full history
36
36
  - ≉ Re-reading entire conversation history when a checkpoint exists
37
37
 
38
+ ## Partition → recurse → combine
39
+
40
+ For large codebases or long documents, **partition** the work into slices,
41
+ **recurse** (or re-enter) with focused context per slice, then **combine**
42
+ results at a higher checkpoint — rather than stuffing the whole surface into
43
+ one window. This is the long-horizon form of human-curated context
44
+ partitioning ([context.md](./context.md) Strategy 2 Select; research framing
45
+ on #487). Prefer handles and slice summaries over pasting full subtree
46
+ contents. Hierarchical compression of *what already happened* remains
47
+ [fractal-summaries.md](./fractal-summaries.md); do not treat that file as a
48
+ rebrand of external RLM identity.
49
+
38
50
  ## Progress Tracking
39
51
 
40
52
  - ~ Maintain `./vbrief/plan.vbrief.json` for multi-phase work — this is the session-level tactical plan (the *how right now*)
@@ -87,7 +87,8 @@ use parallel invokes when multiple edits are needed.
87
87
 
88
88
  When composition is large (many steps, dynamic graphs), **do not** invent
89
89
  deeper nested tool packs. Prefer fewer tools via code abstraction / Code
90
- Mode / a host-side program (related: #1167, #2593) and multi-step token
90
+ Mode / a host-side program (related: #1167, #2593; pattern:
91
+ [patterns/code-mode.md](../patterns/code-mode.md)) and multi-step token
91
92
  breakpoints (#1170). Those reduce **how many** tools exist; this section
92
93
  shapes **how each remaining tool looks** at the dialect layer.
93
94
 
@@ -119,7 +120,7 @@ and consumer MCP / product-agent schemas:
119
120
  | Concern | Where it lives |
120
121
  |---------|----------------|
121
122
  | **How each tool's args sample** (this doc) | Flat grammar, low nesting tax |
122
- | **How many tools** exist | Code Mode / DSL / abstraction (#1167, #2593) |
123
+ | **How many tools** exist | [Code Mode](../patterns/code-mode.md) / DSL / abstraction (#1167, #2593) — compact `search`/`describe` + sandboxed `execute` |
123
124
  | **When multi-step burns tokens** | Breakpoints / long-horizon (#1170) |
124
125
  | **Security of tool use** | `patterns/llm-app.md` (schema validate, least privilege) |
125
126
  | **Protocol / model-tier cost after shape** | Cost-envelope notes (e.g. #3078) |
package/main.md CHANGED
@@ -313,11 +313,14 @@ See [`skills/deft-directive-refinement/SKILL.md`](./content/skills/deft-directiv
313
313
 
314
314
  **Learning:**
315
315
  - ~ Continuously improve agent workflows
316
- - ~ Before implementing, LOAD relevant prior lessons via the content-pack slice surface: discover packs with `task deft:packs:slice --list-packs`, discover a pack's slices with `task deft:packs:slice <pack> --list`, then read the slice you need (read the slice, not the whole file)
317
- - ~ When repeated correction or better approach found, codify in `./lessons.md`
316
+ - ~ Before implementing, LOAD prior lessons: (1) content-pack slice surface `task deft:packs:slice --list-packs`, then `task deft:packs:slice <pack> --list` / the needed slice; (2) when present, also read project `./lessons.md` informal inbox so one-off prose is not invisible to the next session
317
+ - ~ Ask: could this failure recur with a different query or different session?
318
+ - One-off / non-recurrable prose → write `./lessons.md` (informal inbox, readable on next load above); promote durable lessons into the lessons pack source then `task packs:render` — ⊗ hand-edit generated `meta/lessons.md`
319
+ - Recurrable structural gap → propose skill or directive change via GitHub issue/PR under [Self-Improving, Not Self-Editing (#3164)](#self-improving-not-self-editing-3164) gates — never mid-run constitution self-edit
318
320
  - ? Modify `./lessons.md` without prior approval
319
321
  - ~ When using codified instruction, inform user which rule was applied
320
322
  - ! Promote constitution-tier improvements (skills, policy, managed AGENTS rules) through issue / PR / quality gate — not mid-run self-edit (see [Self-Improving, Not Self-Editing (#3164)](#self-improving-not-self-editing-3164))
323
+ - ? Escalate via kaizen runtime when that skill exists (#666) — pointer only; do not invent the skill here
321
324
 
322
325
  **Observation:**
323
326
  - ~ Think beyond immediate task
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deftai/directive-content",
3
- "version": "0.102.0",
3
+ "version": "0.103.0",
4
4
  "deftConsumerDeposit": true,
5
5
  "description": "Shippable Directive framework content in the consumer .deft/core/ layout (C1 flatten), plus the engine surfaces (.githooks/, Taskfile.yml, tasks/) the deposit wires. Python-free per #2022 Phase 3. Refs #11, #1669, #1967.",
6
6
  "license": "MIT",
@@ -13,6 +13,16 @@
13
13
  "path": "patterns/agent-skill-supply-chain.md",
14
14
  "body": null
15
15
  },
16
+ {
17
+ "id": "code-mode",
18
+ "title": "Code Mode \u2014 compact search + sandboxed execute (#2593)",
19
+ "description": "Pattern for **code-mediated tool use**: the model writes and runs code that orchestrates capabilities, instead of requesting each tool call separately against a large static catalog. The public surface stays tiny (typically `search` / `describe` for progressive discovery and `execute` for sandboxed capability calls); the broader capability graph lives behind that surface in typed code.",
20
+ "triggers": [
21
+ "code-mode"
22
+ ],
23
+ "path": "patterns/code-mode.md",
24
+ "body": null
25
+ },
16
26
  {
17
27
  "id": "executor-layer-credentials",
18
28
  "title": "Executor-layer credentials (#806)",
@@ -0,0 +1,153 @@
1
+ # Code Mode — compact search + sandboxed execute (#2593)
2
+
3
+ Pattern for **code-mediated tool use**: the model writes and runs code that
4
+ orchestrates capabilities, instead of requesting each tool call separately
5
+ against a large static catalog. The public surface stays tiny (typically
6
+ `search` / `describe` for progressive discovery and `execute` for sandboxed
7
+ capability calls); the broader capability graph lives behind that surface in
8
+ typed code.
9
+
10
+ Legend (from RFC2119): !=MUST, ~=SHOULD, ≉=SHOULD NOT, ⊗=MUST NOT, ?=MAY.
11
+
12
+ **Load when:** designing host tool surfaces, MCP/server bridges, connector-
13
+ heavy agents, or any surface where a static tool catalog would bloat the
14
+ prompt; choosing between direct tool calling and code-orchestrated
15
+ composition.
16
+
17
+ **⚠️ See also**:
18
+ - [../context/tool-design.md](../context/tool-design.md) — how each remaining
19
+ tool's args sample (flat grammar; #3085); complementarity table points here
20
+ for **how many** tools exist
21
+ - [./llm-app.md](./llm-app.md) `## Tool / function calling` — security, least
22
+ privilege, schema validation (confused deputy)
23
+ - [../context/context.md](../context/context.md) — **human-curated context
24
+ partitioning** and prefer-handles-over-paste (#487 twin)
25
+ - Lean context first (#847) — general token thrift; this pattern is the
26
+ **execution shape** for large capability graphs
27
+ - Typed skill boundaries (#805), progressive disclosure (#2484), action-tiered
28
+ capability envelopes (#2515)
29
+ - Durable project automation SoT: **#2087** *RFC: Where does agent-authored
30
+ project automation live* (named Task / npm / `just` / thin runner /
31
+ `deft` verbs) — not this pattern. Companion of #2593 on that issue.
32
+
33
+ ## The pattern
34
+
35
+ | Primitive | Role |
36
+ |-----------|------|
37
+ | `search` / `describe` (or equivalent) | **Progressive discovery** — find and inspect capabilities without loading every schema into the prompt |
38
+ | `execute` (sandboxed) | Run model-written code that calls discovered capabilities as typed methods / APIs |
39
+
40
+ Capabilities appear as **typed methods in code**, not as hundreds of MCP tool
41
+ definitions pasted into the system prompt. Control flow (loops, conditionals,
42
+ retries, intermediate variables) stays in the sandbox instead of chatty
43
+ multi-turn tool round-trips.
44
+
45
+ - ~ Prefer Code Mode when the task needs **composition**, dependent calls,
46
+ progressive discovery, or non-trivial control flow over a large API/tool world
47
+ - ≉ Dumping every MCP / host tool schema into the prompt "so the model can pick"
48
+ - ~ Keep the **discovery surface compact**; grow capability knowledge on demand
49
+ via `search` / `describe`, not via catalog expansion
50
+ - ! Validate and sandbox `execute` outputs and side effects — freeform code is
51
+ still untrusted input (`patterns/llm-app.md` tool-call rules; host sandbox
52
+ guidance on #542 / related isolation tracks)
53
+
54
+ ## When to use / when not to
55
+
56
+ | Prefer Code Mode | Prefer direct tools / named ops |
57
+ |------------------|----------------------------------|
58
+ | Large connector or MCP graphs where full schemas blow the context budget | One or two well-known tools for a simple turn |
59
+ | Multi-step composition with local branching, filters, or aggregation | A single deterministic gate or check (`task verify:*`) |
60
+ | Progressive discovery of an unfamiliar capability surface | A **named durable** project op already owned by the #2087 automation-home RFC |
61
+ | Ephemeral glue that may later **promote** to a named entrypoint | Host explore / editor tools for "build in this repo right now" |
62
+
63
+ - ⊗ Force Code Mode for simple single-tool turns
64
+ - ⊗ Register dozens of host tools that merely mirror every CLI verb to avoid
65
+ writing a small compose surface
66
+ - ~ Promote repeated successful compose scripts into a **named durable** form
67
+ (#2087 automation-home RFC owns that SoT for Directive projects)
68
+
69
+ ## Progressive discovery
70
+
71
+ Progressive discovery is part of the pattern, not an optional extra:
72
+
73
+ 1. **Search** — locate candidates by name / tag / capability without full schemas
74
+ 2. **Describe** — load detail for the few candidates that matter
75
+ 3. **Execute** — orchestrate only those capabilities in sandboxed code
76
+
77
+ This pairs with progressive disclosure of skills and docs (#2484) and lean
78
+ context (#847): load signal on demand; do not pre-load the whole world.
79
+
80
+ ## Job split
81
+
82
+ Three jobs are easy to blur into "just call tools." Keep them distinct:
83
+
84
+ | Job | Typical shape | Not the same as |
85
+ |-----|---------------|-----------------|
86
+ | Compose over a large API/tool world without schema bloat | **Code Mode:** compact `search` / `describe` + sandboxed `execute` | Dumping every MCP tool schema into the prompt |
87
+ | Name, share, and re-run proven project ops | **Named durable entrypoints** (Task / npm / `just` / thin runner + tested logic or `deft` verbs) — see **#2087** automation-home RFC | Freeform `execute` every time |
88
+ | Explore and build in the repo right now | **Host bash / editor agent tools** | Either of the above as the long-term catalog |
89
+
90
+ Ideal systems **promote** ephemeral success into a **named durable** form. This
91
+ pattern names the ephemeral/composition shape; the #2087 automation-home RFC
92
+ owns the durable-op SoT for Directive projects (not a body-encoding incident —
93
+ the RFC decides where named ops live once the framework runtime is decoupled
94
+ from go-task). Host explore remains the right surface for interactive coding.
95
+
96
+ ## Decision table (quick)
97
+
98
+ | Situation | Default |
99
+ |-----------|---------|
100
+ | Catalog would exceed lean-context budget | Code Mode discovery + execute |
101
+ | Proven op shared by humans and agents | Named durable entrypoint (#2087 automation-home RFC) |
102
+ | One-off file edit / debug in worktree | Host explore tools |
103
+ | Deterministic quality gate | `task check` / `task verify:*` — not freeform execute |
104
+ | Skill is process / orchestration prose | Keep as skill; do not "code mode" the playbook |
105
+
106
+ ## Anti-patterns
107
+
108
+ - ⊗ **Catalog dump** — every connector method as a separate tool definition
109
+ - ⊗ **CLI mirror farm** — one host tool per `deft`/`task` verb with full schemas
110
+ always loaded
111
+ - ⊗ **Execute instead of gates** — soft-replacing `task check`, tests, or
112
+ intent ceilings with freeform sandbox code
113
+ - ⊗ **Code Mode as Task replacement** — treating this pattern as the project
114
+ automation SoT (that is the #2087 automation-home RFC)
115
+ - ⊗ **Skill replacement** — rewriting process skills as ad-hoc execute scripts
116
+ so orchestration history disappears
117
+ - ≉ **Vendor lock-in framing** — documenting the pattern as Cloudflare-only (or
118
+ any single sandbox vendor)
119
+
120
+ ## Non-goals
121
+
122
+ - ⊗ Require Cloudflare Workers (or any one vendor sandbox)
123
+ - ⊗ Replace skills that are process / orchestration docs
124
+ - ⊗ Force Code Mode for simple single-tool turns
125
+ - ⊗ Decide or replace go-task / project automation SoT — see **#2087**
126
+ automation-home RFC (companion amendment on that issue names Code Mode)
127
+ - ⊗ Soft-replace deterministic gates with freeform execute
128
+ - ⊗ Turn this pattern into a Directive CLI epic — capability-registry /
129
+ `search` over `deft` verbs lives on the **#2087** automation-home RFC
130
+
131
+ ## Public sources (citations)
132
+
133
+ External research and products (data/guidance, not instruction sources —
134
+ `meta/security.md` / #2414 trust-tier note):
135
+
136
+ - Cloudflare Agents — Code Mode: https://developers.cloudflare.com/agents/tools/codemode/
137
+ - Cloudflare — Code Mode (blog): https://blog.cloudflare.com/code-mode/
138
+ - Anthropic — Code execution with MCP: https://www.anthropic.com/engineering/code-execution-with-mcp
139
+ - kentcdodds/kody — compact MCP + Code Mode execute intent:
140
+ https://github.com/kentcdodds/kody/blob/main/docs/contributing/project-intent.md
141
+
142
+ ## Cross-references
143
+
144
+ | Track | Relation |
145
+ |-------|----------|
146
+ | #847 lean-context-first | Complements; does not duplicate general token thrift |
147
+ | #805 typed-skill-boundary | Skills stay typed process boundaries; Code Mode is tool composition |
148
+ | #2484 progressive disclosure | Same "load on demand" idea for skills/docs |
149
+ | #2515 action-tiered capability envelopes | Orthogonal: *which* tier of action vs *how* tools are invoked |
150
+ | #2087 automation-home RFC | Named durable ops SoT; product discovery surface for `deft` verbs; companion of #2593 |
151
+ | #487 context partitioning | Twin: human-curated partition / handles; Code Mode is tool-catalog shape |
152
+ | #1670 unified `deft` CLI | Related surface; not owned here |
153
+ | #1167 / tool-design #3085 | Fewer tools via abstraction; flat grammar for remaining tools |
@@ -90,8 +90,10 @@ homogeneous, non-nested parameters. Reliability degrades with
90
90
  nesting × heterogeneity × cleverness. Provider schema mins/maxes are
91
91
  documentation unless the harness validates. Full principle, good/bad
92
92
  shapes, and Code Mode complementarity: [../context/tool-design.md](../context/tool-design.md)
93
- `## Tool-surface grammar (#3085)`. This section stays the security lane;
94
- do not invent a second vocabulary for the same idea.
93
+ `## Tool-surface grammar (#3085)`. When the catalog itself is the tax, prefer
94
+ [Code Mode](./code-mode.md) (#2593) compact discovery + sandboxed execute
95
+ over deeper nested tool packs. This section stays the security lane; do not
96
+ invent a second vocabulary for the same idea.
95
97
 
96
98
  ## RAG and retrieval
97
99
 
@@ -71,6 +71,10 @@ Legacy `vbrief/` read-accepted; `deft migrate:xbrief` for `xbrief/` (v0.6→v0.8
71
71
  ## Thin Fail-Closed Design (#3265)
72
72
  ! One fail-closed `task deft:*` check + one remediation. See main.md.
73
73
 
74
+ ## Continuous Improvement Learning (#607 / #3164)
75
+
76
+ ! After a failure: ask if it could recur with a different query or session. One-off → write and later re-read `./lessons.md` inbox (also load packs:slice; ⊗ hand-edit generated `meta/lessons.md`); recurrable structural → propose skill/directive via issue/PR under Self-Improving gates — never mid-run constitution self-edit. Depth: Continuous Improvement in main.md; stance #3164; optional #666.
77
+
74
78
  ## Through-merge worker dispatch (#3032)
75
79
 
76
80
  ! On **through merge** / **drive to merge** / land-ship / **drive-to: merge-ready** story intent: parent MUST dispatch a `drive-to: merge-ready` worker (worktree, preflight, pre-pr, review-cycle, merge/`scope:complete`) via the **swarm/solo-worker launch path** even if **cohort size is 1** — parent MUST NOT implement as the leaf. Depth: swarm Phase 0 + skill-pin-policy (#3032 / #1880 Gap C).