@sireai/optimus 0.1.40 → 0.1.43

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 (85) hide show
  1. package/dist/cli/optimus.js +425 -58
  2. package/dist/cli/optimus.js.map +1 -1
  3. package/dist/config/load-config.js +8 -1
  4. package/dist/config/load-config.js.map +1 -1
  5. package/dist/integrations/feishu/feishu-doc-service.d.ts +14 -2
  6. package/dist/integrations/feishu/feishu-doc-service.js +33 -12
  7. package/dist/integrations/feishu/feishu-doc-service.js.map +1 -1
  8. package/dist/integrations/feishu/feishu-document-reader.d.ts +33 -0
  9. package/dist/integrations/feishu/feishu-document-reader.js +597 -0
  10. package/dist/integrations/feishu/feishu-document-reader.js.map +1 -0
  11. package/dist/integrations/jira/jira-access-manager.d.ts +1 -0
  12. package/dist/integrations/jira/jira-access-manager.js +24 -0
  13. package/dist/integrations/jira/jira-access-manager.js.map +1 -1
  14. package/dist/integrations/jira/jira-cli.js +19 -3
  15. package/dist/integrations/jira/jira-cli.js.map +1 -1
  16. package/dist/integrations/jira/jira-submit.js +5 -18
  17. package/dist/integrations/jira/jira-submit.js.map +1 -1
  18. package/dist/integrations/sentry/sentry-cli.js +18 -2
  19. package/dist/integrations/sentry/sentry-cli.js.map +1 -1
  20. package/dist/problem-solving-core/codex/codex-runner.d.ts +2 -0
  21. package/dist/problem-solving-core/codex/codex-runner.js +46 -36
  22. package/dist/problem-solving-core/codex/codex-runner.js.map +1 -1
  23. package/dist/task-environment/delivery/delivery-warning-copy.d.ts +2 -0
  24. package/dist/task-environment/delivery/delivery-warning-copy.js +24 -0
  25. package/dist/task-environment/delivery/delivery-warning-copy.js.map +1 -0
  26. package/dist/task-environment/delivery/feishu-analysis-doc-service.d.ts +32 -1
  27. package/dist/task-environment/delivery/feishu-analysis-doc-service.js +351 -7
  28. package/dist/task-environment/delivery/feishu-analysis-doc-service.js.map +1 -1
  29. package/dist/task-environment/delivery/feishu-card-primitives.d.ts +33 -0
  30. package/dist/task-environment/delivery/feishu-card-primitives.js +95 -0
  31. package/dist/task-environment/delivery/feishu-card-primitives.js.map +1 -0
  32. package/dist/task-environment/delivery/feishu-card-renderer.d.ts +1 -0
  33. package/dist/task-environment/delivery/feishu-card-renderer.js +38 -73
  34. package/dist/task-environment/delivery/feishu-card-renderer.js.map +1 -1
  35. package/dist/task-environment/delivery/feishu-content/feishu-copy-config.js +1 -0
  36. package/dist/task-environment/delivery/feishu-content/feishu-copy-config.js.map +1 -1
  37. package/dist/task-environment/delivery/feishu-notifier.d.ts +5 -0
  38. package/dist/task-environment/delivery/feishu-notifier.js +107 -38
  39. package/dist/task-environment/delivery/feishu-notifier.js.map +1 -1
  40. package/dist/task-environment/delivery/feishu-templates/analysis-message-template.js +3 -0
  41. package/dist/task-environment/delivery/feishu-templates/analysis-message-template.js.map +1 -1
  42. package/dist/task-environment/delivery/pm-feishu-card-renderer.d.ts +19 -0
  43. package/dist/task-environment/delivery/pm-feishu-card-renderer.js +177 -0
  44. package/dist/task-environment/delivery/pm-feishu-card-renderer.js.map +1 -0
  45. package/dist/task-environment/delivery/sentry-feishu-card-renderer.d.ts +1 -0
  46. package/dist/task-environment/delivery/sentry-feishu-card-renderer.js +33 -70
  47. package/dist/task-environment/delivery/sentry-feishu-card-renderer.js.map +1 -1
  48. package/dist/task-environment/delivery/task-delivery-service.d.ts +6 -1
  49. package/dist/task-environment/delivery/task-delivery-service.js +142 -10
  50. package/dist/task-environment/delivery/task-delivery-service.js.map +1 -1
  51. package/dist/task-environment/delivery/task-publication-service.d.ts +1 -0
  52. package/dist/task-environment/delivery/task-publication-service.js +22 -0
  53. package/dist/task-environment/delivery/task-publication-service.js.map +1 -1
  54. package/dist/task-environment/intake/manual-problem-intake.js +54 -0
  55. package/dist/task-environment/intake/manual-problem-intake.js.map +1 -1
  56. package/dist/task-environment/orchestration/execution-context-assembler.d.ts +1 -0
  57. package/dist/task-environment/orchestration/execution-context-assembler.js +58 -3
  58. package/dist/task-environment/orchestration/execution-context-assembler.js.map +1 -1
  59. package/dist/task-environment/orchestration/task-orchestrator.d.ts +1 -0
  60. package/dist/task-environment/orchestration/task-orchestrator.js +41 -5
  61. package/dist/task-environment/orchestration/task-orchestrator.js.map +1 -1
  62. package/dist/task-environment/orchestration/task-package-inputs.d.ts +2 -0
  63. package/dist/task-environment/orchestration/task-package-inputs.js +83 -0
  64. package/dist/task-environment/orchestration/task-package-inputs.js.map +1 -0
  65. package/dist/task-environment/orchestration/task-runtime-policy.d.ts +4 -0
  66. package/dist/task-environment/orchestration/task-runtime-policy.js +38 -0
  67. package/dist/task-environment/orchestration/task-runtime-policy.js.map +1 -0
  68. package/dist/task-environment/result-paths.d.ts +9 -0
  69. package/dist/task-environment/result-paths.js +36 -0
  70. package/dist/task-environment/result-paths.js.map +1 -0
  71. package/dist/types.d.ts +45 -1
  72. package/package.json +1 -1
  73. package/task-harnesses/bugfix/ACCEPT.md +3 -2
  74. package/task-harnesses/bugfix/CONSTRAINTS.md +10 -4
  75. package/task-harnesses/bugfix/EVOLUTION.md +2 -8
  76. package/task-harnesses/bugfix/ROLE.md +7 -11
  77. package/task-harnesses/bugfix/STANDARD.md +81 -0
  78. package/task-harnesses/pm/ACCEPT.md +66 -0
  79. package/task-harnesses/pm/CONSTRAINTS.md +60 -0
  80. package/task-harnesses/pm/CONTEXT.md +50 -0
  81. package/task-harnesses/pm/EVOLUTION.md +77 -0
  82. package/task-harnesses/pm/ROLE.md +44 -0
  83. package/task-harnesses/pm/STANDARD.md +483 -0
  84. package/task-harnesses/pm/manifest.json +13 -0
  85. package/task-harnesses/registry.json +4 -0
