@phren/cli 0.3.28 → 0.3.30
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/dist/bridge/hand-off-queue.d.ts +6 -0
- package/dist/bridge/hand-off-queue.js +29 -9
- package/dist/bridge/resources.d.ts +21 -0
- package/dist/bridge/resources.js +58 -2
- package/dist/bridge/server-launch.js +2 -1
- package/dist/bridge/server-routes.js +33 -2
- package/dist/bridge/simulators.d.ts +3 -1
- package/dist/bridge/simulators.js +40 -5
- package/dist/bridge/task-routes.d.ts +282 -0
- package/dist/bridge/task-routes.js +162 -0
- package/dist/bridge/uploads.d.ts +4 -0
- package/dist/bridge/uploads.js +15 -0
- package/dist/bridge-hook.mjs +4292 -2993
- package/dist/cli/namespaces-store.js +32 -1
- package/dist/cli/namespaces-tasks.d.ts +1 -0
- package/dist/cli/namespaces-tasks.js +55 -4
- package/dist/cli/ops.d.ts +2 -1
- package/dist/cli/ops.js +20 -4
- package/dist/cli-registry.js +5 -4
- package/dist/data/task-contract.d.ts +75 -0
- package/dist/data/task-contract.js +161 -0
- package/dist/data/task-format.d.ts +20 -0
- package/dist/data/task-format.js +55 -0
- package/dist/data/task-metadata.d.ts +10 -0
- package/dist/data/task-metadata.js +24 -0
- package/dist/data/task-store-directory.d.ts +21 -0
- package/dist/data/task-store-directory.js +37 -0
- package/dist/data/tasks.d.ts +38 -2
- package/dist/data/tasks.js +221 -28
- package/dist/modules/registry.js +3 -3
- package/dist/shell/input.js +49 -4
- package/dist/shell/state-store.d.ts +1 -0
- package/dist/shell/state-store.js +2 -0
- package/dist/shell/view.js +19 -3
- package/dist/store-registry.d.ts +12 -1
- package/dist/store-registry.js +52 -4
- package/dist/sync/task-claim.d.ts +1 -0
- package/dist/sync/task-claim.js +8 -1
- package/dist/sync/task-merge.d.ts +0 -9
- package/dist/sync/task-merge.js +48 -1
- package/dist/tools/tasks.js +31 -18
- package/dist/ui/page.js +1 -0
- package/dist/ui/scripts.js +64 -5
- package/dist/ui/server.js +18 -0
- package/package.json +1 -1
package/dist/ui/scripts.js
CHANGED
|
@@ -935,6 +935,45 @@ export function renderTasksAndSettingsScript(authToken) {
|
|
|
935
935
|
});
|
|
936
936
|
}
|
|
937
937
|
|
|
938
|
+
window.editTaskContract = function(index, field, value) {
|
|
939
|
+
var task = _allTasks[index];
|
|
940
|
+
if (!task) return;
|
|
941
|
+
var updates = { project: task.project, item: task.stableId ? 'bid:' + task.stableId : task.id };
|
|
942
|
+
if (field === 'dependencies') {
|
|
943
|
+
var choices = _allTasks.filter(function(t) { return t.identity && t !== task; });
|
|
944
|
+
var selected = task.dependencies || [];
|
|
945
|
+
var retained = selected.filter(function(d) { return !choices.some(function(t) { return t.identity.storeId === d.storeId && t.identity.project === d.project && t.identity.stableId === d.stableId; }); });
|
|
946
|
+
var panel = document.getElementById('task-prerequisites-' + index);
|
|
947
|
+
if (!panel) return;
|
|
948
|
+
if (value !== 'save') {
|
|
949
|
+
panel.hidden = !panel.hidden;
|
|
950
|
+
var unavailableNotice = retained.length ? '<p role="note">Some prerequisites are not available in this picker and will be kept. This picker cannot remove them. Use the CLI or API to remove these links or clear the dependency list. If a retained target is unavailable to the server, saving other prerequisite changes will fail until it is restored or removed.</p>' + retained.map(function(d) {
|
|
951
|
+
var current = (task.prerequisites || []).find(function(p) { return p.storeId === d.storeId && p.project === d.project && p.stableId === d.stableId; });
|
|
952
|
+
var responsibility = !current || current.missing ? 'Unknown responsibility' : current.responsibility === 'human' ? 'Human' : 'Agent';
|
|
953
|
+
return '<div>' + esc(responsibility + ' · ' + (current ? current.title : 'Unavailable prerequisite')) + ' <code style="overflow-wrap:anywhere">' + esc(d.storeId + '/' + d.project + '/' + d.stableId) + '</code></div>';
|
|
954
|
+
}).join('') : '';
|
|
955
|
+
panel.innerHTML = unavailableNotice + choices.map(function(t, choice) {
|
|
956
|
+
var checked = selected.some(function(d) { return d.storeId === t.identity.storeId && d.project === t.identity.project && d.stableId === t.identity.stableId; });
|
|
957
|
+
var responsibility = t.responsibility === 'human' ? 'Human' : 'Agent';
|
|
958
|
+
return '<label><input type="checkbox" data-task-choice="' + choice + '"' + (checked ? ' checked' : '') + '> ' + esc(responsibility + ' · ' + t.line) + ' <code style="overflow-wrap:anywhere">' + esc(t.identity.storeId + '/' + t.identity.project + '/' + t.identity.stableId) + '</code></label><br>';
|
|
959
|
+
}).join('') + '<button data-ts-action="savePrerequisites" data-index="' + index + '">Save prerequisites</button>';
|
|
960
|
+
panel._choices = choices;
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
// Retain unavailable prerequisites unless explicitly removed through CLI/API.
|
|
964
|
+
var dependencies = retained;
|
|
965
|
+
panel.querySelectorAll('input:checked').forEach(function(input) { dependencies.push(panel._choices[Number(input.getAttribute('data-task-choice'))].identity); });
|
|
966
|
+
updates.dependencies = JSON.stringify(dependencies);
|
|
967
|
+
} else updates[field] = value;
|
|
968
|
+
var csrfUrl = _tsAuthToken ? tsAuthUrl('/api/csrf-token') : '/api/csrf-token';
|
|
969
|
+
fetch(csrfUrl).then(function(r) { return r.json(); }).then(function(csrf) {
|
|
970
|
+
var body = new URLSearchParams(updates);
|
|
971
|
+
if (csrf.token) body.set('_csrf', csrf.token);
|
|
972
|
+
return fetch(_tsAuthToken ? tsAuthUrl('/api/tasks/update') : '/api/tasks/update', { method: 'POST', body: body });
|
|
973
|
+
}).then(function(r) { return r.json(); }).then(function(data) { if (data.ok) loadTasks(); else alert(data.error || 'Task update failed. Your selections have been kept.'); })
|
|
974
|
+
.catch(function(err) { alert('Task update could not be confirmed. Your selections have been kept; check the task before retrying. ' + String(err)); });
|
|
975
|
+
};
|
|
976
|
+
|
|
938
977
|
window.completeTaskFromUi = function(project, item) {
|
|
939
978
|
var csrfUrl = _tsAuthToken ? tsAuthUrl('/api/csrf-token') : '/api/csrf-token';
|
|
940
979
|
fetch(csrfUrl).then(function(r) { return r.json(); }).then(function(csrfData) {
|
|
@@ -997,15 +1036,18 @@ export function renderTasksAndSettingsScript(authToken) {
|
|
|
997
1036
|
window.filterTasks = function() {
|
|
998
1037
|
var projectFilter = (document.getElementById('tasks-filter-project') || {}).value || '';
|
|
999
1038
|
var sectionFilter = (document.getElementById('tasks-filter-section') || {}).value || '';
|
|
1039
|
+
var responsibilityFilter = (document.getElementById('tasks-filter-responsibility') || {}).value || '';
|
|
1000
1040
|
var showDone = sectionFilter === 'Done';
|
|
1001
1041
|
var tasks = _allTasks.filter(function(t) {
|
|
1002
1042
|
if (projectFilter && t.project !== projectFilter) return false;
|
|
1043
|
+
if (responsibilityFilter && (t.responsibility || 'agent') !== responsibilityFilter) return false;
|
|
1003
1044
|
if (sectionFilter && t.section !== sectionFilter) return false;
|
|
1004
1045
|
if (!sectionFilter && t.section === 'Done') return false;
|
|
1005
1046
|
return true;
|
|
1006
1047
|
});
|
|
1007
1048
|
var doneTasks = showDone ? [] : _allTasks.filter(function(t) {
|
|
1008
1049
|
if (projectFilter && t.project !== projectFilter) return false;
|
|
1050
|
+
if (responsibilityFilter && (t.responsibility || 'agent') !== responsibilityFilter) return false;
|
|
1009
1051
|
return t.section === 'Done' || t.checked;
|
|
1010
1052
|
});
|
|
1011
1053
|
|
|
@@ -1032,12 +1074,20 @@ export function renderTasksAndSettingsScript(authToken) {
|
|
|
1032
1074
|
function isNotDone(t) { return t.section !== 'Done' && !t.checked; }
|
|
1033
1075
|
|
|
1034
1076
|
function renderTaskRow(t) {
|
|
1077
|
+
var index = _allTasks.indexOf(t);
|
|
1078
|
+
var taskMatch = t.stableId ? 'bid:' + t.stableId : t.id;
|
|
1035
1079
|
var isDone = t.section === 'Done' || t.checked;
|
|
1036
1080
|
var priClass = t.priority ? 'task-row-priority-' + esc(t.priority) : 'task-row-priority-none';
|
|
1037
1081
|
var html = '<div class="task-row' + (isDone ? ' task-row-done' : '') + '">';
|
|
1038
1082
|
html += '<div class="task-row-priority ' + priClass + '"></div>';
|
|
1039
1083
|
html += '<div class="task-row-content">';
|
|
1040
1084
|
html += '<span class="task-row-text">' + esc(t.line) + '</span>';
|
|
1085
|
+
html += '<div>' + esc((t.responsibility || 'agent') === 'human' ? 'Human' : 'Agent') + ' · ' + esc(t.readiness || 'ready') + '</div>';
|
|
1086
|
+
(t.prerequisites || []).forEach(function(d) {
|
|
1087
|
+
var responsibility = d.missing ? 'Unknown responsibility' : d.responsibility === 'human' ? 'Human' : 'Agent';
|
|
1088
|
+
html += '<div>' + (d.missing ? 'Unavailable' : d.completed ? '✓' : 'Waiting on') + ' · ' + esc(responsibility + ' · ' + d.title) + '<br><code style="overflow-wrap:anywhere">' + esc(d.storeId + '/' + d.project + '/' + d.stableId) + '</code></div>';
|
|
1089
|
+
});
|
|
1090
|
+
html += '<div id="task-prerequisites-' + index + '" hidden></div>';
|
|
1041
1091
|
html += '</div>';
|
|
1042
1092
|
html += '<div class="task-row-meta">';
|
|
1043
1093
|
html += pinIndicator(t.pinned);
|
|
@@ -1046,10 +1096,13 @@ export function renderTasksAndSettingsScript(authToken) {
|
|
|
1046
1096
|
html += projectBadge(t.project);
|
|
1047
1097
|
html += '</div>';
|
|
1048
1098
|
html += '<div class="task-row-actions">';
|
|
1099
|
+
html += '<select aria-label="Task responsibility" data-task-field="responsibility" data-index="' + index + '"><option value="agent"' + ((t.responsibility || 'agent') === 'agent' ? ' selected' : '') + '>Agent</option><option value="human"' + (t.responsibility === 'human' ? ' selected' : '') + '>Human</option></select>';
|
|
1100
|
+
html += '<select aria-label="Task section" data-task-field="section" data-index="' + index + '">' + ['Queue', 'Active', 'Done'].map(function(section) { return '<option' + (t.section === section ? ' selected' : '') + '>' + section + '</option>'; }).join('') + '</select>';
|
|
1101
|
+
html += '<button data-ts-action="editPrerequisites" data-index="' + index + '">Prerequisites</button>';
|
|
1049
1102
|
if (!isDone) {
|
|
1050
|
-
html += '<button class="task-action-btn task-action-complete" data-ts-action="completeTask" data-project="' + esc(t.project) + '" data-item="' + esc(
|
|
1103
|
+
html += '<button class="task-action-btn task-action-complete" data-ts-action="completeTask" data-project="' + esc(t.project) + '" data-item="' + esc(taskMatch) + '" title="Mark done"><svg width="14" height="14" viewBox="0 0 16 16" fill="none"><path d="M3 8.5l3.5 3.5 6.5-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>';
|
|
1051
1104
|
}
|
|
1052
|
-
html += '<button class="task-action-btn task-action-delete" data-ts-action="removeTask" data-project="' + esc(t.project) + '" data-item="' + esc(
|
|
1105
|
+
html += '<button class="task-action-btn task-action-delete" data-ts-action="removeTask" data-project="' + esc(t.project) + '" data-item="' + esc(taskMatch) + '" title="Delete task"><svg width="12" height="12" viewBox="0 0 16 16" fill="none"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg></button>';
|
|
1053
1106
|
html += '</div>';
|
|
1054
1107
|
html += '</div>';
|
|
1055
1108
|
return html;
|
|
@@ -1080,9 +1133,10 @@ export function renderTasksAndSettingsScript(authToken) {
|
|
|
1080
1133
|
// Add task input at top (only when a specific project is selected)
|
|
1081
1134
|
if (projectFilter) {
|
|
1082
1135
|
html += '<div class="task-add-bar">';
|
|
1083
|
-
html += '<input id="task-add-input-' + esc(projectFilter) + '" type="text" class="task-add-input" placeholder="Add
|
|
1084
|
-
html += '<button class="task-add-btn" data-ts-action="addTask" data-project="' + esc(projectFilter) + '"><svg width="14" height="14" viewBox="0 0 16 16" fill="none"><path d="M8 3v10M3 8h10" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg> Add</button>';
|
|
1136
|
+
html += '<input id="task-add-input-' + esc(projectFilter) + '" type="text" class="task-add-input" placeholder="Add an Agent task to ' + esc(projectFilter) + '\u2026" data-ts-action="addTaskKeydown" data-project="' + esc(projectFilter) + '">';
|
|
1137
|
+
html += '<button class="task-add-btn" data-ts-action="addTask" data-project="' + esc(projectFilter) + '"><svg width="14" height="14" viewBox="0 0 16 16" fill="none"><path d="M8 3v10M3 8h10" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg> Add Agent task</button>';
|
|
1085
1138
|
html += '</div>';
|
|
1139
|
+
html += '<p role="note">New tasks are created as Agent work. Creating a Human task in one step is not supported here.</p>';
|
|
1086
1140
|
}
|
|
1087
1141
|
|
|
1088
1142
|
// Group by section: Active first, then Queue
|
|
@@ -1660,7 +1714,9 @@ export function renderTasksAndSettingsScript(authToken) {
|
|
|
1660
1714
|
var actionEl = target.closest('[data-ts-action]');
|
|
1661
1715
|
if (!actionEl) return;
|
|
1662
1716
|
var action = actionEl.getAttribute('data-ts-action');
|
|
1663
|
-
if (action === '
|
|
1717
|
+
if (action === 'editPrerequisites') { editTaskContract(Number(actionEl.getAttribute('data-index')), 'dependencies', 'edit'); }
|
|
1718
|
+
else if (action === 'savePrerequisites') { editTaskContract(Number(actionEl.getAttribute('data-index')), 'dependencies', 'save'); }
|
|
1719
|
+
else if (action === 'toggleDoneSection') { toggleDoneSection(actionEl); }
|
|
1664
1720
|
else if (action === 'completeTask') { completeTaskFromUi(actionEl.getAttribute('data-project'), actionEl.getAttribute('data-item')); }
|
|
1665
1721
|
else if (action === 'removeTask') { removeTaskFromUi(actionEl.getAttribute('data-project'), actionEl.getAttribute('data-item')); }
|
|
1666
1722
|
else if (action === 'addTask') { addTaskFromUi(actionEl.getAttribute('data-project')); }
|
|
@@ -2052,6 +2108,9 @@ export function renderEventWiringScript() {
|
|
|
2052
2108
|
// --- Tasks filters ---
|
|
2053
2109
|
var tasksFilterProject = document.getElementById('tasks-filter-project');
|
|
2054
2110
|
if (tasksFilterProject) tasksFilterProject.addEventListener('change', function() { filterTasks(); });
|
|
2111
|
+
document.addEventListener('change', function(e) { var el = e.target; if (el && el.hasAttribute('data-task-field')) editTaskContract(Number(el.getAttribute('data-index')), el.getAttribute('data-task-field'), el.value); });
|
|
2112
|
+
var taskResponsibilityFilter = document.getElementById('tasks-filter-responsibility');
|
|
2113
|
+
if (taskResponsibilityFilter) taskResponsibilityFilter.addEventListener('change', function() { filterTasks(); });
|
|
2055
2114
|
var tasksFilterSection = document.getElementById('tasks-filter-section');
|
|
2056
2115
|
if (tasksFilterSection) tasksFilterSection.addEventListener('change', function() { filterTasks(); });
|
|
2057
2116
|
|
package/dist/ui/server.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { taskView } from "../data/task-contract.js";
|
|
1
2
|
import { nonInteractiveGitEnv } from "../utils-helpers.js";
|
|
2
3
|
import { moduleSnapshot } from "../modules/runtime.js";
|
|
3
4
|
import { disabledHint } from "../modules/registry.js";
|
|
@@ -555,6 +556,7 @@ function handleGetTasks(res, ctx) {
|
|
|
555
556
|
for (const section of ["Active", "Queue", "Done"]) {
|
|
556
557
|
for (const item of doc.items[section]) {
|
|
557
558
|
tasks.push({
|
|
559
|
+
...taskView(ctx.phrenPath, doc, item),
|
|
558
560
|
project: doc.project, section: item.section, line: item.line, priority: item.priority,
|
|
559
561
|
pinned: item.pinned, githubIssue: item.githubIssue, githubUrl: item.githubUrl,
|
|
560
562
|
context: item.context, checked: item.checked, sessionId: item.sessionId,
|
|
@@ -890,7 +892,23 @@ function handlePostTaskUpdate(req, res, url, ctx) {
|
|
|
890
892
|
const item = String(parsed.item || "");
|
|
891
893
|
if (!project || !item || !isValidProjectName(project))
|
|
892
894
|
return jsonErr(res, "Missing or invalid project/item", 400);
|
|
895
|
+
const denied = permissionDeniedError(ctx.phrenPath, "update_task", project);
|
|
896
|
+
if (denied)
|
|
897
|
+
return jsonErr(res, denied, 403);
|
|
893
898
|
const updates = {};
|
|
899
|
+
if (parsed.responsibility !== undefined) {
|
|
900
|
+
if (parsed.responsibility !== "human" && parsed.responsibility !== "agent")
|
|
901
|
+
return jsonErr(res, "Responsibility must be human or agent", 400);
|
|
902
|
+
updates.responsibility = parsed.responsibility;
|
|
903
|
+
}
|
|
904
|
+
if (parsed.dependencies !== undefined) {
|
|
905
|
+
try {
|
|
906
|
+
updates.dependencies = JSON.parse(String(parsed.dependencies));
|
|
907
|
+
}
|
|
908
|
+
catch {
|
|
909
|
+
return jsonErr(res, "Dependencies must be a JSON array", 400);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
894
912
|
if (Object.prototype.hasOwnProperty.call(parsed, "text"))
|
|
895
913
|
updates.text = String(parsed.text || "");
|
|
896
914
|
if (Object.prototype.hasOwnProperty.call(parsed, "priority"))
|