orbitmap 0.4.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +73 -10
  2. package/dist/adapters/cloud.d.ts +85 -10
  3. package/dist/adapters/cloud.js +118 -17
  4. package/dist/adapters/cloud.js.map +1 -1
  5. package/dist/adapters/factory.js +7 -0
  6. package/dist/adapters/factory.js.map +1 -1
  7. package/dist/adapters/local/adapter.d.ts +47 -8
  8. package/dist/adapters/local/adapter.js +37 -17
  9. package/dist/adapters/local/adapter.js.map +1 -1
  10. package/dist/adapters/local/context.d.ts +13 -1
  11. package/dist/adapters/local/context.js +7 -2
  12. package/dist/adapters/local/context.js.map +1 -1
  13. package/dist/adapters/local/entities/documents.d.ts +18 -4
  14. package/dist/adapters/local/entities/documents.js +46 -7
  15. package/dist/adapters/local/entities/documents.js.map +1 -1
  16. package/dist/adapters/local/entities/planning.d.ts +36 -7
  17. package/dist/adapters/local/entities/planning.js +245 -39
  18. package/dist/adapters/local/entities/planning.js.map +1 -1
  19. package/dist/adapters/local/entities/tasks.d.ts +16 -7
  20. package/dist/adapters/local/entities/tasks.js +55 -42
  21. package/dist/adapters/local/entities/tasks.js.map +1 -1
  22. package/dist/adapters/local/entities/work-items.d.ts +28 -7
  23. package/dist/adapters/local/entities/work-items.js +111 -39
  24. package/dist/adapters/local/entities/work-items.js.map +1 -1
  25. package/dist/adapters/local/lists.d.ts +139 -0
  26. package/dist/adapters/local/lists.js +230 -0
  27. package/dist/adapters/local/lists.js.map +1 -0
  28. package/dist/adapters/local/rules.js +22 -0
  29. package/dist/adapters/local/rules.js.map +1 -1
  30. package/dist/adapters/local/shapes.d.ts +165 -22
  31. package/dist/adapters/local/shapes.js +338 -50
  32. package/dist/adapters/local/shapes.js.map +1 -1
  33. package/dist/adapters/local/types.d.ts +5 -0
  34. package/dist/adapters/local/types.js.map +1 -1
  35. package/dist/adapters/types.d.ts +72 -9
  36. package/dist/agent-instructions.d.ts +39 -10
  37. package/dist/agent-instructions.js +268 -68
  38. package/dist/agent-instructions.js.map +1 -1
  39. package/dist/commands/context.d.ts +62 -37
  40. package/dist/commands/context.js +105 -36
  41. package/dist/commands/context.js.map +1 -1
  42. package/dist/commands/docs.d.ts +4 -0
  43. package/dist/commands/docs.js +12 -5
  44. package/dist/commands/docs.js.map +1 -1
  45. package/dist/commands/ideas.d.ts +3 -0
  46. package/dist/commands/ideas.js +14 -7
  47. package/dist/commands/ideas.js.map +1 -1
  48. package/dist/commands/intent.d.ts +26 -0
  49. package/dist/commands/intent.js +110 -7
  50. package/dist/commands/intent.js.map +1 -1
  51. package/dist/commands/issues.d.ts +4 -0
  52. package/dist/commands/issues.js +15 -7
  53. package/dist/commands/issues.js.map +1 -1
  54. package/dist/commands/mission.d.ts +2 -0
  55. package/dist/commands/mission.js +9 -5
  56. package/dist/commands/mission.js.map +1 -1
  57. package/dist/commands/setup-agent.d.ts +34 -0
  58. package/dist/commands/setup-agent.js +95 -4
  59. package/dist/commands/setup-agent.js.map +1 -1
  60. package/dist/commands/start.d.ts +13 -0
  61. package/dist/commands/start.js +125 -13
  62. package/dist/commands/start.js.map +1 -1
  63. package/dist/commands/tasks.d.ts +23 -5
  64. package/dist/commands/tasks.js +46 -23
  65. package/dist/commands/tasks.js.map +1 -1
  66. package/dist/commands/vibes.d.ts +3 -0
  67. package/dist/commands/vibes.js +11 -5
  68. package/dist/commands/vibes.js.map +1 -1
  69. package/dist/errors.d.ts +23 -2
  70. package/dist/errors.js +31 -3
  71. package/dist/errors.js.map +1 -1
  72. package/dist/index.js +108 -36
  73. package/dist/index.js.map +1 -1
  74. package/dist/list-meta.d.ts +117 -0
  75. package/dist/list-meta.js +160 -0
  76. package/dist/list-meta.js.map +1 -0
  77. package/dist/list-options.d.ts +33 -0
  78. package/dist/list-options.js +70 -0
  79. package/dist/list-options.js.map +1 -0
  80. package/dist/workspace-resolve.d.ts +47 -1
  81. package/dist/workspace-resolve.js +74 -11
  82. package/dist/workspace-resolve.js.map +1 -1
  83. package/dist/write-target.d.ts +9 -0
  84. package/dist/write-target.js +11 -2
  85. package/dist/write-target.js.map +1 -1
  86. package/package.json +2 -2
@@ -8,18 +8,20 @@
8
8
  *
9
9
  * Pure functions only: no file I/O, no validation (that is `rules.ts`).
10
10
  */
11
- import type { AreaFile, DocumentRecord, IntentRecord, MissionRecord, TaskRecord, WorkspaceFile } from './types.js';
11
+ import type { AreaFile, DocumentRecord, IntentRecord, IssueRecord, MissionRecord, TaskRecord, WorkspaceFile } from './types.js';
12
12
  /**
13
13
  * The API splits an entity number into `task_number` (the bare code) and
14
14
  * `display_number` (`TS-<code>`); locally we store the prefixed form.
15
15
  */
16
16
  export declare function stripEntityPrefix(entityNumber: string): string;
17
- /** The implicit local agent, in the `/context` agent shape. */
17
+ /**
18
+ * The implicit local agent, in the `/context` agent shape. Since API 10.0.0 the agent
19
+ * block is a bare identity ping — the `introduction` field is gone.
20
+ */
18
21
  export declare function agentShape(): {
19
22
  id: string;
20
23
  name: string;
21
24
  slug: string;
22
- introduction: string;
23
25
  };
24
26
  /** Workspace as embedded in `areas` list items. */
25
27
  export declare function workspaceShape(workspace: WorkspaceFile): {
@@ -85,40 +87,181 @@ export declare function areaOverviewEnvelope(area: AreaFile, tasks: readonly Tas
85
87
  };
86
88
  /** Number of `##` headings in a document body (the API's `sections_count`). */
87
89
  export declare function countSections(body: string): number;
88
- /** Document entry as embedded in `/context` and task detail. */
90
+ /** Document entry as embedded in task detail (`workspace_knowledge`). */
89
91
  export declare function documentEntry(document: DocumentRecord, body: string): Record<string, unknown>;
92
+ /**
93
+ * Extract the handle-tier TL;DR from an intent/mission field — a 1:1 port of the
94
+ * provider's `App\Support\TldrParser`, so both adapters summarize identically.
95
+ *
96
+ * An explicit TL;DR is everything before the first `---` rule on its own line. Without
97
+ * a rule, the first paragraph is truncated to {@link TLDR_MAX_LENGTH} code points on a
98
+ * word boundary and flagged as `missing` (the lazy-backfill signal).
99
+ */
100
+ export declare function extractTldr(field: string | null | undefined): {
101
+ tldr: string | null;
102
+ missing: boolean;
103
+ };
104
+ /**
105
+ * `meta.more` — one entry per handle type, how to fetch deeper. Locked copy from the
106
+ * IN-vnz6fs design (the provider carries it verbatim); do not paraphrase.
107
+ */
108
+ export declare const CONTEXT_MORE: Readonly<Record<string, string>>;
109
+ /** An intent as the store hands it out: frontmatter + the body (= `outcome`). */
110
+ export interface IntentFileLike {
111
+ frontmatter: IntentRecord;
112
+ body: string;
113
+ }
114
+ /**
115
+ * The missions worth matching against: the active one, the latest closed one (recency
116
+ * of outcome context) and the next {@link CONTEXT_NEXT_MISSIONS_CAP} in manual order —
117
+ * the provider's `selectMissions`, over local records.
118
+ */
119
+ export declare function selectContextMissions(missions: readonly MissionRecord[]): MissionRecord[];
120
+ /**
121
+ * The deduped union of the provider's four mechanical intent lists, over local files.
122
+ * Deliberately NO status filter anywhere — a closed intent is valid matching context.
123
+ *
124
+ * Two local substitutions, both because the file store lacks a dimension the server has:
125
+ *
126
+ * - Lists (b) "what this agent touched last" and (d) "what anyone moved recently" are
127
+ * the same list here: intents carry no work-log tail locally (only tasks have a
128
+ * `## Work Log`, spec §4.5) and there is exactly one agent, so `updated_at` DESC is
129
+ * the closest analogue of both recency signals.
130
+ * - List (c), the backlog head, orders by `intent_number` (creation order): local
131
+ * intents have no manual `sort_order`.
132
+ */
133
+ export declare function selectContextIntents(intents: readonly IntentFileLike[], missionNumbers: readonly string[]): IntentFileLike[];
134
+ /** One `missions[]` entry: handle + outcome TL;DR. */
135
+ export declare function contextMissionEntry(mission: MissionRecord): Record<string, unknown>;
136
+ /**
137
+ * One `intents[]` entry: handle, mission, areas and the three TL;DRs. `areas` is the
138
+ * caller-resolved slug list — declared (`frontmatter.areas`) beats task-derived, both
139
+ * computed by the adapter, exactly like the provider's declared-over-derived rule.
140
+ */
141
+ export declare function contextIntentEntry(file: IntentFileLike, areas: readonly string[]): Record<string, unknown>;
142
+ /**
143
+ * `workitems[]` — standalone mission work only: tasks and issues hanging directly off
144
+ * a mission (`mission` set, `intent` null), never subtasks. Intent-linked work is
145
+ * deliberately absent — it is reached through its intent on demand.
146
+ */
147
+ export declare function contextWorkitemEntries(tasks: ReadonlyArray<{
148
+ frontmatter: TaskRecord;
149
+ area: string | null;
150
+ }>, issues: ReadonlyArray<{
151
+ frontmatter: IssueRecord;
152
+ }>): Array<Record<string, unknown>>;
153
+ /**
154
+ * `documents[]` metadata entry. `when_to_use` is the `context` column renamed on the
155
+ * wire (API 10.0.0); `scope` is always `workspace` locally — local documents belong to
156
+ * the workspace (spec §4.1), never to one area.
157
+ */
158
+ export declare function contextDocumentEntry(document: DocumentRecord): Record<string, unknown>;
90
159
  export interface ContextInput {
91
160
  workspace: WorkspaceFile;
161
+ /** The resolved context area — its presence selects the area branch of the response. */
92
162
  area?: AreaFile;
93
- activeMission?: MissionRecord | null;
94
- tasks: readonly TaskRecord[];
95
- documents: readonly Record<string, unknown>[];
163
+ missions: Array<Record<string, unknown>>;
164
+ intents: Array<Record<string, unknown>>;
165
+ workitems: Array<Record<string, unknown>>;
166
+ /** Every area of the workspace (the local "reach"), already ordered by name. */
167
+ areas: readonly AreaFile[];
168
+ documents: Array<Record<string, unknown>>;
96
169
  }
97
- /** `GET /context` envelope. */
170
+ /**
171
+ * `GET /context` envelope (API 10.0.0). Identity first — `agent`, then `area` (area
172
+ * branch) or `workspace` (workspace branch) — followed by the matching material:
173
+ * missions, intents, workitems, areas, documents metadata and `meta.more`. The old
174
+ * `tasks` / `active_mission` / `open_intents` / `agent.introduction` are gone.
175
+ */
98
176
  export declare function contextEnvelope(input: ContextInput): {
99
177
  data: Record<string, unknown>;
100
178
  };
101
179
  /**
102
- * One row of `GET /tasks`.
103
- *
104
- * `area` is present **only** in the workspace-scoped listing (no `X-Orbitmap-Area`), exactly
105
- * as the API does it: the area-scoped rows are unchanged, so nothing that reads them today
106
- * sees a new key.
180
+ * Rows per page when the caller named no `--limit`, and the ceiling one may ask for.
181
+ * Both are the API's own numbers (`LIMIT_HELP`: "Rows per page (default 30, max 100)"),
182
+ * reimplemented here because in local mode there is no server to apply them.
107
183
  */
108
- export declare function taskListItem(task: TaskRecord, description: string | null, area?: AreaFile): Record<string, unknown>;
184
+ export declare const DEFAULT_LIST_LIMIT = 30;
185
+ export declare const MAX_LIST_LIMIT = 100;
186
+ /** One area's contribution to a page: what it showed, and what it holds. */
187
+ export interface PerAreaCount {
188
+ slug: string | null;
189
+ shown: number;
190
+ total: number;
191
+ }
109
192
  /**
110
- * `GET /tasks` envelope.
193
+ * `meta.applied_filters` — the caller's question, echoed back.
111
194
  *
112
- * Area scope keeps its historical `meta: { count }` byte for byte. Workspace scope adds
113
- * `scope: 'workspace'` (the marker commands branch on) plus the workspace identity the
114
- * same two extra keys the API emits.
195
+ * ALWAYS present and ALWAYS complete: a short list must never be ambiguous between
196
+ * "nothing exists" and "you did not ask for it" (IN-nahetc). `null` means the dimension
197
+ * does not apply to this list (intents and missions have no area; only tasks have an
198
+ * assignee), never "no filter" — that is spelled `all` / `any`.
115
199
  */
116
- export declare function tasksListEnvelope(items: Array<Record<string, unknown>>, workspace?: WorkspaceFile): {
200
+ export interface AppliedListFilters {
201
+ areas: string | null;
202
+ status: string | null;
203
+ hidden_by_status: number;
204
+ assignee: string | null;
205
+ intent: string | null;
206
+ mission: string | null;
207
+ limit: number;
208
+ }
209
+ /** The list envelope every local list answers with. */
210
+ export interface ListEnvelope {
117
211
  data: Array<Record<string, unknown>>;
118
212
  meta: Record<string, unknown>;
119
- };
120
- /** The `task` block of the task-detail envelope. */
121
- export declare function taskShape(task: TaskRecord, area: AreaFile, description: string | null): Record<string, unknown>;
213
+ }
214
+ export interface ListEnvelopeInput {
215
+ /** Every row matching every filter, in list order BEFORE paging. */
216
+ rows: ReadonlyArray<Record<string, unknown>>;
217
+ workspace: WorkspaceFile;
218
+ /** Where this page starts (decoded from `cursor`). */
219
+ offset: number;
220
+ /** Rows in this page. */
221
+ limit: number;
222
+ filters: AppliedListFilters;
223
+ /**
224
+ * How to read a row's area slug for `per_area`. Omit for a list with no area dimension
225
+ * (intents, missions, and local documents, which are workspace-scoped by §4.1): `per_area`
226
+ * is then `[]`, exactly as the provider answers for `/intents` and `/missions`.
227
+ */
228
+ areaOf?: (row: Record<string, unknown>) => string | null;
229
+ }
230
+ /**
231
+ * The 9.0.0 list envelope, built once for every local list.
232
+ *
233
+ * Paging is a plain offset encoded as the opaque `next_cursor` (local mode has no keyset
234
+ * to page on, and the cursor is documented as opaque). `total` counts everything the
235
+ * filters matched, so the truncation line and `--all` behave exactly as they do against
236
+ * the API; `per_area` splits that total per area and reports how much of each is on THIS
237
+ * page.
238
+ */
239
+ export declare function listEnvelope(input: ListEnvelopeInput): ListEnvelope;
240
+ /** The area slug an area-scoped row carries in its `area` block, or `null`. */
241
+ export declare function rowAreaSlug(row: Record<string, unknown>): string | null;
242
+ /**
243
+ * One row of `GET /tasks`.
244
+ *
245
+ * Every row carries its `area` since API 9.0.0 — the list spans the whole workspace, so
246
+ * "which area is this?" has to be answerable from the row — plus `agent_id` and
247
+ * `assigned_user_id`: the list stopped being caller-only, so "mine, someone else's, or free"
248
+ * has to be answerable from the row too.
249
+ */
250
+ export declare function taskListItem(task: TaskRecord, description: string | null, area: AreaFile): Record<string, unknown>;
251
+ /**
252
+ * `GET /tasks` envelope — {@link listEnvelope} with the task defaults, kept as a named
253
+ * builder because `tasks.ts` is the only caller that needs no extra arguments.
254
+ */
255
+ export declare function tasksListEnvelope(input: ListEnvelopeInput): ListEnvelope;
256
+ /**
257
+ * The `task` block of the task-detail envelope.
258
+ *
259
+ * `logCount` feeds the freshness pair's second half (API 10.1.0): `last_log_id` is the
260
+ * id of the newest `logs[]` entry, whose ids are `<task_number>-log-<n>` (see
261
+ * {@link workLogEntryShape}) — so the newest is simply `-log-<logCount>`, or `null`
262
+ * when the task has no log yet.
263
+ */
264
+ export declare function taskShape(task: TaskRecord, area: AreaFile, description: string | null, logCount?: number): Record<string, unknown>;
122
265
  /** Compact task shape used for subtasks and dependency references. */
123
266
  export declare function taskSummary(task: TaskRecord): Record<string, unknown>;
124
267
  export interface TaskDetailInput {