write-helpers.mjs
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠ breaking
10 days ago
| 1 | /** |
| 2 | * Shared helpers for task-write seven-tier tests. |
| 3 | */ |
| 4 | import fs from 'node:fs'; |
| 5 | import path from 'node:path'; |
| 6 | |
| 7 | import { |
| 8 | precheckApprovedTaskProposal, |
| 9 | reconcileApprovedTaskProposal, |
| 10 | } from '../../../lib/task/task-write.mjs'; |
| 11 | import { getProposal, updateProposalStatus } from '../../../hub/proposals-store.mjs'; |
| 12 | import { getRepoRoot } from '../../../lib/repo-root.mjs'; |
| 13 | |
| 14 | export const visibleAll = new Set(['personal', 'project', 'org']); |
| 15 | |
| 16 | /** |
| 17 | * @param {string} dataDir |
| 18 | * @returns {string} |
| 19 | */ |
| 20 | export function emptyTaskStarterDir(dataDir) { |
| 21 | const d = path.join(dataDir, 'empty-starter'); |
| 22 | fs.mkdirSync(d, { recursive: true }); |
| 23 | return d; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @param {string} dataDir |
| 28 | * @param {string} proposalId |
| 29 | */ |
| 30 | export function approveTaskProposal(dataDir, proposalId) { |
| 31 | const proposal = getProposal(dataDir, proposalId); |
| 32 | const pre = precheckApprovedTaskProposal(dataDir, proposal); |
| 33 | if (!pre.ok) return pre; |
| 34 | reconcileApprovedTaskProposal(dataDir, pre); |
| 35 | updateProposalStatus(dataDir, proposalId, 'approved'); |
| 36 | return { ok: true, pre }; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * @returns {object} |
| 41 | */ |
| 42 | export function sampleTaskCreatePayload() { |
| 43 | return { |
| 44 | proposal_kind: 'task_create', |
| 45 | intent: 'Add personal practice goal', |
| 46 | task: { |
| 47 | task_id: 'task_practice_june', |
| 48 | kind: 'personal', |
| 49 | scope: 'personal', |
| 50 | title: 'Daily scale practice', |
| 51 | workspace_id: 'ws_personal', |
| 52 | due_at: '2026-06-30T17:00:00.000Z', |
| 53 | assignee_ref: null, |
| 54 | assigner_ref: null, |
| 55 | artifact_links: [], |
| 56 | }, |
| 57 | }; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * @returns {object} |
| 62 | */ |
| 63 | export function sampleLoopCreatePayload() { |
| 64 | return { |
| 65 | proposal_kind: 'task_loop_create', |
| 66 | intent: 'Weekly mentor check-in series', |
| 67 | loop: { |
| 68 | loop_id: 'loop_mentor_w25', |
| 69 | kind: 'mentor_checkin', |
| 70 | scope: 'personal', |
| 71 | title: 'Weekly mentor check-in', |
| 72 | workspace_id: 'ws_personal', |
| 73 | status: 'active', |
| 74 | recurrence: { |
| 75 | kind: 'interval', |
| 76 | every: 1, |
| 77 | unit: 'week', |
| 78 | anchor_at: '2026-06-23T09:00:00.000Z', |
| 79 | }, |
| 80 | timezone: 'America/Los_Angeles', |
| 81 | flow_id: null, |
| 82 | boundary_policy: 'propose_only', |
| 83 | memory_links: [], |
| 84 | handoff_refs: [], |
| 85 | until_at: null, |
| 86 | }, |
| 87 | }; |
| 88 | } |
| 89 | |
| 90 | export const loopStarterDir = path.join(getRepoRoot(), 'task-loops/starter'); |
File History
1 commit
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠
10 days ago