.agents/skills/segment-create/SKILL.md
Goal
Inputs
type and docs filename (e.g., new)New)New){{.Text}})Contract
markdown skill (.github/skills/markdown/SKILL.md).Implementation steps
src/segments/<id>.gopackage segments
import (
"github.com/jandedobbeleer/oh-my-posh/src/segments/options"
"github.com/jandedobbeleer/oh-my-posh/src/runtime"
)
type {{goType}} struct {
Base
// computed fields used in template
Text string
}
// properties
const (
{{#each properties}}
// {{this.title}}: {{this.description}}
{{ pascalCase this.key }} options.Property = "{{this.key}}"
{{/each}})
func (s *{{goType}}) Enabled() bool {
// set up data for the template, using defaults from properties
{{#if (propExists properties "text")}}
s.Text = s.props.GetString({{ pascalCase "text" }}, {{ defaultFor "text" }})
{{else}}
s.Text = s.props.GetString({{ pascalCase (firstKey properties) }}, "")
{{/if}}
return true
}
func (s *{{goType}}) Template() string {
return {{ printf "%q" template }}
}
src/config/segment_types.goinit() there is gob.Register(&segments.{{goType}}{}) exactly
once.{{ upper id }} SegmentType = "{{id}}" in the alphabetical
block.var Segments = map[SegmentType]func() SegmentWriter{} with key
{{ upper id }} mapping to &segments.{{goType}}{}.segment-docs skill (.github/skills/segment-docs/SKILL.md) for the
Go-to-documentation type mapping and rules for extracting options and template properties.website/docs/segments/{{category}}/{{id}}.mdx.---
id: {{id}}
title: {{title}}
sidebar_label: {{title}}
---
## What
{{description}}
## Sample Configuration
import Config from '@site/src/components/Config.js';
<Config data={{
"type": "{{id}}",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#193549",
"background": "#ffeb3b",
"options": {
{{#each option}}
"{{this.key}}": {{ json this.default }},
{{/each}}
}
}}/>
## Options
| Name | Type | Description | Default |
| ---- | ---- | ----------- | ------- |
{{#each option}}| `{{this.key}}` | `{{this.type}}` | {{this.description}} | `{{ stringify this.default }}` |
{{/each}}
website/sidebars.js under the correct category array to include
"segments/{{category}}/{{id}}".themes/schema.json."{{id}}" to #/definitions/segment/properties/type/enum if missing.allOf entry for this segment guarded by
{ properties: { type: { const: "{{id}}" } } } that declares each property
as defined by inputs. Use appropriate JSON Schema types and include title,
description, default.allOf array in a stable order by type name if feasible; otherwise
append if not present.Validation
go build (task: build oh-my-posh). Ensure no compile
errors.Notes
Optional
src/segments/{{id}}_test.go using the
table-driven style. Include at least a happy-path test that asserts
Enabled() returns true and the template renders expected output with default
options.