Skip to content

В API генерации Task Pack добавь булево поле, показывающее, был ли refinement... #4

Description

@drag1web

ContextForge Task Pack

Task Pack: #21 — В API генерации Task Pack добавь булево поле, показывающее, был ли refinement...
Project: contextforge
Task type: general
Target: codex
Generated: 2026-07-16T16:36:33.446Z
GitHub issue draft created: 2026-07-16T16:40:44.384Z

Original Task

В API генерации Task Pack добавь булево поле, показывающее, был ли refinement получен из кеша.

Generated Task Pack

Open generated prompt

AI Task Pack

Target Tool

Codex

Task Type

general

Task

В API генерации Task Pack добавь булево поле, показывающее, был ли refinement получен из кеша.

Project Context

  • Project: contextforge
  • Package manager: npm
  • Detected stack: React, Svelte, TypeScript, Vite, Electron, Express, PostgreSQL, SQLite, Tailwind CSS, Framer Motion, Docker
  • Readiness score: 86

Project metadata:

{
  "name": "contextforge",
  "projectRoot": "<local-project>",
  "packageManager": "npm",
  "detectedStack": [
    "React",
    "Svelte",
    "TypeScript",
    "Vite",
    "Electron",
    "Express",
    "PostgreSQL",
    "SQLite",
    "Tailwind CSS",
    "Framer Motion",
    "Docker"
  ],
  "scripts": {
    "apps/desktop/renderer:dev": "vite --host 127.0.0.1 --port 5173 --strictPort",
    "dev": "vite --host 127.0.0.1 --port 5173 --strictPort",
    "apps/desktop/renderer:build": "tsc -b && vite build",
    "build": "tsc -b && vite build",
    "apps/desktop/renderer:preview": "vite preview",
    "preview": "vite preview",
    "root:dev": "concurrently -k -n SERVER,RENDERER,ELECTRON -c blue,green,magenta \"npm run dev:server\" \"npm run dev:renderer\" \"npm run dev:electron\"",
    "dev:server": "npm run dev -w @contextforge/server",
    "dev:renderer": "npm run dev -w @contextforge/renderer",
    "dev:electron": "wait-on tcp:5173 tcp:4000 && cross-env ELECTRON_RENDERER_URL=http://localhost:5173 electron apps/desktop/electron/main.cjs",
    "root:build": "npm run build -w @contextforge/renderer && npm run build -w @contextforge/server",
    "test:selector": "npm run test:selector -w @contextforge/server",
    "test:selector:rollout": "npm run test:selector:rollout -w @contextforge/server",
    "test:selector:rollout-ui": "npm exec -w @contextforge/server -- tsx ../scripts/pipelineBadge.smoke.ts",
    "benchmark:selector": "npm run benchmark:selector -w @contextforge/server",
    "benchmark:selector:validation": "npm run benchmark:selector:validation -w @contextforge/server",
    "benchmark:selector:snapshot": "npm run benchmark:selector:snapshot -w @contextforge/server",
    "db:up": "docker compose up -d",
    "db:down": "docker compose down",
    "db:logs": "docker compose logs -f postgres",
    "server:dev": "tsx watch src/index.ts",
    "server:build": "tsc",
    "server:test:selector": "tsx src/ollama/taskFileSelector.smoke.ts",
    "server:test:selector:replay": "tsx src/ollama/taskFileSelector.replay.ts",
    "test:selector:replay": "tsx src/ollama/taskFileSelector.replay.ts",
    "server:test:selector:benchmark": "tsx src/selection/benchmark/benchmarkSmoke.ts",
    "test:selector:benchmark": "tsx src/selection/benchmark/benchmarkSmoke.ts",
    "server:test:selector:rollout": "tsx src/selection/pipelineRollout.smoke.ts",
    "server:benchmark:selector": "tsx src/selection/benchmark/benchmarkRunner.ts",
    "server:benchmark:selector:validation": "tsx src/selection/benchmark/benchmarkRunner.ts --split validation --external-only",
    "server:benchmark:selector:snapshot": "tsx src/selection/benchmark/benchmarkSnapshot.ts",
    "server:start": "node dist/index.js",
    "start": "node dist/index.js"
  },
  "readinessScore": 86
}

Relevant File Candidates