@@ -0,0 +1,38 @@
1
+ const TASK_RUNTIME_POLICIES = {
2
+ bugfix: {
3
+ taskType: "bugfix",
4
+ executionBinding: "repo_bound",
5
+ artifactContract: "patch_result",
6
+ requiresRepository: true,
7
+ requiresRepoMemory: true,
8
+ supportsPublication: true,
9
+ supportsPatchArtifact: true,
10
+ primaryResultFile: "result.md",
11
+ expectedPrimaryArtifacts: ["result.md", "patch.diff"]
12
+ },
13
+ pm: {
14
+ taskType: "pm",
15
+ executionBinding: "artifact_only",
16
+ artifactContract: "prototype_result",
17
+ requiresRepository: false,
18
+ requiresRepoMemory: false,
19
+ supportsPublication: false,
20
+ supportsPatchArtifact: false,
21
+ primaryResultFile: "result.md",
22
+ expectedPrimaryArtifacts: ["result.md"]
23
+ }
24
+ };
25
+ export function getTaskRuntimePolicy(taskType) {
26
+ const policy = TASK_RUNTIME_POLICIES[taskType];
27
+ if (!policy) {
28
+ throw new Error(`No runtime policy registered for taskType ${taskType}.`);
29
+ }
30
+ return policy;
31
+ }
32
+ export function taskRequiresRepository(taskType) {
33
+ return getTaskRuntimePolicy(taskType).requiresRepository;
34
+ }
35
+ export function taskSupportsPublication(taskType) {
36
+ return getTaskRuntimePolicy(taskType).supportsPublication;
37
+ }
38
+ //# sourceMappingURL=task-runtime-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-runtime-policy.js","sourceRoot":"","sources":["../../../src/task-environment/orchestration/task-runtime-policy.ts"],"names":[],"mappings":"AAEA,MAAM,qBAAqB,GAAsC;IAC/D,MAAM,EAAE;QACN,QAAQ,EAAE,QAAQ;QAClB,gBAAgB,EAAE,YAAY;QAC9B,gBAAgB,EAAE,cAAc;QAChC,kBAAkB,EAAE,IAAI;QACxB,kBAAkB,EAAE,IAAI;QACxB,mBAAmB,EAAE,IAAI;QACzB,qBAAqB,EAAE,IAAI;QAC3B,iBAAiB,EAAE,WAAW;QAC9B,wBAAwB,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC;KACtD;IACD,EAAE,EAAE;QACF,QAAQ,EAAE,IAAI;QACd,gBAAgB,EAAE,eAAe;QACjC,gBAAgB,EAAE,kBAAkB;QACpC,kBAAkB,EAAE,KAAK;QACzB,kBAAkB,EAAE,KAAK;QACzB,mBAAmB,EAAE,KAAK;QAC1B,qBAAqB,EAAE,KAAK;QAC5B,iBAAiB,EAAE,WAAW;QAC9B,wBAAwB,EAAE,CAAC,WAAW,CAAC;KACxC;CACF,CAAC;AAEF,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,MAAM,MAAM,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,6CAA6C,QAAQ,GAAG,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,QAAgB;IACrD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,CAAC,kBAAkB,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,QAAgB;IACtD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,CAAC,mBAAmB,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,9 @@
1
+ interface ResultPathResolutionContext {
2
+ taskRootDir: string;
3
+ addresses: {
4
+ artifactDir: string;
5
+ workspaceDir: string;
6
+ };
7
+ }
8
+ export declare function resolveTaskResultPath(resultPath: string, context: ResultPathResolutionContext): string;
9
+ export {};
@@ -0,0 +1,36 @@
1
+ import { resolve, relative, sep } from "node:path";
2
+ function normalizePathLike(value) {
3
+ return value.replaceAll("\\", "/").replace(/^\.\/+/u, "").replace(/\/+/gu, "/").replace(/\/$/u, "");
4
+ }
5
+ function isWithinBaseDir(baseDir, targetPath) {
6
+ const relativePath = relative(resolve(baseDir), resolve(targetPath));
7
+ return relativePath === ""
8
+ || (!relativePath.startsWith(`..${sep}`) && relativePath !== "..");
9
+ }
10
+ function startsWithPathPrefix(candidatePath, prefixPath) {
11
+ const normalizedCandidate = normalizePathLike(candidatePath);
12
+ const normalizedPrefix = normalizePathLike(prefixPath);
13
+ return normalizedCandidate === normalizedPrefix
14
+ || normalizedCandidate.startsWith(`${normalizedPrefix}/`);
15
+ }
16
+ export function resolveTaskResultPath(resultPath, context) {
17
+ const trimmedResultPath = resultPath.trim();
18
+ if (trimmedResultPath.startsWith("/")) {
19
+ return resolve(trimmedResultPath);
20
+ }
21
+ const artifactDir = resolve(context.addresses.artifactDir);
22
+ const taskRootDir = resolve(context.taskRootDir);
23
+ const workspaceDir = resolve(context.addresses.workspaceDir);
24
+ const candidates = [];
25
+ for (const baseDir of [taskRootDir, workspaceDir]) {
26
+ const artifactPathFromBase = relative(baseDir, artifactDir);
27
+ if (artifactPathFromBase.length > 0
28
+ && isWithinBaseDir(baseDir, artifactDir)
29
+ && startsWithPathPrefix(trimmedResultPath, artifactPathFromBase)) {
30
+ candidates.push(resolve(baseDir, trimmedResultPath));
31
+ }
32
+ }
33
+ candidates.push(resolve(artifactDir, trimmedResultPath));
34
+ return candidates[0] ?? resolve(artifactDir, trimmedResultPath);
35
+ }
36
+ //# sourceMappingURL=result-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result-paths.js","sourceRoot":"","sources":["../../src/task-environment/result-paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAUnD,SAAS,iBAAiB,CAAC,KAAa;IACtC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACtG,CAAC;AAED,SAAS,eAAe,CAAC,OAAe,EAAE,UAAkB;IAC1D,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IACrE,OAAO,YAAY,KAAK,EAAE;WACrB,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC,IAAI,YAAY,KAAK,IAAI,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,oBAAoB,CAAC,aAAqB,EAAE,UAAkB;IACrE,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAC7D,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACvD,OAAO,mBAAmB,KAAK,gBAAgB;WAC1C,mBAAmB,CAAC,UAAU,CAAC,GAAG,gBAAgB,GAAG,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,UAAkB,EAClB,OAAoC;IAEpC,MAAM,iBAAiB,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;IAC5C,IAAI,iBAAiB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACtC,OAAO,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3D,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACjD,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAC7D,MAAM,UAAU,GAAa,EAAE,CAAC;IAEhC,KAAK,MAAM,OAAO,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,EAAE,CAAC;QAClD,MAAM,oBAAoB,GAAG,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC5D,IACE,oBAAoB,CAAC,MAAM,GAAG,CAAC;eAC5B,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC;eACrC,oBAAoB,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,EAChE,CAAC;YACD,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEzD,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;AAClE,CAAC"}
package/dist/types.d.ts CHANGED
@@ -106,6 +106,28 @@ export interface RuntimeEventContent {
106
106
  branch?: string;
107
107
  metadata?: Record<string, unknown>;
108
108
  }
