@phren/cli 0.2.16 → 0.3.1

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 (102) hide show
  1. package/dist/bridge/agent-hooks.d.ts +17 -6
  2. package/dist/bridge/agent-hooks.js +59 -24
  3. package/dist/bridge/claude-question-dialog.d.ts +65 -0
  4. package/dist/bridge/claude-question-dialog.js +210 -0
  5. package/dist/bridge/code-note.d.ts +2 -1
  6. package/dist/bridge/code-note.js +13 -4
  7. package/dist/bridge/code-routes.d.ts +32 -14
  8. package/dist/bridge/code-routes.js +131 -8
  9. package/dist/bridge/command.js +92 -2
  10. package/dist/bridge/computers.d.ts +5 -0
  11. package/dist/bridge/computers.js +10 -4
  12. package/dist/bridge/conductor-group.d.ts +23 -0
  13. package/dist/bridge/conductor-group.js +25 -0
  14. package/dist/bridge/dispatch-returns.d.ts +2 -0
  15. package/dist/bridge/dispatch-returns.js +12 -8
  16. package/dist/bridge/dispatch.d.ts +4 -1
  17. package/dist/bridge/dispatch.js +30 -5
  18. package/dist/bridge/hand-off.js +5 -1
  19. package/dist/bridge/herdr.d.ts +7 -0
  20. package/dist/bridge/herdr.js +53 -2
  21. package/dist/bridge/install.d.ts +0 -4
  22. package/dist/bridge/install.js +3 -3
  23. package/dist/bridge/link.d.ts +48 -0
  24. package/dist/bridge/link.js +136 -0
  25. package/dist/bridge/memory-store.d.ts +23 -0
  26. package/dist/bridge/memory-store.js +152 -0
  27. package/dist/bridge/pair.d.ts +46 -0
  28. package/dist/bridge/pair.js +240 -0
  29. package/dist/bridge/peers.d.ts +9 -0
  30. package/dist/bridge/peers.js +25 -2
  31. package/dist/bridge/protocol.js +20 -1
  32. package/dist/bridge/schedule-watch.d.ts +2 -0
  33. package/dist/bridge/schedule-watch.js +16 -3
  34. package/dist/bridge/server-launch.d.ts +9 -0
  35. package/dist/bridge/server-launch.js +34 -11
  36. package/dist/bridge/server-pane-routes.d.ts +7 -0
  37. package/dist/bridge/server-pane-routes.js +128 -18
  38. package/dist/bridge/server-routes.d.ts +3 -0
  39. package/dist/bridge/server-routes.js +55 -29
  40. package/dist/bridge/server-stream.js +4 -1
  41. package/dist/bridge/speech-key.d.ts +33 -0
  42. package/dist/bridge/speech-key.js +106 -0
  43. package/dist/bridge/speech-transcribe.js +1 -1
  44. package/dist/bridge/speech.d.ts +1 -3
  45. package/dist/bridge/speech.js +2 -16
  46. package/dist/bridge/transcript-preview.d.ts +2 -0
  47. package/dist/bridge/transcript-preview.js +15 -0
  48. package/dist/bridge-hook.mjs +9940 -3601
  49. package/dist/cli/config-policy.js +25 -0
  50. package/dist/cli/extract.d.ts +0 -8
  51. package/dist/cli/extract.js +1 -1
  52. package/dist/cli-handlers.js +6 -0
  53. package/dist/cli-registry.js +21 -9
  54. package/dist/content/learning.js +1 -1
  55. package/dist/content/validate.d.ts +14 -3
  56. package/dist/content/validate.js +174 -114
  57. package/dist/data/access.d.ts +9 -0
  58. package/dist/data/access.js +18 -0
  59. package/dist/data/tasks.d.ts +26 -0
  60. package/dist/data/tasks.js +72 -1
  61. package/dist/entrypoint.js +7 -0
  62. package/dist/generated/memory-ui-graph.browser.js +520 -410
  63. package/dist/governance/policy.js +4 -3
  64. package/dist/governance/rbac.d.ts +1 -1
  65. package/dist/governance/rbac.js +1 -0
  66. package/dist/hooks.d.ts +0 -15
  67. package/dist/hooks.js +1 -1
  68. package/dist/init/init-uninstall.js +13 -3
  69. package/dist/init/init-walkthrough.d.ts +10 -0
  70. package/dist/init/init-walkthrough.js +24 -1
  71. package/dist/init/init.d.ts +5 -0
  72. package/dist/init/init.js +54 -32
  73. package/dist/init/setup.js +19 -5
  74. package/dist/init/store-gitignore.d.ts +0 -5
  75. package/dist/init/store-gitignore.js +0 -8
  76. package/dist/link/context-imports.d.ts +15 -0
  77. package/dist/link/context-imports.js +101 -0
  78. package/dist/link/doctor.js +38 -4
  79. package/dist/mcp/profile.d.ts +0 -4
  80. package/dist/mcp/profile.js +2 -14
  81. package/dist/memory-ui-graph.runtime.js +520 -410
  82. package/dist/modules/code-package.js +10 -2
  83. package/dist/modules/config.d.ts +7 -0
  84. package/dist/modules/config.js +17 -0
  85. package/dist/modules/registry.js +6 -5
  86. package/dist/profile-store.js +39 -3
  87. package/dist/project-topics.d.ts +1 -0
  88. package/dist/project-topics.js +9 -6
  89. package/dist/shared/retrieval.d.ts +0 -2
  90. package/dist/shared/retrieval.js +1 -1
  91. package/dist/sync/task-claim.d.ts +22 -0
  92. package/dist/sync/task-claim.js +45 -0
  93. package/dist/tools/code.js +29 -21
  94. package/dist/tools/config.js +3 -0
  95. package/dist/tools/dispatch.js +3 -3
  96. package/dist/tools/finding.d.ts +11 -0
  97. package/dist/tools/finding.js +154 -99
  98. package/dist/tools/tasks.js +40 -1
  99. package/dist/ui/server.js +18 -1
  100. package/dist/update.js +21 -10
  101. package/package.json +8 -7
  102. package/starter/global/skills/conductor/SKILL.md +42 -10