Inspect these files before modifying code:

  • server/src/routes/taskPacks.ts
    • kind: source
    • usage: inspect-and-edit
    • evidence: code-graph support signal: 86%
    • size: 80 KB
    • reason: API boundary imports the existing producer and is the implementation owner for exposing cached as the public boolean field generationcached.
  • server/src/ollama/taskPackGenerationReliability.ts
    • kind: source
    • usage: inspect-only
    • evidence: code-graph support signal: 84%
    • size: 72 KB
    • reason: Existing producer already exposes the related value (cached); reuse it as the source of truth instead of creating a duplicate field inside the generated payload schema.
  • apps/desktop/renderer/src/types/index.ts
    • kind: source
    • usage: inspect-only
    • evidence: code-graph support signal: 80%
    • size: 27 KB
    • reason: Existing client/shared contract already contains the related public field (generationcached); retain it to verify the API response shape without adding UI state or unrelated display files.

Code Context Snippets

These snippets are partial context only. Inspect full files before editing.

server/src/routes/taskPacks.ts

import { createHash } from "node:crypto";
import fs from "node:fs/promises";
import path from "node:path";
import { Router } from "express";
import { z } from "zod";

import { storage } from "../storage/index.js";
import {
  appendSelectorDiagnostics,
  getAppSettings,
} from "../settings/settingsService.js";
import {
  buildTaskPackRulesTemplatePrompt,
  RulesServiceError,
} from "../rules/rulesService.js";
import {
  analyzeTaskIntent,
  type TaskIntentAnalysis,
} from "../ollama/taskIntentAnalyzer.js";
import {
  generateReliableTaskPack,
  type TaskPackGenerationDiagnostics,
} from "../ollama/taskPackGenerationReliability.js";
import {
  type TaskFileSelection,
  type SelectedTaskFileUsage,
} from "../ollama/taskFileSelector.js";
import {
  scanProjectInventory,
  type ProjectInventory,
  type ProjectInventoryFile,
  type ProjectInventoryFileKind,
} from "../scanner/projectInventoryScanner.js";
import {
  evaluateContextSelectionQuality,
  type ContextSelectionQuality,
} from "../selection/contextQuality.js";
import { isSecretLikePath } from "../selection/safetyPolicy.js";
import type { FileSelectionEvidence } from "../selection/repositorySemanticIndex.js";
import { buildExportSafeProjectMetadata } from "../taskPacks/taskPackPrivacy.js";
import { resolveTaskUnderstandingInteraction } from "../taskPacks/taskUnderstandingInteraction.js";
import {
  applySelectionEvidenceGate,
  buildTaskExecutionContractFromIntent,
  type TaskExecutionContract,
} from "../taskPacks/taskExecutionContract.js";
import {
  applyTaskClarifications


<!-- Snippet truncated. Inspect the full file before editing. -->

server/src/ollama/taskPackGenerationReliability.ts

import { z } from "zod";

import type { TaskExecutionContract } from "../taskPacks/taskExecutionContract.js";
import type { AiProviderId } from "../ai/providerService.js";
import type { FileSelectionEvidence } from "../selection/repositorySemanticIndex.js";
import { recordPerformanceCacheEvent } from "../performance/performanceTrace.js";
import { generateWithConfiguredAi } from "../ai/providerService.js";
import {
  getAppSettings,
  type AppSettings,
} from "../settings/settingsService.js";
import {
  buildGenerationCacheKey,
  getCachedGeneration,
  setCachedGeneration,
} from "./generationCache.js";
import {
  extractExplicitReplacementValue,
  hasMissingReplacementValue,
} from "./taskValueGrounding.js";

export {
  extractExplicitReplacementValue,
  type ExplicitReplacementValue,
} from "./taskValueGrounding.js";

const MAX_PROMPT_CHARS = 24_000;
const MAX_REPAIR_RESPONSE_CHARS = 8_000;
const MAX_RETRY_PROMPT_CHARS = 28_000;
const MAX_ITEM_CHARS = 600;

const REFINEMENT_ARRAY_LIMITS = {
  implementationGuidance: 10,
  constraints: 8,
  acceptanceCriteria: 10,
  verificationSteps: 10,
  finalResponseRequirements: 8,
} as const;

const POLICY_REFINEMENT_ARRAY_LIMITS = {
  implementationGuidance: 7,
  constraints: 5,
  acceptanceCriteria: 6,
  verificationSteps: 5,
  finalResponseRequirements: 4,
} as const;

const boundedLineSchema = z
  .string()
  .trim()
  .min(3)
  .max(MAX_ITEM_CHARS)
  .transform((value) => normalizeGuidanceLine(value));

export const taskPackRefinementSchema = z.object({
  implementationGuidance: z
    .array(boundedLineSchema)
    .min(1)
    .ma


<!-- Snippet truncated. Inspect the full file before editing. -->

apps/desktop/renderer/src/types/index.ts

export interface ReadinessCheck {
  key: string;
  label: string;
  passed: boolean;
  points: number;
  message: string;
}

export interface ScannerPackageSummary {
  path: string;
  name: string | null;
  scripts: Record<string, string>;
}

export interface ScannerSignals {
  packageFiles: string[];
  docs: string[];
  envExamples: string[];
  testFiles: string[];
  testConfigs: string[];
  ciFiles: string[];
  lockFiles: string[];
  configs: string[];
  directories: string[];
  commands: {
    dev: string | null;
    build: string | null;
    test: string | null;
    typecheck: string | null;
    lint: string | null;
  };
  packages: ScannerPackageSummary[];
  inventory: {
    totalFiles: number;
    totalDirectories: number;
    truncated: boolean;
    maxDepth: number;
    maxEntries: number;
  };
}

export interface ReadinessReport {
  score: number;
  checks: ReadinessCheck[];
  issues: string[];
  signals?: ScannerSignals;
}

export type TargetTool = "codex" | "cursor" | "claude" | "gemini" | "generic";

export type TemplateTaskType =
  | "general"
  | "ui"
  | "backend"
  | "fullstack"
  | "build"
  | "bugfix"
  | "refactor"
  | "docs"
  | "tests";

export type RuleCategory =
  | "general"
  | "ui"
  | "backend"
  | "bugfix"
  | "refactor"
  | "docs"
  | "tests"
  | "assets"
  | "verification";

export interface PromptTemplate {
  id: string;
  name: string;
  description: string;
  targetTool: TargetTool;
  taskType: TemplateTaskType;
  content: string;
  isBuiltin: boolean;
  createdAt?: string;
  updatedAt?: string;
}

export interface RuleItem {
  id: string;
 


<!-- Snippet truncated. Inspect the full file before editing. -->

ContextForge Assisted Notes

Task Intent Analysis

  • Source: ollama
  • Task area: backend
  • Risk level: medium
  • Intent confidence: 0.95
  • Intent tags: form-flow, backend-flow
  • Domain terms: генерации, task, pack, булево, поле, показывающее, был, refinement, получен
  • File role hints: component, state, style, api, route, service
  • Structured targets: none
  • Edit scope: target_with_supporting_context
  • Understanding readiness: ready
  • Understanding action: update
  • Understanding goal: Add a boolean field to the Task Pack generation API indicating if refinement was retrieved from cache.
  • Interpretation risk: objective
  • Change definition: bounded

Execution Contract

  • Mode: implementation
  • Implementation guidance allowed: yes
  • Required layers: backend
  • Confirmed targets: server/src/routes/taskPacks.ts
  • Proposed targets: none
  • Target evidence: server/src/ollama/taskPackGenerationReliability.ts=graph_supported, server/src/routes/taskPacks.ts=graph_supported, apps/desktop/renderer/src/types/index.ts=graph_supported
  • Implementation gate reasons: none
  • Unresolved decisions: none
  • Candidate layer coverage: backend
  • Confirmed layer coverage: backend
  • Missing confirmed layers: none
  • Missing required layers (candidate-level): none

AI File Selection

  • Source: deterministic
  • Selection origin: final-decision
  • Used fallback: no
  • Duration: 4791 ms
  • Effective task area: backend
  • Asset mode: none
  • Rejected model paths: none
  • Evidence summary: user_confirmed=0, inventory_exact=0, graph_supported=3, model_proposed=0, ranked_candidate=0

Project Inventory

  • Total files found: 261
  • Files kept in inventory: 261
  • Truncated: no

Investigation Trace

  • Trigger: Existing implementation candidates require trace verification.

  • Seeds: server/src/routes/taskPacks.ts, server/src/contextComposer/contextComposerService.ts, server/src/ollama/taskPackGenerationReliability.ts, apps/desktop/renderer/src/api/client.ts, apps/desktop/renderer/src/App.backup.txt, apps/desktop/renderer/src/components/modals/GeneratedTaskPackModal.tsx, apps/desktop/renderer/src/components/modals/GlobalSearchModal.tsx, apps/desktop/renderer/src/components/ui/Modal.tsx, apps/desktop/renderer/src/hooks/useDashboardController.ts, apps/desktop/renderer/src/i18n/index.ts, apps/desktop/renderer/src/pages/DashboardHomePage.tsx, apps/desktop/renderer/src/pages/DashboardPage.tsx

  • Inspected files: 16; edges followed: 64; hops: 1; duration: 506.6 ms; cache reused: no

  • Confirmed owner candidates: none

  • Probable owner candidates: server/src/routes/taskPacks.ts

  • Reference/display candidates: server/src/contextComposer/contextComposerService.ts, server/src/ollama/taskPackGenerationReliability.ts, apps/desktop/renderer/src/api/client.ts, apps/desktop/renderer/src/App.backup.txt, apps/desktop/renderer/src/components/modals/GeneratedTaskPackModal.tsx, apps/desktop/renderer/src/components/modals/GlobalSearchModal.tsx, apps/desktop/renderer/src/components/ui/Modal.tsx, apps/desktop/renderer/src/hooks/useDashboardController.ts

  • Unresolved trace points: Trace stopped at file limit.

  • server/src/routes/taskPacks.ts: route-owner, probable; symbols=refinement, validation, taskpackgenerationreliability, boolean, generation, taskpack, taskpackgeneration, buildstabletaskpackrefinementcacheidentity, refinementcacheidentity, taskpackrefinement

  • server/src/contextComposer/contextComposerService.ts: reference, reference; symbols=validation, boolean

  • server/src/ollama/taskPackGenerationReliability.ts: reference, reference; symbols=refinement, validation, boolean, generation, taskpackrefinementpolicydiagnostics, refinementarraylimits, policyrefinementarraylimits, taskpackrefinementschema, taskpackrefinement, refinementitems, validationissuecodes, parsedrefinement

  • apps/desktop/renderer/src/api/client.ts: reference, reference; symbols=boolean, apirequesterror, getgithubintegrationstatus, startgithubdeviceauth, pollgithubdeviceauth, signoutgithub, getprojects, addproject, rescanproject, getprojectgithubrepositorylink, initializeprojectgitrepository, setprojectgithuboriginremote, linkprojectgithubrepository, getagentspreview, saveagentsfile, getstorageaudit

  • apps/desktop/renderer/src/App.backup.txt: consumer-display, reference; symbols=project, taskpack, getscorelabel, loadprojects, loadtaskpacks, handleselectproject, handlerescanproject, handlegenerateagentspreview, handlesaveagentsfile, handlecreatetaskpack, selectedpath, readinessscore, isexpanded, classname, onclick, disabled

  • apps/desktop/renderer/src/components/modals/GeneratedTaskPackModal.tsx: consumer-display, reference; symbols=generatedtaskpackmodal, generatedtaskpackmodalprops, promptviewmode, formatduration, formatdate, gettaskpackbodylabel, gettaskpackbodydescription, infotile, handlecopyprompt, viewswitchtransition, markdownpreviewstyles, generatedprompt, bodylabel, bodydescription, classname, eyebrow

  • apps/desktop/renderer/src/components/modals/GlobalSearchModal.tsx: consumer-display, reference; symbols=globalsearchmodal, lucideicon, apppageid, globalsearchmodalprops, searchitem, normalize, getprojectstack, getresulticon, getresultkind, handlesubmitfirstresult, handlecopyworkspaceresult, inputref, normalizedquery, timeoutid, searchitems, visiblelocalresults

  • apps/desktop/renderer/src/components/ui/Modal.tsx: consumer-display, reference; symbols=boolean, reactnode, modalprops, requestclose, handlekeydown, modalexitms, maxwidth, scrollable, classname, onclick, isvisible, isclosing, timeout, eyebrow, children, onclose

  • apps/desktop/renderer/src/hooks/useDashboardController.ts: reference, reference; symbols=boolean, usedashboardcontroller, parsemultilinerules, getclarificationsignature, getblockedcontextmessage, settaskpackdraft, loadprojects, loadtaskpacks, refreshdashboard, handleselectproject, handlerescanproject, handlegenerateagentspreview, handleopenprojectcontextfile, handleregenerateagentspreview, handlesaveagentsfile, generatetaskpackfromdraft

  • apps/desktop/renderer/src/i18n/index.ts: reference, reference; symbols=applanguage, resolveapplanguage, applyapplanguage, preferences, language, resources, resolvedlanguage, checkspassed, tokengeneration, translation, addproject, scanning, refresh, refreshing, savechanges, unsaved

  • imports: server/src/routes/taskPacks.ts -> server/src/storage/index.ts

  • imports: server/src/routes/taskPacks.ts -> server/src/settings/settingsService.ts

  • imports: server/src/routes/taskPacks.ts -> server/src/rules/rulesService.ts

  • imports: server/src/routes/taskPacks.ts -> server/src/ollama/taskIntentAnalyzer.ts

  • imports: server/src/routes/taskPacks.ts -> server/src/ollama/taskPackGenerationReliability.ts

  • imports: server/src/routes/taskPacks.ts -> server/src/ollama/taskFileSelector.ts

  • imports: server/src/routes/taskPacks.ts -> server/src/selection/contextQuality.ts

  • imports: server/src/routes/taskPacks.ts -> server/src/selection/safetyPolicy.ts

  • imported_by: server/src/index.ts -> server/src/routes/taskPacks.ts

  • imported_by: server/src/ollama/taskPackGenerationReliability.smoke.ts -> server/src/routes/taskPacks.ts

Notes

  • Project inventory was collected by ContextForge before selecting files.
  • Files were selected from real inventory paths and validated before being added to this Task Pack.
  • Protected context sections were generated by the backend and restored after local AI generation.
  • Task intent source: ollama; area: backend; confidence: 0.95.
  • Structured intent: 0 primary target(s); edit scope target_with_supporting_context.
  • Task understanding: ready; action update; can proceed yes.
  • Effective task area: backend.
  • Asset mode: none.
  • File selection source: deterministic; selection origin: final-decision; selected files: 3.
  • Context quality: ready; score: 100/100.
  • Asset files were detected and kept in inventory for asset-related tasks.
  • Source files were detected.
  • Style files were detected.
  • Config files were detected.
  • Documentation files were detected.
  • Inventory includes dynamic text hints extracted from real file names and readable file contents.
  • Inventory includes generic technical file roles inferred from paths and framework conventions.
  • Selector engine version: 2026-07-16.canonical-final-decision-v1.
  • Selector safety profile: canonical-selection-gate-v1.
  • Final selection was rebuilt from API contract evidence: server/src/ollama/taskPackGenerationReliability.ts already produces cached, and server/src/routes/taskPacks.ts owns the API boundary.
  • Reuse/expose operation proven: surface the existing producer value through the API boundary instead of adding a second semantic field to the refinement payload.
  • Existing public contract retained as reference: apps/desktop/renderer/src/types/index.ts (generationcached).
  • Execution mode: implementation.
  • Confirmed 1 implementation target(s) from current user/code evidence.
  • No unconfirmed target proposal was retained.
  • Required technical layers: backend.
  • No unresolved execution decision was retained.
  • Selector prompt shortlist included 24 of 261 real inventory files and omitted 237 lower-ranked candidates.
  • No task type conflict detected.
  • No semantically weak model-selected paths were accepted.
  • All selected paths were validated against project inventory and semantic quality gates.

Agent Instructions

Use a concise implementation plan, make focused edits, and keep the final response review-friendly.

Handle the task with the smallest practical set of changes. Avoid unrelated restructuring.

Before editing:

  • Inspect the relevant file candidates and snippets provided by ContextForge.
  • Treat inspect-only files as reference context.
  • Treat asset-reference files as binary/reference context unless the task explicitly requires asset changes.
  • Use only real files from the project.
  • Keep the implementation focused on the user's actual task.

AI-refined implementation guidance

  • In server/src/routes/taskPacks.ts, modify the API handler that generates the Task Pack response to expose this new generationCached boolean field in the public API contract.
  • Ensure that the client-side type definition in apps/desktop/renderer/src/types/index.ts is updated (if necessary, though it's marked inspect-only) to reflect the presence of the generationCached field for consumers.

Constraints

  • Do not invent project files: Do not invent files, folders, APIs, scripts, dependencies, environment variables, or implementation details that are not present in the provided context.
  • Inspect before editing: Inspect the selected files and snippets before editing. If snippets are partial or truncated, inspect the full file first.
  • Focused review scope: Keep changes focused and reviewable. Do not perform unrelated rewrites, formatting sweeps, dependency changes, or architecture changes.
  • Respect inspect-only files: Files marked as inspect-only are reference context. Do not edit them unless the user explicitly changes the task scope.
  • Asset reference safety: Files marked as asset-reference or non-text context should be treated as binary/reference context unless the task explicitly requests asset replacement or asset editing.
  • No fake verification: Do not claim tests, builds, or checks were run unless they were actually run. If verification was not run, state what should be checked.

Task-specific safeguards

  • The new boolean field must be sourced from the existing cache status logic within server/src/ollama/taskPackGenerationReliability.ts.
  • Only modify the API boundary (server/src/routes/taskPacks.ts) to expose the cached status, avoiding duplication of the source value.

Known AI-Readiness Issues

  • A test script exists, but no test files or test config were detected in the scanned project paths.

Acceptance Criteria

  • The requested task is implemented using real project files only.
  • Changes are focused and do not introduce unrelated behavior.
  • The final response explains what changed and how to verify it.

Task-specific acceptance checks

  • The Task Pack generation payload in server/src/ollama/taskPackGenerationReliability.ts must include a boolean field indicating cache usage.
  • The API endpoint defined in server/src/routes/taskPacks.ts must successfully return the new generationCached boolean field when generating a Task Pack.
  • Client-side consumers relying on apps/desktop/renderer/src/types/index.ts should be able to access the generationCached field without type errors.

Verification

  • Run the existing build script if the change can affect production output.
  • If a command cannot be run, explain why and provide manual verification steps.

Suggested verification

  • Run npm run build and verify that the compilation succeeds after adding the new field.
  • Manually test the Task Pack generation API endpoint, ensuring the response payload includes a boolean value for generationCached (both true and false cases).

Expected Final Response

Return a concise final response with:

  • Files changed
  • What was changed
  • Verification performed
  • Any risks, limitations, or manual checks still needed

Additional response requirements

  • List all files modified.
  • Describe how the cache status is now exposed via the API.
  • Confirm that the new field type is correctly reported in the response schema.
  • Report any manual checks required for client integration.

ContextForge Rules & Criteria

This section is generated and validated by ContextForge. Preserve it exactly.

Selected Template

  • ID: template.codex.general
  • Name: Codex · general
  • Target tool: codex
  • Task type: general
  • Built-in: yes

Selected Rule Profile

  • ID: profile.safe-general
  • Name: Safe general task
  • Task type: general
  • Built-in: yes

Enabled Toggle Rules

  • Do not invent project files (general): Do not invent files, folders, APIs, scripts, dependencies, environment variables, or implementation details that are not present in the provided context.
  • Inspect before editing (general): Inspect the selected files and snippets before editing. If snippets are partial or truncated, inspect the full file first.
  • Focused review scope (general): Keep changes focused and reviewable. Do not perform unrelated rewrites, formatting sweeps, dependency changes, or architecture changes.
  • Respect inspect-only files (general): Files marked as inspect-only are reference context. Do not edit them unless the user explicitly changes the task scope.
  • Asset reference safety (assets): Files marked as asset-reference or non-text context should be treated as binary/reference context unless the task explicitly requests asset replacement or asset editing.
  • No fake verification (verification): Do not claim tests, builds, or checks were run unless they were actually run. If verification was not run, state what should be checked.

Custom User Rules

  • No custom user rules provided.

Acceptance Criteria Preset

  • ID: criteria.general-done
  • Name: General done
  • Task type: general

Final Acceptance Criteria

  • The requested task is implemented using real project files only.
  • Changes are focused and do not introduce unrelated behavior.
  • The final response explains what changed and how to verify it.

Created from ContextForge. Project source files stay local; this issue contains only the generated task brief.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions