Skill v1.0.1
currentAutomated scan100/100+3 new
version: "1.0.1" name: knowledge-build description: "Orchestrates parallel KB generation using spatial analysis and a map-reduce architecture with incremental and feature-learning modes." allowed-tools: Bash(echo ), Bash(rp1 ), Bash(git ), Bash(jq ), Bash(wc ), Bash(mkdir ) metadata: category: knowledge is_workflow: true arcade_tracked: false workflow: run_policy: fresh identity_args: [] version: 2.2.1 tags:
- documentation
- analysis
- planning
- core
- parallel
created: 2025-10-25 updated: 2026-04-09 author: cloud-on-prem/rp1 arguments:
- name: FEATURE_ID
type: string required: false description: "Feature ID to incorporate learnings from an archived or active feature into KB" sub_agents:
- "rp1-base:kb-spatial-analyzer"
- "rp1-base:kb-concept-extractor"
- "rp1-base:kb-architecture-mapper"
- "rp1-base:kb-interaction-mapper"
- "rp1-base:kb-module-analyzer"
- "rp1-base:kb-pattern-extractor"
Knowledge Build
§ROLE: KB orchestrator. Update kbRoot, not workRoot.
§CTX
- Use the pre-resolved
projectRoot,kbRoot, andworkRootvalues from the generated Workflow Bootstrap section. - KB outputs live under
kbRoot: index.mdconcept_map.mdarchitecture.mdinteraction-model.mdmodules.mdpatterns.mdstate.jsonmeta.jsonindex.mdis orchestrator-owned. Never delegate it.state.jsonis shareable.meta.jsonis local-only and SHOULD be gitignored.- Exclude these paths from change scope and file hygiene:
node_modules/,.git/,build/,dist/,cli/dist/,target/,.next/,__pycache__/,vendor/,.venv/,.rp1/context/
§DO
- Execute immediately. No approval loop.
- Single pass. No refinement loop.
- Treat this as an orchestrator, not a wrapper.
FULLmeans wide evidence collection, not blank-slate regeneration.- When prior KB exists, section agents MUST reconcile against it, even in
FULL. - Section agents MUST also treat prior KB as incomplete and perform one explicit novelty scan for material knowledge absent from it.
- Replace all placeholders with concrete values before dispatching child agents.
- Spawn the 5 analysis agents in one parallel batch.
- Wait patiently for child agents on the critical path. Do not declare them stalled after a short wait.
- Keep user-visible output terse:
- Initial status line
- Sparse progress only when useful
- Final report or fatal error
§PROC
1. Detect Mode
- Use the pre-resolved directories. Create
kbRootif missing. - If
FEATURE_IDis non-empty:
- Set
MODE=FEATURE_LEARNING. - Search, in order:
{workRoot}/archives/features/{FEATURE_ID}{workRoot}/features/{FEATURE_ID}- If neither exists: report the checked paths, stop.
- Read:
requirements.mddesign.mdfield-notes.mdif presenttasks.md- Extract
FILES_MODIFIEDfromtasks.mdimplementation summaries.
Accept patterns like **Files**: and **Files Modified**:.
- If
FILES_MODIFIEDis empty: explain that feature learning needs a concrete file scope, stop. - Build
FEATURE_CONTEXTwith: - feature id
- feature path
- summarized requirements
- architectural decisions
- discoveries from field notes
- implementation patterns
files_modified- Set:
FILE_SCOPE=FILES_MODIFIEDFILE_DIFFS={}INITIAL_MESSAGE=Feature learning build for {FEATURE_ID}
- Else use git-driven mode:
- Read
{kbRoot}/state.jsonif it exists. - Get
CURRENT_COMMITviagit rev-parse HEAD. - If no
state.json: - Set
MODE=FULL FILE_SCOPE=[]FILE_DIFFS={}INITIAL_MESSAGE=First-time KB generation with parallel analysis (10-15 min)- Else read:
OLD_COMMIT=state.json.git_commitREPO_TYPE=state.json.repo_type // "single-project"repo_root+current_project_pathfrom{kbRoot}/meta.json- Fallback: use
state.jsonfor those local fields only ifmeta.jsonis absent - If
OLD_COMMIT == CURRENT_COMMIT: - Output
KB is up-to-date (commit {CURRENT_COMMIT}). No regeneration needed.and stop - Build scoped changed-file list:
- If
REPO_TYPE=monorepo, run diff fromrepo_rootand filter tocurrent_project_pathunless it is.or empty - Else diff the current repo normally
- Drop excluded paths and obviously irrelevant binary/media files
- If scoped change list is empty:
- Update only
git_commitinstate.json - Keep all other fields unchanged
- Output
No in-scope changes. Updated commit reference ({OLD_COMMIT} -> {CURRENT_COMMIT}).and stop - Preserve the full scoped changed-file list as the evidence frontier in both
FULLandINCREMENTAL. - Count changed files:
> 50->MODE=FULL<= 50->MODE=INCREMENTAL- If
MODE=FULL: INITIAL_MESSAGE=Large change set ({N} files). Wide reconcile (10-15 min)FILE_SCOPE=<scoped changed files>- Build
FILE_DIFFSaspath -> git diff OLD_COMMIT CURRENT_COMMIT -- path - If
MODE=INCREMENTAL: INITIAL_MESSAGE=Changes detected since last build ({OLD_COMMIT} -> {CURRENT_COMMIT}). Analyzing {N} changed files (2-5 min)FILE_SCOPE=<scoped changed files>- Build
FILE_DIFFSaspath -> git diff OLD_COMMIT CURRENT_COMMIT -- path
- Print
INITIAL_MESSAGE.
2. Spatial Analysis
- Spawn the spatial analyzer with the actual mode and changed-file frontier:
{% dispatch_agent "rp1-base:kb-spatial-analyzer" %} Use the computed build inputs from the parent orchestrator.
- MODE: actual build mode (
FULL,INCREMENTAL, orFEATURE_LEARNING) - CHANGED_FILES: actual JSON array for the scoped changed-file list when available; empty only for first-time
FULL - Task: rank files 0-5 and categorize them into
index_files,concept_files,arch_files,interaction_files,module_files - Return JSON only with:
repo_typemonorepo_projectstotal_files_scannedindex_filesconcept_filesarch_filesinteraction_filesmodule_fileslocal_meta
Do not echo placeholder tokens. {% enddispatch_agent %}
- Parse and validate the JSON.
- Fatal if:
- JSON missing
- required keys missing
- all file categories empty
- Store:
repo_typemonorepo_projectslocal_meta.repo_rootlocal_meta.current_project_path
3. Parallel Analysis
- Compute:
PATTERN_FILES = unique(concept_files + module_files)INTERACTION_FILES = unique(interaction_files)- per-agent diff subsets from
FILE_DIFFS
- Spawn all 5 analyzers in one batch:
{% dispatch_agent "rp1-base:kb-concept-extractor", background %} Use the parent-computed inputs.
- KB_ROOT={kbRoot}
- MODE: actual mode
- REPO_TYPE: actual repo type
- CONCEPT_FILES_JSON: actual JSON array
- FILE_DIFFS: actual diff subset JSON or empty object
- FEATURE_CONTEXT: actual feature context JSON or empty object
- Task: return JSON only for
concept_map.md
{% enddispatch_agent %}
{% dispatch_agent "rp1-base:kb-architecture-mapper", background %} Use the parent-computed inputs.
- KB_ROOT={kbRoot}
- MODE: actual mode
- REPO_TYPE: actual repo type
- ARCH_FILES_JSON: actual JSON array
- FILE_DIFFS: actual diff subset JSON or empty object
- FEATURE_CONTEXT: actual feature context JSON or empty object
- Task: return JSON only for
architecture.md
{% enddispatch_agent %}
{% dispatch_agent "rp1-base:kb-interaction-mapper", background %} Use the parent-computed inputs.
- KB_ROOT={kbRoot}
- MODE: actual mode
- REPO_TYPE: actual repo type
- INTERACTION_FILES_JSON: actual JSON array
- FILE_DIFFS: actual diff subset JSON or empty object
- FEATURE_CONTEXT: actual feature context JSON or empty object
- Task: return JSON only for
interaction-model.md
{% enddispatch_agent %}
{% dispatch_agent "rp1-base:kb-module-analyzer", background %} Use the parent-computed inputs.
- KB_ROOT={kbRoot}
- MODE: actual mode
- REPO_TYPE: actual repo type
- MODULE_FILES_JSON: actual JSON array
- FILE_DIFFS: actual diff subset JSON or empty object
- FEATURE_CONTEXT: actual feature context JSON or empty object
- Task: return JSON only for
modules.md
{% enddispatch_agent %}
{% dispatch_agent "rp1-base:kb-pattern-extractor", background %} Use the parent-computed inputs.
- KB_ROOT={kbRoot}
- MODE: actual mode
- REPO_TYPE: actual repo type
- PATTERN_FILES_JSON: actual JSON array
- FILE_DIFFS: actual diff subset JSON or empty object
- FEATURE_CONTEXT: actual feature context JSON or empty object
- Task: return JSON only for
patterns.md - Constraint: rendered
patterns.mdMUST stay <=150 lines
{% enddispatch_agent %}
- Wait for all 5 agents to finish.
- Parse JSON from each response.
- Failure policy:
- 0 failures: continue normally
- 1 failure: continue, but generate a placeholder section for the failed file and report partial success
- 2+ failures: do not write partial KB, stop
4. Reduce + Write
- Read needed KB templates directly from
plugins/base/skills/artifact-templates/templates/knowledge-base/(fall back torp1-base:artifact-templatesSKILL.md index if a direct path fails). - Merge analyzer output into:
concept_map.mdarchitecture.mdinteraction-model.mdmodules.mdpatterns.md
- Validate the
architecture.mdMermaid diagram viarp1-base:mermaid.
- If invalid: simplify or omit the broken diagram, do not fail the whole run for diagram syntax alone.
- Write these files first:
{kbRoot}/concept_map.md{kbRoot}/architecture.md{kbRoot}/interaction-model.md{kbRoot}/modules.md{kbRoot}/patterns.md
- Count lines for the written markdown files.
- Generate
index.mddirectly from aggregated results plus measured line counts. - Write
{kbRoot}/index.mdlast. - Write
{kbRoot}/state.jsonwith:
strategy=parallel-map-reducerepo_typemonorepo_projectsgenerated_atgit_commitfiles_analyzedlanguagesmetrics
- Write
{kbRoot}/meta.jsonwith:
repo_rootcurrent_project_path
meta.jsonis local-only. Write it, but do not register it anywhere.
§FAIL
Fatal errors:
- missing feature path
- empty
FILES_MODIFIEDin feature mode - git failure during git-driven mode
- spatial analyzer failure or invalid JSON
- template load failure
- repeated write failure
- 2+ analyzer failures
On any fatal error:
- output a concise message naming the failed phase + cause
- stop immediately
§OUT
User-visible output only:
- Initial mode/status line
- Optional high-level progress line when the run is long
- Final report
Final report must include:
- overall result:
Knowledge Base Generated SuccessfullyFeature Learnings Captured- or
Partial KB Generated - repository type
- files analyzed
- files written under
.rp1/context/ - note that this passive workflow does not register an Arcade run
- reminder: agents load KB automatically via progressive disclosure