@@ -13,6 +13,10 @@ const ACTIVE_HEADINGS = new Set(["active", "in progress", "in-progress", "curren
13
13
  const QUEUE_HEADINGS = new Set(["queue", "queued", "task", "todo", "upcoming", "next"]);
14
14
  const DONE_HEADINGS = new Set(["done", "completed", "finished", "archived"]);
15
15
  export { TASK_FILE_ALIASES, TASKS_FILENAME, isTaskFileName } from "../filenames.js";
16
+ const CLAIM_LINE = /^Claimed:\s+([A-Za-z0-9][A-Za-z0-9._-]{0,252})\s+(\d{4}-\d{2}-\d{2}T[0-9:.]+Z)(?:\s+session:([A-Za-z0-9._:-]{1,128}))?$/;
17
+ function formatClaim(claim) {
18
+ return `Claimed: ${claim.computer} ${claim.at}${claim.session ? ` session:${claim.session}` : ""}`;
19
+ }
16
20
  const TASK_SECTIONS = ["Active", "Queue", "Done"];
17
21
  function normalizePriority(text) {
18
22
  const m = text.replace(/\s*\[pinned\]/gi, "").match(/\[(high|medium|low)\]\s*$/i);
@@ -77,6 +81,7 @@ function formatGitHubIssueReference(item) {
77
81
  }
78
82
  function parseContinuation(lines, idx) {
79
83
  let context;
84
+ let claim;
80
85
  let githubIssue;
81
86
  let githubUrl;
82
87
  let linesToSkip = 0;
@@ -94,6 +99,12 @@ function parseContinuation(lines, idx) {
94
99
  linesToSkip++;
95
100
  continue;
96
101
  }
102
+ const claimed = CLAIM_LINE.exec(trimmed);
103
+ if (claimed) {
104
+ claim = { computer: claimed[1], at: claimed[2], ...(claimed[3] ? { session: claimed[3] } : {}) };
105
+ linesToSkip++;
106
+ continue;
107
+ }
97
108
  if (trimmed.startsWith("GitHub:")) {
98
109
  const parsed = parseGitHubIssueReference(trimmed.slice("GitHub:".length));
99
110
  githubIssue = parsed.githubIssue;
@@ -103,7 +114,7 @@ function parseContinuation(lines, idx) {
103
114
  }
104
115
  break;
105
116
  }
106
- return { context, githubIssue, githubUrl, linesToSkip };
117
+ return { context, githubIssue, githubUrl, claim, linesToSkip };
107
118
  }
108
119
  /** Pattern that matches the task metadata comment embedded in task item lines.
109
120
  * Format: <!-- bid:HASH [rank:N] [lastActivity:ISO] -->
@@ -251,6 +262,7 @@ function parseTaskContent(project, taskPath, content) {
251
262
  pinned: pinned || undefined,
252
263
  githubIssue: continuation.githubIssue,
253
264
  githubUrl: continuation.githubUrl,
265
+ claim: continuation.claim,
254
266
  });
255
267
  i += continuation.linesToSkip;
256
268
  }
@@ -277,6 +289,8 @@ function renderTask(doc) {
277
289
  const githubRef = formatGitHubIssueReference(item);
278
290
  if (githubRef)
279
291
  out.push(` GitHub: ${githubRef}`);
292
+ if (item.claim)
293
+ out.push(` ${formatClaim(item.claim)}`);
280
294
  }
281
295
  out.push("");
282
296
  }
@@ -499,6 +513,7 @@ export function completeTasks(phrenPath, project, matches) {
499
513
  const [item] = parsed.data.items[found.match.section].splice(found.match.index, 1);
500
514
  item.section = "Done";
501
515
  item.checked = true;
516
+ item.claim = undefined;
502
517
  parsed.data.items.Done.unshift(item);
503
518
  completed.push(item.line);
504
519
  }
@@ -525,6 +540,7 @@ export function completeTask(phrenPath, project, match) {
525
540
  const [item] = parsed.data.items[found.match.section].splice(found.match.index, 1);
526
541
  item.section = "Done";
527
542
  item.checked = true;
543
+ item.claim = undefined;
528
544
  parsed.data.items.Done.unshift(item);
529
545
  writeTaskDoc(parsed.data);
530
546
  return phrenOk(`Marked done in ${project}: ${item.line}`);
@@ -804,6 +820,61 @@ export function promoteTask(phrenPath, project, match, moveToActive) {
804
820
  return phrenOk(item);
805
821
  });
806
822
  }
823
+ /** A claim this old may be taken over with `force`: its conductor has likely gone. */
824
+ export const STALE_CLAIM_MS = 24 * 60 * 60 * 1000;
825
+ /**
826
+ * Takes a task for `claim.computer`: moves it to Active and records the claim.
827
+ * Refuses a task another computer holds unless `force` is set and that claim
828
+ * is stale; claiming again from the same computer refreshes it. With
829
+ * `release`, clears this computer's claim and returns the task to the Queue.
830
+ */
831
+ export function claimTask(phrenPath, project, match, claim, opts = {}) {
832
+ const bPath = canonicalTaskFilePath(phrenPath, project);
833
+ if (!bPath)
834
+ return phrenErr(`Project name "${project}" is not valid.`, PhrenError.INVALID_PROJECT_NAME);
835
+ const preCheck = ensureProject(phrenPath, project);
836
+ if (!preCheck.ok)
837
+ return forwardErr(preCheck);
838
+ return withSafeLock(bPath, () => {
839
+ const parsed = readTasks(phrenPath, project);
840
+ if (!parsed.ok)
841
+ return forwardErr(parsed);
842
+ const found = findItemByMatch(parsed.data, match);
843
+ if (found.error)
844
+ return phrenErr(found.error, found.errorCode ?? PhrenError.AMBIGUOUS_MATCH);
845
+ if (!found.match)
846
+ return taskItemNotFound(project, match);
847
+ const item = parsed.data.items[found.match.section][found.match.index];
848
+ if (item.section === "Done")
849
+ return phrenErr(`This task is already done: ${item.line}`, PhrenError.VALIDATION_ERROR);
850
+ const held = item.claim && item.claim.computer !== claim.computer ? item.claim : undefined;
851
+ if (held) {
852
+ const stale = (opts.now ?? Date.now()) - Date.parse(held.at) > STALE_CLAIM_MS;
853
+ if (!opts.force || !stale) {
854
+ return phrenErr(`${held.computer} claimed this task at ${held.at}${stale ? "; the claim is over a day old, so force can take it over" : ""}.`, PhrenError.PERMISSION_DENIED);
855
+ }
856
+ }
857
+ if (opts.release) {
858
+ if (!item.claim)
859
+ return phrenErr(`This task is not claimed: ${item.line}`, PhrenError.VALIDATION_ERROR);
860
+ item.claim = undefined;
861
+ parsed.data.items[item.section].splice(found.match.index, 1);
862
+ item.section = "Queue";
863
+ parsed.data.items.Queue.unshift(item);
864
+ }
865
+ else {
866
+ item.claim = claim;
867
+ if (item.section !== "Active") {
868
+ parsed.data.items[item.section].splice(found.match.index, 1);
869
+ item.section = "Active";
870
+ item.checked = false;
871
+ parsed.data.items.Active.unshift(item);
872
+ }
873
+ }
874
+ writeTaskDoc(parsed.data);
875
+ return phrenOk(item);
876
+ });
877
+ }
807
878
  export function workNextTask(phrenPath, project) {
808
879
  const bPath = canonicalTaskFilePath(phrenPath, project);
809
880
  if (!bPath)
@@ -1,4 +1,5 @@
1
1
  import { activateModules, moduleSnapshot } from "./modules/runtime.js";
2
+ import { enableHookForPhone } from "./modules/config.js";
2
3
  import { disabledCommand } from "./cli-registry.js";
3
4
  import * as fs from "fs";
4
5
  import * as path from "path";
@@ -149,6 +150,12 @@ export async function runTopLevelCommand(argv, opts = {}) {
149
150
  const store = findPhrenPath() ?? defaultPhrenPath();
150
151
  snapshot = ["modules", "init", "quickstart", "verify", "uninstall", "doctor"].includes(cmd.name) || argv.includes("--help") || argv.includes("-h")
151
152
  ? moduleSnapshot(store) : activateModules(store);
153
+ const wantsHook = cmd.name === "pair" || (cmd.name === "bridge" && argv[1] === "install");
154
+ if (wantsHook && !snapshot.has("hook") && !argv.includes("--help") && !argv.includes("-h")) {
155
+ if (enableHookForPhone(store))
156
+ console.log("Turned on the Hook module for this store (phren modules disable hook turns it off).");
157
+ snapshot = activateModules(store, undefined, true);
158
+ }
152
159
  const unavailable = disabledCommand([cmd.name, ...argv.slice(1)].join(" "), snapshot);
153
160
  if (unavailable) {
154
161
  console.error(unavailable);