dsh-continual-evolve 0.10.5 → 0.11.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 (69) hide show
  1. package/README.md +25 -31
  2. package/README.zh.md +18 -21
  3. package/lib/approval.d.ts +19 -6
  4. package/lib/approval.js +73 -12
  5. package/lib/audit-log.d.ts +19 -0
  6. package/lib/audit-log.js +52 -0
  7. package/lib/auto.js +1 -0
  8. package/lib/benchmark-command.d.ts +1 -1
  9. package/lib/benchmark-command.js +1 -1
  10. package/lib/command-util.d.ts +70 -0
  11. package/lib/command-util.js +123 -0
  12. package/lib/command.d.ts +7 -40
  13. package/lib/command.js +25 -459
  14. package/lib/copy.d.ts +4 -41
  15. package/lib/copy.js +0 -102
  16. package/lib/declines.d.ts +2 -0
  17. package/lib/declines.js +4 -0
  18. package/lib/evolve-event.js +2 -1
  19. package/lib/extraction-phase.d.ts +132 -0
  20. package/lib/extraction-phase.js +236 -0
  21. package/lib/index.d.ts +26 -42
  22. package/lib/index.js +24 -34
  23. package/lib/inject.d.ts +13 -119
  24. package/lib/inject.js +12 -260
  25. package/lib/injection-caps.d.ts +4 -0
  26. package/lib/injection-caps.js +4 -0
  27. package/lib/injection-directory.d.ts +29 -0
  28. package/lib/injection-directory.js +78 -0
  29. package/lib/injection-rank.d.ts +85 -0
  30. package/lib/injection-rank.js +161 -0
  31. package/lib/listener.d.ts +45 -0
  32. package/lib/listener.js +199 -0
  33. package/lib/maintenance-commands.d.ts +23 -0
  34. package/lib/maintenance-commands.js +136 -0
  35. package/lib/memory-agent.d.ts +7 -41
  36. package/lib/memory-agent.js +8 -276
  37. package/lib/memory-apply.d.ts +44 -0
  38. package/lib/memory-apply.js +202 -0
  39. package/lib/memory-manifest.d.ts +16 -0
  40. package/lib/memory-manifest.js +70 -0
  41. package/lib/mount-command.js +1 -1
  42. package/lib/notify.d.ts +9 -20
  43. package/lib/notify.js +0 -40
  44. package/lib/plan-command.d.ts +12 -0
  45. package/lib/plan-command.js +38 -0
  46. package/lib/prefix-cache.d.ts +2 -1
  47. package/lib/review-scheduler.d.ts +1 -1
  48. package/lib/review-scheduler.js +2 -10
  49. package/lib/runtime-commands.d.ts +14 -0
  50. package/lib/runtime-commands.js +115 -0
  51. package/lib/service.d.ts +16 -2
  52. package/lib/service.js +74 -1
  53. package/lib/store.d.ts +1 -2
  54. package/lib/store.js +2 -2
  55. package/lib/tool.d.ts +7 -0
  56. package/lib/tool.js +4 -4
  57. package/lib/turn-snapshot.d.ts +7 -1
  58. package/lib/turn-snapshot.js +14 -0
  59. package/lib/types.d.ts +10 -0
  60. package/lib/types.js +6 -0
  61. package/lib/wrapup-candidates.d.ts +127 -0
  62. package/lib/wrapup-candidates.js +161 -0
  63. package/lib/wrapup-command.d.ts +2 -1
  64. package/lib/wrapup-command.js +7 -4
  65. package/lib/wrapup-proposals.d.ts +101 -0
  66. package/lib/wrapup-proposals.js +281 -0
  67. package/lib/wrapup.d.ts +8 -212
  68. package/lib/wrapup.js +4 -438
  69. package/package.json +1 -1
