Search by

adachsoft / project-map-prompt-function

Arkadiusz Adach

Prompt function exposing project map to prompt templates.

Package info

gitlab.com/a.adach/project-map-prompt-function

Issues

pkg:composer/adachsoft/project-map-prompt-function

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-11-30 02:59 UTC

This package is auto-updated.

Last update: 2026-11-30 01:59:51 UTC


README

A prompt-template function that makes a configured project's project map available to prompt templates as JSON. It resolves the current project from the prompt engine context and reads the map from the project's configured base path.

Features

  • Exposes the project map through the project_map prompt function.
  • Provides a compact summary through executeSummary().
  • Returns a useful response when a project has not created a map index yet.
  • Validates the project context and project base path, and reports failures through ProjectMapPromptFunctionException.

Installation

Install the package with Composer:

composer require adachsoft/project-map-prompt-function

Integration

Create the function with your project's ProjectConfigRepositoryInterface implementation, set the project_id in the prompt engine context, and register the function. Registration also associates the function with the prompt engine.

use AdachSoft\ProjectMapPromptFunction\ProjectMapPromptFunction;
use AdachSoft\ProjectConfigLib\ProjectConfigRepositoryInterface;
use AdachSoft\PromptTemplateLib\PublicApi\PromptEngineInterface;

/** @var PromptEngineInterface $engine */
/** @var ProjectConfigRepositoryInterface $projectConfigRepository */
$engine->setContextValue('project_id', 'my-project');
$engine->registerFunction(new ProjectMapPromptFunction($projectConfigRepository));

The project configuration identified by project_id must contain a non-empty base_path parameter pointing to the project root. The function is named project_map; use that name in templates according to the syntax configured for your prompt engine.

See the usage example for details about the available output and context requirements.

Requirements

  • PHP 8.3 or later.
  • Composer.

Usage

Register ProjectMapPromptFunction with the prompt engine as shown in Integration, then call project_map from a prompt template. For a complete example, see the usage example.