@diffexai/diffex 0.2.4 → 0.2.5

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/AGENTS.md +0 -4
  4. package/dist/core/agent-session.d.ts +0 -1
  5. package/dist/core/agent-session.js +3 -10
  6. package/dist/core/sdk.js +1 -1
  7. package/dist/core/system-prompt-production.d.ts +7 -0
  8. package/dist/core/system-prompt-production.js +108 -0
  9. package/dist/core/system-prompt.d.ts +2 -2
  10. package/dist/core/system-prompt.js +34 -28
  11. package/dist/core/tools/subagents.js +22 -9
  12. package/dist/modes/print-mode.js +12 -14
  13. package/dist/node_modules/@diffexai/diffex-agent-core/distribution-components.json +4 -4
  14. package/dist/node_modules/@diffexai/diffex-agent-core/distribution-files.json +1 -1
  15. package/dist/node_modules/@diffexai/diffex-agent-core/package.json +1 -1
  16. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/.manifest.json +1 -1
  17. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/amazon-bedrock.json +1 -1
  18. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  19. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/fireworks.json +1 -1
  20. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/nvidia.json +1 -1
  21. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/opencode-go.json +1 -1
  22. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/opencode.json +1 -1
  23. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/openrouter.json +1 -1
  24. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  25. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/qwen-token-plan.json +1 -1
  26. package/dist/node_modules/@diffexai/diffex-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  27. package/dist/node_modules/@diffexai/diffex-ai/distribution-components.json +3 -3
  28. package/dist/node_modules/@diffexai/diffex-ai/distribution-files.json +12 -12
  29. package/dist/node_modules/@diffexai/diffex-ai/package.json +1 -1
  30. package/dist/node_modules/@diffexai/diffex-client/distribution-components.json +3 -3
  31. package/dist/node_modules/@diffexai/diffex-client/distribution-files.json +1 -1
  32. package/dist/node_modules/@diffexai/diffex-client/package.json +1 -1
  33. package/dist/node_modules/@diffexai/diffex-harness-state/distribution-components.json +2 -2
  34. package/dist/node_modules/@diffexai/diffex-harness-state/distribution-files.json +1 -1
  35. package/dist/node_modules/@diffexai/diffex-harness-state/package.json +1 -1
  36. package/dist/node_modules/@diffexai/diffex-protocol/distribution-components.json +2 -2
  37. package/dist/node_modules/@diffexai/diffex-protocol/distribution-files.json +1 -1
  38. package/dist/node_modules/@diffexai/diffex-protocol/package.json +1 -1
  39. package/dist/node_modules/@diffexai/diffex-telemetry/distribution-components.json +2 -2
  40. package/dist/node_modules/@diffexai/diffex-telemetry/distribution-files.json +1 -1
  41. package/dist/node_modules/@diffexai/diffex-telemetry/package.json +1 -1
  42. package/dist/node_modules/@diffexai/diffex-tui/distribution-components.json +2 -2
  43. package/dist/node_modules/@diffexai/diffex-tui/distribution-files.json +1 -1
  44. package/dist/node_modules/@diffexai/diffex-tui/package.json +1 -1
  45. package/dist/server/create-harness.js +1 -1
  46. package/distribution-components.json +11 -11
  47. package/distribution-files.json +50 -42
  48. package/npm-shrinkwrap.json +2 -2
  49. package/package.json +1 -31
  50. package/release/distribution-manifest.json +4 -4
  51. package/release/install-package-lock.json +5 -5
  52. package/release/install-package.json +2 -2
  53. package/docs/compaction.md +0 -401
  54. package/docs/containerization.md +0 -84
  55. package/docs/custom-provider.md +0 -774
  56. package/docs/environment-variables.md +0 -88
  57. package/docs/evolution.md +0 -90
  58. package/docs/extensions.md +0 -2982
  59. package/docs/images/interactive-mode.png +0 -0
  60. package/docs/images/tree-view.png +0 -0
  61. package/docs/installation.md +0 -118
  62. package/docs/json.md +0 -91
  63. package/docs/keybindings.md +0 -241
  64. package/docs/llama-cpp.md +0 -99
  65. package/docs/models.md +0 -565
  66. package/docs/packages.md +0 -232
  67. package/docs/prompt-templates.md +0 -96
  68. package/docs/providers.md +0 -317
  69. package/docs/quickstart.md +0 -161
  70. package/docs/rpc.md +0 -1647
  71. package/docs/sdk.md +0 -1332
  72. package/docs/security.md +0 -66
  73. package/docs/session-format.md +0 -438
  74. package/docs/sessions.md +0 -162
  75. package/docs/settings.md +0 -341
  76. package/docs/shell-aliases.md +0 -13
  77. package/docs/skills.md +0 -227
  78. package/docs/terminal-setup.md +0 -152
  79. package/docs/themes.md +0 -326
  80. package/docs/tmux.md +0 -63
  81. package/docs/tui.md +0 -940
  82. package/docs/usage.md +0 -434
