@mjasnikovs/pi-task 0.38.31 → 0.39.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.
Files changed (59) hide show
  1. package/README.md +2 -1
  2. package/dist/config/config.d.ts +16 -2
  3. package/dist/config/config.js +7 -2
  4. package/dist/config/group-args.d.ts +52 -0
  5. package/dist/config/group-args.js +110 -0
  6. package/dist/config/group-models.d.ts +88 -0
  7. package/dist/config/group-models.js +117 -0
  8. package/dist/config/groups.d.ts +76 -0
  9. package/dist/config/groups.js +110 -0
  10. package/dist/config/option-picker.d.ts +70 -0
  11. package/dist/config/option-picker.js +113 -0
  12. package/dist/config/reasoning.d.ts +26 -64
  13. package/dist/config/reasoning.js +31 -115
  14. package/dist/config/register.d.ts +144 -24
  15. package/dist/config/register.js +345 -56
  16. package/dist/index.js +2 -0
  17. package/dist/remote/push.js +1 -7
  18. package/dist/shared/data-home.d.ts +8 -0
  19. package/dist/shared/data-home.js +14 -0
  20. package/dist/shared/model-endpoint.d.ts +53 -0
  21. package/dist/shared/model-endpoint.js +98 -2
  22. package/dist/shared/reasoning-capability.d.ts +25 -5
  23. package/dist/shared/reasoning-capability.js +18 -9
  24. package/dist/task/child-runner.d.ts +19 -16
  25. package/dist/task/child-runner.js +64 -36
  26. package/dist/task/context-usage.d.ts +46 -0
  27. package/dist/task/context-usage.js +41 -0
  28. package/dist/task/gate-child.d.ts +15 -4
  29. package/dist/task/gate-child.js +2 -2
  30. package/dist/task/gate-deps.js +7 -2
  31. package/dist/task/implementation-hold.d.ts +118 -0
  32. package/dist/task/implementation-hold.js +165 -0
  33. package/dist/task/model-hold-stash.d.ts +43 -0
  34. package/dist/task/model-hold-stash.js +70 -0
  35. package/dist/task/orchestrator.d.ts +18 -5
  36. package/dist/task/orchestrator.js +36 -4
  37. package/dist/task/phases.js +2 -2
  38. package/dist/task/research-worker.d.ts +2 -2
  39. package/dist/task/research-worker.js +1 -1
  40. package/dist/workers/docs-core.js +2 -2
  41. package/dist/workers/docs-lookup.d.ts +4 -3
  42. package/dist/workers/docs-lookup.js +1 -1
  43. package/dist/workers/fetch-core.js +2 -2
  44. package/dist/workers/focused-extractor.d.ts +4 -3
  45. package/dist/workers/focused-extractor.js +5 -4
  46. package/dist/workers/index.js +2 -0
  47. package/dist/workers/model-warning.d.ts +69 -0
  48. package/dist/workers/model-warning.js +113 -0
  49. package/dist/workers/pi-worker-core.d.ts +7 -7
  50. package/dist/workers/pi-worker-core.js +4 -3
  51. package/dist/workers/pi-worker-docs.js +2 -2
  52. package/dist/workers/pi-worker.js +4 -4
  53. package/dist/workers/reasoning-warning.d.ts +17 -9
  54. package/dist/workers/reasoning-warning.js +69 -22
  55. package/package.json +1 -1
  56. package/dist/config/reasoning-args.d.ts +0 -23
  57. package/dist/config/reasoning-args.js +0 -28
  58. package/dist/task/implementation-thinking.d.ts +0 -56
  59. package/dist/task/implementation-thinking.js +0 -32
