@wrongstack/tools 0.313.0 → 0.316.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.
- package/dist/_edit-match.d.ts +3 -2
- package/dist/_output-spool.d.ts +4 -3
- package/dist/_shell-pick.d.ts +2 -1
- package/dist/_spawn-stream.d.ts +2 -1
- package/dist/_syntax-check.d.ts +2 -1
- package/dist/audit.js +10 -4055
- package/dist/bash-kill-guard.d.ts +3 -6
- package/dist/bash.js +9 -2308
- package/dist/batch-tool-use.js +2 -187
- package/dist/browser/index.js +25 -1339
- package/dist/browser/network-guard-proxy.d.ts +2 -1
- package/dist/builtin.js +69 -33949
- package/dist/chunk-22B7GE5T.js +260 -0
- package/dist/chunk-2VSZC6QM.js +113 -0
- package/dist/chunk-3PVYQFRQ.js +472 -0
- package/dist/chunk-42BHI7TN.js +337 -0
- package/dist/chunk-4BHUSMNL.js +104 -0
- package/dist/chunk-4I4LWFOO.js +431 -0
- package/dist/chunk-4UESMQDP.js +122 -0
- package/dist/chunk-553IQUMO.js +478 -0
- package/dist/chunk-5H4GSJAI.js +223 -0
- package/dist/chunk-6RNIFLG4.js +305 -0
- package/dist/chunk-7EY5DCRO.js +434 -0
- package/dist/chunk-A6BRWIXN.js +317 -0
- package/dist/chunk-AHHDWNXC.js +200 -0
- package/dist/chunk-BSLVR56S.js +199 -0
- package/dist/chunk-BTSFTGIL.js +7 -0
- package/dist/chunk-D33S4RQG.js +222 -0
- package/dist/chunk-DA4KNE2H.js +4412 -0
- package/dist/chunk-DR7JOQTC.js +520 -0
- package/dist/chunk-EEOFQDT6.js +898 -0
- package/dist/chunk-EJWSCQ6D.js +137 -0
- package/dist/chunk-EMRGN4KM.js +170 -0
- package/dist/chunk-FQZOHLG3.js +89 -0
- package/dist/chunk-GOIZNNOA.js +221 -0
- package/dist/chunk-HFXSNKCV.js +196 -0
- package/dist/chunk-HYX2TZ7O.js +1272 -0
- package/dist/chunk-I64BS3VC.js +15 -0
- package/dist/chunk-IVWV2UM6.js +955 -0
- package/dist/chunk-IXMNTNW5.js +238 -0
- package/dist/chunk-IYK7XGDZ.js +892 -0
- package/dist/chunk-J5SKD6LN.js +235 -0
- package/dist/chunk-JNNVRHMV.js +2111 -0
- package/dist/chunk-JOHXDF3D.js +295 -0
- package/dist/chunk-JRJJX3L5.js +424 -0
- package/dist/chunk-K3WNSHUF.js +1371 -0
- package/dist/chunk-L25CVUVR.js +2830 -0
- package/dist/chunk-LIJQMYYX.js +59 -0
- package/dist/chunk-LWKUTMD5.js +197 -0
- package/dist/chunk-MQX2KXVW.js +54 -0
- package/dist/chunk-MZZN7VCD.js +359 -0
- package/dist/chunk-NBDZMMG2.js +169 -0
- package/dist/chunk-NKJW5GFO.js +366 -0
- package/dist/chunk-NKNOBUBU.js +522 -0
- package/dist/chunk-O4MBV4AX.js +134 -0
- package/dist/chunk-OUBDL3WH.js +3515 -0
- package/dist/chunk-PQKK5JH7.js +101 -0
- package/dist/chunk-PY2IOS7C.js +1000 -0
- package/dist/chunk-Q5JPPCZC.js +12 -0
- package/dist/chunk-QBV725YG.js +128 -0
- package/dist/chunk-QZQSPUBF.js +315 -0
- package/dist/chunk-RGISBZBD.js +231 -0
- package/dist/chunk-RJZQWEMS.js +84 -0
- package/dist/chunk-RXISBFR5.js +315 -0
- package/dist/chunk-S5CCLZL3.js +99 -0
- package/dist/chunk-SDLVH5RZ.js +178 -0
- package/dist/chunk-T2F4S7U4.js +1723 -0
- package/dist/chunk-TEBQ4VPZ.js +163 -0
- package/dist/chunk-U4D5S3VQ.js +21 -0
- package/dist/chunk-U4VAATKP.js +193 -0
- package/dist/chunk-UCYQTZ7F.js +113 -0
- package/dist/chunk-UKU2ZX4C.js +203 -0
- package/dist/chunk-UNSKG6DC.js +159 -0
- package/dist/chunk-V43EQ6VR.js +68 -0
- package/dist/chunk-VB3MJGCV.js +610 -0
- package/dist/chunk-VFKPWSOX.js +154 -0
- package/dist/chunk-VJNHFZ7J.js +190 -0
- package/dist/chunk-VXECAJJ7.js +1091 -0
- package/dist/chunk-WHIIIREL.js +223 -0
- package/dist/chunk-Z6DAKQ3U.js +1 -0
- package/dist/chunk-ZJQ4IGXK.js +474 -0
- package/dist/chunk-ZLTFLC25.js +385 -0
- package/dist/circuit-breaker.js +3 -191
- package/dist/codebase-index/ast-invariant-engine.d.ts +5 -4
- package/dist/codebase-index/binary-frame.d.ts +0 -2
- package/dist/codebase-index/bm25.d.ts +1 -1
- package/dist/codebase-index/circuit-breaker.d.ts +2 -1
- package/dist/codebase-index/codebase-ast-replace-tool.d.ts +3 -2
- package/dist/codebase-index/codebase-impact-analysis-tool.d.ts +4 -3
- package/dist/codebase-index/codebase-invariant-check-tool.d.ts +3 -2
- package/dist/codebase-index/codebase-repo-map-tool.d.ts +3 -2
- package/dist/codebase-index/codebase-skeleton-tool.d.ts +3 -2
- package/dist/codebase-index/codebase-targeted-test-tool.d.ts +3 -2
- package/dist/codebase-index/content-hash.d.ts +0 -2
- package/dist/codebase-index/import-extractor.d.ts +0 -13
- package/dist/codebase-index/index-service.d.ts +1 -1
- package/dist/codebase-index/index.js +84 -13688
- package/dist/codebase-index/languages.d.ts +2 -1
- package/dist/codebase-index/module-roots.d.ts +3 -2
- package/dist/codebase-index/parser-batch.d.ts +0 -5
- package/dist/codebase-index/parser-dispatch.d.ts +2 -1
- package/dist/codebase-index/parser-output.d.ts +4 -3
- package/dist/codebase-index/parser-worker-pool.d.ts +0 -2
- package/dist/codebase-index/parser-worker-script.d.ts +1 -16
- package/dist/codebase-index/parser-worker-script.js +8 -3995
- package/dist/codebase-index/project-server-client-state.d.ts +2 -2
- package/dist/codebase-index/project-server-endpoint.d.ts +0 -15
- package/dist/codebase-index/project-server.js +60 -8548
- package/dist/codebase-index/tree-sitter/visitor.d.ts +2 -1
- package/dist/codebase-index/tree-sitter-parser.d.ts +0 -2
- package/dist/codebase-index/ts-parser.d.ts +1 -1
- package/dist/codebase-index/vector-search.d.ts +2 -1
- package/dist/codebase-index/wal-maintenance.d.ts +3 -2
- package/dist/codebase-index/worker.js +20 -8416
- package/dist/codebase-index/writer-admin.d.ts +0 -1
- package/dist/codebase-index/writer-search.d.ts +0 -9
- package/dist/design.js +2 -299
- package/dist/diff.js +4 -256
- package/dist/document.js +4 -222
- package/dist/e2e.js +5 -476
- package/dist/edit.js +14 -10200
- package/dist/exec.js +16 -3131
- package/dist/fetch.js +8 -398
- package/dist/format.js +10 -3750
- package/dist/generic-parser-VUXDIAOZ.js +13 -0
- package/dist/git.js +4 -380
- package/dist/glob.js +6 -280
- package/dist/go-parser-JXYKJHRC.js +469 -0
- package/dist/grep.js +7 -604
- package/dist/index.js +318 -35387
- package/dist/install.js +10 -4091
- package/dist/json-parser-IBHZ4BZC.js +213 -0
- package/dist/json.js +4 -665
- package/dist/kanban-contract-actions.d.ts +1 -1
- package/dist/kanban-detail-actions.d.ts +2 -1
- package/dist/kanban-presence.d.ts +2 -1
- package/dist/kanban-serializer.d.ts +0 -8
- package/dist/kanban-split-task-handler.d.ts +2 -2
- package/dist/kanban-tool-types.d.ts +2 -1
- package/dist/kanban.js +3 -2096
- package/dist/languages/diagnostics.d.ts +2 -1
- package/dist/languages/index.js +23 -4664
- package/dist/languages/legacy-bridge.d.ts +3 -2
- package/dist/languages/types.d.ts +2 -1
- package/dist/legacy-bridge-7M6QLUQN.js +18 -0
- package/dist/lint.js +10 -3706
- package/dist/logs.js +4 -287
- package/dist/memory.js +6 -215
- package/dist/mode.js +3 -99
- package/dist/outdated.js +4 -5170
- package/dist/pack.js +65 -33897
- package/dist/parser-dispatch-QH4XPGG6.js +14 -0
- package/dist/patch.js +13 -9935
- package/dist/plan.js +5 -3286
- package/dist/process-registry.js +8 -651
- package/dist/ps-slash.js +12 -1439
- package/dist/pwsh.d.ts +0 -1
- package/dist/py-parser-IS4HKYMF.js +16 -0
- package/dist/read.js +13 -9816
- package/dist/replace.js +15 -10014
- package/dist/rs-parser-XHUUO2KZ.js +81 -0
- package/dist/scaffold.js +4 -253
- package/dist/search.js +5 -585
- package/dist/session-kanban-sync.d.ts +0 -6
- package/dist/session-kanban.js +30 -972
- package/dist/skill.js +2 -215
- package/dist/spawn-background.d.ts +1 -1
- package/dist/task.js +5 -3410
- package/dist/test.js +10 -3773
- package/dist/todo.js +4 -2891
- package/dist/tool-help.js +3 -123
- package/dist/tool-search.js +3 -79
- package/dist/tool-tier.js +68 -33984
- package/dist/tool-use.js +2 -93
- package/dist/tree-sitter-parser-AIERW3YI.js +15 -0
- package/dist/tree.js +4 -288
- package/dist/ts-parser-RCTYKSVI.js +232 -0
- package/dist/typecheck.js +10 -3753
- package/dist/win32.js +6 -60
- package/dist/write.js +14 -9882
- package/dist/yaml-parser-4SAXV3PL.js +157 -0
- 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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
};
|