@@ -1,88 +0,0 @@
1
- # Environment Variables
2
-
3
- Diffex uses environment variables in three ways:
4
-
5
- - Variables such as `DIFFEX_OFFLINE` configure the Diffex process.
6
- - Diffex sets `DIFFEX_CODING_AGENT` so child processes can detect that they run inside Diffex.
7
- - Commands run by the LLM-callable bash tool receive `DIFFEX_*` variables describing the current session.
8
-
9
- Provider API-key variables are documented separately in [Providers](providers.md#environment-variables-or-auth-file).
10
-
11
- ## Process Marker
12
-
13
- The CLI and RPC entry points set `DIFFEX_CODING_AGENT=true`. Child processes inherit it and can use it to detect that they run inside Diffex. It is not session-specific and is not set automatically when Diffex is embedded through the SDK.
14
-
15
- ## Bash Tool Session Environment
16
-
17
- Commands run by the bash tool receive the current Diffex session state:
18
-
19
- | Variable | Description |
20
- |----------|-------------|
21
- | `DIFFEX_SESSION_ID` | Current session ID |
22
- | `DIFFEX_SESSION_FILE` | Absolute path to the current session JSONL file; unset for ephemeral sessions |
23
- | `DIFFEX_PROVIDER` | Currently selected model provider |
24
- | `DIFFEX_MODEL` | Currently selected model ID |
25
- | `DIFFEX_REASONING_LEVEL` | Current effective reasoning level: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max` |
26
-
27
- The values are resolved when each command starts. Switching models or changing the reasoning level therefore affects the next bash command without restarting Diffex. `DIFFEX_PROVIDER` and `DIFFEX_MODEL` identify the selected Diffex model, not a different upstream model that a router may choose internally.
28
-
29
- When asked which model or provider is running, inspect these variables instead of inferring the answer from the system prompt:
30
-
31
- ```bash
32
- printf '%s/%s\n' "$DIFFEX_PROVIDER" "$DIFFEX_MODEL"
33
- printf 'reasoning=%s session=%s\n' "$DIFFEX_REASONING_LEVEL" "$DIFFEX_SESSION_ID"
34
- ```
35
-
36
- The session file can be inspected directly when the session is persistent:
37
-
38
- ```bash
39
- if [ -n "$DIFFEX_SESSION_FILE" ]; then
40
- tail -n 1 "$DIFFEX_SESSION_FILE"
41
- fi
42
- ```
43
-
44
- These variables are injected into the LLM-callable bash tool. They are not injected into user-entered `!` or `!!` commands.
45
-
46
- ### Custom Bash Tools
47
-
48
- Bash tools created with `createBashTool()` expose the session environment by default when registered with Diffex. Injection happens before `spawnHook`, so a hook receives the variables in `ctx.env`:
49
-
50
- ```typescript
51
- const bashTool = createBashTool(cwd, {
52
- spawnHook: (ctx) => ({
53
- ...ctx,
54
- env: { ...ctx.env, CI: "1" },
55
- }),
56
- });
57
- ```
58
-
59
- Disable session metadata independently of the spawn hook:
60
-
61
- ```typescript
62
- const bashTool = createBashTool(cwd, {
63
- exposeSessionEnvironment: false,
64
- spawnHook: (ctx) => ctx,
65
- });
66
- ```
67
-
68
- When disabled, Diffex removes inherited values for these variables so nested Diffex processes do not expose stale parent-session metadata.
69
-
70
- ## Diffex Process Configuration
71
-
72
- These variables are read by Diffex itself:
73
-
74
- | Variable | Description |
75
- |----------|-------------|
76
- | `DIFFEX_CODING_AGENT_DIR` | Override the config directory; default is `~/.diffex/agent` |
77
- | `DIFFEX_CODING_AGENT_SESSION_DIR` | Override session storage; overridden by `--session-dir` |
78
- | `DIFFEX_PACKAGE_DIR` | Override the package directory, useful for Nix/Guix store paths |
79
- | `DIFFEX_OFFLINE` | Disable startup network operations, including update checks and package updates |
80
- | `DIFFEX_SKIP_VERSION_CHECK` | Disable the automatic Diffex release check |
81
- | `DIFFEX_PROVIDER_ATTRIBUTION` | Override optional provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no`; defaults off |
82
- | `DIFFEX_CACHE_RETENTION` | Set to `long` for extended provider prompt caching where supported |
83
- | `DIFFEX_SHARE_VIEWER_URL` | Override the base URL used by `/share` |
84
- | `DIFFEX_HARDWARE_CURSOR` | Set to `1` to show the hardware cursor; see [Terminal setup](terminal-setup.md) |
85
- | `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
86
- | `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
87
-
88
- Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and cloud-provider configuration are listed in [Providers](providers.md#environment-variables-or-auth-file).
package/docs/evolution.md DELETED
@@ -1,90 +0,0 @@
1
- # Harness Evolution
2
-
3
- Diffex can derive workspace-scoped guidance from persisted invocation evidence and store it in immutable harness revisions. A revision can contain `EVOLVE.md` memory and complete evolved skill packages rooted at `skills/<name>/SKILL.md`, including referenced UTF-8 scripts, assets, and documentation. The selected revision changes both together.
4
-
5
- ## Controls
6
-
7
- Use `/evolve` to:
8
-
9
- - inspect evidence eligibility and running or completed jobs;
10
- - select the evolution model, which defaults to the current session model until explicitly set;
11
- - start, resume, cancel, or browse evolution work;
12
- - inspect memory proposals and their evidence;
13
- - distinguish analysis completion from waiting, retrying, completed, partially failed, or failed candidate generation;
14
- - inspect each skill candidate's registry state, latest transition time and reason, readable supporting and contradicting evidence, textual draft diff, deterministic validation, and retrieval/behavior evaluation when available;
15
- - inspect automatic skill activation after deterministic validation succeeds and any available persisted evaluation is accepted;
16
- - inspect target revisions and roll back an activated evolved skill to its pre-activation revision, even when later descendants preserved it;
17
- - enable or disable future tracing and evolution work.
18
-
19
- Accepted skill candidates activate automatically once deterministic validation and any configured retrieval and behavior evaluation finish. Retrieval and behavior evaluation is temporarily skipped when no evaluator is configured; in that case, deterministic structure, provenance, scope, security, and inventory validation still must pass before automatic activation. If harness memory changes after validation, activation automatically rebases the candidate onto the selected revision and preserves its memory. Automatic activation may also rebase over unrelated evolved-skill changes after rechecking the candidate's exact source and target paths; conflicting skill changes remain blocked.
20
-
21
- Use `/version` to inspect compatible revisions for the current workspace and select one, including skill creation and update revisions that preserve memory. Validated bundles determine membership; missing descriptive metadata produces an unknown-time label rather than hiding a compatible revision. Workspace provenance comes from successful write or activation receipts matched to their workspace, or an unchanged-memory descendant of a compatible revision, and every skill must match the workspace. Merely observing a revision as a local job's input does not establish workspace ownership. Unattributed memory-only revisions cannot be assumed compatible.
22
-
23
- The picker orders revisions by recorded activation time (newest first), with unknown times last and revision hashes breaking ties. Skill activation times come from persisted writer receipts. Historical memory receipts use a frozen input timestamp, so memory revisions use their activation checkpoint completion time, falling back to job completion when that checkpoint is unavailable. Immutable bundles are not rewritten to add this information.
24
-
25
- Rows show revision hashes, lesson counts, and evolved skill counts. Revision details show memory and the complete skill inventory, including package versions and files. Selecting a revision that removes or changes skills requires confirmation; the preview compares both the shared selection and this session's active skills. Missing comparison contents also require confirmation. Selection validates the complete bundle. Corrupt, unsupported, or workspace-mismatched bundles remain unavailable.
26
-
27
- ### Candidate and activation states
28
-
29
- A proposed skill is a candidate, not a bundle member. An accepted candidate has passed its configured gates but may still await activation. A successfully written bundle can appear before activation, with an unknown activation time. An activation receipt records a historical bundle selection; it does not prove the skill is present in the currently selected revision. `/version` shows the selected bundle's actual contents. Main-job completion does not imply subsequent skill synthesis, validation, or activation has finished; inspect candidate generation and individual candidates in `/evolve` separately.
30
-
31
- ## Request boundaries
32
-
33
- Harness selection is resolved at prompt admission. A fresh prompt observes the selected revision; in-flight work and already admitted queued messages keep their pinned memory and skill versions. Background candidate validation reads the atomically selected revision directly, so it does not depend on a session reaching its next prompt boundary first. If `/version` changes while an evolution job is running, its memory activation continues from the frozen base and cannot replace the newer selection. Separate skill work can still activate a compatible descendant later.
34
-
35
- The footer identifies the active harness and shows background evolution activity. `/skills` lists only evolved skills from the active revision whose workspace identity matches the current workspace. Harness selection is workspace-scoped: sessions in the same workspace observe each other's selections at prompt boundaries, while sessions in other workspaces keep their own selected revision.
36
-
37
- ## Automatic eligibility
38
-
39
- When evolution is enabled, automatic work considers only invocation evidence accumulated by the active workspace and requires all of the following:
40
-
41
- - at least 400,000 reported input and output tokens from unprocessed assistant messages;
42
- - at least three eligible settled invocations;
43
- - no blocking job;
44
- - a 10-minute cooldown after the previous automatic run.
45
-
46
- Each automatic run freezes the oldest unprocessed invocation evidence up to the same 400,000-token trigger threshold, including the complete invocation that reaches or crosses it. This can exceed 400,000 tokens only to preserve that invocation boundary, including when a single invocation exceeds the threshold. Later invocations remain unprocessed. A larger backlog is processed in successive threshold-sized batches after each cooldown, not all at once. A remaining partial batch waits until it reaches 400,000 tokens. The token total is the sum of provider-reported input and output usage shown after assistant responses. It does not estimate serialized evidence size or add cache-read and cache-write usage. Evolution model calls use the current session model unless a model is explicitly selected in `/evolve`; the explicit selection stays fixed across later session-model switches and may consume that provider's quota. Manual `/evolve` work remains uncapped and uses the same frozen evidence and validation boundaries.
47
-
48
- ## Lesson feedback and grooming
49
-
50
- After each completed assistant output with active evolution memory, a private continuation asks only which used lessons were helpful or harmful. Valid reports score helpful +1, harmful -1.5, and omitted lessons -1; a valid empty report scores every eligible lesson -1. Failed or invalid reports change no scores. Reports stay out of conversation history, extension events, exports, compaction, traces, and evolution snapshots.
51
-
52
- Scores start at 0, persist per workspace, and apply atomically once per session/output. REPLACE creates a new lesson identity at 0; removed or superseded identities stop accruing points. `DEFAULT_LESSON_POLICY` and `LessonPolicy` in `packages/evolution/src/lesson-score-store.ts` expose the shared typed defaults, not per-session settings. Scores never appear in EVOLVE.md or model prompts.
53
-
54
- Before an eligible automatic or manual run freezes its input, Diffex grooms the selected revision's lessons, skipping grooming when its memory is empty. Lessons with scores at or below -5 are removed first; if more than 12 remain, the lowest-scoring lessons are removed until 12 remain. Equal scores remove earlier lessons first. This maintenance includes manual lessons, verifies their content digests, and compacts lesson numbering through the memory writer. Below these limits, the selected revision is unchanged.
55
-
56
- The job snapshots the post-groom revision, including its evolved skills, rather than the session's pinned revision. In-flight prompts remain pinned; the next prompt observes the selected revision. The `/evolve` Browse view shows **Reorganizing lessons** during grooming.
57
-
58
- ## Private skill feedback
59
-
60
- After each completed assistant output with workspace-matching evolved skills, a separate private continuation uses the existing system prompt and conversation to request only helpful/harmful judgments on skills used. It shares the lesson-report transport without sharing assessment exchanges. Reports are validated against the workspace, revision, package identities, and exposed skill names/aliases captured before that output. Installed, unknown, ambiguous, duplicate, or malformed references invalidate the whole report.
61
-
62
- Skill reports never enter conversation history, extension events, exports, compaction, durable traces, lifecycle observations, or evolution snapshots. Valid reports score helpful +1, harmful -1.5, and every omitted active evolved skill -1. A valid empty report scores every eligible skill -1; failed, missing, or invalid reports change no scores. Explicit and inferred scores commit atomically once per session/output, independently of lesson reports.
63
-
64
- Only output-bound package identities still present in the selected workspace revision accrue points. Updated packages start at 0, retired packages stop accruing, and installed skills are never scored. Scores never modify skill artifacts. `DEFAULT_SKILL_POLICY` and `SkillPolicy` in `packages/evolution/src/skill-score-store.ts` expose the shared typed scoring, grooming, and reset defaults, not per-session settings. Reporting and grooming are skipped without workspace-matching evolved skills in the active harness.
65
-
66
- Before an eligible automatic or manual run freezes its input, skill grooming removes workspace-matching evolved skills at or below -8 points, then removes the lowest-scoring survivors until at most 10 remain. Equal scores are ordered by skill ID. Removals verify the frozen package version and content digest and use the skill writer's staging and activation path without candidate evaluation. Installed skills and other workspaces are untouched; historical revisions, scores, and lifecycle observations remain available for audit. Below these limits grooming does not advance the selection. The job freezes the post-groom revision and skill catalog; the next prompt observes that selection while admitted prompts remain pinned.
67
-
68
- ## Validation and security
69
-
70
- Source traces, tool output, files, and generated drafts are treated as untrusted data. Deterministic validation checks structure, provenance, workspace scope, immutable versions, the closed package inventory, portable paths, local-reference resolution, aggregate size limits, and bounded sensitive-data rules. Retrieval and behavioral evaluation remain separate capabilities but are temporarily skipped when the runtime has no evaluator.
71
-
72
- These checks do not prove semantic safety and are not a sandbox. When evaluation is skipped, Diffex has not verified retrieval quality, behavior improvement, misapplication, or regressions. Review candidate supporting and contradicting evidence, draft diffs, validation issues, and any available evaluation results before activation. See [Security](security.md).
73
-
74
- ## Storage and recovery
75
-
76
- Evolution state is stored beneath the effective agent directory:
77
-
78
- - `evolution-workspaces/<workspace-id>/traces/` contains immutable invocation evidence intervals for one workspace;
79
- - `evolution-workspaces/<workspace-id>/evolution/` contains that workspace's jobs, artifacts, candidate history, observations, receipts, and recovery state;
80
- - `evolution-workspaces/<workspace-id>/evolution-failures/` contains that workspace's failure reports;
81
- - `harness-state/versions/` contains shared immutable revisions;
82
- - `harness-state/selections/` contains independent selected pointers keyed by workspace identity.
83
-
84
- Sessions resolved to the same workspace identity share evidence totals, jobs, candidates, and harness selection. Different workspace identities never contribute traces, invocation counts, token totals, or jobs to each other. A process that switches to a session in another workspace rotates its trace destination before attaching the replacement session.
85
-
86
- The evolution persistence API also provides `skill-scores/` ledgers, partitioned by evolution scope and exact workspace identity. Registration takes a validated harness bundle and includes only its workspace-matching evolved skills, never installed skills. Totals follow the skill ID, package version, and content digest across unrelated harness revisions; changed packages start at 0 and superseded totals remain available for audit. Writes validate revision membership and use atomic compare-and-swap updates. Schema version 2 retains applied output keys alongside totals for replay protection across restarts and concurrent sessions. Scoring holds harness selection stable until commit. Grooming uses compare-and-swap activation and refuses to rebase a scored removal onto a concurrently changed selection.
87
-
88
- Interrupted jobs and candidate work resume from durable checkpoints. Writer retries use stable idempotency keys, leases, exact base revisions, and compare-and-swap selection. Skill rollback follows immutable ancestry to the candidate's application boundary and selects its existing pre-activation revision; it does not mutate historical revisions.
89
-
90
- Set `evolution.enabled` to `false` in global settings or use the toggle in `/evolve` to stop future tracing and background/manual evolution controls. Already-running Diffex processes monitor this global setting and stop their trace collectors and evolution workers when another process disables it. Disabling evolution does not unselect the current harness or remove already active evolved skills.