Token导航 LogoToken导航TokenDH.com
研究检索只读github未标认证来源可访问许可证需确认审计通过

populationpopulation 搜索

Agent Skill

population 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

376

周安装

16

GitHub Stars

公开资料未说明

下载量

132
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:population(population 搜索)
来源仓库:https://github.com/efesto-cloud/skills
仓库路径:skills/population
安装命令:
npx skills add https://github.com/efesto-cloud/skills --skill population
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/efesto-cloud/skills --skill population

简介

population 用于查找、检索和筛选相关信息,适合根据关键词或任务场景快速定位候选结果。

  • 它能帮助 Agent 组织信息线索或缩小搜索范围,使用时需明确查询目标和筛选条件。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装,需结合原始 README 确认具体用法。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写操作。
  • population 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Population Skill

Installation: If not already installed, add the required packages:

  • pnpm add @efesto-cloud/population (for Populate type and normalizePopulate helper)
  • pnpm add @efesto-cloud/mongodb-population (for BasePopulator and QueryBuilder classes)

Adds MongoDB population support — typed eager-loading of related documents via aggregation $lookup — to an existing entity. The entity, its DTO, document type, mapper, and repository are assumed to already exist. This skill only patches them where needed and writes the population infrastructure.

Scope: Shape type, QueryBuilder, Populator, plus targeted patches to entity, DTO, document, mapper, and repository interface/implementation.

Does not: create entities or repositories from scratch, write use cases, or manage DI container wiring.


Phase 0 — Clarify Intent

If the user has not specified which entity to populate and/or which fields should be populated, use AskUserQuestion to ask:

  1. Which entity needs population?
  2. Which fields should be populatable, and for each:

- What is the source collection/entity? - Is it a single value (1:1) or an array (1:many)? - Does the related entity itself have a populator already? (nested population)

Do not proceed until you have at least the entity name and one field to populate.


Phase 1 — Discover the Project Structure

Before touching any file, orient yourself:

  1. Find the collection enum — typically src/db/CollectionNameEnum.ts or similar. You'll need the collection name constant for $lookup.
  2. Check for existing populators — browse src/repo/shape/, src/repo/populate/, src/repo/query/. If any exist, read one to match the exact import style.
  3. Read the target entitysrc/entity/FooEntity.ts
  4. Read the target DTOsrc/dto/IFoo.ts
  5. Read the target documentsrc/db/Documents/FooDocument.ts
  6. Read the target mappersrc/mapper/FooMapper.ts
  7. Read the repository interfacesrc/repo/IFooRepo.ts
  8. Read the repository implementationsrc/repo/impl/FooRepoImpl.ts

If src/repo/shape/ or src/repo/populate/ directories do not yet exist, create them.


Phase 2 — Patch Satellite Files

Patch each file only where something is actually missing. Do not rewrite files wholesale.

2a. Entity

For each populated field bar on entity Foo:

  • Props type must include an optional field for the populated value:

- 1:1 → bar: Bar | null (initialized to null in create()) - 1:many via foreign key on Bar → bars: Bar[] (initialized to [] in create())

  • create() static method — if the populated field has a meaningful default, accept it as an optional param. Typically bar is not passed to create() (it starts null/empty and is filled by the mapper after aggregation).
  • toDTO() — if the DTO has an optional bar? field, map it: bar: this.props.bar?.toDTO()?? null.
  • Getter — add get bar(): Bar | null (or Bar[]) if missing.
  • No populateBar() mutation method needed — the mapper sets the field directly after aggregation.

2b. DTO

For each populated field bar on IFoo:

  • Add bar?: IBar | null (optional — it may or may not be present depending on query).
  • For 1:many: bars?: IBar[].
  • If the DTO lives inside a namespace, add the field to the correct variant.
  • If a separate index.ts re-exports the DTO, no change needed there unless you added a new sub-type.

2c. Document

For each populated field bar on FooDocument:

  • Add bar?: BarDocument | null (always optional — absent on raw stored documents, present only after $lookup).
  • For 1:many: bars?: BarDocument[].
  • The FK reference field (bar_id: ObjectId | null) should already be present; do not add a second FK.

