@wrongstack/tools 0.310.1 → 0.313.1

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 (135) hide show
  1. package/dist/_shell-pick.d.ts +5 -10
  2. package/dist/audit.js +10 -4055
  3. package/dist/bash.js +9 -2332
  4. package/dist/batch-tool-use.js +2 -187
  5. package/dist/browser/index.js +25 -1339
  6. package/dist/builtin.js +69 -33985
  7. package/dist/chunk-2CTB3UK5.js +197 -0
  8. package/dist/chunk-2ME7ZWDD.js +1272 -0
  9. package/dist/chunk-2TFQDEPU.js +113 -0
  10. package/dist/chunk-2ZCJNKFE.js +315 -0
  11. package/dist/chunk-3PVYQFRQ.js +472 -0
  12. package/dist/chunk-3QMQBO5Z.js +89 -0
  13. package/dist/chunk-42AKKX7O.js +385 -0
  14. package/dist/chunk-42SKEETB.js +113 -0
  15. package/dist/chunk-4BHUSMNL.js +104 -0
  16. package/dist/chunk-4I4LWFOO.js +431 -0
  17. package/dist/chunk-553IQUMO.js +478 -0
  18. package/dist/chunk-55KF77OK.js +1944 -0
  19. package/dist/chunk-6HLZK37X.js +359 -0
  20. package/dist/chunk-6RNIFLG4.js +305 -0
  21. package/dist/chunk-A6BRWIXN.js +317 -0
  22. package/dist/chunk-AHHDWNXC.js +200 -0
  23. package/dist/chunk-B2CIOKWP.js +899 -0
  24. package/dist/chunk-BTSFTGIL.js +7 -0
  25. package/dist/chunk-D33S4RQG.js +222 -0
  26. package/dist/chunk-DIJKHSUO.js +134 -0
  27. package/dist/chunk-DPL47QGS.js +3515 -0
  28. package/dist/chunk-EMRGN4KM.js +170 -0
  29. package/dist/chunk-FGOABE4Z.js +955 -0
  30. package/dist/chunk-FW65TP4G.js +520 -0
  31. package/dist/chunk-GOIZNNOA.js +221 -0
  32. package/dist/chunk-H5MJUAA6.js +295 -0
  33. package/dist/chunk-H5OHH6F4.js +223 -0
  34. package/dist/chunk-HC5RM4WY.js +199 -0
  35. package/dist/chunk-HEQFMLZ7.js +190 -0
  36. package/dist/chunk-HFXSNKCV.js +196 -0
  37. package/dist/chunk-HXSBQ2SE.js +1723 -0
  38. package/dist/chunk-ILESNGNM.js +163 -0
  39. package/dist/chunk-INF5CGAO.js +137 -0
  40. package/dist/chunk-IWDFZ6XR.js +337 -0
  41. package/dist/chunk-IXMNTNW5.js +238 -0
  42. package/dist/chunk-J4SRJKBW.js +428 -0
  43. package/dist/chunk-J5SKD6LN.js +235 -0
  44. package/dist/chunk-JRJJX3L5.js +424 -0
  45. package/dist/chunk-KXNDHMUB.js +366 -0
  46. package/dist/chunk-LIJQMYYX.js +59 -0
  47. package/dist/chunk-MAN26PZ5.js +260 -0
  48. package/dist/chunk-MKRQMLZA.js +474 -0
  49. package/dist/chunk-NBDZMMG2.js +169 -0
  50. package/dist/chunk-NHA6BEIH.js +101 -0
  51. package/dist/chunk-OA6YJIWL.js +4412 -0
  52. package/dist/chunk-OZC255IC.js +2830 -0
  53. package/dist/chunk-PUR6WU2B.js +154 -0
  54. package/dist/chunk-Q5JPPCZC.js +12 -0
  55. package/dist/chunk-QBV725YG.js +128 -0
  56. package/dist/chunk-QHVW4AAM.js +892 -0
  57. package/dist/chunk-QNJ7AQ4B.js +1000 -0
  58. package/dist/chunk-RGISBZBD.js +231 -0
  59. package/dist/chunk-RJZQWEMS.js +84 -0
  60. package/dist/chunk-RP2ZA47V.js +15 -0
  61. package/dist/chunk-RXISBFR5.js +315 -0
  62. package/dist/chunk-S5CCLZL3.js +99 -0
  63. package/dist/chunk-TVTCSBJF.js +122 -0
  64. package/dist/chunk-U4D5S3VQ.js +21 -0
  65. package/dist/chunk-U4VAATKP.js +193 -0
  66. package/dist/chunk-UKU2ZX4C.js +203 -0
  67. package/dist/chunk-UNSKG6DC.js +159 -0
  68. package/dist/chunk-URFKEIHM.js +1091 -0
  69. package/dist/chunk-UTV7YAW7.js +178 -0
  70. package/dist/chunk-V43EQ6VR.js +68 -0
  71. package/dist/chunk-VB3MJGCV.js +610 -0
  72. package/dist/chunk-WHIIIREL.js +223 -0
  73. package/dist/chunk-XMIFYKUT.js +1371 -0
  74. package/dist/chunk-YF2RSV34.js +54 -0
  75. package/dist/chunk-Z6DAKQ3U.js +1 -0
  76. package/dist/chunk-ZIGAZFWE.js +522 -0
  77. package/dist/circuit-breaker.js +3 -191
  78. package/dist/codebase-index/index.js +84 -13688
  79. package/dist/codebase-index/parser-worker-script.js +8 -3995
  80. package/dist/codebase-index/project-server.js +60 -8548
  81. package/dist/codebase-index/worker.js +20 -8416
  82. package/dist/design.js +2 -299
  83. package/dist/diff.js +4 -256
  84. package/dist/document.js +4 -222
  85. package/dist/e2e.js +5 -476
  86. package/dist/edit.js +14 -10200
  87. package/dist/exec.js +16 -3131
  88. package/dist/fetch.js +8 -398
  89. package/dist/format.js +10 -3750
  90. package/dist/generic-parser-VUXDIAOZ.js +13 -0
  91. package/dist/git.js +4 -380
  92. package/dist/glob.js +6 -280
  93. package/dist/go-parser-6CA77WZ4.js +469 -0
  94. package/dist/grep.js +7 -604
  95. package/dist/index.js +318 -35423
  96. package/dist/install.js +10 -4091
  97. package/dist/json-parser-7YMDJSBJ.js +213 -0
  98. package/dist/json.js +4 -665
  99. package/dist/kanban.js +3 -2096
  100. package/dist/languages/index.js +23 -4664
  101. package/dist/legacy-bridge-7UKZT46G.js +18 -0
  102. package/dist/lint.js +10 -3706
  103. package/dist/logs.js +4 -287
  104. package/dist/memory.js +6 -215
  105. package/dist/mode.js +3 -99
  106. package/dist/outdated.js +4 -5170
  107. package/dist/pack.js +65 -33933
  108. package/dist/parser-dispatch-VPOFDO2U.js +14 -0
  109. package/dist/patch.js +13 -9935
  110. package/dist/plan.js +5 -3286
  111. package/dist/process-registry.js +8 -651
  112. package/dist/ps-slash.js +12 -1439
  113. package/dist/py-parser-GPM5VYRG.js +16 -0
  114. package/dist/read.js +13 -9816
  115. package/dist/replace.js +15 -10014
  116. package/dist/rs-parser-WVQ4KYCX.js +81 -0
  117. package/dist/scaffold.js +4 -253
  118. package/dist/search.js +5 -585
  119. package/dist/session-kanban.js +30 -972
  120. package/dist/skill.js +2 -215
  121. package/dist/task.js +5 -3410
  122. package/dist/test.js +10 -3773
  123. package/dist/todo.js +4 -2891
  124. package/dist/tool-help.js +3 -123
  125. package/dist/tool-search.js +3 -79
  126. package/dist/tool-tier.js +68 -34020
  127. package/dist/tool-use.js +2 -93
  128. package/dist/tree-sitter-parser-YCILHGZD.js +17 -0
  129. package/dist/tree.js +4 -288
  130. package/dist/ts-parser-YH4ZMWMH.js +232 -0
  131. package/dist/typecheck.js +10 -3753
  132. package/dist/win32.js +6 -60
  133. package/dist/write.js +14 -9882
  134. package/dist/yaml-parser-GFAOKV53.js +157 -0
  135. package/package.json +5 -5
package/dist/logs.js CHANGED
@@ -1,291 +1,8 @@
1
- // src/logs.ts
2
- import { spawn } from "node:child_process";
3
- import { buildChildEnv } from "@wrongstack/core/utils";
4
-
5
- // src/_regex.ts
6
1
  import {
7
- capSubject,
8
- compileUserRegex,
9
- MAX_SUBJECT_LEN
10
- } from "@wrongstack/primitives";
11
-
12
- // src/_util.ts
13
- import * as fsp from "node:fs/promises";
14
- import * as path from "node:path";
15
- import * as Core from "@wrongstack/core/utils";
16
- function resolvePath(input, ctx) {
17
- return path.isAbsolute(input) ? path.normalize(input) : path.resolve(ctx.workingDir ?? ctx.cwd, input);
18
- }
19
- function allowedRoots(ctx) {
20
- return [path.resolve(ctx.projectRoot), path.resolve(Core.wstackGlobalRoot())];
21
- }
22
- function isInsideAny(target, roots) {
23
- return roots.some((root) => {
24
- const rel = path.relative(root, target);
25
- return rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel);
26
- });
27
- }
28
- function ensureInsideRoot(absPath, ctx) {
29
- const target = path.resolve(absPath);
30
- if (ctx.allowOutsideProjectRoot) return target;
31
- if (isInsideAny(target, allowedRoots(ctx))) return target;
32
- throw new Error(`Path "${absPath}" is outside project root "${path.resolve(ctx.projectRoot)}"`);
33
- }
34
- function safeResolve(input, ctx) {
35
- return ensureInsideRoot(resolvePath(input, ctx), ctx);
36
- }
37
- async function resolveRealInsideRoot(absPath, ctx) {
38
- if (ctx.allowOutsideProjectRoot) return absPath;
39
- const realRoots = await Promise.all(
40
- allowedRoots(ctx).map((r) => fsp.realpath(r).catch(() => path.resolve(r)))
41
- );
42
- let probe = absPath;
43
- const pendingTail = [];
44
- for (; ; ) {
45
- let real;
46
- try {
47
- real = await fsp.realpath(probe);
48
- } catch (err) {
49
- if (err.code === "ENOENT") {
50
- const parent = path.dirname(probe);
51
- if (parent === probe) return absPath;
52
- pendingTail.unshift(path.basename(probe));
53
- probe = parent;
54
- continue;
55
- }
56
- throw err;
57
- }
58
- const candidate = pendingTail.length > 0 ? path.join(real, ...pendingTail) : real;
59
- if (isInsideAny(candidate, realRoots)) {
60
- return candidate;
61
- }
62
- throw new Error(
63
- `Path "${absPath}" resolves through a symlink outside project root "${realRoots[0]}"`
64
- );
65
- }
66
- }
67
- async function safeResolveReal(input, ctx) {
68
- const abs = safeResolve(input, ctx);
69
- return await resolveRealInsideRoot(abs, ctx);
70
- }
71
-
72
- // src/logs.ts
73
- var logsTool = {
74
- name: "logs",
75
- category: "Logs",
76
- description: "Read logs from files or Docker containers. Useful for debugging running applications.",
77
- usageHint: "DEBUGGING TOOL \u2014 USE CAREFULLY IN AUTONOMOUS MODE:\n\n- Prefer `path` for local files or `service` for Docker containers.\n- Always use `filter` (regex) when possible to reduce noise and token usage.\n- `since` narrows Docker logs to a recent window.",
78
- permission: "confirm",
79
- mutating: false,
80
- timeoutMs: 3e4,
81
- maxOutputBytes: 262144,
82
- capabilities: ["shell.restricted"],
83
- icon: "logs",
84
- inputSchema: {
85
- type: "object",
86
- properties: {
87
- service: {
88
- type: "string",
89
- description: "Docker container name (passed to `docker logs`)"
90
- },
91
- path: {
92
- type: "string",
93
- description: "Path to log file (alternative to service)"
94
- },
95
- lines: {
96
- type: "integer",
97
- description: "Number of log lines to fetch (default: 100, 0 for all)",
98
- minimum: 0,
99
- maximum: 1e4
100
- },
101
- filter: {
102
- type: "string",
103
- description: "Regex pattern to filter log lines"
104
- },
105
- since: {
106
- type: "string",
107
- enum: ["1h", "6h", "24h", "all"],
108
- description: 'Only show Docker logs since duration (ignored for files; "all" = no limit)'
109
- },
110
- cwd: { type: "string", description: "Working directory (default: cwd)" }
111
- }
112
- },
113
- async execute(input, ctx, opts) {
114
- const cwd = input.cwd ? await safeResolveReal(input.cwd, ctx) : ctx.cwd;
115
- const lines = input.lines ?? 100;
116
- let filterRe = null;
117
- if (input.filter) {
118
- const compiled = compileUserRegex(input.filter, "i");
119
- if (!compiled.ok) {
120
- throw new Error(`logs: ${compiled.reason}`);
121
- }
122
- filterRe = compiled.regex;
123
- }
124
- if (input.service) {
125
- return await dockerLogs(input.service, lines, filterRe, cwd, opts.signal, input.since);
126
- }
127
- if (input.path) {
128
- return await fileLogs(await safeResolveReal(input.path, ctx), lines, filterRe);
129
- }
130
- return {
131
- source: "none",
132
- entries: [],
133
- total: 0,
134
- truncated: false,
135
- stream_mode: false
136
- };
137
- }
138
- };
139
- async function dockerLogs(service, lines, filterRe, cwd, signal, since) {
140
- const args = ["logs"];
141
- if (lines > 0) args.push("--tail", String(lines));
142
- if (since && since !== "all") {
143
- const sinceMap = { "1h": "1h", "6h": "6h", "24h": "24h" };
144
- args.push("--since", sinceMap[since] ?? "1h");
145
- }
146
- if (!/^[a-zA-Z0-9][a-zA-Z0-9._:-]+$/.test(service)) {
147
- return {
148
- source: `docker:${service}`,
149
- entries: [],
150
- total: 0,
151
- truncated: false,
152
- stream_mode: false
153
- };
154
- }
155
- args.push("--timestamps", service);
156
- return new Promise((resolve2) => {
157
- let stdout = "";
158
- let stderr = "";
159
- const MAX = 2e5;
160
- let settled = false;
161
- const empty = () => ({
162
- source: `docker:${service}`,
163
- entries: [],
164
- total: 0,
165
- truncated: false,
166
- stream_mode: false
167
- });
168
- const finish = (result) => {
169
- if (settled) return;
170
- settled = true;
171
- clearTimeout(timer);
172
- resolve2(result);
173
- };
174
- const child = spawn("docker", args, {
175
- cwd,
176
- signal,
177
- env: buildChildEnv(),
178
- stdio: ["ignore", "pipe", "pipe"],
179
- windowsHide: true
180
- });
181
- const timer = setTimeout(() => {
182
- child.kill("SIGTERM");
183
- finish(empty());
184
- }, DOCKER_LOGS_TIMEOUT_MS);
185
- child.stdout?.on("data", (c) => {
186
- if (stdout.length < MAX) stdout += c.toString();
187
- });
188
- child.stderr?.on("data", (c) => {
189
- if (stderr.length < MAX) stderr += c.toString();
190
- });
191
- child.stdout?.on("error", (e) => {
192
- console.log(
193
- JSON.stringify({ level: "debug", event: "pipe_error", stream: "stdout", error: e.message })
194
- );
195
- });
196
- child.stderr?.on("error", (e) => {
197
- console.log(
198
- JSON.stringify({ level: "debug", event: "pipe_error", stream: "stderr", error: e.message })
199
- );
200
- });
201
- child.on("close", () => {
202
- const output = stdout + stderr;
203
- const entries = parseLogLines(output, filterRe);
204
- finish({
205
- source: `docker:${service}`,
206
- entries,
207
- total: entries.length,
208
- truncated: output.length >= MAX,
209
- stream_mode: false
210
- });
211
- });
212
- child.on("error", () => finish(empty()));
213
- });
214
- }
215
- var DOCKER_LOGS_TIMEOUT_MS = 3e3;
216
- var MAX_TAIL_LINES = 1e5;
217
- async function fileLogs(path2, lines, filterRe) {
218
- const { createInterface } = await import("node:readline");
219
- const { createReadStream } = await import("node:fs");
220
- const entries = [];
221
- const effLines = lines > 0 ? Math.min(lines, MAX_TAIL_LINES) : MAX_TAIL_LINES;
222
- const window = new Array(effLines);
223
- let writeIdx = 0;
224
- let totalLines = 0;
225
- const rl = createInterface({
226
- input: createReadStream(path2),
227
- crlfDelay: Number.POSITIVE_INFINITY
228
- });
229
- for await (const line of rl) {
230
- if (filterRe && !filterRe.test(line)) continue;
231
- window[writeIdx] = line;
232
- writeIdx = (writeIdx + 1) % effLines;
233
- totalLines++;
234
- }
235
- const ordered = [];
236
- const start = totalLines >= effLines ? writeIdx : 0;
237
- const count = Math.min(totalLines, effLines);
238
- for (let i = 0; i < count; i++) {
239
- const v = window[(start + i) % effLines];
240
- if (v !== void 0) ordered.push(v);
241
- }
242
- for (const line of ordered) {
243
- const parsed = parseLine(line);
244
- if (parsed) entries.push(parsed);
245
- }
246
- return {
247
- source: path2,
248
- entries,
249
- total: entries.length,
250
- truncated: totalLines > effLines,
251
- stream_mode: false
252
- };
253
- }
254
- function parseLogLines(output, filterRe) {
255
- const lines = output.split("\n").filter(Boolean);
256
- const entries = [];
257
- for (const line of lines) {
258
- if (filterRe && !filterRe.test(line)) continue;
259
- const parsed = parseLine(line);
260
- if (parsed) entries.push(parsed);
261
- }
262
- return entries;
263
- }
264
- function parseLine(line) {
265
- const tsRe = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?)\s+(?:\[?(\w+)\]?)\s*(.*)/;
266
- const match = tsRe.exec(line);
267
- if (match) {
268
- return {
269
- timestamp: match[1] ?? "",
270
- level: match[2]?.toLowerCase() ?? "info",
271
- message: match[3] ?? ""
272
- };
273
- }
274
- const levelRe = /(ERROR|WARN|INFO|DEBUG|TRACE)\s+(.*)/i;
275
- const levelMatch = levelRe.exec(line);
276
- if (levelMatch) {
277
- return {
278
- timestamp: "",
279
- level: levelMatch[1]?.toLowerCase() ?? "info",
280
- message: levelMatch[2] ?? line
281
- };
282
- }
283
- return {
284
- timestamp: "",
285
- level: "info",
286
- message: line
287
- };
288
- }
2
+ logsTool
3
+ } from "./chunk-RGISBZBD.js";
4
+ import "./chunk-Q5JPPCZC.js";
5
+ import "./chunk-D33S4RQG.js";
289
6
  export {
290
7
  logsTool
291
8
  };
package/dist/memory.js CHANGED
@@ -1,218 +1,9 @@
1
- // src/memory.ts
2
- import { ToolValidationError } from "@wrongstack/core/types";
3
- function rememberTool(memory) {
4
- return {
5
- name: "remember",
6
- category: "Session",
7
- description: "Persist facts, conventions, decisions, and preferences into long-term memory. Memories survive restarts and are scored for relevance in future sessions.",
8
- usageHint: "Persist facts, conventions, decisions, and preferences into long-term memory.\n\nWHEN TO USE:\n- Project conventions discovered during a task (build tool, lint rules, code style)\n- Architecture decisions made (chose X over Y, decided to use pattern Z)\n- User preferences expressed (prefers short names, always uses pnpm)\n- Anti-patterns identified (never do X, avoid pattern Y)\n- File/location references useful across sessions\n\nWHEN NOT TO USE:\n- Temporary task state or progress \u2192 use `todo`\n- One-off debugging notes\n- Information already obvious from the codebase\n\nAlways include `type` and `priority`. Use 1-3 `tags` for grouping.\nBetter to remember a fact now than rediscover it next session.",
9
- permission: "confirm",
10
- mutating: true,
11
- timeoutMs: 2e3,
12
- capabilities: ["memory.write"],
13
- icon: "settings",
14
- inputSchema: {
15
- type: "object",
16
- properties: {
17
- text: {
18
- type: "string",
19
- description: "The fact or note to remember. Keep it concise and factual."
20
- },
21
- scope: {
22
- type: "string",
23
- enum: ["project-agents", "project-memory", "user-memory"],
24
- description: "Where to store it: project-memory (shared), user-memory (personal), or project-agents."
25
- },
26
- type: {
27
- type: "string",
28
- enum: ["fact", "decision", "convention", "preference", "reference", "anti_pattern"],
29
- description: "Category for filtering and relevance scoring."
30
- },
31
- tags: {
32
- type: "array",
33
- items: { type: "string" },
34
- description: "Hashtag-style tags for grouping and search."
35
- },
36
- priority: {
37
- type: "string",
38
- enum: ["critical", "high", "medium", "low"],
39
- description: "Priority level. Critical = always injected into context."
40
- }
41
- },
42
- required: ["text"]
43
- },
44
- async execute(input) {
45
- if (!input?.text) {
46
- throw new ToolValidationError({
47
- message: "remember: text is required",
48
- field: "text"
49
- });
50
- }
51
- const scope = input.scope ?? "project-memory";
52
- await memory.remember(input.text, scope, {
53
- type: input.type,
54
- tags: input.tags,
55
- priority: input.priority
56
- });
57
- return { ok: true, scope };
58
- }
59
- };
60
- }
61
- function forgetTool(memory) {
62
- return {
63
- name: "forget",
64
- category: "Session",
65
- description: "Remove memory entries that contain the given substring (case-insensitive). Use with caution. Pass `dry_run: true` to preview the matching entries (capped at 20) without deleting anything.",
66
- usageHint: "This permanently deletes matching memories in the chosen scope.\n- Provide a reasonably specific `query` to avoid deleting unrelated memories.\n- Always double-check before calling with broad queries \u2014 `dry_run: true` previews the matches without deleting.\n- Use `remember` + `forget` together to maintain clean long-term memory.",
67
- permission: "confirm",
68
- // WS-046: gives permission decisions something to key on — the substring
69
- // being forgotten.
70
- subjectKey: "query",
71
- mutating: true,
72
- timeoutMs: 2e3,
73
- capabilities: ["memory.delete"],
74
- icon: "settings",
75
- inputSchema: {
76
- type: "object",
77
- properties: {
78
- query: { type: "string" },
79
- scope: { type: "string", enum: ["project-agents", "project-memory", "user-memory"] },
80
- dry_run: {
81
- type: "boolean",
82
- description: "When true, return the matched entries (capped at 20) WITHOUT deleting them. Default false."
83
- }
84
- },
85
- required: ["query"]
86
- },
87
- async execute(input) {
88
- if (!input?.query) {
89
- throw new ToolValidationError({
90
- message: "forget: query is required",
91
- field: "query"
92
- });
93
- }
94
- const scope = input.scope ?? "project-memory";
95
- if (input.dry_run) {
96
- const entries = await memory.list(scope);
97
- const needle = input.query.toLowerCase();
98
- const matching = entries.filter((entry) => entry.text.toLowerCase().includes(needle));
99
- return {
100
- removed: 0,
101
- scope,
102
- dryRun: true,
103
- matched: matching.length,
104
- matches: matching.slice(0, 20).map((entry) => entry.text)
105
- };
106
- }
107
- const removed = await memory.forget(input.query, scope);
108
- return { removed, scope };
109
- }
110
- };
111
- }
112
- function searchMemoryTool(memory) {
113
- return {
114
- name: "search_memory",
115
- category: "Session",
116
- description: "Search memory entries by content. With the default backend this does substring matching; semantic/graph backends use embedding similarity or graph traversal.",
117
- usageHint: "Search long-term memory for relevant facts, conventions, or decisions.\n- Returns results ordered by relevance (newest-first for default, similarity for semantic).\n- Use before starting a task to recall project conventions and past decisions.\n- `limit` caps results (default 5, max 20).",
118
- permission: "auto",
119
- mutating: false,
120
- timeoutMs: 2e3,
121
- capabilities: ["memory.read"],
122
- inputSchema: {
123
- type: "object",
124
- properties: {
125
- query: {
126
- type: "string",
127
- description: "Search query \u2014 words or phrase to find in memory."
128
- },
129
- scope: {
130
- type: "string",
131
- enum: ["project-agents", "project-memory", "user-memory"],
132
- description: "Which scope to search. Defaults to project-memory."
133
- },
134
- limit: {
135
- type: "number",
136
- description: "Maximum results to return (default 5, max 20)."
137
- }
138
- },
139
- required: ["query"]
140
- },
141
- async execute(input) {
142
- if (!input?.query) {
143
- throw new ToolValidationError({
144
- message: "search_memory: query is required",
145
- field: "query"
146
- });
147
- }
148
- const scope = input.scope ?? "project-memory";
149
- const limit = Math.min(input.limit ?? 5, 20);
150
- const entries = await memory.search(input.query, scope, limit);
151
- return {
152
- results: entries.map((e) => ({
153
- text: e.text,
154
- ts: e.ts,
155
- scope: e.scope,
156
- type: e.type,
157
- tags: e.tags,
158
- priority: e.priority
159
- }))
160
- };
161
- }
162
- };
163
- }
164
- function relatedMemoryTool(memory) {
165
- return {
166
- name: "find_related_memories",
167
- category: "Session",
168
- description: "Find memories related to the given text via graph traversal. Only available with graph backends; falls back to content search with file backends.",
169
- usageHint: "Discover memories connected to a topic through co-occurrence or similarity edges.\n- Useful for exploring what else the project knows about a given concept.\n- Falls back to content search when no graph backend is configured.\n- `limit` caps results (default 5, max 20).",
170
- permission: "auto",
171
- mutating: false,
172
- timeoutMs: 2e3,
173
- capabilities: ["memory.read"],
174
- inputSchema: {
175
- type: "object",
176
- properties: {
177
- text: {
178
- type: "string",
179
- description: "Text to find related memories for."
180
- },
181
- scope: {
182
- type: "string",
183
- enum: ["project-agents", "project-memory", "user-memory"],
184
- description: "Which scope to search. Defaults to project-memory."
185
- },
186
- limit: {
187
- type: "number",
188
- description: "Maximum results to return (default 5, max 20)."
189
- }
190
- },
191
- required: ["text"]
192
- },
193
- async execute(input) {
194
- if (!input?.text) {
195
- throw new ToolValidationError({
196
- message: "find_related_memories: text is required",
197
- field: "text"
198
- });
199
- }
200
- const scope = input.scope ?? "project-memory";
201
- const limit = Math.min(input.limit ?? 5, 20);
202
- const entries = memory.findRelated ? await memory.findRelated(input.text, scope, limit) : await memory.search(input.text, scope, limit);
203
- return {
204
- results: entries.map((e) => ({
205
- text: e.text,
206
- ts: e.ts,
207
- scope: e.scope,
208
- type: e.type,
209
- tags: e.tags,
210
- priority: e.priority
211
- }))
212
- };
213
- }
214
- };
215
- }
1
+ import {
2
+ forgetTool,
3
+ relatedMemoryTool,
4
+ rememberTool,
5
+ searchMemoryTool
6
+ } from "./chunk-WHIIIREL.js";
216
7
  export {
217
8
  forgetTool,
218
9
  relatedMemoryTool,
package/dist/mode.js CHANGED
@@ -1,102 +1,6 @@
1
- // src/mode.ts
2
- function modeFamily(mode) {
3
- if (mode.tags?.includes("lite")) return "lite";
4
- if (mode.tags?.includes("deep")) return "deep";
5
- if (mode.tags?.includes("balanced") || mode.id === "default") return "balanced";
6
- return "custom";
7
- }
8
- function createModeTool(modeStore) {
9
- return {
10
- name: "mode",
11
- category: "Session",
12
- description: "Manage agent operating modes. Modes change the agent's behavior, personality, and system prompt for different workflows (e.g. coding, security review, planning).",
13
- usageHint: "POWERFUL BEHAVIOR CONTROL TOOL:\n\n- Use `list` to see available modes.\n- Use `set <modeId>` to switch the agent into a specific role/mode.\n- Use `get` to check current mode.\n- Use `clear` to return to default behavior.\nSwitching modes is very effective for specialized tasks. The mode change affects how the agent reasons and which guidelines it follows.",
14
- permission: "confirm",
15
- // WS-046: gives permission decisions something to key on — the mode being
16
- // activated. Permission semantics are unchanged.
17
- subjectKey: "mode",
18
- mutating: true,
19
- timeoutMs: 5e3,
20
- capabilities: ["session.mode"],
21
- icon: "settings",
22
- inputSchema: {
23
- type: "object",
24
- properties: {
25
- action: {
26
- type: "string",
27
- enum: ["get", "list", "set", "clear"],
28
- description: "The mode operation to perform."
29
- },
30
- mode: {
31
- type: "string",
32
- description: "The mode identifier to activate (only required when action=set)."
33
- }
34
- },
35
- required: ["action"]
36
- },
37
- async execute(input) {
38
- switch (input.action) {
39
- case "get": {
40
- const mode = await modeStore.getActiveMode();
41
- return {
42
- action: "get",
43
- currentMode: mode?.id,
44
- success: true,
45
- message: mode ? `Current mode: ${mode.name} \u2014 ${mode.description}` : "No mode set (using default)"
46
- };
47
- }
48
- case "list": {
49
- const modes = await modeStore.listModes();
50
- const lines = modes.map((m) => ` ${m.id.padEnd(20)} [${modeFamily(m)}] ${m.name} \u2014 ${m.description}`).join("\n");
51
- return {
52
- action: "list",
53
- modes: modes.map((m) => ({
54
- id: m.id,
55
- name: m.name,
56
- description: m.description,
57
- family: modeFamily(m),
58
- tags: m.tags ?? []
59
- })),
60
- success: true,
61
- message: lines
62
- };
63
- }
64
- case "set": {
65
- if (!input.mode) {
66
- return { action: "set", success: false, message: "mode is required for action=set" };
67
- }
68
- const mode = await modeStore.getMode(input.mode);
69
- if (!mode) {
70
- return { action: "set", success: false, message: `Mode "${input.mode}" not found` };
71
- }
72
- await modeStore.setActiveMode(input.mode);
73
- return {
74
- action: "set",
75
- currentMode: mode.id,
76
- success: true,
77
- message: `Switched to mode: ${mode.name}
78
-
79
- ${mode.description}`
80
- };
81
- }
82
- case "clear": {
83
- await modeStore.setActiveMode(null);
84
- return {
85
- action: "clear",
86
- success: true,
87
- message: "Mode cleared \u2014 using default mode"
88
- };
89
- }
90
- default:
91
- return {
92
- action: input.action,
93
- success: false,
94
- message: `Unknown action "${input.action}"`
95
- };
96
- }
97
- }
98
- };
99
- }
1
+ import {
2
+ createModeTool
3
+ } from "./chunk-4BHUSMNL.js";
100
4
  export {
101
5
  createModeTool
102
6
  };