dsh-tg-bridge 1.21.0 → 1.21.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.
- package/goals.mjs +19 -3
- package/package.json +1 -1
package/goals.mjs
CHANGED
|
@@ -68,8 +68,24 @@ export function addTask(state, key, text) {
|
|
|
68
68
|
if (!clean) return null;
|
|
69
69
|
const goal = goalOf(state, key);
|
|
70
70
|
if (!goal) return null;
|
|
71
|
-
|
|
71
|
+
// The cap is on WORK, not on history: a ticked task is a record of what was
|
|
72
|
+
// done, and counting it against the limit froze the list the moment a goal ran
|
|
73
|
+
// long — every new task was rejected in silence, so the checklist stopped
|
|
74
|
+
// matching the work. Ticked entries stay (their numbers stay valid); only the
|
|
75
|
+
// open ones are capped.
|
|
76
|
+
if (goal.tasks.filter((task) => !task.done).length >= MAX_TASKS) return null;
|
|
72
77
|
goal.tasks.push({ text: clean, done: false });
|
|
78
|
+
// Bound the history without touching the work: past 60 lines the oldest ticked
|
|
79
|
+
// entries go, so a goal that runs for months does not carry every closed task
|
|
80
|
+
// in every prompt. A trim renumbers the rest — the block is re-read each turn,
|
|
81
|
+
// so the numbers in front of the agent are always the current ones.
|
|
82
|
+
if (goal.tasks.length > MAX_TASKS * 2) {
|
|
83
|
+
let excess = goal.tasks.length - MAX_TASKS * 2;
|
|
84
|
+
goal.tasks = goal.tasks.filter((task) => {
|
|
85
|
+
if (excess > 0 && task.done) { excess -= 1; return false; }
|
|
86
|
+
return true;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
73
89
|
goal.updatedAt = new Date().toISOString();
|
|
74
90
|
return goal.tasks.length;
|
|
75
91
|
}
|
|
@@ -162,7 +178,7 @@ export function applyGoalJob(state, job) {
|
|
|
162
178
|
}
|
|
163
179
|
case 'add':
|
|
164
180
|
if (!goalOf(state, job.key)) setGoal(state, job.key, 'Tasks');
|
|
165
|
-
return addTask(state, job.key, job.text) ? 'task added' :
|
|
181
|
+
return addTask(state, job.key, job.text) ? 'task added' : `task rejected: ${MAX_TASKS} open`;
|
|
166
182
|
case 'done':
|
|
167
183
|
return doneTask(state, job.key, job.index) ? 'task done' : 'bad task number';
|
|
168
184
|
case 'remove':
|
|
@@ -199,7 +215,7 @@ export function drainGoalJobs(state, dir, doneDir) {
|
|
|
199
215
|
continue;
|
|
200
216
|
}
|
|
201
217
|
const status = applyGoalJob(state, job);
|
|
202
|
-
const ok = !status.startsWith('bad') && status !== 'no goal' && status !== 'empty goal' && status
|
|
218
|
+
const ok = !status.startsWith('bad') && status !== 'no goal' && status !== 'empty goal' && !status.startsWith('task rejected');
|
|
203
219
|
if (ok) applied += 1;
|
|
204
220
|
try {
|
|
205
221
|
renameSync(full, join(doneDir, `${ok ? '' : 'failed-'}${file}`));
|
package/package.json
CHANGED