@hienlh/ppm 0.26.29 → 0.26.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/CHANGELOG.md +6 -0
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/http-api.md +1 -1
- package/docs/architecture/ppm-assistant.md +10 -3
- package/package.json +1 -1
- package/src/services/assistant-cards/assistant-cards-db.ts +7 -0
- package/src/services/assistant-cards/manager-report-env.ts +15 -3
- package/src/services/assistant-cards/manager-report-tool.ts +55 -11
- package/src/shared/assistant-limits.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.26.30] - 2026-11-23
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **Manager chats are no longer cut off after 20 reports an hour**: every report reaches the PPM Assistant, and one repeating a card that is still open is folded into that card instead of filed again.
|
|
8
|
+
|
|
3
9
|
## [0.26.29] - 2026-11-23
|
|
4
10
|
|
|
5
11
|
### Fixed
|
|
@@ -83,4 +83,4 @@ This skill covers the `ppm` CLI, its HTTP API, and its config DB. It does **not*
|
|
|
83
83
|
- Third-party extensions (inspect via `ppm ext list`).
|
|
84
84
|
- The Claude Agent SDK internals (separate skill).
|
|
85
85
|
|
|
86
|
-
<!-- Generated for PPM v0.26.
|
|
86
|
+
<!-- Generated for PPM v0.26.30 at build time. Re-run `ppm export skill --install` to refresh. -->
|
|
@@ -899,4 +899,4 @@ Authenticate with `?token=<token>` (see Authentication).
|
|
|
899
899
|
- `/ws/android`
|
|
900
900
|
- `/ws/project/<project>/<type>/<id>` — `<type>`: `terminal`, `chat`, `group`, `lsp` (for `chat`, `<id>` is the session id)
|
|
901
901
|
|
|
902
|
-
<!-- Generated from src/server/routes/ for PPM v0.26.
|
|
902
|
+
<!-- Generated from src/server/routes/ for PPM v0.26.30 -->
|
|
@@ -1358,9 +1358,16 @@ in `assistant_cards` (migration 65) and announced on `/ws/global` as `assistant:
|
|
|
1358
1358
|
Telegram gets it through `markdownToTelegramHtml`, which escapes before it adds a tag. The title,
|
|
1359
1359
|
the draft and the rules diff stay plain text: a draft is what would be sent, character for
|
|
1360
1360
|
character. The manager is told to write bodies that way (short sections, bullets, bold, code).
|
|
1361
|
-
- **Caps.**
|
|
1362
|
-
|
|
1363
|
-
card
|
|
1361
|
+
- **Caps.** No limit on how many reports a manager files: an hourly cap (20) refused the 21st
|
|
1362
|
+
report outright, so a decision past it was lost, and real managers reached it while the user was
|
|
1363
|
+
answering every card. What stops a manager stuck in a loop is that a report identical to an open
|
|
1364
|
+
card of the same manager — kind, title, body, draft, options, images, compared as stored
|
|
1365
|
+
(`sameReport`) — is not filed again: the call returns that card's id with a note, and nothing is
|
|
1366
|
+
sent to Telegram twice. Once that card is answered, dismissed or resolved, the same report makes a
|
|
1367
|
+
new card. 2 urgent per manager per quiet window, after which an urgent report becomes a decision
|
|
1368
|
+
held for the morning; the same urgent title collapses into one card
|
|
1369
|
+
(`src/shared/assistant-limits.ts`). Each refused or merged report is logged at INFO with its kind,
|
|
1370
|
+
project, session and reason, never its text.
|
|
1364
1371
|
- **Answering.** `POST /api/assistant/cards/:id/answer` answers the exact request an approval or
|
|
1365
1372
|
question card mirrors, through `chatControl().answerApproval` with origin `assistant_card`; Allow
|
|
1366
1373
|
is refused when the card does not show everything that would run. A question card is answered with
|
package/package.json
CHANGED
|
@@ -241,6 +241,13 @@ export function findOpenUrgentTitled(sessionId: string, title: string, since: nu
|
|
|
241
241
|
return row ? toRow(row) : null;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
/** This manager's open cards of `kind` with exactly this title and body, newest first. */
|
|
245
|
+
export function findOpenSessionCardsWithText(sessionId: string, kind: AssistantCardKind, title: string, body: string): CardRow[] {
|
|
246
|
+
return (getDb().query(`SELECT ${COLUMNS} FROM assistant_cards
|
|
247
|
+
WHERE status = 'open' AND kind = ? AND session_id = ? AND title = ? AND body = ?
|
|
248
|
+
ORDER BY created_at DESC`).all(kind, sessionId, title, body) as Raw[]).map(toRow);
|
|
249
|
+
}
|
|
250
|
+
|
|
244
251
|
/** The open card mirroring `requestId` in a manager chat, if any. */
|
|
245
252
|
export function findOpenRequestCard(requestId: string): CardRow | null {
|
|
246
253
|
const row = getDb().query(`SELECT ${COLUMNS} FROM assistant_cards
|
|
@@ -8,8 +8,9 @@ import { assistantClock } from "../assistant-wake/assistant-clock.ts";
|
|
|
8
8
|
import { currentQuietWindowStart } from "../assistant-wake/wake-quiet-hours.ts";
|
|
9
9
|
import { textResult, type Json } from "../mcp-http-endpoint.ts";
|
|
10
10
|
import { assistantCards } from "./assistant-cards.service.ts";
|
|
11
|
-
import { countSessionCardsSince, findOpenUrgentTitled } from "./assistant-cards-db.ts";
|
|
12
|
-
import { DIGEST_NOT_ASKED, fileReport, type ReportEnv } from "./manager-report-tool.ts";
|
|
11
|
+
import { countSessionCardsSince, findOpenSessionCardsWithText, findOpenUrgentTitled } from "./assistant-cards-db.ts";
|
|
12
|
+
import { DIGEST_NOT_ASKED, fileReport, sameReport, type ReportEnv } from "./manager-report-tool.ts";
|
|
13
|
+
import { createLogger } from "../logger.ts";
|
|
13
14
|
import { readShotSync } from "../design/shots/design-shots.service.ts";
|
|
14
15
|
import { projectKey } from "../project-name-for-path.ts";
|
|
15
16
|
|
|
@@ -17,6 +18,7 @@ import { projectKey } from "../project-name-for-path.ts";
|
|
|
17
18
|
export const NOT_A_MANAGER = "Only a project's manager chat can report to PPM Assistant. Answer the user in this chat instead.";
|
|
18
19
|
|
|
19
20
|
type DigestAnswerHandler = ReportEnv["digestAnswer"];
|
|
21
|
+
const log = createLogger("assistant-cards");
|
|
20
22
|
|
|
21
23
|
const NO_DIGEST: DigestAnswerHandler = () => ({ ok: false, message: DIGEST_NOT_ASKED });
|
|
22
24
|
let digestAnswers: DigestAnswerHandler = NO_DIGEST;
|
|
@@ -33,6 +35,13 @@ export const reportEnv: ReportEnv = {
|
|
|
33
35
|
const row = findOpenUrgentTitled(sessionId, title, since);
|
|
34
36
|
return row ? assistantCards.toCard(row) : null;
|
|
35
37
|
},
|
|
38
|
+
openIdentical: (sessionId, card) => {
|
|
39
|
+
for (const row of findOpenSessionCardsWithText(sessionId, card.kind, card.title, card.body ?? "")) {
|
|
40
|
+
const open = assistantCards.toCard(row);
|
|
41
|
+
if (sameReport(open, card)) return open;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
},
|
|
36
45
|
shotOf: (id, projectPath) => {
|
|
37
46
|
const shot = readShotSync(id);
|
|
38
47
|
if (!shot || projectKey(shot.projectPath) !== projectKey(projectPath)) return null;
|
|
@@ -49,7 +58,10 @@ export const isReportingManager = (sessionId: string): boolean => managerChats.i
|
|
|
49
58
|
/** The tool call: refused unless the caller is a manager chat, checked against the live table. */
|
|
50
59
|
export function reportToAssistantCall(sessionId: string, args: unknown, env: ReportEnv = reportEnv): Json {
|
|
51
60
|
const row = managerChats.forSession(sessionId);
|
|
52
|
-
if (!row)
|
|
61
|
+
if (!row) {
|
|
62
|
+
log.info(`report from session ${sessionId} refused: not a manager chat`);
|
|
63
|
+
return textResult(NOT_A_MANAGER, true);
|
|
64
|
+
}
|
|
53
65
|
const result = fileReport(env, { sessionId: row.sessionId, projectName: row.projectName, projectPath: row.projectPath }, args);
|
|
54
66
|
if (!result.ok) return textResult(result.message, true);
|
|
55
67
|
return textResult(JSON.stringify({
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
REPORT_KINDS, type AssistantCard, type AssistantCardKind, type CardDraft, type CardImage, type CardOption, type ReportKind,
|
|
6
6
|
} from "../../shared/assistant-cards.ts";
|
|
7
7
|
import { REPORT_TO_ASSISTANT_TOOL } from "../../shared/session-collab.ts";
|
|
8
|
-
import {
|
|
8
|
+
import { URGENT_PER_MANAGER_PER_QUIET_WINDOW } from "../../shared/assistant-limits.ts";
|
|
9
9
|
import { neutralizePpmTags } from "../assistant-watch/watch-event-text.ts";
|
|
10
10
|
import { cleanCardBody, cleanCardTitle, cleanOptionLabel } from "./card-text-cleaning.ts";
|
|
11
11
|
import { listsChoicesInText } from "./card-choices-in-text.ts";
|
|
@@ -22,6 +22,10 @@ import type { NewCard } from "./assistant-cards.service.ts";
|
|
|
22
22
|
* A subagent of the manager reaches the same endpoint with the same token, and an MCP call carries
|
|
23
23
|
* nothing that ties it to the tool call the CLI made, so PPM cannot tell the two apart: the manager
|
|
24
24
|
* rules tell the manager not to take a child's word for anything.
|
|
25
|
+
*
|
|
26
|
+
* There is no cap on how many reports a manager files: a decision refused for being one too many
|
|
27
|
+
* was simply lost. What stops a manager stuck in a loop is that a report identical to one still open
|
|
28
|
+
* (kind, title, body and everything attached) is not filed again: the call gets that card back.
|
|
25
29
|
*/
|
|
26
30
|
|
|
27
31
|
export const REPORT_TITLE_MAX = 120;
|
|
@@ -56,6 +60,8 @@ export interface ReportEnv {
|
|
|
56
60
|
countSince(sessionId: string, kinds: readonly AssistantCardKind[], since: number): number;
|
|
57
61
|
/** An open urgent card of this manager with this exact title since `since`, if any. */
|
|
58
62
|
openUrgentTitled(sessionId: string, title: string, since: number): AssistantCard | null;
|
|
63
|
+
/** An open card of this manager that is the same report as `card` ({@link sameReport}), if any. */
|
|
64
|
+
openIdentical(sessionId: string, card: NewCard): AssistantCard | null;
|
|
59
65
|
/**
|
|
60
66
|
* A design screenshot of this project, by id; null when it is not one (unknown, too old, or of
|
|
61
67
|
* another project). Absent where no screenshots exist.
|
|
@@ -76,9 +82,37 @@ export type ReportResult = { ok: true; cardId?: string; kind: AssistantCardKind;
|
|
|
76
82
|
|
|
77
83
|
export const DIGEST_TAKEN = "Your answer is in the morning digest PPM is putting together. A second digest answer replaces this one.";
|
|
78
84
|
export const DIGEST_NOT_ASKED = "No morning digest was asked of this chat; use done, failed, needs_decision or urgent.";
|
|
85
|
+
/** Told to a manager whose report is word for word one still open on the user's card. */
|
|
86
|
+
export const SAME_REPORT_NOTE = "The same report is already on the user's card, still open; it was not filed again.";
|
|
79
87
|
export const DIGEST_CLOSED = "The morning digest was already put together. Report this as done or needs_decision instead.";
|
|
80
88
|
|
|
81
89
|
const isObj = (v: unknown): v is Record<string, unknown> => !!v && typeof v === "object" && !Array.isArray(v);
|
|
90
|
+
|
|
91
|
+
type ReportShape = Pick<NewCard, "kind" | "title" | "body" | "payload">;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Whether two cards are the same report: kind, title, body and what the manager attached (draft,
|
|
95
|
+
* choices, pictures), compared as stored. PPM's own additions to the payload do not count.
|
|
96
|
+
*/
|
|
97
|
+
export function sameReport(a: ReportShape, b: ReportShape): boolean {
|
|
98
|
+
const key = (c: ReportShape) => {
|
|
99
|
+
const p = c.payload ?? {};
|
|
100
|
+
return JSON.stringify([c.kind, c.title, c.body ?? "", p.draft ?? null, p.options ?? null, p.images ?? null, p.urgentCapped === true]);
|
|
101
|
+
};
|
|
102
|
+
return key(a) === key(b);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** A refused call, logged with its kind and reason only: the report's words stay out of the log. */
|
|
106
|
+
function refuse(caller: ReportCaller, requested: unknown, reason: string, message: string): ReportResult {
|
|
107
|
+
const kind = REPORT_KINDS.includes(requested as ReportKind) ? requested : "unknown";
|
|
108
|
+
log.info(`report ${kind} from ${caller.projectName} (session ${caller.sessionId}) refused: ${reason}`);
|
|
109
|
+
return { ok: false, message };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function logMerged(caller: ReportCaller, kind: AssistantCardKind, cardId: string): void {
|
|
113
|
+
log.info(`report ${kind} from ${caller.projectName} (session ${caller.sessionId}) is the same as open card ${cardId}: not filed again`);
|
|
114
|
+
}
|
|
115
|
+
|
|
82
116
|
const draftOnly = (text: string): string => neutralizePpmTags(neutralizeBlockMarkers(text));
|
|
83
117
|
|
|
84
118
|
/** sha256(to + "\n" + text): what the user's OK names, and what the manager must then send unchanged. */
|
|
@@ -164,16 +198,13 @@ function cleanOptions(raw: unknown[]): CardOption[] {
|
|
|
164
198
|
export function fileReport(env: ReportEnv, caller: ReportCaller, raw: unknown): ReportResult {
|
|
165
199
|
const args = isObj(raw) ? raw : {};
|
|
166
200
|
const invalid = fieldError(args);
|
|
167
|
-
if (invalid) return
|
|
201
|
+
if (invalid) return refuse(caller, args.kind, "invalid fields", invalid);
|
|
168
202
|
const now = env.now();
|
|
169
203
|
const requested = args.kind as ReportKind;
|
|
170
204
|
if (requested === "digest") {
|
|
171
205
|
const items = Array.isArray(args.items) ? (args.items as string[]).map((i) => cleanCardBody(i, DIGEST_ITEM_MAX)).filter(Boolean) : [];
|
|
172
206
|
const taken = env.digestAnswer(caller.sessionId, items);
|
|
173
|
-
return taken.ok ? { ok: true, kind: "digest", note: DIGEST_TAKEN } : taken;
|
|
174
|
-
}
|
|
175
|
-
if (env.countSince(caller.sessionId, REPORT_KINDS, now - HOUR_MS) >= REPORTS_PER_MANAGER_PER_HOUR) {
|
|
176
|
-
return { ok: false, message: `This chat filed ${REPORTS_PER_MANAGER_PER_HOUR} reports in the last hour; wait, or put several things in one report.` };
|
|
207
|
+
return taken.ok ? { ok: true, kind: "digest", note: DIGEST_TAKEN } : refuse(caller, "digest", "digest not taken", taken.message);
|
|
177
208
|
}
|
|
178
209
|
|
|
179
210
|
const title = cleanCardTitle(args.title);
|
|
@@ -183,7 +214,10 @@ export function fileReport(env: ReportEnv, caller: ReportCaller, raw: unknown):
|
|
|
183
214
|
const windowStart = env.quietWindowStart();
|
|
184
215
|
// The same urgent thing said twice is one card: within the quiet window, or the last hour.
|
|
185
216
|
const same = env.openUrgentTitled(caller.sessionId, title, windowStart ?? now - HOUR_MS);
|
|
186
|
-
if (same)
|
|
217
|
+
if (same) {
|
|
218
|
+
logMerged(caller, "urgent", same.id);
|
|
219
|
+
return { ok: true, cardId: same.id, kind: "urgent", note: "The same urgent report is already on the user's card." };
|
|
220
|
+
}
|
|
187
221
|
if (windowStart !== null && env.countSince(caller.sessionId, ["urgent"], windowStart) >= URGENT_PER_MANAGER_PER_QUIET_WINDOW) {
|
|
188
222
|
kind = "needs_decision";
|
|
189
223
|
note = "Quiet hours: this chat already raised its urgent reports for tonight, so this one waits as a decision for the morning.";
|
|
@@ -196,7 +230,8 @@ export function fileReport(env: ReportEnv, caller: ReportCaller, raw: unknown):
|
|
|
196
230
|
for (const id of new Set(args.images as string[])) {
|
|
197
231
|
const shot = env.shotOf?.(id, caller.projectPath) ?? null;
|
|
198
232
|
if (!shot) {
|
|
199
|
-
return
|
|
233
|
+
return refuse(caller, requested, "not a screenshot of this project",
|
|
234
|
+
`"${id.slice(0, 40)}" is not a screenshot of this project's designs (they last seven days); take one with design_screenshot.`);
|
|
200
235
|
}
|
|
201
236
|
images.push(shot);
|
|
202
237
|
}
|
|
@@ -216,7 +251,7 @@ export function fileReport(env: ReportEnv, caller: ReportCaller, raw: unknown):
|
|
|
216
251
|
const choicesInText = !options && (kind === "needs_decision" || kind === "urgent")
|
|
217
252
|
&& listsChoicesInText(`${typeof args.title === "string" ? args.title : ""}
|
|
218
253
|
${typeof args.body === "string" ? args.body : ""}`);
|
|
219
|
-
const
|
|
254
|
+
const newCard: NewCard = {
|
|
220
255
|
kind,
|
|
221
256
|
projectName: caller.projectName,
|
|
222
257
|
projectPath: caller.projectPath,
|
|
@@ -231,7 +266,14 @@ ${typeof args.body === "string" ? args.body : ""}`);
|
|
|
231
266
|
},
|
|
232
267
|
// A decision only waits for the user's answer; news wakes the Assistant.
|
|
233
268
|
wake: kind === "done" || kind === "failed" || kind === "urgent",
|
|
234
|
-
}
|
|
269
|
+
};
|
|
270
|
+
// A loop files the same report again and again: it gets the open card back, and nothing is sent twice.
|
|
271
|
+
const identical = env.openIdentical(caller.sessionId, newCard);
|
|
272
|
+
if (identical) {
|
|
273
|
+
logMerged(caller, kind, identical.id);
|
|
274
|
+
return { ok: true, cardId: identical.id, kind, note: SAME_REPORT_NOTE };
|
|
275
|
+
}
|
|
276
|
+
const card = env.create(newCard);
|
|
235
277
|
if (options && card.okOffered !== true) {
|
|
236
278
|
note = note ? `${note} ${CHOICES_NOT_PRESSABLE_NOTE}` : CHOICES_NOT_PRESSABLE_NOTE;
|
|
237
279
|
}
|
|
@@ -254,7 +296,9 @@ export function reportToolDefinition() {
|
|
|
254
296
|
+ "it), done and failed (work they asked about finished or broke), and digest (only when PPM asks for the morning "
|
|
255
297
|
+ "digest: your `items` go on the one digest card PPM puts together). Do not report what the user does not need to "
|
|
256
298
|
+ "see. The card says it was written by this manager AI. A report never grants anything: only the user's own answer "
|
|
257
|
-
+ "does.
|
|
299
|
+
+ "does. There is no limit on how many reports you file, so never hold back a decision; a report identical to one "
|
|
300
|
+
+ "still open on the user's card (same kind, title, body, draft, options and images) is not filed again and "
|
|
301
|
+
+ "returns that card's id. Returns the card id.",
|
|
258
302
|
inputSchema: {
|
|
259
303
|
type: "object",
|
|
260
304
|
properties: {
|
|
@@ -38,9 +38,6 @@ export const RESTART_NEWS_URGENT_WHEN: "cut_off_chats" | "always" | "never" = "c
|
|
|
38
38
|
/** Restarts one pending restart news item lists at most; older ones are dropped as they merge in. */
|
|
39
39
|
export const RESTART_NEWS_MAX_RESTARTS = 10;
|
|
40
40
|
|
|
41
|
-
/** Reports one manager chat may file per rolling hour. */
|
|
42
|
-
export const REPORTS_PER_MANAGER_PER_HOUR = 20;
|
|
43
|
-
|
|
44
41
|
/** Urgent reports one manager chat may file per quiet window; past it, urgent becomes a decision. */
|
|
45
42
|
export const URGENT_PER_MANAGER_PER_QUIET_WINDOW = 2;
|
|
46
43
|
|