2d. Mapper

For each populated field bar, update FooMapper.from():

// After building the base entity:
if (doc.bar) {
    entity.props.bar = BarMapper.from(doc.bar);
}
// or for arrays:
if (doc.bars) {
    entity.props.bars = doc.bars.map(BarMapper.from);
}

The to() direction (entity → document) should not include populated fields — they are loaded, not saved, through this path.


Phase 3 — Write Population Core Files

Read the reference files before writing:

  • references/shape-example.ts — Shape types (leaf vs nested)
  • references/query-builder-example.ts — QueryBuilder with populateWith()
  • references/populator-example.ts — flat Populator (no nesting)
  • references/populator-nested-example.ts — nested Populator delegating to sub-populator

3a. Shape — src/repo/shape/FooShape.ts

// Leaf fields use `true`; fields whose related entity is also populatable use that entity's Shape type.
import type { BarShape } from './BarShape.js'; // only if Bar also has a populator

export type FooShape = {
    bar: true;           // 1:1, leaf — Bar has no further population
    items: true;         // 1:many, leaf
    baz: BazShape;       // 1:1, nested — Baz itself has populatable fields
};

3b. QueryBuilder — src/repo/query/FooQueryBuilder.ts

import { normalizePopulate, type Populate } from '@efesto-cloud/population';
import { QueryBuilder } from '@efesto-cloud/mongodb-population';
import FooDocument from '~/db/Documents/FooDocument.js';
import FooPopulator from '../populate/FooPopulator.js';
import type { FooShape } from '../shape/FooShape.js';

export default class FooQueryBuilder extends QueryBuilder<FooDocument> {
    populateWith(fields: Populate<FooShape> = {}): this {
        const normalized = normalizePopulate(fields, FooPopulator.SHAPE);
        const pipeline = FooPopulator.buildPipeline(normalized);
        this.push_populate_pipeline(pipeline);
        return this;
    }
}

3c. Populator — src/repo/populate/FooPopulator.ts

For each field:

  • 1:1 relationship (Bar lives in its own collection, Foo stores bar_id): use lookup + unwind.
  • 1:many relationship (Bar stores foo_id as FK, or Foo stores an array of IDs): use lookup only, no unwind.
  • Nested population (Bar itself has a populator): pass a sub-pipeline to the lookup. See references/populator-nested-example.ts.
import { BasePopulator, type NormalizedPopulate } from '@efesto-cloud/mongodb-population';
import CollectionNameEnum from '~/db/CollectionNameEnum.js';
import type TCollectionName from '~/db/TCollectionName.js';
import type { FooShape } from '../shape/FooShape.js';

export default class FooPopulator extends BasePopulator<FooShape, TCollectionName> {
    static readonly SHAPE: FooShape = {
        bar: true,
        items: true,
    };

    private bar(): void {
        if (!this.markPopulated('bar')) return;
        this.addStages(
            this.lookup({
                from: CollectionNameEnum.bar,   // collection name constant
                localField: 'bar_id',           // FK on Foo document
                foreignField: '_id',
                as: 'bar',
            }),
            this.unwind('bar'),                 // 1:1 — flatten array to single object
        );
    }

    private items(): void {
        if (!this.markPopulated('items')) return;
        this.addStages(
            this.lookup({
                from: CollectionNameEnum.item,
                localField: '_id',              // Foo's own _id
                foreignField: 'foo_id',         // FK on Item documents
                as: 'items',
            }),
            // No unwind — keeps the array
        );
    }

    populate(spec: NormalizedPopulate<FooShape>): this {
        if (spec.bar) this.bar();
        if (spec.items) this.items();
        return this;
    }

    static buildPipeline(spec: NormalizedPopulate<FooShape>): import('mongodb').Document[] {
        return new FooPopulator().populate(spec).build();
    }
}

Phase 4 — Patch the Repository

4a. Repository Interface — src/repo/IFooRepo.ts

Add the Options namespace with a populate field, and add options? param to every query method (save/saveMany/delete do not need it):

import type { Populate } from '@efesto-cloud/population';
import type { FooShape } from './shape/FooShape.js';

interface IFooRepo {
    search(query: IFooRepo.Search, options?: IFooRepo.Options): Promise<Foo[]>;
    get(id: ObjectId, options?: IFooRepo.Options): Promise<Maybe<Foo>>;
    findByIds(ids: ObjectId[], options?: IFooRepo.Options): Promise<Foo[]>;
    // ... other query methods
    save(entity: Foo): Promise<void>;
}

namespace IFooRepo {
    export type Options = {
        populate?: Populate<FooShape>;
    };
}

export default IFooRepo;

4b. Repository Implementation — src/repo/impl/FooRepoImpl.ts

Switch each query method to use FooQueryBuilder with .populateWith(options?.populate):

async get(id: ObjectId, options?: IFooRepo.Options): Promise<Maybe<Foo>> {
    const pipeline = new FooQueryBuilder()
        .match({ _id: id } as Filter<FooDocument>)
        .populateWith(options?.populate)
        .limit(1)
        .build();

    const results = await this.coll.aggregate<FooDocument>(
        pipeline, { session: this.db.session }
    ).toArray();

    if (results.length === 0) return Maybe.none();
    return Maybe.maybe(FooMapper.from(results[0]!));
}

Methods that already use aggregate() just need .populateWith(options?.populate) inserted into the builder chain. Methods that use findOne() or find() should be converted to aggregate() with the QueryBuilder.


Special Cases

Polymorphic entity (discriminated union)

If Foo has a type discriminator and different variants have different populatable fields:

  • The Shape can include all fields across variants: {fontFile: true; rasterFile: true; vectorFile: true;}.
  • In the populator, each private method populates only the relevant field — because $lookup on a non-existent FK just returns an empty array, which is then dropped by unwind or ignored.
  • Alternatively, if the variant shapes are completely disjoint, create separate Shape types with a union.

Nested population (the related entity also has a populator)

When Bar itself has a BarPopulator, you can pass a sub-pipeline into the $lookup:

private bar(nestedSpec: NormalizedPopulate<BarShape>): void {
    if (!this.markPopulated('bar')) return;
    const nestedPipeline = BarPopulator.buildPipeline(nestedSpec);
    this.addStages(
        this.lookup({
            from: CollectionNameEnum.bar,
            localField: 'bar_id',
            foreignField: '_id',
            as: 'bar',
            pipeline: nestedPipeline,    // <-- sub-population
        }),
        this.unwind('bar'),
    );
}

The Shape field must then be typed as BarShape (not true), and the populate() method receives spec.bar as a NormalizedPopulate<BarShape>.

$lookup with $in (Foo stores an array of IDs)

When Foo.bar_ids is an array of ObjectIds pointing to Bar documents:

this.lookup({
    from: CollectionNameEnum.bar,
    localField: 'bar_ids',   // array field on Foo
    foreignField: '_id',
    as: 'bars',
})
// No unwind — result is an array matching the IDs

Optional relationship (FK can be null)

For bar_id: ObjectId | null, the $lookup returns an empty array when FK is null. Use:

this.addStages(
    this.lookup({ from: CollectionNameEnum.bar, localField: 'bar_id', foreignField: '_id', as: 'bar' }),
    this.unwind('bar', { preserveNullAndEmptyArrays: true }),
);

Then in the mapper: entity.props.bar = doc.bar? BarMapper.from(doc.bar): null.


Phase 5 — Typecheck

Run the typecheck command for the core package then fix any errors before considering the task done.


Reference Files

  • references/shape-example.ts — Shape type examples with comments
  • references/query-builder-example.ts — Full QueryBuilder
  • references/populator-example.ts — Flat populator (leaf fields only)
  • references/populator-nested-example.ts — Populator with nested sub-population

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

39.64%
按下载量换算52

Claude

28.89%
按下载量换算38

Cursor

19.05%
按下载量换算25

Gemini CLI

10.09%
按下载量换算13

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills