privateer-agent 0.2.1 → 0.3.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/README.md +135 -443
- package/bin/privateer-tui +86 -0
- package/bin/privateer.mjs +17 -6
- package/bin/pv +28 -0
- package/package.json +26 -23
- package/src/auth/privateer.ts +57 -0
- package/src/boot.ts +43 -0
- package/src/bridge/engineAdapter.ts +182 -0
- package/src/cli/chat.ts +243 -0
- package/src/config/paths.ts +24 -46
- package/src/config/permissionMode.ts +5 -0
- package/src/crypto/outboxSeal.ts +61 -0
- package/src/daemon/index.ts +204 -121
- package/src/daemon/ipc.ts +1 -1
- package/src/engine/errors.ts +85 -45
- package/src/engine/router.ts +11 -165
- package/src/ext/permissionGate.ts +216 -0
- package/src/main.ts +32 -0
- package/src/permissions/classify.ts +172 -0
- package/src/permissions/gate.ts +11 -14
- package/src/permissions/mode.ts +6 -2
- package/src/permissions/{uiGate.ts → modeGate.ts} +18 -3
- package/src/providers/account.ts +170 -0
- package/src/providers/catalog.ts +73 -61
- package/src/providers/genModelsJson.ts +97 -0
- package/src/remote/relayClient.ts +15 -0
- package/src/remote/remoteBridge.ts +152 -0
- package/src/routines/delivery.ts +118 -9
- package/src/routines/schema.ts +24 -5
- package/src/routines/store.ts +44 -1
- package/src/routines/toolSelect.ts +3 -1
- package/src/session.ts +81 -273
- package/src/tools/routine.ts +120 -101
- package/src/tools/saveAttachment.ts +39 -42
- package/src/tools/sendFile.ts +75 -0
- package/src/util/attachmentStore.ts +18 -35
- package/src/util/redact.ts +33 -3
- package/LICENSE +0 -21
- package/src/agents/loader.ts +0 -49
- package/src/commands/custom.ts +0 -123
- package/src/commands/registry.ts +0 -618
- package/src/components/AgentGroupView.tsx +0 -104
- package/src/components/App.tsx +0 -1626
- package/src/components/ApprovalPrompt.tsx +0 -49
- package/src/components/Banner.tsx +0 -78
- package/src/components/Markdown.tsx +0 -183
- package/src/components/ModeHint.tsx +0 -40
- package/src/components/ModelPicker.tsx +0 -302
- package/src/components/Onboarding.tsx +0 -203
- package/src/components/OptionPicker.tsx +0 -134
- package/src/components/PlanConfirm.tsx +0 -37
- package/src/components/PrivateerLogin.tsx +0 -109
- package/src/components/PromptInput.tsx +0 -602
- package/src/components/RewindPicker.tsx +0 -69
- package/src/components/Root.tsx +0 -116
- package/src/components/SessionPicker.tsx +0 -64
- package/src/components/StatusBar.tsx +0 -131
- package/src/components/TodoPanel.tsx +0 -36
- package/src/components/ToolCallView.tsx +0 -113
- package/src/components/Transcript.tsx +0 -210
- package/src/components/figures.ts +0 -14
- package/src/components/promptModel.ts +0 -73
- package/src/components/spinnerVerbs.ts +0 -46
- package/src/components/theme.ts +0 -57
- package/src/components/types.ts +0 -34
- package/src/components/useTeeShield.ts +0 -104
- package/src/components/useTerminalWidth.ts +0 -24
- package/src/components/useZdrShield.ts +0 -126
- package/src/config/load.ts +0 -115
- package/src/config/schema.ts +0 -94
- package/src/context/outputStyles.ts +0 -42
- package/src/context/projectInfo.ts +0 -59
- package/src/context/systemPrompt.ts +0 -176
- package/src/engine/QueryEngine.ts +0 -399
- package/src/hooks/engine.ts +0 -155
- package/src/main.tsx +0 -209
- package/src/mcp/client.ts +0 -251
- package/src/mcp/oauth.ts +0 -245
- package/src/memory/auto.ts +0 -146
- package/src/memory/checkpoints.ts +0 -227
- package/src/memory/store.ts +0 -127
- package/src/providers/attestation.ts +0 -149
- package/src/providers/capabilities.ts +0 -104
- package/src/providers/models.ts +0 -183
- package/src/providers/registry.ts +0 -71
- package/src/providers/resolve.ts +0 -78
- package/src/skills/installer.ts +0 -222
- package/src/skills/loader.ts +0 -88
- package/src/tools/askUser.ts +0 -92
- package/src/tools/bash.ts +0 -98
- package/src/tools/context.ts +0 -128
- package/src/tools/edit.ts +0 -67
- package/src/tools/exec.ts +0 -60
- package/src/tools/glob.ts +0 -39
- package/src/tools/grep.ts +0 -86
- package/src/tools/index.ts +0 -83
- package/src/tools/memory.ts +0 -53
- package/src/tools/processRegistry.ts +0 -77
- package/src/tools/read.ts +0 -42
- package/src/tools/sendFileToClient.ts +0 -55
- package/src/tools/skill.ts +0 -44
- package/src/tools/task.ts +0 -52
- package/src/tools/todo.ts +0 -36
- package/src/tools/todoStore.ts +0 -31
- package/src/tools/walk.ts +0 -44
- package/src/tools/web.ts +0 -145
- package/src/tools/worktree.ts +0 -145
- package/src/tools/write.ts +0 -40
- package/src/util/images.ts +0 -378
- package/src/util/limit.ts +0 -32
- package/src/version.ts +0 -13
package/src/commands/custom.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { globalPaths, projectPaths } from "../config/paths.ts";
|
|
4
|
-
import { walkFiles } from "../tools/walk.ts";
|
|
5
|
-
|
|
6
|
-
// A user-authored slash command loaded from a markdown file under
|
|
7
|
-
// .privateer/commands/. The body is a prompt template; frontmatter is optional.
|
|
8
|
-
export interface CustomCommand {
|
|
9
|
-
name: string; // file path minus .md, separators → ":" (e.g. "git/pr.md" → "git:pr")
|
|
10
|
-
description: string;
|
|
11
|
-
argumentHint?: string;
|
|
12
|
-
allowedTools?: string[];
|
|
13
|
-
model?: string;
|
|
14
|
-
body: string;
|
|
15
|
-
scope: "project" | "user";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Minimal YAML-ish frontmatter: a leading `---` block of `key: value` lines. Values
|
|
19
|
-
// may be quoted, continue onto indented lines, or use block scalars (`key: |` / `key: >`)
|
|
20
|
-
// — enough for real-world command/agent/skill files without a YAML dependency.
|
|
21
|
-
export function parseFrontmatter(raw: string): { meta: Record<string, string>; body: string } {
|
|
22
|
-
const lines = raw.split("\n");
|
|
23
|
-
if (lines[0]?.trim() !== "---") return { meta: {}, body: raw };
|
|
24
|
-
const meta: Record<string, string> = {};
|
|
25
|
-
let i = 1;
|
|
26
|
-
let lastKey: string | undefined;
|
|
27
|
-
for (; i < lines.length; i++) {
|
|
28
|
-
const line = lines[i];
|
|
29
|
-
if (line.trim() === "---") {
|
|
30
|
-
i++;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
const m = line.match(/^([A-Za-z0-9_-]+)\s*:\s*(.*)$/);
|
|
34
|
-
if (m) {
|
|
35
|
-
const key = m[1].toLowerCase();
|
|
36
|
-
const val = m[2].trim();
|
|
37
|
-
const block = /^([|>])[+-]?$/.exec(val);
|
|
38
|
-
if (block) {
|
|
39
|
-
// Block scalar: consume the following blank or more-indented lines. Literal
|
|
40
|
-
// (|) keeps line breaks; folded (>) joins lines with spaces.
|
|
41
|
-
const parts: string[] = [];
|
|
42
|
-
let indent = 0;
|
|
43
|
-
while (i + 1 < lines.length) {
|
|
44
|
-
const next = lines[i + 1];
|
|
45
|
-
const blank = next.trim() === "";
|
|
46
|
-
if (!blank && !/^[ \t]/.test(next)) break;
|
|
47
|
-
i++;
|
|
48
|
-
if (blank) {
|
|
49
|
-
parts.push("");
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
const lead = next.match(/^[ \t]*/)![0].length;
|
|
53
|
-
if (!indent) indent = lead;
|
|
54
|
-
parts.push(next.slice(Math.min(indent, lead)));
|
|
55
|
-
}
|
|
56
|
-
meta[key] =
|
|
57
|
-
block[1] === "|"
|
|
58
|
-
? parts.join("\n").replace(/\s+$/, "")
|
|
59
|
-
: parts
|
|
60
|
-
.map((p) => p.trim())
|
|
61
|
-
.filter(Boolean)
|
|
62
|
-
.join(" ");
|
|
63
|
-
} else {
|
|
64
|
-
meta[key] = unquote(val);
|
|
65
|
-
}
|
|
66
|
-
lastKey = key;
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
// An indented non-empty line after `key: value` continues that value.
|
|
70
|
-
if (lastKey && /^[ \t]/.test(line) && line.trim() !== "") {
|
|
71
|
-
meta[lastKey] = `${meta[lastKey]} ${line.trim()}`.trim();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return { meta, body: lines.slice(i).join("\n").replace(/^\n+/, "") };
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Strip one pair of matching surrounding quotes from a scalar value.
|
|
78
|
-
function unquote(v: string): string {
|
|
79
|
-
const m = /^"(.*)"$/.exec(v) ?? /^'(.*)'$/.exec(v);
|
|
80
|
-
return m ? m[1] : v;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function loadFromDir(dir: string, scope: "project" | "user"): CustomCommand[] {
|
|
84
|
-
if (!existsSync(dir)) return [];
|
|
85
|
-
const out: CustomCommand[] = [];
|
|
86
|
-
for (const rel of walkFiles(dir)) {
|
|
87
|
-
if (!rel.endsWith(".md")) continue;
|
|
88
|
-
const { meta, body } = parseFrontmatter(readFileSync(join(dir, rel), "utf8"));
|
|
89
|
-
out.push({
|
|
90
|
-
name: rel.replace(/\.md$/, "").split("/").join(":"),
|
|
91
|
-
description: meta.description ?? `custom ${scope} command`,
|
|
92
|
-
argumentHint: meta["argument-hint"],
|
|
93
|
-
allowedTools: meta["allowed-tools"]
|
|
94
|
-
?.split(",")
|
|
95
|
-
.map((s) => s.trim())
|
|
96
|
-
.filter(Boolean),
|
|
97
|
-
model: meta.model,
|
|
98
|
-
body: body.trim(),
|
|
99
|
-
scope,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return out;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Load custom commands from user (~/.privateer) then project (./.privateer);
|
|
106
|
-
// a project command overrides a user command of the same name.
|
|
107
|
-
export function loadCustomCommands(cwd: string = process.cwd()): CustomCommand[] {
|
|
108
|
-
const byName = new Map<string, CustomCommand>();
|
|
109
|
-
for (const c of loadFromDir(globalPaths().commands, "user")) byName.set(c.name, c);
|
|
110
|
-
for (const c of loadFromDir(projectPaths(cwd).commands, "project")) byName.set(c.name, c);
|
|
111
|
-
return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Expand a command body against its arguments: $1..$9 are positional words,
|
|
115
|
-
// $ARGUMENTS and $@ are the full argument string.
|
|
116
|
-
export function expandCommand(cmd: CustomCommand, argString: string): string {
|
|
117
|
-
const args = argString.trim();
|
|
118
|
-
const parts = args.length ? args.split(/\s+/) : [];
|
|
119
|
-
return cmd.body
|
|
120
|
-
.replace(/\$([1-9])/g, (_, d: string) => parts[Number(d) - 1] ?? "")
|
|
121
|
-
.replace(/\$ARGUMENTS\b/g, args)
|
|
122
|
-
.replace(/\$@/g, args);
|
|
123
|
-
}
|