@datename/fastcode-termux 0.1.6-beta → 0.1.8-beta.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.
- package/LICENSE +4 -0
- package/README.md +50 -17
- package/dist/agent/approval-json.d.ts +43 -0
- package/dist/agent/approval-json.js +69 -0
- package/dist/agent/approval-native.d.ts +3 -0
- package/dist/agent/approval-native.js +165 -0
- package/dist/agent/approval-store.d.ts +16 -0
- package/dist/agent/approval-store.js +21 -0
- package/dist/agent/approval.d.ts +33 -0
- package/dist/agent/approval.js +40 -5
- package/dist/agent/compaction.d.ts +2 -0
- package/dist/agent/compaction.js +60 -17
- package/dist/agent/guards.d.ts +16 -16
- package/dist/agent/guards.js +978 -24
- package/dist/agent/policy/defaults.d.ts +16 -0
- package/dist/agent/policy/defaults.js +17 -0
- package/dist/agent/policy/egress.d.ts +32 -0
- package/dist/agent/policy/egress.js +280 -0
- package/dist/agent/process-tree.d.ts +20 -0
- package/dist/agent/process-tree.js +81 -10
- package/dist/agent/protocol.d.ts +20 -1
- package/dist/agent/protocol.js +165 -38
- package/dist/agent/registry.d.ts +3 -1
- package/dist/agent/registry.js +168 -11
- package/dist/agent/runner.d.ts +21 -0
- package/dist/agent/runner.js +44 -5
- package/dist/agent/shell-ast.d.ts +11 -0
- package/dist/agent/shell-ast.js +204 -0
- package/dist/agent/shell-session.d.ts +14 -0
- package/dist/agent/shell-session.js +251 -40
- package/dist/agent/tool-schemas.js +26 -7
- package/dist/agent/tools/append_file.js +3 -1
- package/dist/agent/tools/apply_patch.js +44 -4
- package/dist/agent/tools/copy_file.js +26 -3
- package/dist/agent/tools/delete_file.js +22 -3
- package/dist/agent/tools/grep.js +35 -4
- package/dist/agent/tools/make_dir.js +3 -1
- package/dist/agent/tools/move_path.d.ts +7 -0
- package/dist/agent/tools/move_path.js +31 -5
- package/dist/agent/tools/read_file.js +63 -3
- package/dist/agent/tools/read_many.js +21 -3
- package/dist/agent/tools/readers.d.ts +53 -1
- package/dist/agent/tools/readers.js +236 -26
- package/dist/agent/tools/replace_in_file.js +38 -5
- package/dist/agent/tools/shell.js +2 -2
- package/dist/agent/tools/types.d.ts +26 -0
- package/dist/agent/tools/validate.d.ts +15 -2
- package/dist/agent/tools/validate.js +66 -3
- package/dist/agent/tools/write_file.js +3 -1
- package/dist/app.d.ts +2 -1
- package/dist/app.js +526 -85
- package/dist/cli-main.js +363 -0
- package/dist/cli.js +397 -337
- package/dist/commands/about.js +1 -1
- package/dist/commands/clear.d.ts +1 -0
- package/dist/commands/clear.js +1 -1
- package/dist/commands/compact.d.ts +12 -0
- package/dist/commands/compact.js +14 -2
- package/dist/commands/context.js +5 -4
- package/dist/commands/index.js +2 -0
- package/dist/commands/jobs.js +3 -2
- package/dist/commands/kill.js +3 -1
- package/dist/commands/login.d.ts +2 -2
- package/dist/commands/login.js +15 -15
- package/dist/commands/model.d.ts +1 -13
- package/dist/commands/model.js +6 -38
- package/dist/commands/provider.d.ts +1 -15
- package/dist/commands/provider.js +4 -22
- package/dist/commands/skills.js +34 -4
- package/dist/commands/threads.d.ts +9 -0
- package/dist/commands/threads.js +26 -0
- package/dist/config/store.d.ts +21 -0
- package/dist/config/store.js +47 -9
- package/dist/config/trust.d.ts +9 -0
- package/dist/config/trust.js +41 -2
- package/dist/headless.d.ts +7 -0
- package/dist/headless.js +213 -0
- package/dist/index.js +19 -3
- package/dist/lib/debug.d.ts +2 -0
- package/dist/lib/debug.js +22 -0
- package/dist/lib/diagnostics.d.ts +19 -0
- package/dist/lib/diagnostics.js +32 -6
- package/dist/lib/highlight-subset.d.ts +21 -0
- package/dist/lib/highlight-subset.js +88 -0
- package/dist/lib/lifecycle.d.ts +5 -0
- package/dist/lib/lifecycle.js +62 -0
- package/dist/lib/markdown.js +22 -4
- package/dist/providers/deepseek.js +1 -1
- package/dist/providers/openaiCompatible.d.ts +24 -2
- package/dist/providers/openaiCompatible.js +20 -6
- package/dist/providers/spec.d.ts +12 -0
- package/dist/providers/spec.js +29 -0
- package/dist/session/log.d.ts +14 -2
- package/dist/session/log.js +56 -27
- package/dist/session/projection.d.ts +34 -1
- package/dist/session/projection.js +315 -46
- package/dist/skills/manager.d.ts +15 -0
- package/dist/skills/manager.js +135 -18
- package/dist/types.d.ts +15 -0
- package/dist/ui/StatusBar.js +1 -1
- package/package.json +3 -2
- package/src/agent/approval-json.ts +103 -0
- package/src/agent/approval-native.ts +168 -0
- package/src/agent/approval-store.ts +38 -0
- package/src/agent/approval.ts +58 -11
- package/src/agent/compaction.ts +62 -17
- package/src/agent/guards.ts +1049 -25
- package/src/agent/policy/defaults.ts +34 -0
- package/src/agent/policy/egress.ts +335 -0
- package/src/agent/process-tree.ts +105 -23
- package/src/agent/protocol.ts +187 -39
- package/src/agent/registry.ts +186 -14
- package/src/agent/runner.ts +50 -7
- package/src/agent/shell-ast.ts +227 -0
- package/src/agent/shell-session.ts +265 -41
- package/src/agent/tool-schemas.ts +26 -7
- package/src/agent/tools/append_file.ts +3 -1
- package/src/agent/tools/apply_patch.ts +45 -4
- package/src/agent/tools/copy_file.ts +27 -3
- package/src/agent/tools/delete_file.ts +22 -3
- package/src/agent/tools/grep.ts +36 -4
- package/src/agent/tools/make_dir.ts +3 -1
- package/src/agent/tools/move_path.ts +38 -5
- package/src/agent/tools/read_file.ts +64 -3
- package/src/agent/tools/read_many.ts +21 -3
- package/src/agent/tools/readers.ts +289 -26
- package/src/agent/tools/replace_in_file.ts +39 -5
- package/src/agent/tools/shell.ts +2 -2
- package/src/agent/tools/types.ts +43 -1
- package/src/agent/tools/validate.ts +73 -4
- package/src/agent/tools/write_file.ts +3 -1
- package/src/app.ts +533 -82
- package/src/{cli.ts → cli-main.ts} +34 -6
- package/src/commands/about.ts +1 -1
- package/src/commands/clear.ts +1 -1
- package/src/commands/compact.ts +14 -2
- package/src/commands/context.ts +5 -4
- package/src/commands/index.ts +2 -0
- package/src/commands/jobs.ts +3 -2
- package/src/commands/kill.ts +3 -1
- package/src/commands/login.ts +15 -15
- package/src/commands/model.ts +6 -38
- package/src/commands/provider.ts +4 -22
- package/src/commands/skills.ts +34 -4
- package/src/commands/threads.ts +28 -0
- package/src/config/store.ts +47 -9
- package/src/config/trust.ts +45 -2
- package/src/headless.ts +225 -0
- package/src/index.ts +19 -3
- package/src/lib/debug.ts +24 -0
- package/src/lib/diagnostics.ts +32 -6
- package/src/lib/highlight-subset.ts +93 -0
- package/src/lib/lifecycle.ts +69 -0
- package/src/lib/markdown.ts +22 -4
- package/src/providers/deepseek.ts +1 -1
- package/src/providers/openaiCompatible.ts +47 -10
- package/src/providers/spec.ts +42 -0
- package/src/session/log.ts +70 -27
- package/src/session/projection.ts +360 -47
- package/src/skills/manager.ts +140 -18
- package/src/types/highlight-shims.d.ts +14 -0
- package/src/types.ts +16 -1
- package/src/ui/StatusBar.ts +1 -1
- package/tsconfig.json +1 -0
- /package/dist/{cli.d.ts → cli-main.d.ts} +0 -0
package/dist/agent/compaction.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
1
|
+
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { basename, join, resolve, sep } from "node:path";
|
|
3
3
|
import { estMessagesTokens, estTokens } from "../lib/model-meta.js";
|
|
4
4
|
import { getPaths } from "../config/paths.js";
|
|
5
5
|
import { parseToolCalls, stripToolCalls } from "./protocol.js";
|
|
@@ -20,6 +20,15 @@ export function compactionConfigFromEnv() {
|
|
|
20
20
|
const heap = Number(process.env["FASTCODE_HEAP_LIMIT_MB"]);
|
|
21
21
|
if (Number.isFinite(heap) && heap > 0)
|
|
22
22
|
config.heapLimitMb = heap;
|
|
23
|
+
const ratio = Number(process.env["FASTCODE_COMPACTION_RATIO"]);
|
|
24
|
+
if (Number.isFinite(ratio) && ratio > 0 && ratio < 1)
|
|
25
|
+
config.localThresholdRatio = ratio;
|
|
26
|
+
const keepTurns = Number(process.env["FASTCODE_COMPACTION_KEEP_TURNS"]);
|
|
27
|
+
if (Number.isFinite(keepTurns) && keepTurns > 0)
|
|
28
|
+
config.keepTurns = Math.floor(keepTurns);
|
|
29
|
+
const summaryTokens = Number(process.env["FASTCODE_COMPACTION_SUMMARY_TOKENS"]);
|
|
30
|
+
if (Number.isFinite(summaryTokens) && summaryTokens > 0)
|
|
31
|
+
config.maxSummaryTokens = Math.floor(summaryTokens);
|
|
23
32
|
const server = (process.env["FASTCODE_SERVER_COMPACTION"] ?? "").trim().toLowerCase();
|
|
24
33
|
if (["1", "true", "yes", "on"].includes(server))
|
|
25
34
|
config.serverCompactionAware = true;
|
|
@@ -132,7 +141,7 @@ export function buildSummary(messages, config, options) {
|
|
|
132
141
|
continue;
|
|
133
142
|
}
|
|
134
143
|
if (message.role === "assistant") {
|
|
135
|
-
const calls = parseToolCalls(message.content);
|
|
144
|
+
const calls = parseToolCalls(message.content).calls;
|
|
136
145
|
for (const call of calls)
|
|
137
146
|
actions.push(describeCall(call));
|
|
138
147
|
const visible = stripToolCalls(message.content);
|
|
@@ -148,23 +157,31 @@ export function buildSummary(messages, config, options) {
|
|
|
148
157
|
}
|
|
149
158
|
collectFiles(message.content, files);
|
|
150
159
|
}
|
|
160
|
+
const fileList = Array.from(files);
|
|
151
161
|
const sections = [
|
|
152
162
|
"# Session summary",
|
|
153
163
|
"",
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
"",
|
|
157
|
-
"
|
|
158
|
-
...limitLines(actions, 20).map((line) => `- ${line}`),
|
|
164
|
+
// Conclusions first: when the token budget runs out, keep what the
|
|
165
|
+
// session decided rather than the oldest requests.
|
|
166
|
+
"## Notes",
|
|
167
|
+
...limitLines(notes, 10, "notes").map((line) => `- ${line}`),
|
|
159
168
|
"",
|
|
160
169
|
"## Outcomes",
|
|
161
|
-
...limitLines(outcomes, 10).map((line) => `- ${line}`),
|
|
170
|
+
...limitLines(outcomes, 10, "outcomes").map((line) => `- ${line}`),
|
|
162
171
|
"",
|
|
163
172
|
"## Files touched",
|
|
164
|
-
...(
|
|
173
|
+
...(fileList.length > 0
|
|
174
|
+
? [
|
|
175
|
+
...fileList.slice(0, 40).map((file) => `- ${file}`),
|
|
176
|
+
...(fileList.length > 40 ? [`- (${fileList.length - 40} more files not listed)`] : []),
|
|
177
|
+
]
|
|
178
|
+
: ["- (none recorded)"]),
|
|
165
179
|
"",
|
|
166
|
-
"##
|
|
167
|
-
...limitLines(
|
|
180
|
+
"## Requests",
|
|
181
|
+
...limitLines(requests, 8, "requests").map((line) => `- ${line}`),
|
|
182
|
+
"",
|
|
183
|
+
"## Actions",
|
|
184
|
+
...limitLines(actions, 20, "actions").map((line) => `- ${line}`),
|
|
168
185
|
];
|
|
169
186
|
const budget = Math.max(200, Math.floor(config.maxSummaryTokens));
|
|
170
187
|
const kept = [];
|
|
@@ -197,22 +214,48 @@ function collectFiles(text, files) {
|
|
|
197
214
|
if (!matches)
|
|
198
215
|
return;
|
|
199
216
|
for (const match of matches) {
|
|
200
|
-
if (match
|
|
201
|
-
continue;
|
|
202
|
-
if (/^\d+(\.\d+)+$/.test(match))
|
|
217
|
+
if (!looksLikeProjectFile(match))
|
|
203
218
|
continue;
|
|
204
219
|
files.add(match);
|
|
205
220
|
if (files.size >= 200)
|
|
206
221
|
return;
|
|
207
222
|
}
|
|
208
223
|
}
|
|
209
|
-
function
|
|
210
|
-
|
|
224
|
+
function looksLikeProjectFile(value) {
|
|
225
|
+
if (value.length <= 3 || value.length > 240)
|
|
226
|
+
return false;
|
|
227
|
+
if (/^summary-\d/.test(value) || value.includes("//") || value.includes("\\.") || value.startsWith("s/"))
|
|
228
|
+
return false;
|
|
229
|
+
if (/^\d+(\.\d+)+$/.test(value))
|
|
230
|
+
return false;
|
|
231
|
+
return /\.(ts|tsx|js|jsx|mjs|cjs|json|md|txt|py|rs|go|java|kt|kts|c|cc|cpp|h|hpp|sh|bash|zsh|fish|yml|yaml|toml|ini|conf|cfg|env|lock|sql|html|css|scss|sass|less|vue|svelte|rb|php|swift|dart|xml|gradle|properties)$/i.test(value);
|
|
232
|
+
}
|
|
233
|
+
function limitLines(lines, max, label) {
|
|
234
|
+
if (lines.length <= max)
|
|
235
|
+
return lines;
|
|
236
|
+
return [...lines.slice(0, max), `(${lines.length - max} more ${label} not listed)`];
|
|
211
237
|
}
|
|
212
238
|
function clip(text, max) {
|
|
213
239
|
const oneLine = String(text).replace(/\s+/g, " ").trim();
|
|
214
240
|
return oneLine.length > max ? oneLine.slice(0, max) + "…" : oneLine;
|
|
215
241
|
}
|
|
242
|
+
/** Delete a summary file only when it is one of our summary-*.md artifacts. */
|
|
243
|
+
export function removeSummaryFile(file) {
|
|
244
|
+
if (!file)
|
|
245
|
+
return;
|
|
246
|
+
const name = basename(file);
|
|
247
|
+
if (!/^summary-\d+.*\.md$/i.test(name))
|
|
248
|
+
return;
|
|
249
|
+
const sessions = resolve(getPaths().sessions) + sep;
|
|
250
|
+
if (!resolve(file).startsWith(sessions))
|
|
251
|
+
return;
|
|
252
|
+
try {
|
|
253
|
+
rmSync(file, { force: true });
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
// Best effort; an orphan summary is not worth failing compaction.
|
|
257
|
+
}
|
|
258
|
+
}
|
|
216
259
|
function writeSummaryFile(summary) {
|
|
217
260
|
try {
|
|
218
261
|
const dir = getPaths().sessions;
|
package/dist/agent/guards.d.ts
CHANGED
|
@@ -13,28 +13,28 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const DEFAULT_DENY_PATTERNS: string[];
|
|
15
15
|
export declare const FORK_BOMB_MARKERS: string[];
|
|
16
|
+
export type ShellGuardAction = "allow" | "hard_block" | "soft_gate";
|
|
17
|
+
export interface ShellGuardVerdict {
|
|
18
|
+
allow: boolean;
|
|
19
|
+
action: ShellGuardAction;
|
|
20
|
+
code: string;
|
|
21
|
+
target?: string;
|
|
22
|
+
reason?: string;
|
|
23
|
+
alternatives?: string[];
|
|
24
|
+
output?: string;
|
|
25
|
+
pattern?: string;
|
|
26
|
+
bypassed?: boolean;
|
|
27
|
+
}
|
|
16
28
|
/**
|
|
17
29
|
* Decide whether a shell command may run.
|
|
18
30
|
* Returns { allow: true } or { allow: false, output: explanation }.
|
|
19
31
|
*/
|
|
20
|
-
export declare function evaluateShellCommand(command: any):
|
|
21
|
-
allow: boolean;
|
|
22
|
-
output: any;
|
|
23
|
-
bypassed: boolean;
|
|
24
|
-
pattern?: undefined;
|
|
25
|
-
} | {
|
|
26
|
-
allow: boolean;
|
|
27
|
-
pattern: string;
|
|
28
|
-
output: string;
|
|
29
|
-
bypassed?: undefined;
|
|
30
|
-
} | {
|
|
31
|
-
allow: boolean;
|
|
32
|
-
output: string;
|
|
33
|
-
bypassed?: undefined;
|
|
34
|
-
pattern?: undefined;
|
|
35
|
-
};
|
|
32
|
+
export declare function evaluateShellCommand(command: any): ShellGuardVerdict;
|
|
36
33
|
export declare const READ_ONLY_TOOLS: Set<string>;
|
|
37
34
|
export declare function splitCommandSegments(command: any): any[];
|
|
35
|
+
export declare function isSharedStoragePath(target: string): boolean;
|
|
36
|
+
export declare function isCriticalReadTarget(target: string): boolean;
|
|
37
|
+
export declare function isSensitiveTarget(target: string): boolean;
|
|
38
38
|
export declare function isReadOnlyCommand(command: any): boolean;
|
|
39
39
|
export declare function isReadOnlyToolCall(call: any): boolean;
|
|
40
40
|
export declare function loopExemptTools(): Set<string>;
|