Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: make plan-feature documentation-aware (#4936)

[._.]/ Adam Eivy00901f29c777
diff --git a/server/lib/workTracker.js b/server/lib/workTracker.js
index 0d9961c1ea..9b1b3ac927 100644
--- a/server/lib/workTracker.js
+++ b/server/lib/workTracker.js
@@ -221,7 +221,7 @@ export const TRACKER_FILING_PRESETS = {
issueLabel: 'plan-feature',
labelDescription: 'Feature plan filed by the plan-feature brainstorm',
planItemBody: 'From the `plan-feature` brainstorm (<today\'s date>). <What the feature is and which user need or goal it serves, 1–2 sentences.> Approach: <the decided approach and the {appName} files/components it would touch>. Scope: <small/medium/large>.',
- bodyRequirements: 'the motivation (which user need or GOALS.md priority this serves), the decided approach naming the {appName} files/components it would touch, an estimated scope, acceptance criteria another agent can verify cold, and any explicit non-goals',
+ bodyRequirements: 'the motivation (which PRD.md requirement or success criterion, GOALS.md priority, or repository-documented user need this serves), the decided approach naming the {appName} files/components it would touch, an estimated scope, acceptance criteria another agent can verify cold, and any explicit non-goals',
planCommitMessage: 'docs(plan-feature): file <N> feature plan(s)',
},
};
diff --git a/server/lib/workTracker.trackerInstructions.test.js b/server/lib/workTracker.trackerInstructions.test.js
index 5ce03ae94c..54c40e86d4 100644
--- a/server/lib/workTracker.trackerInstructions.test.js
+++ b/server/lib/workTracker.trackerInstructions.test.js
@@ -188,6 +188,12 @@ describe('formatTrackerInstructions — plan-feature preset', () => {
expect(gitlab).toContain('--label plan-feature --label plan');
});
+ it('grounds the plan motivation in the PRD first, with goals or repo docs as fallbacks', () => {
+ expect(planFeature.bodyRequirements).toContain('PRD.md requirement or success criterion');
+ expect(planFeature.bodyRequirements).toContain('GOALS.md priority');
+ expect(planFeature.bodyRequirements).toContain('repository-documented user need');
+ });
+
it('keeps the read-only-on-source contract in every forge block', () => {
for (const tracker of ['github', 'gitlab', 'jira']) {
expect(formatTrackerInstructions(tracker, planFeature)).toContain('No source-code edits');
diff --git a/server/services/taskPromptDefaults.test.js b/server/services/taskPromptDefaults.test.js
index f578bf2af8..e2e05298ea 100644
--- a/server/services/taskPromptDefaults.test.js
+++ b/server/services/taskPromptDefaults.test.js
@@ -131,6 +131,26 @@ describe('taskPromptDefaults integrity snapshot', () => {
expect(v9).not.toBe(current);
});
+ // plan-feature v2: product intent is specific-first (PRD → GOALS → repository
+ // docs) and no longer depends on the retired roadmap/rejection-ledger files.
+ it('plan-feature v2 uses the PRD/docs fallback hierarchy and preserves v1', () => {
+ const current = DEFAULT_TASK_PROMPTS['plan-feature'];
+ expect(PROMPT_VERSIONS['plan-feature']).toBe(2);
+ expect(current).toContain('PRD.md');
+ expect(current).toContain('GOALS.md');
+ expect(current).toContain('README.md');
+ expect(current).toContain('docs/README.md');
+ expect(current).toContain('AGENTS.md');
+ expect(current).not.toContain('REJECTED.md');
+ expect(current).not.toContain('ALSO read PLAN.md');
+
+ const v1 = PREVIOUS_DEFAULT_PROMPTS['plan-feature'].find((prompt) => prompt.includes('ALSO read PLAN.md'));
+ expect(v1).toBeDefined();
+ expect(v1).toContain('REJECTED.md');
+ expect(v1).not.toContain('PRD.md');
+ expect(v1).not.toBe(current);
+ });
+
it('do-replan v2 rejects future-only proposals while preserving v1 for migration', () => {
const current = DEFAULT_TASK_PROMPTS['do-replan'];
expect(PROMPT_VERSIONS['do-replan']).toBe(2);
diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.json
index 46b83f28be..f1b26c6712 100644
--- a/server/services/taskPromptDefaults/integrity.snapshot.json
+++ b/server/services/taskPromptDefaults/integrity.snapshot.json
@@ -14,7 +14,7 @@
"data-safety": "86b07f51abdbcbe7016f840b5bb0cd9b",
"simplify": "2a048214d1dd3b75bee9ae1a38fa1589",
"feature-ideas": "d3282f16da29efe2d53595b3b34778bc",
- "plan-feature": "3df6f0a46f2a524af1dc4f83dfdf0647",
+ "plan-feature": "b20980c8eda2256060d09d4bca397244",
"plan-task": "910802d67f3b5a785f068f4d90178543",
"claim-issue": "542ce3673abbdee93e895f9df660aaf7",
"claim-issue-gitlab": "348ed6348b90dcc6eead03e06df049e9",
@@ -53,7 +53,7 @@
"branch-reconcile": 3,
"issue-reconcile": 4,
"refresh-local-llm-catalog": 3,
- "plan-feature": 1,
+ "plan-feature": 2,
"security": 2,
"code-quality": 2,
"test-coverage": 2,
@@ -216,6 +216,9 @@
"525bd0077672bf2f8beec9c0124740c8",
"a9dce67bb9f0837ba904f3412b03637f"
],
+ "plan-feature": [
+ "3df6f0a46f2a524af1dc4f83dfdf0647"
+ ],
"stash-cleanup": [
"f9de8b10937919ceb6656fbdb70179c4"
]
diff --git a/server/services/taskPromptDefaults/previousDefaults.js b/server/services/taskPromptDefaults/previousDefaults.js
index b9179d2f45..1938bb2fc9 100644
--- a/server/services/taskPromptDefaults/previousDefaults.js
+++ b/server/services/taskPromptDefaults/previousDefaults.js
@@ -10304,6 +10304,92 @@ Default branch: {defaultBranch}
the branch). Finish with a 2–4 sentence summary listing exactly which models
were added, updated, or removed and the sources you verified them against.`,
],
+ 'plan-feature': [
+ // v1 default prompt — initial release; superseded by the PRD/docs-first
+ // research hierarchy in v2.
+ `[Improvement: {appName}] Feature Planning — brainstorm one feature and file its plan
+
+You are the planning-only sibling of the \`feature-ideas\` task. Your job is to
+research {appName}, pick ONE feature worth building, and file a decision-complete
+plan for it into the app's task tracker. You do NOT implement anything.
+
+**Read-only on source.** You do NOT edit application code, and you do NOT create
+branches or PRs. Your deliverable is ONE tracker item (described under "Where to
+record the plan" below) carrying a plan another agent — or a human — can pick up
+and execute cold. The plan is the product.
+
+Repository: {repoPath}
+
+## Where to record the plan
+
+{trackerInstructions}
+
+## What to do
+
+1. **Inventory so you don't duplicate.** Follow the "Inventory" step under
+ "Where to record the plan" above for this app's tracker — collect every
+ existing \`[plan-feature-…]\` slug. ALSO read PLAN.md from {repoPath} (if it
+ exists) and skim the last 50 \`git log\` entries plus recent \`.changelog/\`
+ files: an idea that is already an unchecked plan item, an open tracker item,
+ or recently shipped work is NOT a candidate.
+
+2. **Research the app the same way \`feature-ideas\` does.**
+
+ - Read GOALS.md from {repoPath} for the app's goals and priorities. If no
+ GOALS.md exists, focus on general improvements.
+ - Read REJECTED.md from {repoPath} (if it exists) — do NOT re-propose an
+ idea matching a rejected entry.
+ - Check the repo's recently closed-unmerged PRs (\`gh pr list --state closed
+ --search "is:unmerged" --limit 20\`, or the forge's equivalent) — a feature
+ whose PR the user closed WITHOUT merging was rejected; treat those ideas as
+ rejected too.
+ - Review the codebase structure, README, and docs to understand how the app
+ is built, so the plan names real files rather than imagined ones.
+
+3. **Identify ONE small, high-impact feature** that:
+
+ - Aligns with GOALS.md priorities (if available)
+ - Is NOT already shipped, planned, or filed (per step 1)
+ - Does NOT match a REJECTED.md entry or a closed-unmerged automation PR
+ - Saves user time, improves UX, or makes the app more useful
+ - Is self-contained and completable in one session by the agent that claims it
+ - Does NOT duplicate existing functionality
+
+4. **Write the decision-complete plan.** Every design choice is DECIDED, not
+ raised as a question — make the call and state it. The filed item must carry:
+
+ - **A slug-tagged title.** Lowercase kebab-case starting with
+ \`plan-feature-\`, naming the feature (e.g.
+ \`plan-feature-export-universe-to-markdown\`); ≤80 chars total; unique
+ against every existing \`[plan-feature-…]\` slug (re-check before recording).
+ - **Motivation** — which user need or GOALS.md priority this serves, 1–2
+ sentences.
+ - **Approach** — the design you have decided on: the behavior to build, the
+ existing patterns in {appName} it follows, and the concrete files/components
+ it would touch (describe them; do NOT write the code).
+ - **\`Scope: small | medium | large\`** — an honest estimate for one session.
+ - **Acceptance criteria** — checkboxes another agent can verify cold, without
+ asking anyone anything.
+ - **Non-goals** — what this feature deliberately does NOT cover, so the
+ implementing agent doesn't expand scope.
+
+5. **Redact before you publish.** The filed item is world-readable the moment it
+ lands. Never paste a secret, credential, token, hostname, IP address, or
+ absolute path containing a username into the title or body.
+
+6. **Record exactly ONE plan item** using the "Record" mechanics under "Where
+ to record the plan" above. If the feature hinges on a genuine product
+ judgment the user owns (not a design detail you can decide), file it anyway
+ as a **Maybe — needs human call** item with the \`**Decision needed:**\` line
+ the tracker instructions describe — do not skip filing.
+
+7. **Finalize** per the "Finalize" step under "Where to record the plan" above.
+ No source edits, no branches, no PRs.
+
+8. Your final assistant message must be a 2–3 sentence summary of: the feature
+ you planned, where you filed it (item slug / issue number), and the one
+ design call you made that a reviewer is most likely to question.`,
+ ],
'stash-cleanup': [
// v1 default prompt (pre-#4852: named CLAUDE.md as the agent-instructions file)
`[Improvement: {appName}] Git Stash Cleanup
diff --git a/server/services/taskPromptDefaults/prompts.js b/server/services/taskPromptDefaults/prompts.js
index 77fa5fcf2c..0bdd70b681 100644
--- a/server/services/taskPromptDefaults/prompts.js
+++ b/server/services/taskPromptDefaults/prompts.js
@@ -591,32 +591,50 @@ Repository: {repoPath}
1. **Inventory so you don't duplicate.** Follow the "Inventory" step under
"Where to record the plan" above for this app's tracker — collect every
- existing \`[plan-feature-…]\` slug. ALSO read PLAN.md from {repoPath} (if it
- exists) and skim the last 50 \`git log\` entries plus recent \`.changelog/\`
- files: an idea that is already an unchecked plan item, an open tracker item,
- or recently shipped work is NOT a candidate.
-
-2. **Research the app the same way \`feature-ideas\` does.**
-
- - Read GOALS.md from {repoPath} for the app's goals and priorities. If no
- GOALS.md exists, focus on general improvements.
- - Read REJECTED.md from {repoPath} (if it exists) — do NOT re-propose an
- idea matching a rejected entry.
+ existing \`[plan-feature-…]\` slug. Then skim the last 50 \`git log\` entries
+ plus recent \`.changelog/\` files: an idea that is already an open tracker
+ item or recently shipped work is NOT a candidate.
+
+2. **Build a product brief from the repository's documentation.** Use the most
+ specific available source of intent, and make a best effort rather than
+ assuming a missing document means the app has no direction:
+
+ - If \`PRD.md\` exists, read it first. Treat its requirements, acceptance
+ criteria, success metrics, constraints, and non-goals as the primary
+ evaluation for what the feature should accomplish.
+ - If \`GOALS.md\` exists, read it for strategic context and to supplement
+ the PRD. If there is no PRD, use GOALS.md as the primary statement of
+ desired direction.
+ - If neither exists, start with the root \`README.md\`, \`docs/README.md\`
+ (if present), relevant guides, architecture notes, ADRs, design documents,
+ and other product documentation in the repository. In all cases, inspect
+ the relevant documentation for feature-specific context and fill gaps
+ from it. Extract stated users, problems, workflows, constraints, and
+ success signals rather than inventing a product direction.
+ - If PRD.md and GOALS.md conflict, follow the PRD's concrete requirements
+ and success criteria; use GOALS.md as strategic context and call out any
+ material tension in the filed plan.
+ - Read the repository's \`AGENTS.md\` or \`CLAUDE.md\` files as implementation
+ constraints, not as a substitute for product intent. When documentation
+ is sparse, validate the inferred need against the current source, tests,
+ and recent history and name the evidence in the plan.
- Check the repo's recently closed-unmerged PRs (\`gh pr list --state closed
--search "is:unmerged" --limit 20\`, or the forge's equivalent) — a feature
whose PR the user closed WITHOUT merging was rejected; treat those ideas as
rejected too.
- - Review the codebase structure, README, and docs to understand how the app
- is built, so the plan names real files rather than imagined ones.
+ - Review the codebase structure and relevant source files so the plan names
+ real files rather than imagined ones.
3. **Identify ONE small, high-impact feature** that:
- - Aligns with GOALS.md priorities (if available)
+ - Aligns with PRD.md requirements and success criteria when available;
+ otherwise aligns with GOALS.md or the repository documentation gathered
+ in step 2
- Is NOT already shipped, planned, or filed (per step 1)
- - Does NOT match a REJECTED.md entry or a closed-unmerged automation PR
+ - Does NOT duplicate existing functionality or repeat a closed-unmerged
+ automation PR
- Saves user time, improves UX, or makes the app more useful
- Is self-contained and completable in one session by the agent that claims it
- - Does NOT duplicate existing functionality
4. **Write the decision-complete plan.** Every design choice is DECIDED, not
raised as a question — make the call and state it. The filed item must carry:
@@ -625,8 +643,8 @@ Repository: {repoPath}
\`plan-feature-\`, naming the feature (e.g.
\`plan-feature-export-universe-to-markdown\`); ≤80 chars total; unique
against every existing \`[plan-feature-…]\` slug (re-check before recording).
- - **Motivation** — which user need or GOALS.md priority this serves, 1–2
- sentences.
+ - **Motivation** — which documented requirement, success criterion, goal, or
+ evidenced user need this serves, 1–2 sentences.
- **Approach** — the design you have decided on: the behavior to build, the
existing patterns in {appName} it follows, and the concrete files/components
it would touch (describe them; do NOT write the code).
diff --git a/server/services/taskPromptDefaults/versions.js b/server/services/taskPromptDefaults/versions.js
index 7d9a13bddc..3c349e683d 100644
--- a/server/services/taskPromptDefaults/versions.js
+++ b/server/services/taskPromptDefaults/versions.js
@@ -23,7 +23,7 @@ export const PROMPT_VERSIONS = {
'branch-reconcile': 3, // v3: SUPERSEDED is a first-class outcome — a branch whose problem the default branch already solved a different way is reported and left untouched, never merged (merging it undoes shipped work). A resolvable conflict is explicitly NOT evidence the work is still wanted, and every branch is rebased + test-verified before it reaches a PR. v2: a branch whose "Do:" line ends in a merge isn't finished until it IS merged — the sub-agent waits CI out in-session instead of handing back a green-but-open PR, and the old blanket "never merge unreviewed work" rule (which vetoed the per-branch merge instruction) is replaced by the explicit CI-green + MERGEABLE + review gate. v1: per-app coordinator that finishes in-flight LOCAL branches (open PR / resolve conflicts / drive review / auto-merge) after the deterministic merged-branch cleanup pass. Peer-safe (local refs only). Replaced the PortOS-only branchReconcileScheduler.
'issue-reconcile': 4, // v4: follow-up recipes apply independent slashdo dispatch hints and contributor labels (`good first issue`/`help wanted`, Jira hyphenated equivalents) instead of only `plan`. v3: adds a JIRA arm — status-based zombies (a ticket left In Review with remaining scope + no live claim; JIRA has no `in-progress` label) detected via the PortOS JIRA API and healed through ticket transitions + `POST tickets`, routed in via the app's resolved workTracker ('jira') rather than the git host. v2: forge-aware — the scan + coordinator now cover GitLab (`glab` issues + MRs) as well as GitHub, resolved from the app's origin host; every heal command is shown as gh/glab and the injected header names the forge. v1: per-app coordinator that heals ZOMBIE issues (open + in-progress but their PR merged with no live claim) after the deterministic gh/git scan. Applies the partial-ship hybrid — close + file a scoped follow-up when the remainder is separable, else comment "done/remaining" + release the claim so the queue re-picks it.
'refresh-local-llm-catalog': 3, // v3: catalog maintenance now preserves the primary-lane + cross-lane recommendation taxonomy and reserves featured treatment for a deliberate first choice. v2: PortOS-only task, so it names the fragment command directly: `npm run changelog:add -- changed "…"` instead of hand-appending to `.changelog/NEXT.md`. v1: research current local models, refresh LOCAL_LLM_CATALOG + EDITORIAL_FAMILY_RANK, PR (PortOS repo only)
- 'plan-feature': 1, // v1: net-new type — the planning-only sibling of feature-ideas. Brainstorms ONE feature via the same research pipeline (GOALS.md, changelog/git log, REJECTED.md, closed-unmerged PRs) but never implements: the deliverable is ONE decision-complete plan (motivation, decided approach, scope, acceptance criteria, non-goals) filed into the app's resolved work tracker via {trackerInstructions}, for claim-issue/plan-task to pick up later. Net-new (no PREVIOUS_DEFAULT_PROMPTS entry needed).
+ 'plan-feature': 2, // v2: PRD.md is the primary product/evaluation source, GOALS.md supplements or falls back, and repository documentation is the best-effort fallback when neither exists; removes obsolete roadmap/rejection-ledger research dependencies while retaining the resolved work-tracker filing flow. v1: net-new planning-only sibling of feature-ideas.
// Basic self-improvement tasks — versioned so installs created before the
// Jan→Feb 2026 genericization (which still have the app-name-hardcoded "PortOS"
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.js
index 7729ff6e38..afa9db652a 100644
--- a/server/services/taskSchedule.js
+++ b/server/services/taskSchedule.js
@@ -224,7 +224,8 @@ export const SELF_IMPROVEMENT_TASK_TYPES = [
// non-PortOS app does nothing. See DEFAULT_TASK_PROMPTS['refresh-local-llm-catalog'].
'refresh-local-llm-catalog',
// The planning-only sibling of `feature-ideas`: runs the same brainstorm
- // research (GOALS.md, changelog/git log, REJECTED.md, closed-unmerged PRs)
+ // research (PRD.md/GOALS.md or repository docs, changelog/git log, and
+ // closed-unmerged PRs)
// but NEVER implements — its deliverable is ONE decision-complete feature
// plan filed into the app's resolved work tracker via {trackerInstructions}
// (PLAN.md checklist item / GitHub / GitLab issue / JIRA ticket), which the
@@ -482,11 +483,11 @@ export const DEFAULT_TASK_INTERVALS = {
// default; the user enables it on the PortOS app.
'refresh-local-llm-catalog': { type: INTERVAL_TYPES.WEEKLY, enabled: false, providerId: null, model: null, prompt: null, taskMetadata: { useWorktree: true, openPR: true, simplify: true } },
// plan-feature files a plan, not code — tracker-filing posture mirrors
- // reference-watch: writable (the PLAN.md path commits checklist items), no
+ // reference-watch: writable (a file-based tracker commits checklist items), no
// managed worktree, no PR. Weekly (not daily like feature-ideas) so an
// enabled run doesn't flood the tracker with plans — one filed plan per run.
- // runAfter do-replan for the same grounding feature-ideas has: proposals are
- // checked against a fresh PLAN.md that already accounts for in-flight work.
+ // runAfter do-replan so proposals are checked against the freshest available
+ // work tracker before a new feature plan is filed.
'plan-feature': { type: INTERVAL_TYPES.WEEKLY, enabled: false, providerId: null, model: null, prompt: null, runAfter: ['do-replan'], taskMetadata: { useWorktree: false, openPR: false, readOnly: false } },
// layered-intelligence is a programmatic-I/O task (agent-backed, hooked). Daily
// by default; per-app scheduling (enabled/interval/provider/model) is set in the
diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.js
index 22cf2ea14d..4087a13c55 100644
--- a/server/services/taskSchedule.test.js
+++ b/server/services/taskSchedule.test.js
@@ -1368,11 +1368,11 @@ describe('taskSchedule', () => {
expect(cfg.type).toBe(INTERVAL_TYPES.WEEKLY)
// Off by default — enabling it is the user's consent to scheduled LLM runs.
expect(cfg.enabled).toBe(false)
- // Same grounding as feature-ideas: proposals checked against a fresh PLAN.md.
+ // Refresh the configured work tracker before filing a new proposal.
expect(cfg.runAfter).toEqual(['do-replan'])
expect(cfg.taskMetadata.useWorktree).toBe(false)
expect(cfg.taskMetadata.openPR).toBe(false)
- // Writable: the PLAN.md tracker path commits checklist items.
+ // Writable: a file-based tracker path commits checklist items.
expect(cfg.taskMetadata.readOnly).toBe(false)
// Filing posture comes from TRACKER_FILING_PRESETS membership at dispatch,
// not a static lock.
@@ -1393,9 +1393,14 @@ describe('taskSchedule', () => {
expect(prompt).toContain('{repoPath}')
// The tracker block is injected at dispatch, so the token must survive here.
expect(prompt).toContain('{trackerInstructions}')
- // Same research pipeline as feature-ideas' brainstorm phase.
+ // Product intent is specific-first, with repository documentation as the
+ // fallback when a project has neither a PRD nor goals document.
+ expect(prompt).toContain('PRD.md')
expect(prompt).toContain('GOALS.md')
- expect(prompt).toContain('REJECTED.md')
+ expect(prompt).toContain('README.md')
+ expect(prompt).toContain('docs/README.md')
+ expect(prompt).not.toContain('PLAN.md')
+ expect(prompt).not.toContain('REJECTED.md')
expect(prompt).toContain('closed-unmerged')
// Never implements — the plan IS the deliverable.
expect(prompt).toContain('no branches, no PRs')