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.
Files changed (111) hide show
  1. package/README.md +135 -443
  2. package/bin/privateer-tui +86 -0
  3. package/bin/privateer.mjs +17 -6
  4. package/bin/pv +28 -0
  5. package/package.json +26 -23
  6. package/src/auth/privateer.ts +57 -0
  7. package/src/boot.ts +43 -0
  8. package/src/bridge/engineAdapter.ts +182 -0
  9. package/src/cli/chat.ts +243 -0
  10. package/src/config/paths.ts +24 -46
  11. package/src/config/permissionMode.ts +5 -0
  12. package/src/crypto/outboxSeal.ts +61 -0
  13. package/src/daemon/index.ts +204 -121
  14. package/src/daemon/ipc.ts +1 -1
  15. package/src/engine/errors.ts +85 -45
  16. package/src/engine/router.ts +11 -165
  17. package/src/ext/permissionGate.ts +216 -0
  18. package/src/main.ts +32 -0
  19. package/src/permissions/classify.ts +172 -0
  20. package/src/permissions/gate.ts +11 -14
  21. package/src/permissions/mode.ts +6 -2
  22. package/src/permissions/{uiGate.ts → modeGate.ts} +18 -3
  23. package/src/providers/account.ts +170 -0
  24. package/src/providers/catalog.ts +73 -61
  25. package/src/providers/genModelsJson.ts +97 -0
  26. package/src/remote/relayClient.ts +15 -0
  27. package/src/remote/remoteBridge.ts +152 -0
  28. package/src/routines/delivery.ts +118 -9
  29. package/src/routines/schema.ts +24 -5
  30. package/src/routines/store.ts +44 -1
  31. package/src/routines/toolSelect.ts +3 -1
  32. package/src/session.ts +81 -273
  33. package/src/tools/routine.ts +120 -101
  34. package/src/tools/saveAttachment.ts +39 -42
  35. package/src/tools/sendFile.ts +75 -0
  36. package/src/util/attachmentStore.ts +18 -35
  37. package/src/util/redact.ts +33 -3
  38. package/LICENSE +0 -21
  39. package/src/agents/loader.ts +0 -49
  40. package/src/commands/custom.ts +0 -123
  41. package/src/commands/registry.ts +0 -618
  42. package/src/components/AgentGroupView.tsx +0 -104
  43. package/src/components/App.tsx +0 -1626
  44. package/src/components/ApprovalPrompt.tsx +0 -49
  45. package/src/components/Banner.tsx +0 -78
  46. package/src/components/Markdown.tsx +0 -183
  47. package/src/components/ModeHint.tsx +0 -40
  48. package/src/components/ModelPicker.tsx +0 -302
  49. package/src/components/Onboarding.tsx +0 -203
  50. package/src/components/OptionPicker.tsx +0 -134
  51. package/src/components/PlanConfirm.tsx +0 -37
  52. package/src/components/PrivateerLogin.tsx +0 -109
  53. package/src/components/PromptInput.tsx +0 -602
  54. package/src/components/RewindPicker.tsx +0 -69
  55. package/src/components/Root.tsx +0 -116
  56. package/src/components/SessionPicker.tsx +0 -64
  57. package/src/components/StatusBar.tsx +0 -131
  58. package/src/components/TodoPanel.tsx +0 -36
  59. package/src/components/ToolCallView.tsx +0 -113
  60. package/src/components/Transcript.tsx +0 -210
  61. package/src/components/figures.ts +0 -14
  62. package/src/components/promptModel.ts +0 -73
  63. package/src/components/spinnerVerbs.ts +0 -46
  64. package/src/components/theme.ts +0 -57
  65. package/src/components/types.ts +0 -34
  66. package/src/components/useTeeShield.ts +0 -104
  67. package/src/components/useTerminalWidth.ts +0 -24
  68. package/src/components/useZdrShield.ts +0 -126
  69. package/src/config/load.ts +0 -115
  70. package/src/config/schema.ts +0 -94
  71. package/src/context/outputStyles.ts +0 -42
  72. package/src/context/projectInfo.ts +0 -59
  73. package/src/context/systemPrompt.ts +0 -176
  74. package/src/engine/QueryEngine.ts +0 -399
  75. package/src/hooks/engine.ts +0 -155
  76. package/src/main.tsx +0 -209
  77. package/src/mcp/client.ts +0 -251
  78. package/src/mcp/oauth.ts +0 -245
  79. package/src/memory/auto.ts +0 -146
  80. package/src/memory/checkpoints.ts +0 -227
  81. package/src/memory/store.ts +0 -127
  82. package/src/providers/attestation.ts +0 -149
  83. package/src/providers/capabilities.ts +0 -104
  84. package/src/providers/models.ts +0 -183
  85. package/src/providers/registry.ts +0 -71
  86. package/src/providers/resolve.ts +0 -78
  87. package/src/skills/installer.ts +0 -222
  88. package/src/skills/loader.ts +0 -88
  89. package/src/tools/askUser.ts +0 -92
  90. package/src/tools/bash.ts +0 -98
  91. package/src/tools/context.ts +0 -128
  92. package/src/tools/edit.ts +0 -67
  93. package/src/tools/exec.ts +0 -60
  94. package/src/tools/glob.ts +0 -39
  95. package/src/tools/grep.ts +0 -86
  96. package/src/tools/index.ts +0 -83
  97. package/src/tools/memory.ts +0 -53
  98. package/src/tools/processRegistry.ts +0 -77
  99. package/src/tools/read.ts +0 -42
  100. package/src/tools/sendFileToClient.ts +0 -55
  101. package/src/tools/skill.ts +0 -44
  102. package/src/tools/task.ts +0 -52
  103. package/src/tools/todo.ts +0 -36
  104. package/src/tools/todoStore.ts +0 -31
  105. package/src/tools/walk.ts +0 -44
  106. package/src/tools/web.ts +0 -145
  107. package/src/tools/worktree.ts +0 -145
  108. package/src/tools/write.ts +0 -40
  109. package/src/util/images.ts +0 -378
  110. package/src/util/limit.ts +0 -32
  111. package/src/version.ts +0 -13
@@ -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
- }