109
+ export interface TaskInputReferenceMaterial {
110
+ type: "doc" | "image" | "link" | "note" | "whiteboard" | "sheet" | "bitable" | "file";
111
+ title: string;
112
+ content?: string;
113
+ url?: string;
114
+ token?: string;
115
+ mimeType?: string;
116
+ sourceType?: string;
117
+ }
118
+ export type PmTaskInputReferenceMaterial = TaskInputReferenceMaterial;
119
+ export interface PmTaskInput {
120
+ requirementDocument: string;
121
+ productGoal?: string;
122
+ targetUser?: string;
123
+ coreFlow?: string;
124
+ prototypeScope?: string;
125
+ platform?: "web" | "mobile_web" | "ios" | "android" | "desktop" | "responsive";
126
+ constraints?: string[];
127
+ referenceMaterials?: TaskInputReferenceMaterial[];
128
+ styleDirection?: string;
129
+ changeNotes?: string;
130
+ }
109
131
  export interface FeishuAssigneeIdentity {
110
132
  displayName?: string;
111
133
  login?: string;
@@ -123,6 +145,19 @@ export interface PollingCheckpoint {
123
145
  skippedCount?: number;
124
146
  }
125
147
  export type RepositoryExecutionMode = "copy" | "inplace";
148
+ export type TaskExecutionBinding = "repo_bound" | "artifact_only";
149
+ export type TaskArtifactContract = "patch_result" | "prototype_result" | "analysis_result";
150
+ export interface TaskRuntimePolicy {
151
+ taskType: string;
152
+ executionBinding: TaskExecutionBinding;
153
+ artifactContract: TaskArtifactContract;
154
+ requiresRepository: boolean;
155
+ requiresRepoMemory: boolean;
156
+ supportsPublication: boolean;
157
+ supportsPatchArtifact: boolean;
158
+ primaryResultFile: string;
159
+ expectedPrimaryArtifacts: string[];
160
+ }
126
161
  export interface RepositoryRoot {
127
162
  path: string;
128
163
  alias?: string;
@@ -205,7 +240,7 @@ export interface TriageDecisionRejected {
205
240
  missingInfo?: string[];
206
241
  }
207
242
  export type TriageDecision = TriageDecisionAccepted | TriageDecisionRejected;
208
- export type TaskArtifactKind = "result_md" | "patch_diff" | "publication_plan" | "verification" | "review_packet" | "log" | "attachment";
243
+ export type TaskArtifactKind = "result_md" | "patch_diff" | "prototype_html" | "publication_plan" | "verification" | "review_packet" | "log" | "attachment";
209
244
  export interface TaskArtifact {
210
245
  kind?: TaskArtifactKind;
211
246
  path: string;
@@ -298,6 +333,8 @@ export interface TaskDeliveryBundle {
298
333
  keyEvidence?: string;
299
334
  recommendedAction?: string;
300
335
  analysisDocUrl?: string;
336
+ prototypePreviewUrl?: string;
337
+ prototypeDownloadUrl?: string;
301
338
  risk?: string;
302
339
  nextAction?: string;
303
340
  };
@@ -305,6 +342,7 @@ export interface TaskDeliveryBundle {
305
342
  artifacts: {
306
343
  resultMd?: string;
307
344
  patchDiff?: string;
345
+ prototypeHtml?: string;
308
346
  extras: string[];
309
347
  };
310
348
  publication?: TaskPublicationStatus;
@@ -549,6 +587,7 @@ export interface RepositoryGuidanceContext {
549
587
  }
550
588
  export interface TaskExecutionContext {
551
589
  taskRootDir: string;
590
+ runtimePolicy: TaskRuntimePolicy;
552
591
  addresses: import("./task-environment/execution-addresses.js").ExecutionAddresses;
553
592
  sandboxMode: CodexSandboxMode;
554
593
  approvalPolicy: CodexApprovalPolicy;
@@ -669,6 +708,11 @@ export interface OptimusConfig {
669
708
  webhook?: string;
670
709
  webhooks?: string[];
671
710
  secret?: string;
711
+ defaultRecipient?: {
712
+ displayName?: string;
713
+ email?: string;
714
+ openId?: string;
715
+ };
672
716
  userMappings?: Record<string, {
673
717
  openId: string;
674
718
  displayName?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sireai/optimus",
3
- "version": "0.1.40",
3
+ "version": "0.1.43",
4
4
  "description": "Optimus Codex-native background task runtime and harness scaffolding.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -2,9 +2,10 @@
2
2
 
3
3
  ## Decision target
4
4
  Route real software defect tasks into the `bugfix` harness.
5
- Triage must decide:
5
+ Triage decides only:
6
6
  1. task type fit
7
7
  2. execution admission
8
+
8
9
  The runner, not triage, decides whether final closure is fix or analysis.
9
10
 
10
11
  ## Task type fit
@@ -29,7 +30,7 @@ Accept into execution only when all are true:
29
30
  - named page, feature, module, or flow
30
31
 
31
32
  ## Still acceptable with partial information
32
- Still acceptable when:
33
+ Accept when:
33
34
  - root cause is unknown
34
35
  - reproduction is incomplete
35
36
  - logs, stack traces, screenshots, or tests are missing
@@ -8,7 +8,7 @@
8
8
  - If available evidence contains any file whose basename includes `hprof`, do not skip heap-dump analysis before concluding a memory leak.
9
9
  - Do not prefer screenshot-only or description-only leak reasoning over available HPROF evidence.
10
10
 
11
- ## Patch rules
11
+ ## Patch safety
12
12
  - Change code only after reasoning through module boundaries, call chains, state flow, and upstream/downstream impact.
13
13
  - Do not modify code that is not directly relevant to the reported problem. If wider edits are required, keep a direct causal link to the fix.
14
14
  - Prefer clear, robust, maintainable fixes. Avoid brute-force guards, broad fallbacks, excessive branching, or temporary-looking patches when a cleaner repair is available.
@@ -17,8 +17,13 @@
17
17
  - Important code changes must include useful comments about intent, key decisions, boundary handling, or risk. Do not add comments that only restate obvious behavior.
18
18
  - If code changed, describe what changed, why, affected scope, and validation.
19
19
  - If code did not change, explain why patching is not yet justified.
20
- - Before generating or delivering a patch, self-review the actual diff for regressions, boundary issues, compatibility risk, and unnecessary changes. Fix findings first.
21
- - Before delivery, self-review for new errors, regressions, boundary issues, compatibility issues, and obvious code smell. Fix newly introduced problems before closing.
20
+ - Before delivery, self-review the actual diff for regressions, boundary issues, compatibility risk, unnecessary change, and obvious code smell. Fix findings first.
21
+ - Builder self-review is not a substitute for an explicit reviewer subagent when the review loop is required by the standard.
22
+ - Do not let a patch pass independent review if it deepens, spreads, or hides a known pre-existing issue, even when that issue was not introduced by the current task.
23
+ - Do not widen a patch only to chase elegance or theoretical perfection when a lower-risk credible repair already exists.
24
+ - If every repair path has tradeoffs, prefer the one with smaller blast radius, lower regression probability, and easier rollback.
25
+ - Do not treat reviewer suggestions as mandatory code changes when following them would enlarge scope, reduce validation confidence, or make rollback meaningfully harder.
26
+ - Do not keep revising only to satisfy successive reviewer findings if the patch is becoming broader, more coupled, or less testable than the current best candidate.
22
27
 
23
28
  ## Memory rules
24
29
  - Before solving a repo task, load repo memory for the current task type and repository. If missing, create a minimal reusable memory first, then continue.
@@ -33,7 +38,7 @@
33
38
  - If repo memory conflicts with current repository facts, commands, or validation evidence, trust current evidence and update the memory before finishing.
34
39
 
35
40
  ## Stop conditions
36
- Stop automatic patching and close as analysis if any are true:
41
+ Close as analysis instead of auto-patching if any are true:
37
42
  - no credible root-cause judgment can be formed
38
43
  - input is too incomplete to define a stable change target
39
44
  - required environment, account, device, repository, or external access is missing
@@ -49,3 +54,4 @@ Stop automatic patching and close as analysis if any are true:
49
54
  - expanding problem definition or change scope without evidence
50
55
  - conclusion-only output without supporting evidence
51
56
  - skipping self-review before delivering code changes
57
+ - turning a contained fix into a broader rewrite just to remove every residual reviewer concern
@@ -4,13 +4,7 @@
4
4
  Reflect only to improve future `bugfix` tasks. Do not summarize the current case for its own sake.
5
5
 
6
6
  Focus on reusable experience that improves speed, accuracy, stability, or token cost.
7
-
8
- Highest-value targets:
9
- - shortcuts discovered only after repeated trial and error
10
- - signals that can reduce search cost earlier
11
- - lower-cost validation paths that should have been tried first
12
- - project-specific but reusable bugfix workflows
13
- - repeated dead ends future tasks should avoid
7
+ - Highest-value gains: shorter search paths, stronger earlier signals, cheaper validation choices, reusable repo workflows, repeated dead-end avoidance.
14
8
 
15
9
  ## When to reflect
16
10
  Reflect only after the main task reaches a normal closure.
@@ -51,7 +45,7 @@ Create or update a skill only when all of the following are true:
51
45
  Prefer no skill change over weak skill change. Do not create or update a skill merely because reflection was requested.
52
46
 
53
47
  ## Good candidates
54
- Strong candidates include:
48
+ Strong candidates:
55
49
  - a better entry point discovered after reading many irrelevant files
56
50
  - a shorter call-chain inspection order discovered after multiple false starts
57
51
  - a cheaper validation path discovered after expensive but low-yield validation
@@ -3,23 +3,19 @@
3
3
  ## Identity
4
4
  You are a `Bugfix Engineer` executing an already accepted `bugfix` task inside a real engineering repository.
5
5
 
6
- ## Ownership
7
- - Drive the current defect to a trustworthy closure.
8
- - Stay focused on the defect, the target repository, and the current task package.
9
- - Produce a result that runtime can manage, humans can review, and downstream workflow can consume.
6
+ ## Core responsibility
7
+ - drive one accepted defect to a trustworthy closure
8
+ - stay anchored to the defect, repository facts, and current task package
9
+ - produce a result runtime can consume and humans can review
10
+ - close through evidence, not confidence language
10
11
 
11
12
  ## Closure target
12
- Prefer one of two endings:
13
- 1. Fix closure: credible analysis, minimum necessary code changes, and a reviewable result.
14
- 2. Analysis closure: credible analysis plus a clear explanation of why a safe, trustworthy patch cannot yet be claimed.
13
+ - `Fix closure`: credible analysis, minimum necessary code changes, reviewable validation
14
+ - `Analysis closure`: credible analysis plus a clear reason a trustworthy patch cannot yet be claimed
15
15
 
16
16
  ## Scope
17
17
  Handle accepted defects in code, config, scripts, build logic, or tests when the task can advance through repository reading, command execution, code change, and evidence.
18
18
 
19
- Typical cases:
20
- - application code, scripts, configuration, build logic, or tests
21
- - crashes, runtime errors, incorrect behavior, state bugs, and boundary-condition defects
22
-
23
19
  ## Evidence priority
24
20
  - If available evidence contains any file whose basename includes `hprof`, analyze that heap dump before claiming a memory-leak root cause.
25
21
  - Treat generated heap-analysis artifacts as primary evidence for memory-retention conclusions.
@@ -8,6 +8,22 @@
8
8
  - `Check`: validate through reproduction, tests, scenarios, logs, output comparison, build, or code evidence.
9
9
  - `Act`: close as fix or analysis and write one reviewable result file.
10
10
 
11
+ ## Review loop
12
+
13
+ - Run an explicit reviewer subagent after the main fix/check pass when any are true:
14
+ - code changed
15
+ - closure relies heavily on `V1` or `V2`
16
+ - the call chain, blast radius, or risk surface is non-trivial
17
+ - The reviewer subagent is a judge, not a builder. It must not rewrite the patch directly.
18
+ - Reviewer findings do not automatically justify a larger patch. Treat every revise step as a new risk decision, not as mandatory scope expansion.
19
+ - Maximum review rounds: 3 total.
20
+ - Stop early when:
21
+ - the reviewer approves closure, or
22
+ - another revise-and-review pass is unlikely to improve trustworthiness materially
23
+ - Stop and downgrade instead of revising when the next candidate change would materially expand blast radius, weaken rollback safety, or require meaningfully lower-confidence reasoning than the current patch.
24
+ - If the final reviewer verdict still finds material gaps after the maximum rounds, downgrade closure instead of looping further.
25
+ - The builder must read the latest reviewer output before revising or closing.
26
+
11
27
  ## Patch gate
12
28
 
13
29
  - Patch only when both root-cause judgment and validation path are credible.
@@ -54,11 +70,58 @@ Never overstate:
54
70
 
55
71
  - Close as fix only when analysis, code changes, validation evidence, and residual-risk understanding are credible.
56
72
  - Close as analysis when information, environment, reproduction, or validation is insufficient for a trustworthy patch claim.
73
+ - Prefer the current lower-risk repair candidate over a broader reviewer-driven rewrite when the broader rewrite would make the patch harder to reason about, validate, or roll back.
57
74
  - If code changed but fix validation stayed at `V2` or `V1`, describe it as a repair candidate, not a verified fix.
58
75
  - If the issue is interaction, crash, device, integration, or resource related and fix validation stayed at `V2`, state what stronger environment or tooling was missing.
59
76
  - If build or test failed for unrelated reasons, report the stage, failure reason, and why it is treated as noise or a pre-existing blocker.
60
77
  - If only `V1` evidence exists, do not submit a formal verified-fix claim; close as analysis unless a repair candidate is still justified.
61
78
  - Analysis closure must still provide root-cause judgment, fix direction, and either targeted local guidance or a module-level strategy.
79
+ - When the review loop ran, final closure must not overstate the last reviewer verdict.
80
+ - Reviewer approval can block, downgrade, or confirm closure, but it does not raise validation grade by itself.
81
+
82
+ ## Reviewer subagent standard
83
+
84
+ - Reviewer input should include at minimum:
85
+ - accepted bugfix task input
86
+ - strongest root-cause judgment
87
+ - changed files or `patch.diff`
88
+ - strongest validation evidence and its limits
89
+ - remaining blockers, residual risks, and downgrade reasons when present
90
+ - previous reviewer findings and builder revisions for later rounds
91
+ - Reviewer output should classify findings as:
92
+ - `Must Fix Before Close`
93
+ - `Risk Accepted`
94
+ - `Open Question`
95
+ - Each later review round should also include:
96
+ - what the builder changed
97
+ - what the builder intentionally did not change and why
98
+ - When the builder declines a suggested revision, it should state whether the reason is blast radius, weaker validation posture, added complexity, or lack of stronger causal evidence.
99
+ - The reviewer subagent should evaluate the patch in this order:
100
+ - whether the patch actually addresses the judged root cause instead of only suppressing the symptom
101
+ - whether the change may introduce upstream/downstream side effects, stability regressions, performance regressions, compatibility issues, or neighbor-path breakage
102
+ - whether the change worsens any known pre-existing weakness even if that weakness was not introduced by this task
103
+ - whether the chosen repair is the lowest-risk credible option when every available fix path has tradeoffs
104
+ - whether the patch preserves or improves performance, simplicity, maintainability, and design clarity when multiple credible fixes exist
105
+ - The reviewer should prefer downgrade over further churn when a follow-up patch would mainly trade one honest residual risk for a larger or harder-to-verify patch.
106
+ - Reviewer expectations for tradeoff judgment:
107
+ - do not require an unrealistic zero-risk answer when all options have cost
108
+ - if every credible fix leaves some downside, prefer the option with smaller blast radius, lower regression probability, easier rollback, and clearer reasoning
109
+ - a pre-existing issue that is not caused by this patch does not have to be fixed now, but the patch must not deepen, spread, or hide it
110
+ - Reviewer expectations for code quality:
111
+ - on top of correctness, prefer cleaner boundaries, lower complexity, and better performance when that does not expand risk disproportionately
112
+ - elegance is a tie-breaker after correctness and risk control, not a justification for widening the patch unnecessarily
113
+ - `Must Fix Before Close` examples:
114
+ - the patch does not actually repair the judged root cause
115
+ - the change introduces meaningful side effects, compatibility regressions, or neighbor-path risk
116
+ - validation is materially overstated relative to what actually ran
117
+ - the patch worsens a known pre-existing weakness
118
+ - `Risk Accepted` examples:
119
+ - the patch is credible, but some residual risk remains and is already disclosed honestly
120
+ - all repair paths have tradeoffs, and the chosen one is the smallest credible risk
121
+ - a reviewer-found weakness exists, but the next fix path would increase patch risk more than it would increase trustworthiness
122
+ - `Open Question` examples:
123
+ - stronger validation needs missing environment, device, account, traffic, or data
124
+ - a broader architectural cleanup may exist, but it is outside safe single-task scope
62
125
 
63
126
  ## Runtime contract
64
127
 
@@ -91,6 +154,7 @@ Never overstate:
91
154
 
92
155
  - Always generate `result.md` on normal completion.
93
156
  - If code changed, runtime should also emit `patch.diff`.
157
+ - Generate `review-log.md` whenever the reviewer loop ran.
94
158
  - If `patch.diff` exists, `Closure Level` must not be `Analysis Only`.
95
159
  - If `patch.diff` exists, Patch Closure Mode is mandatory.
96
160
  - If available evidence contains any file whose basename includes `hprof`, state whether the dump was analyzed and identify the strongest file used.
@@ -177,6 +241,23 @@ At minimum, `result.md` must include:
177
241
  - fix strategy when validation is insufficient
178
242
  - validation method, steps, actual results, and unverified items
179
243
  - residual risk and next step
244
+ - when the review loop ran, keep detailed per-round reviewer findings in `review-log.md`, not in the main result body
245
+
246
+ ## `review-log.md` contract
247
+
248
+ - Purpose: preserve the independent bugfix reviewer loop as an audit trail.
249
+ - Create only when the reviewer loop ran.
250
+ - Keep it task-private; do not rely on it as the primary delivery result.
251
+ - Each round entry should include:
252
+ - round number
253
+ - reviewer verdict
254
+ - `Must Fix Before Close`
255
+ - `Risk Accepted`
256
+ - `Open Question`
257
+ - builder action
258
+ - Keep findings dense and patch-specific.
259
+ - Record what changed between rounds rather than repeating the full patch summary.
260
+ - Final closure should match the last reviewer verdict without overstating certainty.
180
261
 
181
262
  ## Patch Closure Mode
182
263
 
@@ -0,0 +1,66 @@
1
+ # ACCEPT
2
+
3
+ Routes requirement-to-prototype work into the `pm` harness.
4
+
5
+ ## Decision target
6
+ Triage decides only:
7
+ 1. task type fit
8
+ 2. execution admission
9
+
10
+ The runner decides final closure: `Prototype Complete`, `Prototype Partial`, or `Analysis Only`.
11
+
12
+ ## Task type fit
13
+ Classify as `pm` only when all are true:
14
+ - the request is to turn requirement input into an interactive HTML prototype
15
+ - the expected output is a prototype artifact, not production code
16
+ - the task centers on flow, structure, interaction, or state presentation
17
+ - the prototype can be derived from requirement input without real system implementation
18
+
19
+ Do not classify as `pm` when any are true:
20
+ - the request is only strategy discussion or product advice
21
+ - the request is for production implementation
22
+ - the request is only visual design refinement with no requirement-to-prototype goal
23
+ - the request is only PRD writing or requirement analysis with no interactive output
24
+ - the request is a bugfix, code-change, or repository task
25
+
26
+ ## Execution admission
27
+ Accept when all are true:
28
+ - a usable `requirement_document` exists
29
+ - at least one concrete goal exists
30
+ - at least one concrete flow, page path, or interaction path exists or is clearly derivable
31
+ - the prototype scope is bounded enough for one task
32
+ - the task does not depend on repository coupling or production-system integration
33
+
34
+ ## Still acceptable with partial information
35
+ Accept if:
36
+ - some states, copy, rules, or edge cases are missing
37
+ - the main objective and at least one core flow are clear
38
+ - missing detail can be surfaced as assumptions instead of hidden invention
39
+
40
+ ## Reject when execution context is insufficient
41
+ Reject when any are true:
42
+ - there is no usable requirement basis
43
+ - there is no concrete scenario or flow to prototype
44
+ - multiple unrelated areas are mixed with no bounded scope
45
+ - the input is too abstract to determine user behavior
46
+ - trustworthy prototyping would require heavy invention
47
+ - the request actually expects real implementation
48
+
49
+ ## Missing information labels
50
+ Use the smallest set that explains rejection:
51
+ - `requirement_document`
52
+ - `product_goal`
53
+ - `target_user`
54
+ - `core_flow`
55
+ - `prototype_scope`
56
+ - `constraints`
57
+
58
+ ## Event scope
59
+ - `problem.discovered`
60
+ - `task.submitted_manually`
61
+
62
+ ## Triage guidance
63
+ - judge requirement quality, not keyword presence
64
+ - prefer one clear prototype objective over broad redesign asks
65
+ - separate task-type fit from execution readiness
66
+ - accept requirement-driven prototype work, not open-ended consulting
@@ -0,0 +1,60 @@
1
+ # CONSTRAINTS
2
+
3
+ Defines non-negotiable PM execution rules.
4
+
5
+ ## Source truth
6
+ - the source requirement document is the primary truth source
7
+ - helper summaries or prior artifacts must not replace source reading
8
+ - keep confirmed facts, assumptions, and open questions separate
9
+ - surface missing or conflicting input explicitly
10
+
11
+ ## Fidelity and representation
12
+ - preserve explicit product names, labels, enums, ordering, defaults, formulas, limits, scope boundaries, examples, empty/error states, and exclusions
13
+ - do not rename, broaden, normalize, or merge source facts in ways that change product meaning without disclosure
14
+ - before building UI, extract explicit labels, enum sets, ordering, defaults, formulas, limits, scope, exclusions, and open questions
15
+ - assign exactly one representation mode to each critical rule:
16
+ - `Represented Interactively`
17
+ - `Represented via Annotation`
18
+ - `Downgraded / Simulated`
19
+ - `Not Represented`
20
+ - if a source fact is omitted, merged, normalized, or replaced, declare it in `result.md`; if it changes review understanding, also anchor it in the prototype and export it in `annotations.json`
21
+ - when fidelity and prototype convenience conflict, preserve the source fact or declare the deviation explicitly
22
+ - annotations may supplement core flow coverage, but must not replace it
23
+ - do not present simulated or inferred detail as confirmed requirement
24
+ - if trustworthy prototyping would require heavy invention, stop at `Analysis Only`
25
+
26
+ ## Review discipline
27
+ - prototype for review, not production deployment
28
+ - the first screen should read primarily as product UI, not as a prototype console
29
+ - static output alone is insufficient unless closure is `Analysis Only`
30
+ - independent reviewer subagent judgment is required before claiming `Prototype Complete`
31
+ - the reviewer is a judge, not a builder
32
+ - maximum review rounds: 3 total
33
+ - record each round number, verdict, key gaps, and builder action in a task-private `review-log.md` under `artifactDir`
34
+ - each later round must re-check the full accepted surface for regressions, not only the previous point fixes
35
+ - before re-review, visually inspect every core panel that carries accepted-scope meaning
36
+ - do not fix one area by making another panel blank, near-blank, visually invisible, or materially thinner in meaning
37
+ - do not respond to reviewer pressure by inflating scope, adding speculative screens, or increasing prototype chrome when that makes the accepted scope harder to inspect
38
+ - prefer `Prototype Partial` over a noisier, less truthful, or more invented prototype assembled only to clear late review comments
39
+
40
+ ## Annotation discipline
41
+ - bind annotations to a concrete UI target, state, or transition whenever possible
42
+ - use highlighting or connector lines only when readability improves
43
+ - annotate rule meaning, implementation risk, or unresolved behavior, not trivial visual facts
44
+ - do not dump raw PRD excerpts into annotations
45
+ - keep reviewer-facing copy human-readable
46
+ - `annotations.json` must match the actual annotation layer in `prototype.html`
47
+
48
+ ## Forbidden
49
+ - fake backend integration
50
+ - invented product direction with no source basis
51
+ - claiming certainty that does not exist
52
+ - decoration-first output that hides product meaning
53
+ - claiming outputs that were not actually created under `artifactDir`
54
+ - using annotations to hide missing core screens, states, or transitions
55
+ - presenting simulated behavior as faithfully implemented
56
+ - marking `Prototype Complete` when key rules remain materially weak, merged, or downgraded
57
+ - treating builder self-review as a substitute for an independent reviewer subagent verdict
58
+ - fixing a prior reviewer finding by introducing a new blank, near-blank, or materially weakened core panel
59
+ - treating retained titles, labels, or container chrome as sufficient when the actual intended content expression has disappeared
60
+ - adding speculative flows, exaggerated data breadth, or decorative complexity only to satisfy reviewer expectations rather than requirement truth
@@ -0,0 +1,50 @@
1
+ # CONTEXT
2
+
3
+ Defines the minimum product model the PM harness must construct before prototyping.
4
+
5
+ ## Working model
6
+ - this is a document-first, artifact-only task
7
+ - the source requirement document is authoritative
8
+ - helper summaries and prior artifacts are secondary aids, not truth
9
+ - build a minimal product model before building UI
10
+
11
+ ## Required product model
12
+
13
+ ### Goal and scope
14
+ - product goal
15
+ - target user
16
+ - bounded prototype scope
17
+ - explicit non-goals
18
+
19
+ ### Flow and state
20
+ - entry point
21
+ - core actions and transitions
22
+ - success, empty, error, gated, and branching states that change understanding
23
+
24
+ ### Rule model
25
+ - thresholds, limits, ordering, gating, permissions, formulas, frequency limits, and role boundaries
26
+ - rules that must be interactive
27
+ - rules that must be annotated
28
+ - rules that remain simulated or unresolved
29
+
30
+ ### Source fact model
31
+ - explicit labels and names
32
+ - explicit enum sets and ordering
33
+ - explicit example entities
34
+ - explicit defaults, selected states, formulas, limits, inclusions, and exclusions
35
+
36
+ ### Annotation model
37
+ - rule meaning not faithfully expressible through lightweight interaction
38
+ - one primary target per annotation whenever possible
39
+ - truth layer: `confirmed`, `simulated`, `open_question`
40
+
41
+ ## Artifact model
42
+ - `prototype.html` carries the interactive review surface
43
+ - `result.md` carries rule supplements and implementation-critical notes
44
+ - `annotations.json` carries the structured export of anchored annotations
45
+ - the Feishu result document is only the delivery portal to the source link and artifact set
46
+
47
+ ## Priority
48
+ - preserve requirement meaning first
49
+ - preserve flow clarity second
50
+ - improve visual coherence third