@agentprojectcontext/apx 1.74.2 → 1.75.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/package.json +1 -1
- package/src/core/agent/prompt-builder.js +26 -7
- package/src/core/agent/render-template.js +22 -0
- package/src/core/profiles/block.js +290 -0
- package/src/core/profiles/bundled/secretary/PROFILE.es.md +44 -0
- package/src/core/profiles/bundled/secretary/PROFILE.md +44 -0
- package/src/core/profiles/bundled/secretary/channels/routine.md +43 -0
- package/src/core/profiles/bundled/secretary/config.schema.json +49 -0
- package/src/core/profiles/bundled/secretary/profile.json +20 -0
- package/src/core/profiles/bundled/secretary/routines/day-close.json +10 -0
- package/src/core/profiles/bundled/secretary/routines/day-open.json +10 -0
- package/src/core/profiles/index.js +16 -0
- package/src/core/profiles/lifecycle.js +720 -0
- package/src/core/profiles/manifest.js +193 -0
- package/src/core/profiles/paths.js +51 -0
- package/src/core/profiles/store.js +184 -0
- package/src/core/runtime-skills/apx-profile/SKILL.md +126 -0
- package/src/core/stores/routines.js +9 -1
- package/src/host/daemon/api/profiles.js +179 -0
- package/src/host/daemon/api/web.js +1 -1
- package/src/host/daemon/api.js +2 -0
- package/src/interfaces/cli/commands/profile.js +252 -0
- package/src/interfaces/cli/index.js +62 -0
- package/src/interfaces/web/dist/assets/index-CQ5kyFej.css +1 -0
- package/src/interfaces/web/dist/assets/{index-CQTIGYCu.js → index-CXeqTvfy.js} +165 -160
- package/src/interfaces/web/dist/assets/index-CXeqTvfy.js.map +1 -0
- package/src/interfaces/web/dist/index.html +2 -2
- package/src/interfaces/web/src/components/settings/ProfilePanel.tsx +245 -0
- package/src/interfaces/web/src/hooks/useProfiles.ts +37 -0
- package/src/interfaces/web/src/i18n/en.ts +31 -0
- package/src/interfaces/web/src/i18n/es.ts +31 -0
- package/src/interfaces/web/src/lib/api/profiles.ts +86 -0
- package/src/interfaces/web/src/screens/SettingsScreen.tsx +6 -2
- package/src/interfaces/web/dist/assets/index-COrRuBp1.css +0 -1
- package/src/interfaces/web/dist/assets/index-CQTIGYCu.js.map +0 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// GET /profiles installed + bundled packages, which one is active
|
|
2
|
+
// GET /profiles/doctor health of the active profile (or ?id=)
|
|
3
|
+
// GET /profiles/:id one package, with its schema, settings and prompt preview
|
|
4
|
+
// POST /profiles/install { source, force? }
|
|
5
|
+
// POST /profiles/use { id, force? }
|
|
6
|
+
// POST /profiles/off
|
|
7
|
+
// PATCH /profiles/config { values: {...}, id? }
|
|
8
|
+
// DELETE /profiles/:id uninstall
|
|
9
|
+
//
|
|
10
|
+
// Thin adapter — body → core/profiles → response. The daemon is the writer on
|
|
11
|
+
// purpose: activating a profile changes the live system prompt and the routine
|
|
12
|
+
// schedule, so the process that owns both has to be the one applying it.
|
|
13
|
+
import { readConfig } from "#core/config/index.js";
|
|
14
|
+
import { readIdentity } from "#core/identity/index.js";
|
|
15
|
+
import {
|
|
16
|
+
listProfilesWithState,
|
|
17
|
+
readProfile,
|
|
18
|
+
readProfileState,
|
|
19
|
+
effectiveProfileConfig,
|
|
20
|
+
installProfile,
|
|
21
|
+
useProfile,
|
|
22
|
+
offProfile,
|
|
23
|
+
setProfileConfig,
|
|
24
|
+
uninstallProfile,
|
|
25
|
+
profileDoctor,
|
|
26
|
+
renderProfilePrompt,
|
|
27
|
+
estimateTokens,
|
|
28
|
+
} from "#core/profiles/index.js";
|
|
29
|
+
|
|
30
|
+
/** 400 for anything the caller could have got right, 500 for the rest. */
|
|
31
|
+
function fail(res, e) {
|
|
32
|
+
const msg = e?.message || String(e);
|
|
33
|
+
const isUserError =
|
|
34
|
+
/not installed|not found|invalid|unknown setting|must be|already|missing|required|not supported|cannot be activated|failed:/i.test(
|
|
35
|
+
msg
|
|
36
|
+
);
|
|
37
|
+
res.status(isUserError ? 400 : 500).json({ error: msg });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function detail(id, { preview = true } = {}) {
|
|
41
|
+
const profile = readProfile(id);
|
|
42
|
+
if (!profile) return null;
|
|
43
|
+
|
|
44
|
+
const cfg = readConfig();
|
|
45
|
+
const state = readProfileState(cfg);
|
|
46
|
+
const identity = (() => { try { return readIdentity(); } catch { return null; } })();
|
|
47
|
+
const settings = effectiveProfileConfig(profile, cfg);
|
|
48
|
+
|
|
49
|
+
const languages = profile.prompts.map((f) => {
|
|
50
|
+
const m = f.match(/^PROFILE\.([\w-]+)\.md$/);
|
|
51
|
+
return m ? m[1] : "en";
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const rendered = preview
|
|
55
|
+
? renderProfilePrompt(profile, {
|
|
56
|
+
identity,
|
|
57
|
+
globalConfig: { ...cfg, profile: { active: id, config: settings } },
|
|
58
|
+
lang: cfg?.user?.language || identity?.language || "en",
|
|
59
|
+
})
|
|
60
|
+
: "";
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
id: profile.id,
|
|
64
|
+
name: profile.manifest.name || profile.id,
|
|
65
|
+
version: profile.manifest.version || null,
|
|
66
|
+
description: profile.manifest.description || "",
|
|
67
|
+
author: profile.manifest.author || null,
|
|
68
|
+
source: profile.source,
|
|
69
|
+
dir: profile.dir,
|
|
70
|
+
active: state.active === id,
|
|
71
|
+
languages: [...new Set(languages)].sort(),
|
|
72
|
+
provides: profile.manifest.provides || {},
|
|
73
|
+
requires: profile.manifest.requires || {},
|
|
74
|
+
schema: profile.schema || null,
|
|
75
|
+
defaults: profile.defaults,
|
|
76
|
+
config: settings,
|
|
77
|
+
budget: profile.manifest.prompt_budget_tokens || null,
|
|
78
|
+
tokens: preview ? estimateTokens(rendered) : null,
|
|
79
|
+
// The rendered block, exactly as it reaches the model. This is the best
|
|
80
|
+
// debugging tool the panel can offer and it costs nothing to expose.
|
|
81
|
+
preview: rendered,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function register(app) {
|
|
86
|
+
app.get("/profiles", (_req, res) => {
|
|
87
|
+
try {
|
|
88
|
+
const cfg = readConfig();
|
|
89
|
+
res.json({
|
|
90
|
+
active: readProfileState(cfg).active,
|
|
91
|
+
profiles: listProfilesWithState(cfg),
|
|
92
|
+
});
|
|
93
|
+
} catch (e) {
|
|
94
|
+
fail(res, e);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Registered before /profiles/:id so "doctor" isn't swallowed as an id.
|
|
99
|
+
app.get("/profiles/doctor", (req, res) => {
|
|
100
|
+
try {
|
|
101
|
+
res.json(profileDoctor(req.query?.id || null));
|
|
102
|
+
} catch (e) {
|
|
103
|
+
fail(res, e);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
app.get("/profiles/:id", (req, res) => {
|
|
108
|
+
try {
|
|
109
|
+
const out = detail(req.params.id, { preview: req.query?.preview !== "0" });
|
|
110
|
+
if (!out) return res.status(404).json({ error: `profile "${req.params.id}" not found` });
|
|
111
|
+
res.json(out);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
fail(res, e);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
app.post("/profiles/install", (req, res) => {
|
|
118
|
+
try {
|
|
119
|
+
const { source, force } = req.body || {};
|
|
120
|
+
if (!source) return res.status(400).json({ error: "body needs { source }" });
|
|
121
|
+
const out = installProfile(source, { force: !!force });
|
|
122
|
+
res.json({
|
|
123
|
+
ok: true,
|
|
124
|
+
profile: detail(out.profile.id),
|
|
125
|
+
warnings: out.warnings,
|
|
126
|
+
tokens: out.tokens,
|
|
127
|
+
doctor: out.doctor,
|
|
128
|
+
});
|
|
129
|
+
} catch (e) {
|
|
130
|
+
fail(res, e);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
app.post("/profiles/use", (req, res) => {
|
|
135
|
+
try {
|
|
136
|
+
const { id, force } = req.body || {};
|
|
137
|
+
if (!id) return res.status(400).json({ error: "body needs { id }" });
|
|
138
|
+
const out = useProfile(id, { confirmReplace: !!force });
|
|
139
|
+
res.json({
|
|
140
|
+
ok: true,
|
|
141
|
+
profile: detail(id),
|
|
142
|
+
routines: out.routines,
|
|
143
|
+
warnings: out.warnings,
|
|
144
|
+
tokens: out.tokens,
|
|
145
|
+
});
|
|
146
|
+
} catch (e) {
|
|
147
|
+
fail(res, e);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
app.post("/profiles/off", (_req, res) => {
|
|
152
|
+
try {
|
|
153
|
+
res.json({ ok: true, ...offProfile() });
|
|
154
|
+
} catch (e) {
|
|
155
|
+
fail(res, e);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
app.patch("/profiles/config", (req, res) => {
|
|
160
|
+
try {
|
|
161
|
+
const { values, id } = req.body || {};
|
|
162
|
+
if (!values || typeof values !== "object") {
|
|
163
|
+
return res.status(400).json({ error: "body needs { values: { key: value } }" });
|
|
164
|
+
}
|
|
165
|
+
const out = setProfileConfig(values, { id: id || null });
|
|
166
|
+
res.json({ ok: true, ...out });
|
|
167
|
+
} catch (e) {
|
|
168
|
+
fail(res, e);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
app.delete("/profiles/:id", (req, res) => {
|
|
173
|
+
try {
|
|
174
|
+
res.json({ ok: true, ...uninstallProfile(req.params.id) });
|
|
175
|
+
} catch (e) {
|
|
176
|
+
fail(res, e);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
@@ -24,7 +24,7 @@ const API_PREFIXES = [
|
|
|
24
24
|
"/health", "/admin", "/projects", "/telegram", "/engines", "/runtimes",
|
|
25
25
|
"/messages", "/sessions", "/tools", "/mcp", "/voice", "/tts", "/desktop", "/overlay",
|
|
26
26
|
"/transcribe", "/run", "/files", "/memory", "/env", "/pair", "/deck",
|
|
27
|
-
"/super-agent", "/identity", "/skills",
|
|
27
|
+
"/super-agent", "/identity", "/skills", "/profiles",
|
|
28
28
|
];
|
|
29
29
|
|
|
30
30
|
export function isApiPath(p) {
|
package/src/host/daemon/api.js
CHANGED
|
@@ -51,6 +51,7 @@ import { register as registerPairing } from "./api/pairing.js";
|
|
|
51
51
|
import { register as registerAdmin } from "./api/admin.js";
|
|
52
52
|
import { register as registerAdminConfig } from "./api/admin-config.js";
|
|
53
53
|
import { register as registerIdentity } from "./api/identity.js";
|
|
54
|
+
import { register as registerProfiles } from "./api/profiles.js";
|
|
54
55
|
import { register as registerWeb } from "./api/web.js";
|
|
55
56
|
import { register as registerConfirm } from "./api/confirm.js";
|
|
56
57
|
|
|
@@ -151,6 +152,7 @@ export function buildApi({
|
|
|
151
152
|
registerAdmin(app, ctx);
|
|
152
153
|
registerAdminConfig(app, ctx);
|
|
153
154
|
registerIdentity(app, ctx);
|
|
155
|
+
registerProfiles(app, ctx);
|
|
154
156
|
|
|
155
157
|
// ---- Web admin panel (static SPA, must mount before 404) ---------
|
|
156
158
|
// Serves src/interfaces/web/dist when present + the /admin/web-token
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// apx profile — install, activate and configure the super-agent's personality.
|
|
2
|
+
//
|
|
3
|
+
// apx profile list
|
|
4
|
+
// apx profile show <id> [--preview]
|
|
5
|
+
// apx profile install <id|path> [--force]
|
|
6
|
+
// apx profile use <id> [--force]
|
|
7
|
+
// apx profile off
|
|
8
|
+
// apx profile config [--set k=v]... [--interactive]
|
|
9
|
+
// apx profile doctor [<id>]
|
|
10
|
+
// apx profile uninstall <id>
|
|
11
|
+
//
|
|
12
|
+
// Everything goes through the daemon: activating a profile changes the live
|
|
13
|
+
// system prompt and rewrites the routine schedule, so the process that owns
|
|
14
|
+
// both has to apply it. Writing config from here would leave the running
|
|
15
|
+
// daemon out of date.
|
|
16
|
+
import readline from "node:readline/promises";
|
|
17
|
+
import { http } from "../http.js";
|
|
18
|
+
|
|
19
|
+
export const PROFILE_USAGE = {
|
|
20
|
+
list: "apx profile list",
|
|
21
|
+
show: "apx profile show <id> [--preview]",
|
|
22
|
+
install: "apx profile install <id|path> [--force]",
|
|
23
|
+
use: "apx profile use <id> [--force]",
|
|
24
|
+
off: "apx profile off",
|
|
25
|
+
config: "apx profile config [--set key=value]... [--interactive]",
|
|
26
|
+
doctor: "apx profile doctor [<id>]",
|
|
27
|
+
uninstall: "apx profile uninstall <id>",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function fail(sub, msg) {
|
|
31
|
+
console.error(`apx profile ${sub}: ${msg}`);
|
|
32
|
+
console.error(`Usage: ${PROFILE_USAGE[sub]}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function asArray(v) {
|
|
37
|
+
if (v === undefined || v === null) return [];
|
|
38
|
+
return Array.isArray(v) ? v : [v];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** `--set k=v --set a=b` → { k: "v", a: "b" } */
|
|
42
|
+
function parseSetFlags(flags) {
|
|
43
|
+
const out = {};
|
|
44
|
+
for (const raw of asArray(flags?.set)) {
|
|
45
|
+
const s = String(raw);
|
|
46
|
+
const eq = s.indexOf("=");
|
|
47
|
+
if (eq < 1) {
|
|
48
|
+
console.error(`apx profile config: --set expects key=value — got "${s}"`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
out[s.slice(0, eq).trim()] = s.slice(eq + 1);
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function printWarnings(warnings = []) {
|
|
57
|
+
for (const w of warnings) console.log(` warning: ${w}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function printDoctor(report) {
|
|
61
|
+
console.log(report.summary);
|
|
62
|
+
if (report.tokens != null) {
|
|
63
|
+
const budget = report.budget ? ` (declared budget ${report.budget})` : "";
|
|
64
|
+
console.log(` prompt: ~${report.tokens} tokens${budget}`);
|
|
65
|
+
}
|
|
66
|
+
for (const c of report.checks || []) {
|
|
67
|
+
const mark = c.level === "error" ? "✖" : "!";
|
|
68
|
+
console.log(` ${mark} [${c.label}] ${c.detail}`);
|
|
69
|
+
if (c.fix) console.log(` fix: ${c.fix}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ── list ────────────────────────────────────────────────────────────────────
|
|
74
|
+
|
|
75
|
+
export async function cmdProfileList() {
|
|
76
|
+
const { active, profiles } = await http.get("/profiles");
|
|
77
|
+
if (!profiles.length) {
|
|
78
|
+
console.log("(no profiles available)");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
for (const p of profiles) {
|
|
82
|
+
const mark = p.active ? "*" : " ";
|
|
83
|
+
const version = p.version ? ` v${p.version}` : "";
|
|
84
|
+
console.log(`${mark} ${p.id.padEnd(16)} ${p.name}${version} [${p.source}]`);
|
|
85
|
+
if (p.description) console.log(` ${p.description}`);
|
|
86
|
+
}
|
|
87
|
+
console.log("");
|
|
88
|
+
console.log(active ? `active: ${active}` : "active: none (vanilla)");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// ── show ────────────────────────────────────────────────────────────────────
|
|
92
|
+
|
|
93
|
+
export async function cmdProfileShow(args) {
|
|
94
|
+
const id = args._[0];
|
|
95
|
+
if (!id) fail("show", "missing <id>");
|
|
96
|
+
|
|
97
|
+
const p = await http.get(`/profiles/${encodeURIComponent(id)}`);
|
|
98
|
+
console.log(`${p.name} (${p.id}) v${p.version || "?"} — ${p.source}${p.active ? " — ACTIVE" : ""}`);
|
|
99
|
+
if (p.description) console.log(p.description);
|
|
100
|
+
console.log(`languages: ${p.languages.join(", ") || "en"}`);
|
|
101
|
+
console.log(`prompt: ~${p.tokens} tokens${p.budget ? ` (declared budget ${p.budget})` : ""}`);
|
|
102
|
+
console.log(`path: ${p.dir}`);
|
|
103
|
+
|
|
104
|
+
const keys = Object.keys(p.config || {});
|
|
105
|
+
if (keys.length) {
|
|
106
|
+
console.log("\nsettings:");
|
|
107
|
+
for (const k of keys.sort()) console.log(` ${k.padEnd(24)} ${p.config[k]}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (args?.flags?.preview) {
|
|
111
|
+
console.log("\n--- rendered prompt block ---");
|
|
112
|
+
console.log(p.preview || "(empty)");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ── install ─────────────────────────────────────────────────────────────────
|
|
117
|
+
|
|
118
|
+
export async function cmdProfileInstall(args) {
|
|
119
|
+
const source = args._[0];
|
|
120
|
+
if (!source) fail("install", "missing <id|path>");
|
|
121
|
+
|
|
122
|
+
const r = await http.post("/profiles/install", { source, force: !!args?.flags?.force });
|
|
123
|
+
console.log(`installed ${r.profile.name} (${r.profile.id}) v${r.profile.version || "?"}`);
|
|
124
|
+
console.log(` prompt: ~${r.tokens} tokens`);
|
|
125
|
+
printWarnings(r.warnings);
|
|
126
|
+
console.log("");
|
|
127
|
+
console.log(`Not active yet — run: apx profile use ${r.profile.id}`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ── use / off ───────────────────────────────────────────────────────────────
|
|
131
|
+
|
|
132
|
+
export async function cmdProfileUse(args) {
|
|
133
|
+
const id = args._[0];
|
|
134
|
+
if (!id) fail("use", "missing <id>");
|
|
135
|
+
|
|
136
|
+
const r = await http.post("/profiles/use", { id, force: !!args?.flags?.force });
|
|
137
|
+
console.log(`active profile: ${r.profile.name} (${r.profile.id})`);
|
|
138
|
+
printWarnings(r.warnings);
|
|
139
|
+
|
|
140
|
+
const { installed = [], skipped = [] } = r.routines || {};
|
|
141
|
+
if (installed.length) console.log(` routines installed: ${installed.join(", ")}`);
|
|
142
|
+
for (const s of skipped) {
|
|
143
|
+
console.log(` routine "${s.name}" left alone (${s.reason.replace(/_/g, " ")})`);
|
|
144
|
+
}
|
|
145
|
+
if (!r.profile.active) console.log(" (warning: profile did not activate)");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export async function cmdProfileOff() {
|
|
149
|
+
const r = await http.post("/profiles/off", {});
|
|
150
|
+
if (!r.was) {
|
|
151
|
+
console.log("no profile was active — nothing to do");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
console.log(`profile "${r.was}" is off — APX is back to vanilla`);
|
|
155
|
+
if (r.routines?.length) console.log(` routines disabled (not deleted): ${r.routines.join(", ")}`);
|
|
156
|
+
console.log(" settings, tasks and memory were kept — `apx profile use` restores them");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// ── config ──────────────────────────────────────────────────────────────────
|
|
160
|
+
|
|
161
|
+
async function interactiveConfig(profile) {
|
|
162
|
+
const props = profile.schema?.properties || {};
|
|
163
|
+
const keys = Object.keys(props);
|
|
164
|
+
if (!keys.length) {
|
|
165
|
+
console.log(`profile "${profile.id}" has no configurable settings`);
|
|
166
|
+
return {};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
170
|
+
const values = {};
|
|
171
|
+
try {
|
|
172
|
+
console.log(`Configuring ${profile.name}. Press enter to keep the current value.\n`);
|
|
173
|
+
for (const key of keys) {
|
|
174
|
+
const def = props[key];
|
|
175
|
+
const current = profile.config?.[key];
|
|
176
|
+
const hint = def.enum ? ` (${def.enum.join(" | ")})` : def.type ? ` (${def.type})` : "";
|
|
177
|
+
const label = def.title || key;
|
|
178
|
+
const answer = (await rl.question(`${label}${hint} [${current ?? ""}]: `)).trim();
|
|
179
|
+
if (answer !== "") values[key] = answer;
|
|
180
|
+
}
|
|
181
|
+
} finally {
|
|
182
|
+
rl.close();
|
|
183
|
+
}
|
|
184
|
+
return values;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export async function cmdProfileConfig(args) {
|
|
188
|
+
const { active } = await http.get("/profiles");
|
|
189
|
+
const id = args?.flags?.profile || active;
|
|
190
|
+
if (!id) {
|
|
191
|
+
console.error("apx profile config: no profile is active — run: apx profile use <id>");
|
|
192
|
+
process.exit(1);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const profile = await http.get(`/profiles/${encodeURIComponent(id)}?preview=0`);
|
|
196
|
+
|
|
197
|
+
let values = parseSetFlags(args?.flags);
|
|
198
|
+
if (args?.flags?.interactive) {
|
|
199
|
+
values = { ...values, ...(await interactiveConfig(profile)) };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// No changes asked for → show the current settings.
|
|
203
|
+
if (!Object.keys(values).length) {
|
|
204
|
+
const props = profile.schema?.properties || {};
|
|
205
|
+
const keys = Object.keys(profile.config || {});
|
|
206
|
+
if (!keys.length) {
|
|
207
|
+
console.log(`profile "${id}" has no settings`);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
console.log(`settings for ${profile.name} (${id}):`);
|
|
211
|
+
for (const k of keys.sort()) {
|
|
212
|
+
const def = props[k] || {};
|
|
213
|
+
const allowed = def.enum ? ` [${def.enum.join(" | ")}]` : "";
|
|
214
|
+
console.log(` ${k.padEnd(24)} ${profile.config[k]}${allowed}`);
|
|
215
|
+
}
|
|
216
|
+
console.log("\nchange one with: apx profile config --set key=value");
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const r = await http.patch("/profiles/config", { values, id });
|
|
221
|
+
console.log(`updated: ${r.changed.join(", ")}`);
|
|
222
|
+
for (const k of r.changed) console.log(` ${k.padEnd(24)} ${r.config[k]}`);
|
|
223
|
+
|
|
224
|
+
const { installed = [], skipped = [] } = r.routines || {};
|
|
225
|
+
if (installed.length) console.log(` routines rescheduled: ${installed.join(", ")}`);
|
|
226
|
+
for (const s of skipped) {
|
|
227
|
+
console.log(` routine "${s.name}" left alone (${s.reason.replace(/_/g, " ")})`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// ── doctor / uninstall ──────────────────────────────────────────────────────
|
|
232
|
+
|
|
233
|
+
export async function cmdProfileDoctor(args) {
|
|
234
|
+
const id = args._[0];
|
|
235
|
+
const q = id ? `?id=${encodeURIComponent(id)}` : "";
|
|
236
|
+
printDoctor(await http.get(`/profiles/doctor${q}`));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export async function cmdProfileUninstall(args) {
|
|
240
|
+
const id = args._[0];
|
|
241
|
+
if (!id) fail("uninstall", "missing <id>");
|
|
242
|
+
|
|
243
|
+
const r = await http.delete(`/profiles/${encodeURIComponent(id)}`);
|
|
244
|
+
console.log(`uninstalled "${r.id}" (${r.source})`);
|
|
245
|
+
if (r.routines?.removed?.length) console.log(` routines removed: ${r.routines.removed.join(", ")}`);
|
|
246
|
+
if (r.routines?.kept?.length) {
|
|
247
|
+
console.log(` kept (you edited these): ${r.routines.kept.join(", ")}`);
|
|
248
|
+
}
|
|
249
|
+
if (r.source === "bundled") {
|
|
250
|
+
console.log(" bundled package hidden — reinstall it any time with: apx profile install " + r.id);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
@@ -151,6 +151,16 @@ import {
|
|
|
151
151
|
cmdTaskReopen,
|
|
152
152
|
cmdTaskPatch,
|
|
153
153
|
} from "./commands/task.js";
|
|
154
|
+
import {
|
|
155
|
+
cmdProfileList,
|
|
156
|
+
cmdProfileShow,
|
|
157
|
+
cmdProfileInstall,
|
|
158
|
+
cmdProfileUse,
|
|
159
|
+
cmdProfileOff,
|
|
160
|
+
cmdProfileConfig,
|
|
161
|
+
cmdProfileDoctor,
|
|
162
|
+
cmdProfileUninstall,
|
|
163
|
+
} from "./commands/profile.js";
|
|
154
164
|
import {
|
|
155
165
|
cmdOrgShow,
|
|
156
166
|
cmdOrgAreaAdd,
|
|
@@ -1607,6 +1617,42 @@ const HELP_TOPICS = new Map(Object.entries({
|
|
|
1607
1617
|
examples: ["apx plugins status telegram"],
|
|
1608
1618
|
}),
|
|
1609
1619
|
|
|
1620
|
+
profile: topic({
|
|
1621
|
+
title: "apx profile",
|
|
1622
|
+
summary:
|
|
1623
|
+
"Install, activate and configure the super-agent's line of work. With no profile active, APX behaves exactly as it always has.",
|
|
1624
|
+
usage: ["apx profile <subcommand> [args] [--flags]"],
|
|
1625
|
+
commands: [
|
|
1626
|
+
["list | ls", "Show every available profile and which one is active."],
|
|
1627
|
+
["show | get <id>", "Details, settings and token cost of one profile."],
|
|
1628
|
+
["install | add <id|path>", "Validate and install a profile. Does NOT activate it."],
|
|
1629
|
+
["use | activate <id>", "Make a profile active and install its routines."],
|
|
1630
|
+
["off | deactivate", "Go back to vanilla. Disables its routines, deletes nothing."],
|
|
1631
|
+
["config", "Show or change the active profile's settings."],
|
|
1632
|
+
["doctor [<id>]", "What is missing for this profile to do its job."],
|
|
1633
|
+
["uninstall | remove <id>", "Remove a profile, keeping anything you edited."],
|
|
1634
|
+
],
|
|
1635
|
+
options: [
|
|
1636
|
+
["--preview", "show: also print the rendered prompt block."],
|
|
1637
|
+
["--set <key=value>", "config: set one setting. Repeatable."],
|
|
1638
|
+
["--interactive", "config: walk through every setting."],
|
|
1639
|
+
["--force", "install: overwrite. use: replace the active profile."],
|
|
1640
|
+
],
|
|
1641
|
+
examples: [
|
|
1642
|
+
"apx profile list",
|
|
1643
|
+
"apx profile install secretary",
|
|
1644
|
+
"apx profile use secretary",
|
|
1645
|
+
"apx profile config --set day_open_at=08:30 --set nudge_budget_per_day=3",
|
|
1646
|
+
"apx profile show secretary --preview",
|
|
1647
|
+
"apx profile off",
|
|
1648
|
+
],
|
|
1649
|
+
}),
|
|
1650
|
+
profiles: topic({
|
|
1651
|
+
title: "apx profiles",
|
|
1652
|
+
summary: "Alias for apx profile.",
|
|
1653
|
+
usage: ["apx profiles <subcommand>"],
|
|
1654
|
+
examples: ["apx profiles list"],
|
|
1655
|
+
}),
|
|
1610
1656
|
task: topic({
|
|
1611
1657
|
title: "apx task",
|
|
1612
1658
|
summary: "Per-project TODO list backed by the daemon (/projects/:pid/tasks).",
|
|
@@ -2753,6 +2799,22 @@ async function dispatch(cmd, rest) {
|
|
|
2753
2799
|
break;
|
|
2754
2800
|
}
|
|
2755
2801
|
|
|
2802
|
+
case "profile":
|
|
2803
|
+
case "profiles": {
|
|
2804
|
+
const sub = rest[0];
|
|
2805
|
+
const a = parseArgs(rest.slice(1));
|
|
2806
|
+
if (!sub || sub === "list" || sub === "ls") await cmdProfileList(a);
|
|
2807
|
+
else if (sub === "show" || sub === "get") await cmdProfileShow(a);
|
|
2808
|
+
else if (sub === "install" || sub === "add") await cmdProfileInstall(a);
|
|
2809
|
+
else if (sub === "use" || sub === "activate") await cmdProfileUse(a);
|
|
2810
|
+
else if (sub === "off" || sub === "deactivate") await cmdProfileOff(a);
|
|
2811
|
+
else if (sub === "config") await cmdProfileConfig(a);
|
|
2812
|
+
else if (sub === "doctor") await cmdProfileDoctor(a);
|
|
2813
|
+
else if (sub === "uninstall" || sub === "remove" || sub === "rm") await cmdProfileUninstall(a);
|
|
2814
|
+
else die(`unknown profile subcommand: ${sub}\nUsage: apx profile <list|show|install|use|off|config|doctor|uninstall>`);
|
|
2815
|
+
break;
|
|
2816
|
+
}
|
|
2817
|
+
|
|
2756
2818
|
case "command":
|
|
2757
2819
|
case "commands": {
|
|
2758
2820
|
const sub = rest[0];
|