@context-forge/core

中文文档
0.19.26发布于 2026/11/07MITTypeScriptES Module近 30 天下载 4426

Core context generation engine for Context Forge — template processing, project state, prompt assembly

原始使用文档
文档目录7 节
  1. Overview
  2. Export Paths
  3. @context-forge/core — Types, interfaces, and browser-safe s…
  4. @context-forge/core/node — Node.js implementations
  5. Key Services
  6. Usage in the Monorepo
  7. License

@context-forge/core

The context generation engine that powers Context Forge. Handles template processing, project state management, prompt parsing, section building, and the full context assembly pipeline.

Overview

This package contains the core logic shared by the MCP server, the CLI, and other Node.js consumers. It has no framework dependencies.

Key capabilities:

  • Context pipeline — assembles structured context prompts from project configuration, templates, and statements
  • Template processing — variable substitution ({{projectName}}, {{fileSlice}}, {fileArch}, {archIndex}, etc.) with conditional sections and artifact aliases
  • Statement management — loads and resolves default statements (project intro, tool intro, instruction blocks)
  • Prompt parsing — reads prompt.ai-project.system.md files and extracts named template sections
  • Project storage — filesystem-backed CRUD for project configuration with backup and migration support

Export Paths

The package provides two entry points to separate browser-safe code from Node.js-dependent code.

@context-forge/core — Types, interfaces, and browser-safe services

import type { ProjectData, UpdateProjectData } from '@context-forge/core';
import type { IProjectStore, IStorageService } from '@context-forge/core';
import { TemplateProcessor, SectionBuilder } from '@context-forge/core';
import { ContextGenerator, ContextIntegrator } from '@context-forge/core';
import { PROMPT_FILE_RELATIVE_PATH, DEFAULT_STATEMENTS } from '@context-forge/core';

This entry point contains no fs or path dependencies and is safe for browser/renderer contexts.

@context-forge/core/node — Node.js implementations

import { FileProjectStore, FileStorageService } from '@context-forge/core/node';
import { createContextPipeline } from '@context-forge/core/node';
import { StatementManager, SystemPromptParser } from '@context-forge/core/node';
import { ProjectPathService } from '@context-forge/core/node';
import { getStoragePath } from '@context-forge/core/node';

// Artifact introspection
import { ArtifactIntrospector } from '@context-forge/core/node';
import { buildModel, scanDirectory } from '@context-forge/core/node';
import { parseFrontmatter, parseSlicePlan } from '@context-forge/core/node';
import { parseTaskItems, parseTaskFile } from '@context-forge/core/node';
import { parseFutureWork, detectDocuments } from '@context-forge/core/node';
import { FutureWorkCollector } from '@context-forge/core/node';

This entry point includes filesystem-dependent services. Use it in main processes, CLI tools, MCP servers, and tests. Do not import from browser/renderer code.

Key Services

ServiceEntry PointDescription
FileProjectStore./nodeFilesystem-backed project CRUD (read, create, update, delete)
createContextPipeline./nodeFactory that wires up all services for a project path and returns a ready-to-use ContextIntegrator
StatementManager./nodeLoads and parses default-statements.md from a project directory
SystemPromptParser./nodeParses prompt.ai-project.system.md into named template sections
ProjectPathService./nodeResolves file paths relative to a project root (task files, slice designs, guides)
ContextIntegrator.Orchestrates full context generation from a ProjectData object
TemplateProcessor.Handles {{variable}} substitution in template strings, including artifact aliases ({arch}, {plan}, {hld}, {spec}) and index extraction ({archIndex}, {planIndex})
SectionBuilder.Assembles individual context sections (statements, instructions, tools)
ArtifactIntrospector./nodeParses methodology documents: slice plans, task files, frontmatter, future work, document detection
buildModel./nodeBuilds a full ProjectModel from a project root path — foundation, initiatives, slices, tasks, future work
FutureWorkCollector./nodeAggregates future work items across all slice plans; groups by initiative; supports status filtering

Usage in the Monorepo

packages/
  context-forge/ @context-forge/context-forge — meta-package (installs cli + mcp)
  core/          ← this package
  cli/           depends on @context-forge/core (workspace:*)
  mcp-server/    depends on @context-forge/core (workspace:*)
  electron/      depends on @context-forge/core (workspace:*)

The MCP server, CLI, and Electron app import types from @context-forge/core and Node.js services from @context-forge/core/node.

License

MIT

版本与发布记录

@context-forge/core 共发布 111 个版本,首次发布于 2026/02/24;过去 12 个月发布了 111 个版本。

版本发布日期距今
0.19.26latest2026/11/073 天前
0.19.252026/11/046 天前
0.19.242026/11/019 天前
0.19.232026/10/3011 天前
0.19.222026/10/3011 天前
0.19.212026/10/2714 天前

关于 @context-forge/core 的常见问题

@context-forge/core 是什么?

Core context generation engine for Context Forge — template processing, project state, prompt assembly

如何安装 @context-forge/core?

在项目目录运行 npm install @context-forge/core,或使用 pnpm add / yarn add / bun add。

@context-forge/core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@context-forge/core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@context-forge/core 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.18.1。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@context-forge/core 可以商用吗?

@context-forge/core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@context-forge/core 的下载量有多少?

根据 npm 官方下载统计,@context-forge/core 在 2026/10/11 – 2026/11/09 这 30 天内被下载 4,426 次,日均约 148 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@context-forge/core 还在维护吗?

最新版本 0.19.26 发布于 2026/11/07(3 天前);至今共发布 111 个版本,其中过去 12 个月发布了 111 个;首次发布于 2026/02/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。