Documentation
¶
Overview ¶
Package export sends an orch project's work out to another tracker.
It is `orch sync` in the other direction, and deliberately a separate verb: sync reads a tracker and writes tasks.json, and promises never to write to the tracker. Export reads tasks and writes to the tracker, and never writes to tasks.json or the state database.
Imports model and graph. The tasks it receives are already hydrated by the caller (internal/cli, rule 30), so it never opens the database itself.
Multica ¶
Everything this file assumes about Multica was read from its source, not from its docs or guessed (github.com/multica-ai/multica):
- server/cmd/multica/cmd_issue.go: `issue create` takes --title, --description-stdin, --status, --parent (an issue id or key), --stage (>=1, only meaningful under a parent) and --project, and prints the created issue as JSON by default (`id`, `identifier`, …). `issue list --output json` prints {"issues": [...], "has_more": bool}, pages with --limit (1..100) and --offset, and --fields narrows each issue to named keys (id, identifier and description among them).
- server/internal/service/builtin_skills/multica-platform/references/ issues.md: a sub-issue created in `todo` enqueues its agent at once, `backlog` parks it; stages are barrier groups whose completion wakes the parent's assignee, and promoting the next stage is left to whoever reads the sub-issues' descriptions.
- server/internal/service/issue.go: creating an issue whose (workspace, project, parent, title) matches an active one is refused with 409, so a blind re-run would fail rather than duplicate — the markers below are what make a re-run skip instead.
- server/cmd/multica/cmd_agent.go: without a workspace the CLI says to run `multica config set workspace_id <id>`; server/cmd/multica/main.go exits non-zero with the message on stderr.
The mapping, and what it loses ¶
Multica has no issue dependencies, only sub-issues grouped into ordered stages under a parent. So each orch phase becomes one parent issue, each task a sub-issue of its phase's parent, and a task's stage is its depth in the dependency graph restricted to what this export creates in that phase. A stage is coarser than a DAG: stage 3 waits for all of stage 2, not only for the tasks it depends on. The exact dependencies go into each sub-issue's description, which is what Multica's own guide says to read before promoting one.
Everything is created in `backlog`, so nothing Multica runs starts on its own.
Index ¶
- Constants
- Variables
- func IsNotFound(err error) bool
- func PhaseTitles(projectRoot, specRoot string, tasks []model.Task) (map[int]string, error)
- func SumSpend(rows []state.Spend) map[string]TaskSpend
- func TaskTitle(t model.Task) string
- type Action
- type ActionKind
- type ClickUp
- type ClickUpClient
- type ClickUpError
- type ClickUpPhase
- type ClickUpPlan
- type Created
- type IssueRef
- type Multica
- type MulticaError
- type MulticaPhase
- type MulticaPlan
- type MulticaTask
- type Runner
- type Selection
- type Summary
- type TaskSpend
Constants ¶
const ClickUpAPIURLEnv = "ORCH_CLICKUP_API_URL"
ClickUpAPIURLEnv overrides ClickUp's API base URL. Tests point it at a fake.
const ClickUpTokenEnv = "CLICKUP_TOKEN"
ClickUpTokenEnv holds the personal API token when no --token-file is given.
const DefaultClickUpAPIURL = "https://api.clickup.com/api/v2"
DefaultClickUpAPIURL is ClickUp's REST API v2.
const LossNote = "Multica has no issue dependencies, only ordered stages under a parent. " +
"A task's stage is its dependency depth, so it waits for the whole previous stage, " +
"not only for its own dependencies; the exact dependencies are in each sub-issue's description."
LossNote is printed once per export: the one thing about the mapping an operator must know before trusting Multica's order.
const MulticaBinary = "multica"
MulticaBinary is the CLI export shells out to.
Variables ¶
var DefaultClickUpStatuses = map[model.Status]string{ model.StatusBacklog: "backlog", model.StatusTodo: "to do", model.StatusInProgress: "in progress", model.StatusBlocked: "blocked", model.StatusDone: "complete", }
DefaultClickUpStatuses is the status each orch status is mirrored as. The names are ClickUp's defaults plus the two orch needs that ClickUp does not ship (backlog, blocked); --status-map overrides any of them.
Functions ¶
func IsNotFound ¶
IsNotFound reports whether err is the multica CLI missing from PATH.
func PhaseTitles ¶
PhaseTitles reads each phase's title from the `# F<n> — <title>` header of the specs its tasks point at (project.SpecOutline). tasks.json keeps no phase names, and "F1" in a tracker says nothing to the people reading it there. A phase with no title falls back to "F<n>" at the call site.
Types ¶
type Action ¶
type Action struct {
Kind ActionKind
Phase int
TaskID string
// Detail is the human part: a list name, "to do → in progress", a field
// name, a dependency id.
Detail string
URL string
}
Action is one step, reported as it happens.
type ActionKind ¶
type ActionKind string
ActionKind names what the mirror did (or, in a dry run, would do).
const ( ActionCreateList ActionKind = "create-list" ActionCreateTask ActionKind = "create-task" ActionMoveStatus ActionKind = "status" ActionSetField ActionKind = "field" ActionDependency ActionKind = "dependency" ActionUnchanged ActionKind = "unchanged" ActionListUnknown ActionKind = "list-pending" ActionMissingState ActionKind = "missing-status" // ActionFieldSkipped is a custom field ClickUp refused to write (a plan's // custom-field quota, a field type it will not take). Fields are optional, // so the mirror warns, stops writing that field for the rest of the run and // carries on with statuses, comments and dependencies. ActionFieldSkipped ActionKind = "field-skipped" )
type ClickUp ¶
type ClickUp struct {
FolderID string
Client *ClickUpClient
// Statuses maps each orch status to a ClickUp status name.
Statuses map[model.Status]string
DryRun bool
}
ClickUp is one destination: a Folder, and how orch statuses are named there.
type ClickUpClient ¶
type ClickUpClient struct {
BaseURL string
Token string
HTTP *http.Client
// Sleep waits; tests replace it so a rate-limit wait costs nothing.
Sleep func(context.Context, time.Duration) error
// Now is the clock rate-limit resets are measured against.
Now func() time.Time
}
ClickUpClient is a minimal ClickUp REST client.
func NewClickUpClient ¶
func NewClickUpClient(baseURL, token string) *ClickUpClient
NewClickUpClient builds a client for baseURL ("" means ClickUp's own).
type ClickUpError ¶
ClickUpError is an answer from ClickUp that was not a success.
func (*ClickUpError) Error ¶
func (e *ClickUpError) Error() string
type ClickUpPhase ¶
ClickUpPhase is one List and the tasks in it.
type ClickUpPlan ¶
type ClickUpPlan struct {
ProjectID string
SpecRoot string
// Language is the language descriptions and comments are written in:
// en, es or pt (anything else falls back to en).
Language string
// TimeoutMultiplier turns an estimate into the time orch lets an attempt
// run, which the description states.
TimeoutMultiplier float64
Phases []ClickUpPhase
// Packages maps "<phase>.<package>" to the package title from the specs
// (project.SpecOutline), for the Package field and the description.
Packages map[string]string
// All is every task in tasks.json, selected or not, by id: descriptions
// name a dependency by its title even when it is outside the selection.
All map[string]model.Task
// Spend is the summed spend per task id.
Spend map[string]TaskSpend
}
ClickUpPlan is the project as it will be mirrored: every selected task, grouped by phase, with what the descriptions and comments need to know.
func PlanClickUp ¶
func PlanClickUp(projectID, specRoot string, tasks []model.Task, sel Selection, outline project.Outline) (ClickUpPlan, error)
PlanClickUp groups the selected tasks by phase. Done tasks are kept: a mirror shows finished work too. tasks must be hydrated (rule 30), since the status is what gets mirrored.
func (ClickUpPlan) Empty ¶
func (p ClickUpPlan) Empty() bool
Empty reports whether the plan selects nothing.
func (ClickUpPlan) PackageLabel ¶
func (p ClickUpPlan) PackageLabel(taskID string) string
PackageLabel is "F0.6 — core identity" for F0.6.T2, "F0.6" when the spec names no title, and "" for an id outside the atomizer's scheme.
func (ClickUpPlan) PhaseContent ¶
func (p ClickUpPlan) PhaseContent(ph ClickUpPhase) string
PhaseContent is a phase List's description.
func (ClickUpPlan) StatusComment ¶
func (p ClickUpPlan) StatusComment(t model.Task, from, to string) string
StatusComment is the comment left when the mirror moves a task: what happened, the latest note orch recorded for it, and what it has cost. ClickUp comments are plain text, so no markdown here.
func (ClickUpPlan) TaskDescription ¶
func (p ClickUpPlan) TaskDescription(t model.Task) string
TaskDescription is a task's ClickUp description, in markdown.
type Created ¶
type Created struct {
// TaskID is the orch task id, or "" for a phase parent.
TaskID string
Phase int
Stage int
Title string
Ref IssueRef
}
Created is one issue an Apply made.
type IssueRef ¶
IssueRef is a Multica issue as the CLI names it: the UUID `--parent` resolves, and the human key (`MUL-123`) people read.
type Multica ¶
type Multica struct {
// Project is the Multica project (id or key) passed as --project, or ""
// for none.
Project string
Run Runner
}
Multica is one Multica destination: which project issues go into, and how the CLI is run.
func (Multica) Apply ¶
Apply creates, in order, every parent and sub-issue plan does not already have: each phase's parent first, then its sub-issues stage by stage, so a parent exists before its children and a dependency's key is known before the description that names it is written.
It stops at the first failure. What was created before it stays, and onCreate has already reported it; the markers make the next run pick up where this one stopped rather than duplicate.
type MulticaError ¶
type MulticaError struct {
// Reason is "not found in PATH" or "exited non-zero".
Reason string
Args []string
Stderr string
Err error
}
MulticaError is a multica invocation that did not produce an answer.
func (*MulticaError) Error ¶
func (e *MulticaError) Error() string
func (*MulticaError) Unwrap ¶
func (e *MulticaError) Unwrap() error
type MulticaPhase ¶
type MulticaPhase struct {
Number int
Title string
Existing *IssueRef
Tasks []MulticaTask
}
MulticaPhase is one parent issue and the sub-issues under it.
type MulticaPlan ¶
type MulticaPlan struct {
// ProjectID namespaces the markers, so two orch projects exporting into
// one Multica workspace (both with an F1.1.T1) never mistake each other's
// issues for their own.
ProjectID string
// SpecRoot is prefixed to a task's specRef in its description.
SpecRoot string
Phases []MulticaPhase
// SkippedDone are tasks left out because orch already has them done.
SkippedDone []string
// Keys maps an orch task id to the Multica key of its issue, for every
// task whose issue exists already or has been created by this run. The
// descriptions read it to name dependencies by their Multica key.
Keys map[string]string
}
MulticaPlan is everything an export would create, worked out before any call to Multica is made that writes. `--dry-run` prints it; a real run prints the same thing and then walks it.
func PlanMultica ¶
func PlanMultica(projectID, specRoot string, tasks []model.Task, sel Selection, phaseTitles map[int]string) (MulticaPlan, error)
PlanMultica works out the parents, sub-issues and stages for tasks.
tasks must be hydrated (rule 30): a task's done-ness decides whether it is exported, and tasks.json's own status stopped being the real one at F-12. A dependency cycle is refused outright — no depth can be assigned to a task on a cycle, and Multica would be handed an order nobody can follow.
func (MulticaPlan) Empty ¶
func (p MulticaPlan) Empty() bool
Empty reports whether the plan has nothing in it at all.
func (MulticaPlan) PhaseDescription ¶
func (p MulticaPlan) PhaseDescription(ph MulticaPhase) string
PhaseDescription is the body of a phase's parent issue.
func (MulticaPlan) TaskDescription ¶
func (p MulticaPlan) TaskDescription(t MulticaTask) string
TaskDescription is the body of a task's sub-issue: the task's own description, then what orch knows about it that Multica has no field for.
type MulticaTask ¶
type MulticaTask struct {
Task model.Task
Stage int
// Existing is set when an issue carrying this task's marker is already
// in Multica; such a task is skipped, never updated.
Existing *IssueRef
}
MulticaTask is one sub-issue.
type Runner ¶
Runner runs one multica invocation with stdin and returns its stdout. The default is NewExecRunner; tests substitute a function.
func NewExecRunner ¶
NewExecRunner runs the multica binary for real: in dir, in its own process group, under a deadline (checklist rule 18).
type Selection ¶
type Selection struct {
// Phases, when non-empty, keeps only tasks in these phases.
Phases []int
// Only, when set, is a glob on the task id — the same `*`, `?`, `[...]`
// `orch run --only` accepts. A malformed pattern matches nothing.
Only string
}
Selection narrows which tasks are exported. The zero value exports every task that is not done.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package clickuptest is an in-memory ClickUp REST API for tests: the subset of endpoints internal/export uses, with the same request and answer shapes.
|
Package clickuptest is an in-memory ClickUp REST API for tests: the subset of endpoints internal/export uses, with the same request and answer shapes. |