@@ -1,23 +0,0 @@
1
- /**
2
- * The live-config bridge for reasoning profiles: group in, argv fragment out.
3
- *
4
- * Separate from reasoning.ts because that module must take no import with a
5
- * runtime side effect — see its header. The `getConfig()` read lives here
6
- * instead: this file imports both, and nothing in config/ imports it back, so
7
- * the graph stays a tree.
8
- *
9
- * Read PER CALL, never cached at module scope, so a /task-config change lands on
10
- * the next child without a restart. Same contract `childBaseArgs` keeps.
11
- */
12
- import { type PiTaskConfig } from './config.js';
13
- import { type ReasoningGroup } from './reasoning.js';
14
- /**
15
- * The `['--thinking', level]` fragment for a group, or `[]` when the group is
16
- * `inherit` and the child should keep falling back to settings.json.
17
- *
18
- * Every argv builder calls this rather than reading config itself. The two
19
- * callers that skip it are not argv builders: the host-session turn
20
- * (implementation-thinking.ts) and the settings UI (register.ts) both need the
21
- * level itself, not a flag, so they call `resolveReasoning` directly.
22
- */
23
- export declare function groupThinkingArgs(group: ReasoningGroup, cfg?: PiTaskConfig): string[];
@@ -1,28 +0,0 @@
1
- /**
2
- * The live-config bridge for reasoning profiles: group in, argv fragment out.
3
- *
4
- * Separate from reasoning.ts because that module must take no import with a
5
- * runtime side effect — see its header. The `getConfig()` read lives here
6
- * instead: this file imports both, and nothing in config/ imports it back, so
7
- * the graph stays a tree.
8
- *
9
- * Read PER CALL, never cached at module scope, so a /task-config change lands on
10
- * the next child without a restart. Same contract `childBaseArgs` keeps.
11
- */
12
- import { getConfig } from './config.js';
13
- import { resolveReasoning, thinkingArgs } from './reasoning.js';
14
- /**
15
- * The `['--thinking', level]` fragment for a group, or `[]` when the group is
16
- * `inherit` and the child should keep falling back to settings.json.
17
- *
18
- * Every argv builder calls this rather than reading config itself. The two
19
- * callers that skip it are not argv builders: the host-session turn
20
- * (implementation-thinking.ts) and the settings UI (register.ts) both need the
21
- * level itself, not a flag, so they call `resolveReasoning` directly.
22
- */
23
- export function groupThinkingArgs(group, cfg) {
24
- // The default is evaluated HERE, per call. Hoisting the read to module scope
25
- // would leave every test green, so the optional parameter is what makes the
26
- // per-call contract assertable.
27
- return thinkingArgs(resolveReasoning(group, cfg ?? getConfig()));
28
- }
@@ -1,56 +0,0 @@
1
- /**
2
- * Hold the host session at the `implementation` group's thinking level for the
3
- * duration of one implementation turn, then put it back.
4
- *
5
- * WHY THIS GROUP IS NOT LIKE THE OTHERS
6
- * -------------------------------------
7
- * Every other reasoning group runs in a child process, so its level is one argv
8
- * flag (`--thinking <level>`, built in reasoning-args.ts) and it dies with the
9
- * child. The implementation turn runs in the USER'S OWN session
10
- * (orchestrator.ts `sendSpec` -> `sendUserMessage` -> `superviseImplementation`),
11
- * so the only lever is `pi.setThinkingLevel`, which is session-global.
12
- *
13
- * THREE THINGS pi DOES that this has to survive:
14
- *
15
- * 1. IT PERSISTS. pi-coding-agent's agent-session `setThinkingLevel` calls
16
- * `settingsManager.setDefaultThinkingLevel(...)` whenever the effective
17
- * level actually changes, and that writes pi's global settings file
18
- * (`~/.pi/agent/settings.json`). Without the restore, running one task would
19
- * silently rewrite the user's global default. That makes `release()`
20
- * load-bearing, not tidy-up.
21
- * 2. IT CLAMPS, to the levels the model declares. A model with no reasoning
22
- * support offers only `off`, so asking for `medium` yields `off`. The
23
- * restore therefore writes back what was READ after setting, never what was
24
- * asked for — otherwise a clamp would ratchet the stored default a little
25
- * further every run.
26
- * 3. IT IS OBSERVABLE, and the user can change it mid-turn: `shift+tab` is the
27
- * default binding for `app.thinking.cycle`, and a change invalidates the
28
- * footer. Restoring blindly would clobber a choice they just made. We detect
29
- * it by comparing the live level at release against what we applied: if it
30
- * has moved, somebody else moved it, and we leave it alone.
31
- *
32
- * We compare rather than subscribe because the extension API's `on(...)` returns
33
- * `void` — there is no unsubscribe handle — so a per-turn listener could only
34
- * ever be added, never removed. The comparison answers the same question with no
35
- * accumulating state.
36
- */
37
- import type { ThinkingLevel } from '@earendil-works/pi-agent-core';
38
- import { type GroupSetting } from '../config/reasoning.js';
39
- /**
40
- * The slice of the extension API this needs, named so tests can drive the
41
- * hold-and-restore with a fake object instead of a live pi session.
42
- */
43
- export interface ThinkingControl {
44
- get(): ThinkingLevel;
45
- set(level: ThinkingLevel): void;
46
- }
47
- /**
48
- * Put the session at the implementation group's level and return the function
49
- * that puts it back. Always call the returned function — `finally`, not the
50
- * happy path.
51
- *
52
- * `inherit` makes NO call at all, not even a redundant set-to-current. It means
53
- * the same thing here as in `thinkingArgs`, which emits no `--thinking` flag for
54
- * it: leave the level wherever it already is.
55
- */
56
- export declare function holdImplementationThinking(control: ThinkingControl, setting?: GroupSetting): () => void;
@@ -1,32 +0,0 @@
1
- import { getConfig } from '../config/config.js';
2
- import { resolveReasoning } from '../config/reasoning.js';
3
- /**
4
- * Put the session at the implementation group's level and return the function
5
- * that puts it back. Always call the returned function — `finally`, not the
6
- * happy path.
7
- *
8
- * `inherit` makes NO call at all, not even a redundant set-to-current. It means
9
- * the same thing here as in `thinkingArgs`, which emits no `--thinking` flag for
10
- * it: leave the level wherever it already is.
11
- */
12
- export function holdImplementationThinking(control, setting = resolveReasoning('implementation', getConfig())) {
13
- if (setting === 'inherit')
14
- return () => { };
15
- const before = control.get();
16
- control.set(setting);
17
- // Post-clamp, so a model that cannot do `medium` does not leave us believing
18
- // it is at `medium` and treating the user's later change as our own.
19
- const applied = control.get();
20
- if (applied === before)
21
- return () => { };
22
- let released = false;
23
- return () => {
24
- // Idempotent by contract: only the first call restores. A later call
25
- // would write `before` on top of whatever the level is by then.
26
- if (released)
27
- return;
28
- released = true;
29
- if (control.get() === applied)
30
- control.set(before);
31
- };
32
- }