@@ -0,0 +1,123 @@
1
+ import { projectKeyOf } from "./project.js";
2
+ /** Parse an optional leading scope token ("global" | "project") off the args. */
3
+ export function scopeArg(tokens) {
4
+ if (tokens[0] === "global") {
5
+ return { scope: "global", rest: tokens.slice(1) };
6
+ }
7
+ if (tokens[0] === "project") {
8
+ return { scope: "project", rest: tokens.slice(1) };
9
+ }
10
+ return { scope: "local", rest: tokens };
11
+ }
12
+ /**
13
+ * The store id a scope reads/writes from the human command: live session id
14
+ * for local, derived project key for project, undefined for global. Throws
15
+ * for project when the session cwd is unavailable.
16
+ */
17
+ export function storeIdForCommand(scope, invocation) {
18
+ if (scope === "local") {
19
+ return invocation.agent.id;
20
+ }
21
+ if (scope === "project") {
22
+ const key = projectKeyOf(invocation.agent);
23
+ if (!key) {
24
+ throw new Error("project scope needs the session cwd (unavailable here) — use local or global instead");
25
+ }
26
+ return key;
27
+ }
28
+ return undefined;
29
+ }
30
+ /**
31
+ * Tokenize a command's raw input with shell-like quoting:
32
+ * - a `#` outside quotes starts a comment (rest of the line is dropped);
33
+ * - whitespace separates tokens;
34
+ * - double or single quotes group words into one token and are stripped.
35
+ *
36
+ * This lets users paste help-text examples verbatim, e.g.
37
+ * `/evolve benchmark add-case <bid> "<title>" "<statement>" "<rubric>"`.
38
+ */
39
+ export function tokenizeEvolveInput(rawInput) {
40
+ const tokens = [];
41
+ let current = "";
42
+ let quote = null;
43
+ for (const char of rawInput) {
44
+ if (quote !== null) {
45
+ if (char === quote) {
46
+ quote = null;
47
+ }
48
+ else {
49
+ current += char;
50
+ }
51
+ continue;
52
+ }
53
+ if (char === '"' || char === "'") {
54
+ quote = char;
55
+ continue;
56
+ }
57
+ if (char === "#") {
58
+ break; // rest of the line is a comment
59
+ }
60
+ if (/\s/.test(char)) {
61
+ if (current.length > 0) {
62
+ tokens.push(current);
63
+ current = "";
64
+ }
65
+ continue;
66
+ }
67
+ current += char;
68
+ }
69
+ if (current.length > 0) {
70
+ tokens.push(current);
71
+ }
72
+ return tokens;
73
+ }
74
+ /** Accept both `<id>` (help-text placeholder form) and bare `id`. */
75
+ export function stripAngleBrackets(value) {
76
+ return value.replace(/^<|>$/g, "");
77
+ }
78
+ /**
79
+ * Locate an entry by id across every kind of a store. Ids are only unique
80
+ * within a kind, so the lookup scans all four and returns the first match
81
+ * (kind + entry) or undefined. Used by archive/unarchive, which take a bare
82
+ * id from the user.
83
+ */
84
+ export function findEntryById(state, id) {
85
+ for (const kind of Object.keys(state.entries)) {
86
+ const entry = state.entries[kind][id];
87
+ if (entry) {
88
+ return [kind, entry];
89
+ }
90
+ }
91
+ return undefined;
92
+ }
93
+ export function parsePositiveInt(value, what) {
94
+ const n = Number(value);
95
+ if (!Number.isInteger(n) || n < 1) {
96
+ throw new Error(`${what} must be a positive integer, got "${value}"`);
97
+ }
98
+ return n;
99
+ }
100
+ export function success(text) {
101
+ return { kind: "success", text };
102
+ }
103
+ export function error(text) {
104
+ return { kind: "error", text };
105
+ }
106
+ /** Human-readable one-refinement rendering shared by every apply path. */
107
+ export function renderResult(result) {
108
+ const applied = result.appliedEdits.filter((e) => e.applied);
109
+ const failed = result.appliedEdits.filter((e) => !e.applied);
110
+ const lines = [
111
+ `refinement ${result.id}${result.rollbackOf ? ` (rollback of ${result.rollbackOf})` : ""}: ${applied.length} applied, ${failed.length} failed`,
112
+ `summary: ${result.summary}`,
113
+ ];
114
+ for (const e of applied) {
115
+ lines.push(`- ${e.action} ${e.kind}:${e.id} (v${(e.after?.version ?? e.before?.version) ?? "?"})`);
116
+ }
117
+ for (const e of failed) {
118
+ lines.push(`- failed ${e.action} ${e.kind}:${e.id ?? "(computed)"} — ${e.error ?? "unknown error"}`);
119
+ }
120
+ lines.push(`expected outcome: ${result.expectedOutcome}`);
121
+ return lines.join("\n");
122
+ }
123
+ //# sourceMappingURL=command-util.js.map
package/lib/command.d.ts CHANGED
@@ -1,46 +1,13 @@
1
1
  /**
2
- * The human-facing `/evolve` command: inspect and drive the continual
3
- * harness from the chat UI without the model in between.
2
+ * The human-facing `/evolve` command router: parse the subcommand and hand
3
+ * off to its implementation file. Subcommand logic lives in the
4
+ * `*-command.ts` modules; this file owns only registration, help text, and
5
+ * the core inspect/rollback flows.
4
6
  */
