@ponythewhite/base-context 1.0.6 → 1.0.8

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 (136) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/base-context-runtime/pyproject.toml +1 -1
  3. package/dist/base-context-runtime/src/rlm/__init__.py +3 -0
  4. package/dist/base-context-runtime/src/rlm/harness.py +86 -48
  5. package/dist/base-context-runtime/test/test_harness.py +215 -140
  6. package/dist/base-context-runtime/uv.lock +1 -1
  7. package/dist/build-info.json +1 -1
  8. package/dist/bundle/amazon-bedrock.js +3 -3
  9. package/dist/bundle/{anthropic-UV5GZDGU.js → anthropic-5PSCZEER.js} +2 -7
  10. package/dist/bundle/{azure-openai-responses-WSNPXLYC.js → azure-openai-responses-AYTLJR33.js} +2 -2
  11. package/dist/bundle/{bundled-modules-MEACET4U.js → bundled-modules-IGMJH2MU.js} +5 -5
  12. package/dist/bundle/{chunk-UPVDERMD.js → chunk-2IPDSTDR.js} +11 -9
  13. package/dist/bundle/chunk-D3KOF57W.js +22040 -0
  14. package/dist/bundle/{chunk-QKI6KEGP.js → chunk-EXEFSSF4.js} +1509 -577
  15. package/dist/bundle/{chunk-VSIYFWYI.js → chunk-KT2BNEPE.js} +21 -8
  16. package/dist/bundle/{chunk-KTNETTHI.js → chunk-Q3MBSBEB.js} +3 -101
  17. package/dist/bundle/{chunk-LFPWHI42.js → chunk-QKIFBA7N.js} +2 -2
  18. package/dist/bundle/{chunk-LIZVVGHR.js → chunk-RVJVXZCS.js} +13 -10
  19. package/dist/bundle/{cli-main-ANUJY7Y4.js → cli-main-BUK7QTHO.js} +4 -4
  20. package/dist/bundle/cli.js +1 -1
  21. package/dist/bundle/{google-T32FMD4G.js → google-HTMCUJ7X.js} +2 -2
  22. package/dist/bundle/{google-vertex-56KP6I3B.js → google-vertex-ZQO65AXF.js} +2 -2
  23. package/dist/bundle/{main-4GIKOHIT.js → main-2FWHT2WZ.js} +5 -5
  24. package/dist/bundle/{mistral-WGBMYIVU.js → mistral-SB7LU56G.js} +1 -1
  25. package/dist/bundle/{openai-codex-responses-PIV2RQ3G.js → openai-codex-responses-5CEW4VN3.js} +53 -27
  26. package/dist/bundle/{openai-completions-64C3JPR4.js → openai-completions-BAZJQSS2.js} +1 -1
  27. package/dist/bundle/{openai-responses-UI7RSTDV.js → openai-responses-VHOE427P.js} +48 -5
  28. package/dist/core/agent-session.d.ts +6 -1
  29. package/dist/core/agent-session.d.ts.map +1 -1
  30. package/dist/core/agent-session.js +189 -31
  31. package/dist/core/agent-session.js.map +1 -1
  32. package/dist/core/canonical-context.d.ts +8 -0
  33. package/dist/core/canonical-context.d.ts.map +1 -1
  34. package/dist/core/canonical-context.js +37 -5
  35. package/dist/core/canonical-context.js.map +1 -1
  36. package/dist/core/compaction/compaction.d.ts +2 -2
  37. package/dist/core/compaction/compaction.d.ts.map +1 -1
  38. package/dist/core/compaction/compaction.js +31 -13
  39. package/dist/core/compaction/compaction.js.map +1 -1
  40. package/dist/core/context-epoch.d.ts +1 -1
  41. package/dist/core/context-epoch.d.ts.map +1 -1
  42. package/dist/core/context-epoch.js +20 -12
  43. package/dist/core/context-epoch.js.map +1 -1
  44. package/dist/core/extensions/types.d.ts +2 -2
  45. package/dist/core/extensions/types.d.ts.map +1 -1
  46. package/dist/core/extensions/types.js.map +1 -1
  47. package/dist/core/history-index-worker.d.ts.map +1 -1
  48. package/dist/core/history-index-worker.js +29 -8
  49. package/dist/core/history-index-worker.js.map +1 -1
  50. package/dist/core/history-index.d.ts +11 -1
  51. package/dist/core/history-index.d.ts.map +1 -1
  52. package/dist/core/history-index.js +2 -1
  53. package/dist/core/history-index.js.map +1 -1
  54. package/dist/core/inference-coordinator.d.ts.map +1 -1
  55. package/dist/core/inference-coordinator.js +110 -13
  56. package/dist/core/inference-coordinator.js.map +1 -1
  57. package/dist/core/kernel/bootstrap.d.ts.map +1 -1
  58. package/dist/core/kernel/bootstrap.js +97 -107
  59. package/dist/core/kernel/bootstrap.js.map +1 -1
  60. package/dist/core/kernel/repl-manager.d.ts.map +1 -1
  61. package/dist/core/kernel/repl-manager.js +11 -0
  62. package/dist/core/kernel/repl-manager.js.map +1 -1
  63. package/dist/core/kernel/shared.d.ts +2 -0
  64. package/dist/core/kernel/shared.d.ts.map +1 -1
  65. package/dist/core/kernel/shared.js.map +1 -1
  66. package/dist/core/messages.d.ts.map +1 -1
  67. package/dist/core/messages.js +4 -1
  68. package/dist/core/messages.js.map +1 -1
  69. package/dist/core/prompts/rlm.d.ts.map +1 -1
  70. package/dist/core/prompts/rlm.js +4 -2
  71. package/dist/core/prompts/rlm.js.map +1 -1
  72. package/dist/core/public-context.d.ts.map +1 -1
  73. package/dist/core/public-context.js +16 -0
  74. package/dist/core/public-context.js.map +1 -1
  75. package/dist/core/refinement/refinement.d.ts +19 -5
  76. package/dist/core/refinement/refinement.d.ts.map +1 -1
  77. package/dist/core/refinement/refinement.js +90 -35
  78. package/dist/core/refinement/refinement.js.map +1 -1
  79. package/dist/core/request-view-selection.d.ts +12 -4
  80. package/dist/core/request-view-selection.d.ts.map +1 -1
  81. package/dist/core/request-view-selection.js +242 -100
  82. package/dist/core/request-view-selection.js.map +1 -1
  83. package/dist/core/retained-tool-output.d.ts +28 -0
  84. package/dist/core/retained-tool-output.d.ts.map +1 -0
  85. package/dist/core/retained-tool-output.js +102 -0
  86. package/dist/core/retained-tool-output.js.map +1 -0
  87. package/dist/core/sdk.d.ts.map +1 -1
  88. package/dist/core/sdk.js +1 -1
  89. package/dist/core/sdk.js.map +1 -1
  90. package/dist/core/selective-recovery.d.ts +47 -3
  91. package/dist/core/selective-recovery.d.ts.map +1 -1
  92. package/dist/core/selective-recovery.js +428 -109
  93. package/dist/core/selective-recovery.js.map +1 -1
  94. package/dist/core/session-history-index.d.ts +3 -1
  95. package/dist/core/session-history-index.d.ts.map +1 -1
  96. package/dist/core/session-history-index.js +1 -1
  97. package/dist/core/session-history-index.js.map +1 -1
  98. package/dist/core/settings-manager.d.ts +5 -0
  99. package/dist/core/settings-manager.d.ts.map +1 -1
  100. package/dist/core/settings-manager.js +3 -0
  101. package/dist/core/settings-manager.js.map +1 -1
  102. package/dist/core/system-prompt.d.ts +3 -1
  103. package/dist/core/system-prompt.d.ts.map +1 -1
  104. package/dist/core/system-prompt.js +3 -3
  105. package/dist/core/system-prompt.js.map +1 -1
  106. package/dist/core/task-frame.d.ts +1 -1
  107. package/dist/core/task-frame.d.ts.map +1 -1
  108. package/dist/core/task-frame.js +21 -1
  109. package/dist/core/task-frame.js.map +1 -1
  110. package/dist/core/task-state-reader.d.ts +10 -2
  111. package/dist/core/task-state-reader.d.ts.map +1 -1
  112. package/dist/core/task-state-reader.js +75 -9
  113. package/dist/core/task-state-reader.js.map +1 -1
  114. package/dist/core/tools/ipython.d.ts +5 -0
  115. package/dist/core/tools/ipython.d.ts.map +1 -1
  116. package/dist/core/tools/ipython.js +59 -17
  117. package/dist/core/tools/ipython.js.map +1 -1
  118. package/dist/core/tools/prime-context.d.ts.map +1 -1
  119. package/dist/core/tools/prime-context.js +1 -1
  120. package/dist/core/tools/prime-context.js.map +1 -1
  121. package/dist/core/view-units.d.ts +4 -0
  122. package/dist/core/view-units.d.ts.map +1 -1
  123. package/dist/core/view-units.js +28 -19
  124. package/dist/core/view-units.js.map +1 -1
  125. package/dist/installer.mjs +98 -77
  126. package/dist/modes/interactive/components/refinement-outcome-message.d.ts.map +1 -1
  127. package/dist/modes/interactive/components/refinement-outcome-message.js.map +1 -1
  128. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  129. package/dist/modes/interactive/interactive-mode.js +5 -5
  130. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  131. package/dist/skills/skill-creator/SKILL.md +18 -1
  132. package/docs/settings.md +45 -0
  133. package/docs/skills.md +77 -2
  134. package/package.json +4 -4
  135. package/skills/skill-creator/SKILL.md +18 -1
  136. package/dist/bundle/chunk-W46VZFI6.js +0 -21681
