@phren/cli 0.3.21 → 0.3.23

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.
@@ -635,8 +635,13 @@ export function updateTask(phrenPath, project, match, updates) {
635
635
  if (updates.context) {
636
636
  if (updates.replace_context || !item.context)
637
637
  item.context = updates.context;
638
- else
638
+ // Agents sometimes send the existing context with their new note. Do
639
+ // not append the complete history to itself on every such update.
640
+ else if (updates.context.startsWith(`${item.context}; `))
641
+ item.context = updates.context;
642
+ else if (updates.context !== item.context && !item.context.endsWith(`; ${updates.context}`)) {
639
643
  item.context = `${item.context}; ${updates.context}`;
644
+ }
640
645
  changes.push("context updated");
641
646
  }
642
647
  if (updates.unlink_github) {
@@ -77,6 +77,7 @@ function agentSkillDirs() {
77
77
  path.join(home, ".cursor", "skills"),
78
78
  path.join(home, ".copilot", "skills"),
79
79
  path.join(home, ".codex", "skills"),
80
+ path.join(home, ".agents", "skills"),
80
81
  ];
81
82
  }
82
83
  // Remove skill symlinks that resolve inside phrenPath. Only touches symlinks, never regular files.
@@ -269,6 +269,17 @@ function ensureGeneratedSkillArtifacts(phrenPath, preferredHome) {
269
269
  catch (err) {
270
270
  debugLog(`ensureGeneratedSkillArtifacts: global skill mirror sync failed: ${errorMessage(err)}`);
271
271
  }
272
+ // The standard user skill directory is how Codex discovers folder skills.
273
+ const nativeSkillsDir = path.join(preferredHome, ".agents", "skills");
274
+ const hadNativeSkillsDir = fs.existsSync(nativeSkillsDir);
275
+ try {
276
+ syncScopeSkillsToDir(phrenPath, "global", nativeSkillsDir);
277
+ if (!hadNativeSkillsDir)
278
+ created.push("~/.agents/skills/");
279
+ }
280
+ catch (err) {
281
+ debugLog(`ensureGeneratedSkillArtifacts: native skill mirror sync failed: ${errorMessage(err)}`);
282
+ }
272
283
  const copilotSkillsDir = path.join(preferredHome, ".copilot", "skills");
273
284
  const hadCopilotSkillsDir = fs.existsSync(copilotSkillsDir);
274
285
  if (isCopilotInstalled()) {
@@ -22,6 +22,7 @@ function agentSkillDirs() {
22
22
  path.join(home, ".cursor", "skills"),
23
23
  path.join(home, ".copilot", "skills"),
24
24
  path.join(home, ".codex", "skills"),
25
+ path.join(home, ".agents", "skills"),
25
26
  ];
26
27
  }
27
28
  export function generatedRootMemoryPath() {
package/dist/link/link.js CHANGED
@@ -248,6 +248,8 @@ function linkGlobal(phrenPath, tools, caps) {
248
248
  log(" global skills -> ~/.claude/skills/");
249
249
  const skillsDir = homePath(".claude", "skills");
250
250
  syncScopeSkillsToDir(phrenPath, "global", skillsDir);
251
+ log(" global skills -> ~/.agents/skills/");
252
+ syncScopeSkillsToDir(phrenPath, "global", homePath(".agents", "skills"));
251
253
  if (tools.has("copilot")) {
252
254
  const copilotSkillsDir = homePath(".copilot", "skills");
253
255
  log(" global skills -> ~/.copilot/skills/");
@@ -10,7 +10,7 @@ import { syncScopeSkillsToDir } from "../skill/files.js";
10
10
  export function refreshLinkedContext(phrenPath, profile) {
11
11
  const caps = resolveManagementCapabilities(phrenPath);
12
12
  if (caps.installSkillLinks) {
13
- for (const tool of [".claude", ".copilot"]) {
13
+ for (const tool of [".claude", ".agents", ".copilot"]) {
14
14
  const dir = homePath(tool, "skills");
15
15
  if (fs.existsSync(path.join(path.dirname(dir), "skill-manifest.json")))
16
16
  syncScopeSkillsToDir(phrenPath, "global", dir);
@@ -132,7 +132,7 @@ export const BUILTIN_MODULES = [
132
132
  hookRoutes: [...routes("GET", ["/v1/dispatch", "/v1/dispatch/capacity", "/v1/dispatch/arrival", "/v1/conductor", "/v1/conductor/grants", "/v1/computers", "/v1/sets", "/v1/authority", "/v1/owner-inbox", "/v1/conductor/integrator"]),
133
133
  ...routes("POST", ["/v1/dispatch", "/v1/dispatch/workers", "/v1/dispatch/returns", "/v1/dispatch/approve", "/v1/dispatch/report", "/v1/dispatch/close", "/v1/owner-inbox", "/v1/conductor/integrator", "/v1/hand-off", "/v1/hand-off/status", "/v1/conductor/grants", "/v1/conductor/make", "/v1/conductor/stop", "/v1/sets/name", "/v1/authority", "/v1/authority/confirm"]), ...routes("DELETE", ["/v1/conductor/grants", "/v1/authority"])],
134
134
  capabilities: ["dispatch", "conductorSets", "ownerInbox", "workerReports", "queuedHandOff"], storeFiles: ["global/skills/conductor/**"],
135
- localFiles: ["<bridge>/hooks.yaml", "<bridge>/conductor.yaml", "<bridge>/conductor-role.json", "<bridge>/authority.yaml", "<bridge>/authority-confirmations.json", "<bridge>/dispatches/*.json", "<bridge>/hand-offs/*.json", "<bridge>/worker-reports/*.json", "<bridge>/closed-workers/*.json", "<bridge>/owner-inbox.json", "<bridge>/integrator.json"], phoneScreens: [], skills: ["conductor"],
135
+ localFiles: ["<bridge>/hooks.yaml", "<bridge>/conductor.yaml", "<bridge>/conductor-role.json", "<bridge>/conductor/brief.md", "<bridge>/authority.yaml", "<bridge>/authority-confirmations.json", "<bridge>/dispatches/*.json", "<bridge>/hand-offs/*.json", "<bridge>/worker-reports/*.json", "<bridge>/closed-workers/*.json", "<bridge>/owner-inbox.json", "<bridge>/integrator.json"], phoneScreens: [], skills: ["conductor"],
136
136
  },
137
137
  {
138
138
  schemaVersion: 1, name: "fanout", version: VERSION, defaultEnabled: false, requires: ["memory", "hook"],
@@ -85,7 +85,13 @@ export function syncScopeSkillsToDir(phrenPath, scope, destDir) {
85
85
  }
86
86
  export function syncSkillLinksForScope(phrenPath, scope) {
87
87
  if (scope.toLowerCase() === "global") {
88
- return syncScopeSkillsToDir(phrenPath, "global", homePath(".claude", "skills"));
88
+ const manifest = syncScopeSkillsToDir(phrenPath, "global", homePath(".claude", "skills"));
89
+ for (const tool of [".agents", ".copilot"]) {
90
+ const dir = homePath(tool, "skills");
91
+ if (fs.existsSync(path.join(path.dirname(dir), "skill-manifest.json")))
92
+ syncScopeSkillsToDir(phrenPath, "global", dir);
93
+ }
94
+ return manifest;
89
95
  }
90
96
  const projectDir = findProjectDir(scope);
91
97
  if (!projectDir)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phren/cli",
3
- "version": "0.3.21",
3
+ "version": "0.3.23",
4
4
  "description": "Knowledge layer for AI agents - CLI, MCP server, and data layer",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,4 +1,5 @@
1
1
  // Installed by Phren Hook and replaced on every update. Copy it under another name to customize.
2
+ import { request } from "node:http";
2
3
  import { execFileSync } from "node:child_process";
3
4
  import { lstatSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
4
5
  import { homedir } from "node:os";
@@ -253,6 +254,27 @@ function writePidBinding(sessionID) {
253
254
  * whose terminal does not watch its agents (tmux); Herdr has its own. */
254
255
  const statusFile = () => path.join(storeRoot(), ".runtime", "sessions", `opencode-status-${process.pid}.json`);
255
256
 
257
+ /** Context reads never hold up a model request when the Hook is unavailable. */
258
+ function conductorContext(session) {
259
+ return new Promise(resolve => {
260
+ const socketPath = path.join(process.env.PHREN_BRIDGE_HOME || path.join(homedir(), ".local/share/phren/bridge"), "agent.sock");
261
+ const data = JSON.stringify({ pid: process.pid, session });
262
+ const req = request({ socketPath, path: "/conductor-context", method: "POST",
263
+ headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(data) } }, res => {
264
+ let body = "";
265
+ res.on("data", chunk => { body += chunk; if (body.length > 16_384) req.destroy(); });
266
+ res.on("end", () => {
267
+ try { const value = JSON.parse(body); finish(res.statusCode === 200 && typeof value.context === "string" ? value.context : undefined); }
268
+ catch { finish(); }
269
+ });
270
+ res.on("error", () => finish());
271
+ });
272
+ const timer = setTimeout(() => { req.destroy(); finish(); }, 1_000);
273
+ function finish(value) { clearTimeout(timer); resolve(value); }
274
+ req.on("error", () => finish()); req.end(data);
275
+ });
276
+ }
277
+
256
278
  export const PhrenTranscriptPlugin = async input => {
257
279
  // The process's own API, bound to its in-process server (no port needed).
258
280
  const client = input?.client;
@@ -396,6 +418,12 @@ export const PhrenTranscriptPlugin = async input => {
396
418
  };
397
419
 
398
420
  return {
421
+ "experimental.chat.system.transform": async (input, output) => {
422
+ const sessionID = text(input?.sessionID);
423
+ if (process.env.PHREN_FANOUT_JOB || !OPENCODE_SESSION.test(sessionID) || sessionID !== boundSession || children.has(sessionID) || !Array.isArray(output?.system)) return;
424
+ const context = await conductorContext(sessionID);
425
+ if (context) output.system.push(context);
426
+ },
399
427
  "chat.message": async (input, output) => {
400
428
  if (!OPENCODE_SESSION.test(text(input?.sessionID)) || !output?.message) return;
401
429
  if (!process.env.PHREN_FANOUT_JOB && !children.has(input.sessionID) && boundSession !== input.sessionID) {