5
7
  import type { Context } from "@deepseek-ai/cordis";
6
- import type { HarnessEntry, HarnessState, RefinementKind } from "./types.js";
7
8
  import type { EvolutionEngine } from "./service.js";
8
- import type { PromotionPolicy } from "./promotion.js";
9
- export interface CommandGateOptions {
10
- requireGlobalApproval: boolean;
11
- }
12
- export interface CommandRuntimeOptions {
13
- rubricKey: Buffer;
14
- /** When a benchmark decision rejects a candidate, roll the refinement back automatically. */
15
- autoRollbackOnReject: boolean;
16
- /** P1: capture failed evolution attempts as draft cases in the auto-regression benchmark. */
17
- autoCase: boolean;
18
- /** Mechanical promotion guards for wrapup/fate (2026-08-22 policy). */
19
- promotionPolicy: PromotionPolicy;
20
- /**
21
- * Initial Memory Agent default from plugin config. The listener is always
22
- * registered; this is not a registration gate.
23
- */
24
- autoReview?: boolean;
25
- }
9
+ import { findEntryById, stripAngleBrackets, tokenizeEvolveInput, type CommandGateOptions, type CommandRuntimeOptions } from "./command-util.js";
10
+ export { findEntryById, stripAngleBrackets, tokenizeEvolveInput };
11
+ export type { CommandGateOptions, CommandRuntimeOptions };
26
12
  export declare function registerEvolveCommand(ctx: Context, engine: EvolutionEngine, opts: CommandGateOptions, runtime: CommandRuntimeOptions): void;
27
- /**
28
- * Tokenize a command's raw input with shell-like quoting:
29
- * - a `#` outside quotes starts a comment (rest of the line is dropped);
30
- * - whitespace separates tokens;
31
- * - double or single quotes group words into one token and are stripped.
32
- *
33
- * This lets users paste help-text examples verbatim, e.g.
34
- * `/evolve benchmark add-case <bid> "<title>" "<statement>" "<rubric>"`.
35
- */
36
- export declare function tokenizeEvolveInput(rawInput: string): string[];
37
- /** Accept both `<id>` (help-text placeholder form) and bare `id`. */
38
- export declare function stripAngleBrackets(value: string): string;
39
- /**
40
- * Locate an entry by id across every kind of a store. Ids are only unique
41
- * within a kind, so the lookup scans all four and returns the first match
42
- * (kind + entry) or undefined. Used by archive/unarchive, which take a bare
43
- * id from the user.
44
- */
45
- export declare function findEntryById(state: HarnessState, id: string): [RefinementKind, HarnessEntry] | undefined;
46
13
  //# sourceMappingURL=command.d.ts.map