@@ -14,9 +14,26 @@ A skill is a directory with a `SKILL.md` file (YAML frontmatter + markdown instr
14
14
 
15
15
  Before writing a Python-backed skill, read [references/python-skills.md](references/python-skills.md) for the package contract.
16
16
 
17
+ ## Small Reusable Helpers
18
+
19
+ Keep a one-off operation inline. For repeated multi-step work, first write an
20
+ ordinary named function with explicit inputs and a result docstring. Read current
21
+ data on each call; do not capture old answers, open handles or hidden REPL state.
22
+ After two useful occurrences across tasks, or an explicit reuse request, save an
23
+ editable `scripts/<name>.py` and a short project `SKILL.md` with the existing name,
24
+ description and invocation conventions. A small helper does not need a Python
25
+ package, `pyproject.toml`, installation or promotion workflow.
26
+
27
+ After edits, execute the updated definition or invoke the saved script afresh
28
+ (for example with `runpy.run_path` in the selected environment). Discover through
29
+ the short description and load code only when needed. Prefer the standard library
30
+ and existing dependencies; no per-call installation or automatic scheduling.
31
+ Ordinary errors remain ordinary tool results. Existing execution permissions and
32
+ native instruction-epoch rules still apply.
33
+
17
34
  ## Creating a Skill
18
35
 
19
- 1. **Pick the kind.** Default to markdown. Go Python only when the agent should *call* the capability (`await my_skill(...)`) instead of following instructions.
36
+ 1. **Pick the kind.** Default to markdown, including small editable Python scripts. Use a Python-backed package when the capability needs an installed module such as `await my_skill(...)`, not just an ordinary helper function.
20
37
  2. **Pick the location.** Ask the user when it is not obvious from context:
21
38
  - Project skill, shared via the repo: `.base-context/skills/<name>/`
22
39
  - Personal global skill: `~/.base-context/skills/<name>/`, or `$BASE_CONTEXT_HOME/skills/<name>/` when configured
package/docs/settings.md CHANGED
@@ -454,6 +454,51 @@ records its first actual native compatibility contract once before sending. This
454
454
  does not select a new view or authorize missing contracts in legacy history. Off
455
455
  is not the independent upstream H benchmark control.
456
456
 
457
+ ### Scoped error-fix notes
458
+
459
+ | Setting | Type | Default | Description |
460
+ | --- | --- | --- | --- |
461
+ | `learning.enabled` | boolean | `false` | Let the active agent save and retrieve small scoped problem/fix notes |
462
+
463
+ This opt-in is separate from automatic refinement. It adds no reviewer or model
464
+ call. After a useful recurring repair reaches normal task success, or after an
465
+ explicit user correction, the agent can upsert a memory with an `error-fix:` key.
466
+ Notes are advice, not policy. The current task and observations take precedence.
467
+
468
+ Workspace notes use the selected project root's `.base-context/harness-state.json`.
469
+ They are not retrieved in a different workspace. Existing session/global paths
470
+ and `harness_state.json` filenames stay unchanged. Explicit CRUD stays available
471
+ when learning is off:
472
+
473
+ ```python
474
+ notes = rlm.get_harness_state(scope="workspace")
475
+ notes.upsert("memory", "Project tests", "Problem: dependency missing. Fix: use .venv/bin/python.",
476
+ id="error-fix:project-tests",
477
+ metadata={"tool": "ipython", "operation": "project tests", "condition": "Dependencies are in this project's .venv"})
478
+ notes.get("memory", "error-fix:project-tests")
479
+ # After the note becomes obsolete:
480
+ notes.delete_memory("error-fix:project-tests")
481
+ ```
482
+
483
+ Use local scope for session-only notes. Global writes require an explicit global
484
+ action. Workspace resolution uses the session owner's selected root, never a
485
+ changed REPL working directory. Missing workspace support does not redirect a
486
+ write to another project. Scope-prefixed IDs such as
487
+ `workspace:error-fix:project-tests` work with ordinary inspect/edit/delete calls.
488
+
489
+ Retrieval requires an exact available-tool name when specified and positive word
490
+ overlap with the current operation or task goal. Known conflicting environment
491
+ versions omit a note; retrieval never probes the environment. At most three
492
+ whole notes fit a 512-unit local text allowance, including their advice wrapper.
493
+ The default conservative request-meter estimate charges one unit per UTF-8 byte;
494
+ it is not an exact provider chat/template token count. No remote count call is
495
+ made for notes. Unchanged advice omits version/timestamp/use bookkeeping.
496
+
497
+ Do not record cancellation, deliberately failing tests, transient rate limits,
498
+ secrets, tracebacks, or permanent command bans. Correct old notes with ordinary
499
+ edit/delete. The existing file owner and atomic save apply; independently running
500
+ writers do not gain lossless multi-process transactions.
501
+
457
502
  ### Automatic refinement
458
503
 
459
504
  | Setting | Type | Default | Description |
package/docs/skills.md CHANGED
@@ -11,6 +11,7 @@ Base Context implements the [Agent Skills standard](https://agentskills.io/speci
11
11
  - [Locations](#locations)
12
12
  - [Built-in Skills](#built-in-skills)
13
13
  - [How Skills Work](#how-skills-work)
14
+ - [Reusable Helpers Without Packaging](#reusable-helpers-without-packaging)
14
15
  - [Python-Backed Skills](#python-backed-skills)
15
16
  - [Creating Skills with Base Context](#creating-skills-with-base-context)
16
17
  - [Skill Commands](#skill-commands)
@@ -152,6 +153,80 @@ Generic non-native behavior is unchanged.
152
153
 
153
154
  Skills with `disable-model-invocation: true` are hidden from the startup skill list. They can still be invoked explicitly with `/skill:name`.
154
155
 
156
+ ## Reusable Helpers Without Packaging
157
+
158
+ For repeated multi-step work, start with an ordinary named Python function in
159
+ `ipython`. Keep one-off operations inline and prefer an existing project command
160
+ when it already does the work. Give changing paths, selectors, output paths and
161
+ options explicit parameters. Reuse the code, not its previous answer: read current
162
+ inputs on every call. Do not capture an open handle or hidden mutable REPL state.
163
+
164
+ After two useful occurrences across tasks, or an explicit request for reuse, save
165
+ the function in an editable `.py` file with a short project markdown skill. This
166
+ is a practical heuristic, not a repetition detector. A small helper needs no
167
+ `pyproject.toml`, package installation, manifest or promotion step. Use the standard
168
+ library and dependencies already available in the selected environment.
169
+
170
+ For example, save `scripts/matching_lines.py` in
171
+ `.base-context/skills/matching-lines/`:
172
+
173
+ ```python
174
+ from pathlib import Path
175
+
176
+
177
+ def matching_lines(path: str, needle: str, limit: int = 20) -> list[tuple[int, str]]:
178
+ """Read a current UTF-8 file; return literal matches with one-based lines."""
179
+ if limit < 1:
180
+ raise ValueError("limit must be positive")
181
+ matches = []
182
+ with Path(path).open(encoding="utf-8") as source:
183
+ for line_number, line in enumerate(source, start=1):
184
+ if needle in line:
185
+ matches.append((line_number, line.rstrip("\r\n")))
186
+ if len(matches) == limit:
187
+ break
188
+ return matches
189
+ ```
190
+
191
+ Add the ordinary `SKILL.md` next to `scripts/`:
192
+
193
+ ```markdown
194
+ ---
195
+ name: matching-lines
196
+ description: Read current UTF-8 files for repeated literal line lookups. Inputs are path, needle and limit; output is a list of one-based line numbers and text.
197
+ ---
198
+ Load scripts/matching_lines.py afresh with runpy.run_path, then call
199
+ matching_lines(path, needle, limit=20). Resolve the script path against this
200
+ skill directory. No matches returns an empty list; ordinary errors propagate.
201
+ ```
202
+
203
+ Only the short skill description enters discovery. Load the instructions and code
204
+ when the active task needs them. For this standard-library helper, a fresh load
205
+ and call in `ipython` can be:
206
+
207
+ ```python
208
+ from runpy import run_path
209
+
210
+ matching_lines = run_path("/repo/.base-context/skills/matching-lines/scripts/matching_lines.py")["matching_lines"]
211
+ matches = matching_lines("/repo/current.txt", "needle", limit=20)
212
+ ```
213
+
214
+ After editing a loaded helper, execute its updated definition before calling it
215
+ again, or load the saved script afresh as above. For project imports or commands,
216
+ use the project's own environment instead of installing them into the kernel.
217
+ Fresh execution of editable code does not replace the captured instruction body
218
+ of an active native skill epoch.
219
+
220
+ Saving a helper does not schedule or authorize execution. Invocation still needs
221
+ the normal model/tool decision or an explicit user workflow, under the existing
222
+ permissions. Do not add an import manager, dependency snapshots or per-call setup.
223
+
224
+ For a useful comparison, include construction and failed attempts, then compare
225
+ 1, 2 and 5 uses with the direct path. Record construction time/tokens, later
226
+ model/tool calls and total sequence cost; report time and money separately. A
227
+ first use is not free warmup. Keep the direct path when saving and finding the
228
+ helper costs more than it saves.
229
+
155
230
  ## Python-Backed Skills
156
231
 
157
232
  A Python-backed skill uses the same `SKILL.md` metadata and invocation behavior as a markdown skill, but also provides a Python package for the Python kernel.
@@ -242,7 +317,7 @@ To force the creation workflow explicitly, invoke the built-in skill command:
242
317
  Tell the agent three things:
243
318
 
244
319
  1. **Scope:** use `.base-context/skills/<name>/` for a project skill committed with the repository, or `~/.base-context/skills/<name>/` for a personal skill.
245
- 2. **Kind:** ask for a markdown skill when the capability is primarily instructions; ask for a Python-backed skill when the agent should call reusable functionality from the Python REPL.
320
+ 2. **Kind:** use a markdown skill with editable scripts for small reusable helpers. Ask for a Python-backed skill when an installed module and its package dependencies are needed.
246
321
  3. **Contract:** describe the intended Python call, inputs, output, dependencies, credentials, and verification behavior.
247
322
 
248
323
  The agent should create `SKILL.md` in both cases. For a Python-backed skill it should also create `pyproject.toml` and `src/<import_name>/__init__.py`, expose a documented callable, and verify that the package imports in the kernel.
@@ -251,7 +326,7 @@ Use `/reload` to rediscover new or edited skill metadata. Start a fresh Base Con
251
326
 
252
327
  ### Installed Skills and Continual Harness Skills
253
328
 
254
- An installed Python-backed skill is a real package on disk that adds executable functionality to the kernel. A continual harness skill entry is a persisted description of a reusable Python call, including its reference and argument contract. `/refine` can create or update the latter after a repeated procedure emerges, but it does not replace packaging new functionality with `skill-creator`.
329
+ An installed Python-backed skill is a real package on disk that adds executable functionality to the kernel. A continual harness skill entry is a persisted description of a reusable Python call, including its reference and argument contract. `/refine` can create or update the latter after a repeated procedure emerges, but a description does not create executable code. Small helpers can use the editable script and markdown-skill path above; an installed package is optional.
255
330
 
256
331
  ## Skill Commands
257
332
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ponythewhite/base-context",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Synerise base-context: a coding and research agent with durable context and a persistent Python REPL",
5
5
  "type": "module",
6
6
  "bin": {
@@ -42,9 +42,9 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@agentclientprotocol/sdk": "^1.3.0",
45
- "@ponythewhite/base-context-agent": "1.0.6",
46
- "@ponythewhite/base-context-ai": "1.0.6",
47
- "@ponythewhite/base-context-tui": "1.0.6",
45
+ "@ponythewhite/base-context-agent": "1.0.8",
46
+ "@ponythewhite/base-context-ai": "1.0.8",
47
+ "@ponythewhite/base-context-tui": "1.0.8",
48
48
  "@silvia-odwyer/photon-node": "^0.3.4",
49
49
  "chalk": "^5.5.0",
50
50
  "cli-highlight": "^2.1.11",
@@ -14,9 +14,26 @@ A skill is a directory with a `SKILL.md` file (YAML frontmatter + markdown instr
14
14
 
15
15
  Before writing a Python-backed skill, read [references/python-skills.md](references/python-skills.md) for the package contract.
16
16
 
17
+ ## Small Reusable Helpers
18
+
19
+ Keep a one-off operation inline. For repeated multi-step work, first write an
20
+ ordinary named function with explicit inputs and a result docstring. Read current
21
+ data on each call; do not capture old answers, open handles or hidden REPL state.
22
+ After two useful occurrences across tasks, or an explicit reuse request, save an
23
+ editable `scripts/<name>.py` and a short project `SKILL.md` with the existing name,
24
+ description and invocation conventions. A small helper does not need a Python
25
+ package, `pyproject.toml`, installation or promotion workflow.
26
+
27
+ After edits, execute the updated definition or invoke the saved script afresh
28
+ (for example with `runpy.run_path` in the selected environment). Discover through
29
+ the short description and load code only when needed. Prefer the standard library
30
+ and existing dependencies; no per-call installation or automatic scheduling.
31
+ Ordinary errors remain ordinary tool results. Existing execution permissions and
32
+ native instruction-epoch rules still apply.
33
+
17
34
  ## Creating a Skill
18
35
 
19
- 1. **Pick the kind.** Default to markdown. Go Python only when the agent should *call* the capability (`await my_skill(...)`) instead of following instructions.
36
+ 1. **Pick the kind.** Default to markdown, including small editable Python scripts. Use a Python-backed package when the capability needs an installed module such as `await my_skill(...)`, not just an ordinary helper function.
20
37
  2. **Pick the location.** Ask the user when it is not obvious from context:
21
38
  - Project skill, shared via the repo: `.base-context/skills/<name>/`
22
39
  - Personal global skill: `~/.base-context/skills/<name>/`, or `$BASE_CONTEXT_HOME/skills/<name>/` when configured