@installagent/sdk 0.10.0 → 0.11.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.
- package/dist/agent-templates.js +1 -1
- package/dist/client-drift.d.ts +6 -0
- package/dist/client-drift.js +30 -28
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/roadmap-migrate.d.ts +75 -0
- package/dist/roadmap-migrate.js +328 -0
- package/dist/roadmap-retire.d.ts +61 -0
- package/dist/roadmap-retire.js +416 -0
- package/dist/template-sync.d.ts +38 -11
- package/dist/template-sync.js +88 -21
- package/package.json +1 -1
- package/templates/workspace-root/skills/client-latest/SKILL.md +1 -1
- package/templates/workspace-root/skills/engagement-spec/SKILL.md +47 -21
- package/templates/workspace-root/skills/engagement-spec/references/spec-templates.md +40 -17
- package/templates/workspace-root/skills/ia-cli/SKILL.md +1 -0
- package/templates/workspace-root/skills/linear/SKILL.md +32 -0
- package/templates/workspace-root/skills/tech-call-prep/SKILL.md +7 -3
package/dist/agent-templates.js
CHANGED
|
@@ -373,7 +373,7 @@ export async function createFromAgentTemplate(input, opts = {}) {
|
|
|
373
373
|
throw new Error(`No template "${input.template}" in the bank (${source}). Known: ${known}.`);
|
|
374
374
|
}
|
|
375
375
|
if (input.client !== undefined && !CLIENT_SLUG.test(input.client)) {
|
|
376
|
-
throw new Error(`--client "${input.client}" is not a slug (lowercase letters, digits and hyphens, e.g.
|
|
376
|
+
throw new Error(`--client "${input.client}" is not a slug (lowercase letters, digits and hyphens, e.g. acme-hvac).`);
|
|
377
377
|
}
|
|
378
378
|
const workflow = applyClientDefaults(JSON.parse(json), {
|
|
379
379
|
template: input.template,
|
package/dist/client-drift.d.ts
CHANGED
|
@@ -87,6 +87,12 @@ export interface ClientDriftOptions {
|
|
|
87
87
|
/** Linear API key; defaults to $LINEAR_API_TOKEN. */
|
|
88
88
|
linearToken?: string;
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* The day client-template's repo-lint rule 20 starts: from then on, a log
|
|
92
|
+
* entry's Follow-ups is `none` or INS ids only (owed work, never shipped work).
|
|
93
|
+
* Mirrors FOLLOWUPS_INS_FROM in client-template/ci/repo-lint.mjs.
|
|
94
|
+
*/
|
|
95
|
+
export declare const FOLLOWUPS_INS_FROM = "2026-11-08";
|
|
90
96
|
/**
|
|
91
97
|
* Compare one client repo (or every one) with n8n, git, Linear and its own lint.
|
|
92
98
|
* Never throws for a source it cannot read: the source goes into
|
package/dist/client-drift.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// `ci/repo-lint.mjs`. It never writes a file, never runs a workflow, and never
|
|
19
19
|
// changes anything on n8n, GitHub or Slack. `postClientDriftReport` is the one
|
|
20
20
|
// write in this module, and only the CLI's `--post` calls it.
|
|
21
|
-
import { existsSync,
|
|
21
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
22
22
|
import { join, resolve } from "node:path";
|
|
23
23
|
import { checkAgentMirror, fetchLiveWorkflows } from "./agent-mirror.js";
|
|
24
24
|
import { parseLinearProjectSlugId } from "./client-linear.js";
|
|
@@ -28,10 +28,10 @@ import { gitStatus } from "./git.js";
|
|
|
28
28
|
import { findProjectBySlugId, LINEAR_API_TOKEN_ENV, LinearAuthError, linearProjectIssueStates, } from "./linear-project.js";
|
|
29
29
|
import { listN8nExecutions } from "./n8n-executions.js";
|
|
30
30
|
import { parseBuildsManifest } from "./portal-sync-builds.js";
|
|
31
|
+
import { selectClientSlugs } from "./template-sync.js";
|
|
31
32
|
/** An active scheduled workflow with no run in this many days is silent. */
|
|
32
33
|
export const CLIENT_DRIFT_SILENCE_DAYS = 7;
|
|
33
34
|
const DAY_MS = 86_400_000;
|
|
34
|
-
const SLUG = /^[a-z0-9][a-z0-9-]*$/;
|
|
35
35
|
/** "(SHADOW)", "TEST run", "[test]" — but not "cardfee-test", a keyword inside a word. */
|
|
36
36
|
const STALE_NAME = /(?:^|[\s([])(shadow|test)(?=$|[\s)\]:,.!-])/i;
|
|
37
37
|
/** A repo-lint drift warning: `⚠ rule 16 — <message>`. Rules 12+ are the drift rules. */
|
|
@@ -43,27 +43,6 @@ const SLACK_LINES_PER_CLIENT = 12;
|
|
|
43
43
|
const message = (error) => (error instanceof Error ? error.message : String(error));
|
|
44
44
|
const short = (text, max) => text.length > max ? `${text.slice(0, max - 1)}…` : text;
|
|
45
45
|
const days = (ms) => ms / DAY_MS;
|
|
46
|
-
function clientSlugs(workspaceDir, options) {
|
|
47
|
-
if (Boolean(options.slug) === Boolean(options.all)) {
|
|
48
|
-
throw new Error("client-drift needs a slug or --all (one of them, not both)");
|
|
49
|
-
}
|
|
50
|
-
const clientsDir = join(workspaceDir, "clients");
|
|
51
|
-
if (options.all) {
|
|
52
|
-
if (!existsSync(clientsDir))
|
|
53
|
-
return [];
|
|
54
|
-
return readdirSync(clientsDir, { withFileTypes: true })
|
|
55
|
-
.filter((e) => e.isDirectory() && e.name.startsWith("client-") && e.name !== "client-template")
|
|
56
|
-
.map((e) => e.name.slice("client-".length))
|
|
57
|
-
.sort();
|
|
58
|
-
}
|
|
59
|
-
const slug = String(options.slug).replace(/^client-/, "");
|
|
60
|
-
if (!SLUG.test(slug))
|
|
61
|
-
throw new Error(`"${options.slug}" is not a client slug (kebab-case, e.g. best-materials)`);
|
|
62
|
-
if (!existsSync(join(clientsDir, `client-${slug}`))) {
|
|
63
|
-
throw new Error(`no checkout at clients/client-${slug} under ${workspaceDir}`);
|
|
64
|
-
}
|
|
65
|
-
return [slug];
|
|
66
|
-
}
|
|
67
46
|
/** owner/repo of a GitHub remote URL (https or ssh), or null. */
|
|
68
47
|
function githubRepo(remote) {
|
|
69
48
|
const match = /github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/.exec(remote.trim());
|
|
@@ -294,11 +273,20 @@ const saysShipped = (heading) => SHIPPED_WORDS.test(heading) && !NOT_SHIPPED.tes
|
|
|
294
273
|
const LOG_HEADING = /^##\s+(\d{4}-\d{2}-\d{2})\b\s*(.*)$/;
|
|
295
274
|
const ISSUE_TOKEN = /\b[A-Z][A-Z0-9]{1,9}-\d+\b/g;
|
|
296
275
|
const CLOSED_STATES = new Set(["completed", "canceled", "duplicate"]);
|
|
276
|
+
const FOLLOW_UPS_FIELD = /^-\s+\*\*Follow-ups?:\*\*/i;
|
|
277
|
+
const INDENTED = /^[ \t]+\S/;
|
|
278
|
+
/**
|
|
279
|
+
* The day client-template's repo-lint rule 20 starts: from then on, a log
|
|
280
|
+
* entry's Follow-ups is `none` or INS ids only (owed work, never shipped work).
|
|
281
|
+
* Mirrors FOLLOWUPS_INS_FROM in client-template/ci/repo-lint.mjs.
|
|
282
|
+
*/
|
|
283
|
+
export const FOLLOWUPS_INS_FROM = "2026-11-08";
|
|
297
284
|
/** Dated delivery-log entries. Fenced examples are skipped. */
|
|
298
285
|
function logEntries(log) {
|
|
299
286
|
const entries = [];
|
|
300
287
|
let current = null;
|
|
301
288
|
let fenced = false;
|
|
289
|
+
let inFollowUps = false;
|
|
302
290
|
for (const line of log.split("\n")) {
|
|
303
291
|
if (/^\s*```/.test(line)) {
|
|
304
292
|
fenced = !fenced;
|
|
@@ -309,15 +297,19 @@ function logEntries(log) {
|
|
|
309
297
|
const heading = LOG_HEADING.exec(line);
|
|
310
298
|
if (heading) {
|
|
311
299
|
const text = heading[2].replace(/^[—–-]\s*/, "").trim();
|
|
312
|
-
current = { date: heading[1], heading: text, tokens: new Set() };
|
|
300
|
+
current = { date: heading[1], heading: text, tokens: new Set(), followUps: new Set() };
|
|
313
301
|
entries.push(current);
|
|
314
302
|
}
|
|
315
303
|
else if (/^##\s/.test(line)) {
|
|
316
304
|
current = null;
|
|
317
305
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
306
|
+
inFollowUps = FOLLOW_UPS_FIELD.test(line) || (inFollowUps && INDENTED.test(line));
|
|
307
|
+
if (!current)
|
|
308
|
+
continue;
|
|
309
|
+
// A rule-20 follow-up is owed work: it must not count as the entry naming the issue.
|
|
310
|
+
const into = inFollowUps && current.date >= FOLLOWUPS_INS_FROM ? current.followUps : current.tokens;
|
|
311
|
+
for (const match of line.matchAll(ISSUE_TOKEN))
|
|
312
|
+
into.add(match[0]);
|
|
321
313
|
}
|
|
322
314
|
return entries;
|
|
323
315
|
}
|
|
@@ -331,6 +323,11 @@ function linearRows(issues, entries, now, add) {
|
|
|
331
323
|
if (known.has(token))
|
|
332
324
|
namedBy.set(token, [...(namedBy.get(token) ?? []), entry]);
|
|
333
325
|
}
|
|
326
|
+
for (const id of entry.followUps) {
|
|
327
|
+
if (known.has(id) || !id.startsWith("INS-"))
|
|
328
|
+
continue;
|
|
329
|
+
add("linear", "check", id, `delivery log ${entry.date}: Follow-ups names ${id}`, "Linear: not in this client's Linear project", "Fix the id in the entry, or move the issue into this client's project (a Linear write: the account owner does it).");
|
|
330
|
+
}
|
|
334
331
|
}
|
|
335
332
|
for (const issue of issues) {
|
|
336
333
|
const naming = namedBy.get(issue.identifier) ?? [];
|
|
@@ -407,7 +404,7 @@ function linearReader(options) {
|
|
|
407
404
|
*/
|
|
408
405
|
export async function clientDrift(options) {
|
|
409
406
|
const workspaceDir = resolve(options.workspaceDir ?? ".");
|
|
410
|
-
const slugs =
|
|
407
|
+
const { slugs, adhoc } = selectClientSlugs(workspaceDir, options, "client-drift");
|
|
411
408
|
const now = (options.now ?? (() => new Date()))();
|
|
412
409
|
const silenceDays = options.silenceDays ?? CLIENT_DRIFT_SILENCE_DAYS;
|
|
413
410
|
const execFileImpl = options.execFileImpl ?? execFileAsync;
|
|
@@ -478,6 +475,11 @@ export async function clientDrift(options) {
|
|
|
478
475
|
"Read-only: GET /workflows and GET /executions (status only, never run data); Linear GraphQL queries (never a mutation); git status/log/remote; gh pr list; the repo's own ci/repo-lint.mjs. Nothing was written.",
|
|
479
476
|
`Silence: an active scheduled workflow with no run in ${silenceDays} days. n8n keeps only its newest ~10,000 runs, so "no run kept" is drift only when the kept window is at least that long.`,
|
|
480
477
|
"`check` rows are prompts for a person; only `drift` rows (and unread sources) fail the run.",
|
|
478
|
+
...(adhoc.length > 0
|
|
479
|
+
? [
|
|
480
|
+
`Skipped ad hoc repos (not official Install Agent projects; name one to check it): ${adhoc.join(", ")}.`,
|
|
481
|
+
]
|
|
482
|
+
: []),
|
|
481
483
|
],
|
|
482
484
|
};
|
|
483
485
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { type AgentBankOptions, type AgentTemplateInfo, type AgentTemplateMatch,
|
|
|
4
4
|
export { CLAUDE_CONFIG_DIR_ENV, type ClaudeHoursExportOptions, type ClaudeHoursExportResult, type ClaudeHoursSummaryRow, compactClaudeHoursExport, type DeliverClaudeHoursExportOptions, type DeliverClaudeHoursExportResult, deliverClaudeHoursExport, exportClaudeHours, HOURS_EXPORT_DIR, HOURS_EXPORT_SCHEMA, HOURS_EXPORT_SECRET_ENV, HOURS_EXPORT_SECRET_HEADER, HOURS_EXPORT_WEBHOOK_URL, PROMPT_WINDOW_MINUTES, parseLedgerDate, parseMinuteIso, type SaveClaudeHoursExportOptions, type SendClaudeHoursExportOptions, saveClaudeHoursExport, sendClaudeHoursExport, TOOL_INPUT_PATH_KEYS, UNATTRIBUTED_SLUG, } from "./claude-hours.js";
|
|
5
5
|
export { ClientBuildAuthError, type ClientBuildDoc, type ClientBuildOptions, type ClientBuildResult, clientBuild, GITHUB_API_TOKEN_ENV, } from "./client-build.js";
|
|
6
6
|
export { type ClientCall, type ClientContextOptions, type ClientContextResult, clientContext, } from "./client-context.js";
|
|
7
|
-
export { CLIENT_DRIFT_SILENCE_DAYS, type ClientDriftClient, type ClientDriftOptions, type ClientDriftResult, clientDrift, type DriftCheck, type DriftFinding, type DriftLevel, formatClientDriftSlack, type PostClientDriftOptions, type PostClientDriftResult, postClientDriftReport, type RepoStatusInfo, type StatusFn, } from "./client-drift.js";
|
|
7
|
+
export { CLIENT_DRIFT_SILENCE_DAYS, type ClientDriftClient, type ClientDriftOptions, type ClientDriftResult, clientDrift, type DriftCheck, type DriftFinding, type DriftLevel, FOLLOWUPS_INS_FROM, formatClientDriftSlack, type PostClientDriftOptions, type PostClientDriftResult, postClientDriftReport, type RepoStatusInfo, type StatusFn, } from "./client-drift.js";
|
|
8
8
|
export { AIRTABLE_API_TOKEN_ENV, buildAssertionClaims, ClientDriveAuthError, type ClientDriveDoc, type ClientDriveSearchOptions, type ClientDriveSearchResult, clientDriveSearch, GOOGLE_SERVICE_ACCOUNT_KEY_ENV, parseServiceAccountKey, } from "./client-drive.js";
|
|
9
9
|
export { ClientIntakeAuthError, type ClientIntakeInput, type ClientIntakeOptions, type ClientIntakeResult, type ClientIntakeStep, clientIntake, LINEAR_CLIENT_TEAM_ID_ENV, } from "./client-intake.js";
|
|
10
10
|
export { ClientLinearAuthError, type ClientLinearProjectOptions, clientLinearProject, parseLinearProjectSlugId, type ResolvedClientLinearProject, resolveClientLinearProject, } from "./client-linear.js";
|
|
@@ -42,10 +42,12 @@ export { detectPlatform, detectPlatformInfo, detectShell, opNeedsAnotherShell, t
|
|
|
42
42
|
export { DEFAULT_PORTAL_URL, PORTAL_ADMIN_SECRET_ENV, PORTAL_BUILD_TYPES, PORTAL_PASSWORD_WARNING, PORTAL_SYNC_MAX_DAYS, PORTAL_URL_ENV, type PortalAddUserInput, type PortalAddUserResult, PortalAdminAuthError, type PortalAdminOptions, type PortalAgent, type PortalAgentSyncRow, type PortalBuild, type PortalBuildType, type PortalCreateAgentInput, type PortalCreateBuildInput, type PortalCreateOrgInput, type PortalCreateOrgResult, type PortalListAgentsResult, type PortalListBuildsResult, type PortalListOrgsResult, type PortalOrg, type PortalOrgUser, PortalRequestError, type PortalSetAgentNameInput, type PortalSetAgentNameResult, type PortalSetAgentStatusInput, type PortalSetAgentStatusResult, type PortalSetAgentTriageResult, type PortalSetAgentWorkflowInput, type PortalSetAgentWorkflowResult, type PortalSetBuildDetailsInput, type PortalSetBuildDetailsResult, type PortalSetBuildStatusInput, type PortalSetDriveFolderResult, type PortalSetPasswordResult, type PortalSetUserInput, type PortalSetUserResult, type PortalSyncRunsResult, type PortalTriageBackfillResult, type PortalTriageProvider, type PortalTriageRecordsPage, portalAddUser, portalBackfillTriageRecords, portalBuildType, portalBuildWorkflowId, portalCreateAgent, portalCreateBuild, portalCreateOrg, portalListAgents, portalListBuilds, portalListOrgs, portalReadTriageRecords, portalSetAgentName, portalSetAgentStatus, portalSetAgentTriage, portalSetAgentWorkflow, portalSetBuildDetails, portalSetBuildName, portalSetBuildStatus, portalSetBuildTriage, portalSetBuildWorkflow, portalSetDriveFolder, portalSetOrgSlackChannel, portalSetPassword, portalSetUser, portalSyncRuns, validatePortalBuildFields, } from "./portal-admin.js";
|
|
43
43
|
export { BUILD_DESCRIPTION_MAX, BUILD_NAME_MAX, BUILDS_MANIFEST_END, BUILDS_MANIFEST_START, type BuildsManifest, type BuildsManifestSource, type BuildsManifestState, type BuildsSyncAction, type BuildsSyncActionResult, type BuildsSyncOptions, type BuildsSyncOrgResult, type BuildsSyncPlan, type BuildsSyncResult, type ManifestBuild, type ManifestBuildStatus, parseBuildsManifest, planBuildsSync, type RemoteClientMdReader, syncBuilds, } from "./portal-sync-builds.js";
|
|
44
44
|
export { expectedGithubAccount, type PrOpenOptions, type PrOpenResult, parseGithubRemote, prOpen, } from "./pr-open.js";
|
|
45
|
+
export { CLIENT_LINE_MAX, parseRoadmapRows, ROADMAP_LABELS, ROADMAP_SOURCES, type RoadmapMigrateClient, type RoadmapMigrateOptions, type RoadmapMigrateResult, type RoadmapMigrateRow, type RoadmapRow, roadmapMigrate, } from "./roadmap-migrate.js";
|
|
46
|
+
export { type OnboardingChange, type OnboardingRetirePlan, planOnboardingRetire, ROADMAP_ARCHIVE, ROADMAP_FILE, type RoadmapRetireClient, type RoadmapRetireOptions, type RoadmapRetireResult, roadmapRetire, } from "./roadmap-retire.js";
|
|
45
47
|
export { type StandupCallPrep, type StandupCallPrepStatus, type StandupGitState, type StandupIssueRef, type StandupLinear, type StandupOptions, type StandupRepo, type StandupRepoLint, type StandupResult, type StandupStaleTodo, standup, } from "./standup.js";
|
|
46
48
|
export { type SyncRepoResult, type SyncRepoStatus, type SyncReposOptions, type SyncReposResult, syncRepos, workspaceRepoNames, } from "./sync-repos.js";
|
|
47
49
|
export { type SyncTemplatesFileResult, type SyncTemplatesFileStatus, type SyncTemplatesOptions, type SyncTemplatesResult, syncTemplates, TEMPLATE_CLAUDE_SETTINGS, TEMPLATE_ROOT_DOCS, } from "./sync-templates.js";
|
|
48
|
-
export {
|
|
50
|
+
export { adhocReason, selectClientSlugs, TEMPLATE_RETIRED_FILES, TEMPLATE_SYNCED_FILES, type TemplateSyncFileResult, type TemplateSyncFileStatus, type TemplateSyncOptions, type TemplateSyncRepoResult, type TemplateSyncResult, templateSync, } from "./template-sync.js";
|
|
49
51
|
export { TRIAGE_BACKFILL_CHUNK, type TriageBackfillOptions, type TriageBackfillResult, triageBackfill, } from "./triage-backfill.js";
|
|
50
52
|
export { checkTriageRecordWiring, detectWorkflowProvider, PORTAL_INGEST_CREDENTIAL_NAME, TRIAGE_RECORDS_PATH, type TriageEnableOptions, type TriageEnableResult, type TriageWiringCheck, type TriageWiringCheckId, type TriageWiringReport, triageEnable, } from "./triage-enable.js";
|
|
51
53
|
export { CRITICAL_PRIORITIES, CRITICAL_URGENCIES, detectProvider, GMAIL_HEADERS, GMAIL_LANE_BY_DISPOSITION, laneFor, OUTLOOK_HEADERS, OUTLOOK_LANE_BY_CATEGORY, parseCsv, parseLaneOverrides, type RecordTable, readRecordSheetTable, resolveRecordSheetId, SHEETS_SCOPE, seededRandom, TRIAGE_GATES, TRIAGE_LANES, TRIAGE_STAGES, type TriageGateSampleOptions, type TriageGateSampleResult, type TriageHealthOptions, type TriageHealthResult, type TriageLane, type TriageProvider, type TriageRecordRow, type TriageSampleRow, type TriageSoakReportOptions, type TriageSoakReportResult, type TriageSourceOptions, type TriageStage, type TriageWindow, triageGateSample, triageHealth, triageSoakReport, } from "./triage-gates.js";
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export { createFromAgentTemplate, listAgentTemplates, N8N_API_KEY_ENV, N8N_API_U
|
|
|
7
7
|
export { CLAUDE_CONFIG_DIR_ENV, compactClaudeHoursExport, deliverClaudeHoursExport, exportClaudeHours, HOURS_EXPORT_DIR, HOURS_EXPORT_SCHEMA, HOURS_EXPORT_SECRET_ENV, HOURS_EXPORT_SECRET_HEADER, HOURS_EXPORT_WEBHOOK_URL, PROMPT_WINDOW_MINUTES, parseLedgerDate, parseMinuteIso, saveClaudeHoursExport, sendClaudeHoursExport, TOOL_INPUT_PATH_KEYS, UNATTRIBUTED_SLUG, } from "./claude-hours.js";
|
|
8
8
|
export { ClientBuildAuthError, clientBuild, GITHUB_API_TOKEN_ENV, } from "./client-build.js";
|
|
9
9
|
export { clientContext, } from "./client-context.js";
|
|
10
|
-
export { CLIENT_DRIFT_SILENCE_DAYS, clientDrift, formatClientDriftSlack, postClientDriftReport, } from "./client-drift.js";
|
|
10
|
+
export { CLIENT_DRIFT_SILENCE_DAYS, clientDrift, FOLLOWUPS_INS_FROM, formatClientDriftSlack, postClientDriftReport, } from "./client-drift.js";
|
|
11
11
|
export { AIRTABLE_API_TOKEN_ENV, buildAssertionClaims, ClientDriveAuthError, clientDriveSearch, GOOGLE_SERVICE_ACCOUNT_KEY_ENV, parseServiceAccountKey, } from "./client-drive.js";
|
|
12
12
|
export { ClientIntakeAuthError, clientIntake, LINEAR_CLIENT_TEAM_ID_ENV, } from "./client-intake.js";
|
|
13
13
|
export { ClientLinearAuthError, clientLinearProject, parseLinearProjectSlugId, resolveClientLinearProject, } from "./client-linear.js";
|
|
@@ -45,10 +45,12 @@ export { detectPlatform, detectPlatformInfo, detectShell, opNeedsAnotherShell, }
|
|
|
45
45
|
export { DEFAULT_PORTAL_URL, PORTAL_ADMIN_SECRET_ENV, PORTAL_BUILD_TYPES, PORTAL_PASSWORD_WARNING, PORTAL_SYNC_MAX_DAYS, PORTAL_URL_ENV, PortalAdminAuthError, PortalRequestError, portalAddUser, portalBackfillTriageRecords, portalBuildType, portalBuildWorkflowId, portalCreateAgent, portalCreateBuild, portalCreateOrg, portalListAgents, portalListBuilds, portalListOrgs, portalReadTriageRecords, portalSetAgentName, portalSetAgentStatus, portalSetAgentTriage, portalSetAgentWorkflow, portalSetBuildDetails, portalSetBuildName, portalSetBuildStatus, portalSetBuildTriage, portalSetBuildWorkflow, portalSetDriveFolder, portalSetOrgSlackChannel, portalSetPassword, portalSetUser, portalSyncRuns, validatePortalBuildFields, } from "./portal-admin.js";
|
|
46
46
|
export { BUILD_DESCRIPTION_MAX, BUILD_NAME_MAX, BUILDS_MANIFEST_END, BUILDS_MANIFEST_START, parseBuildsManifest, planBuildsSync, syncBuilds, } from "./portal-sync-builds.js";
|
|
47
47
|
export { expectedGithubAccount, parseGithubRemote, prOpen, } from "./pr-open.js";
|
|
48
|
+
export { CLIENT_LINE_MAX, parseRoadmapRows, ROADMAP_LABELS, ROADMAP_SOURCES, roadmapMigrate, } from "./roadmap-migrate.js";
|
|
49
|
+
export { planOnboardingRetire, ROADMAP_ARCHIVE, ROADMAP_FILE, roadmapRetire, } from "./roadmap-retire.js";
|
|
48
50
|
export { standup, } from "./standup.js";
|
|
49
51
|
export { syncRepos, workspaceRepoNames, } from "./sync-repos.js";
|
|
50
52
|
export { syncTemplates, TEMPLATE_CLAUDE_SETTINGS, TEMPLATE_ROOT_DOCS, } from "./sync-templates.js";
|
|
51
|
-
export {
|
|
53
|
+
export { adhocReason, selectClientSlugs, TEMPLATE_RETIRED_FILES, TEMPLATE_SYNCED_FILES, templateSync, } from "./template-sync.js";
|
|
52
54
|
export { TRIAGE_BACKFILL_CHUNK, triageBackfill, } from "./triage-backfill.js";
|
|
53
55
|
export { checkTriageRecordWiring, detectWorkflowProvider, PORTAL_INGEST_CREDENTIAL_NAME, TRIAGE_RECORDS_PATH, triageEnable, } from "./triage-enable.js";
|
|
54
56
|
export { CRITICAL_PRIORITIES, CRITICAL_URGENCIES, detectProvider, GMAIL_HEADERS, GMAIL_LANE_BY_DISPOSITION, laneFor, OUTLOOK_HEADERS, OUTLOOK_LANE_BY_CATEGORY, parseCsv, parseLaneOverrides, readRecordSheetTable, resolveRecordSheetId, SHEETS_SCOPE, seededRandom, TRIAGE_GATES, TRIAGE_LANES, TRIAGE_STAGES, triageGateSample, triageHealth, triageSoakReport, } from "./triage-gates.js";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export declare const ROADMAP_SOURCES: string[];
|
|
2
|
+
export declare const CLIENT_LINE_MAX = 140;
|
|
3
|
+
export declare const ROADMAP_LABELS: readonly ["value", "client-ask", "parked"];
|
|
4
|
+
export interface RoadmapRow {
|
|
5
|
+
rank: string;
|
|
6
|
+
work: string;
|
|
7
|
+
tag: string;
|
|
8
|
+
status: string;
|
|
9
|
+
clientLine: string;
|
|
10
|
+
/** The first INS id in the Work column: the row's issue. */
|
|
11
|
+
id: string | null;
|
|
12
|
+
/** Every other INS id the row names, for a person to check. */
|
|
13
|
+
alsoNamed: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface RoadmapMigrateRow extends RoadmapRow {
|
|
16
|
+
/** The issue's state type in Linear, or null when there is no issue to read. */
|
|
17
|
+
linearState: string | null;
|
|
18
|
+
/** null when there is nothing to compare (no issue). */
|
|
19
|
+
stateMatches: boolean | null;
|
|
20
|
+
labelsToAdd: string[];
|
|
21
|
+
clientLineToAdd: string | null;
|
|
22
|
+
/** Why the row's Client line is not added. */
|
|
23
|
+
refused: string | null;
|
|
24
|
+
/** Why the row cannot be migrated as it is (no INS id, not in the project). */
|
|
25
|
+
problem: string | null;
|
|
26
|
+
/** apply only: this row's labels / description were written. */
|
|
27
|
+
applied?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface RoadmapMigrateClient {
|
|
30
|
+
slug: string;
|
|
31
|
+
dir: string;
|
|
32
|
+
/** The roadmap file that was read, repo-relative. */
|
|
33
|
+
source: string | null;
|
|
34
|
+
project: {
|
|
35
|
+
name: string;
|
|
36
|
+
url: string;
|
|
37
|
+
} | null;
|
|
38
|
+
rows: RoadmapMigrateRow[];
|
|
39
|
+
/** Set when this client was not migrated, with the reason. */
|
|
40
|
+
skipped: string | null;
|
|
41
|
+
}
|
|
42
|
+
export interface RoadmapMigrateResult {
|
|
43
|
+
workspaceDir: string;
|
|
44
|
+
clients: RoadmapMigrateClient[];
|
|
45
|
+
/** --all only: the ad hoc repos left out (see adhocReason). */
|
|
46
|
+
adhocSkipped: string[];
|
|
47
|
+
/** Labels the planned writes need that Linear does not have yet. */
|
|
48
|
+
labelsToCreate: string[];
|
|
49
|
+
/** apply only: the labels created. */
|
|
50
|
+
createdLabels: string[];
|
|
51
|
+
applied: boolean;
|
|
52
|
+
/** apply only: the number of Linear mutations sent. */
|
|
53
|
+
writes: number;
|
|
54
|
+
notes: string[];
|
|
55
|
+
}
|
|
56
|
+
export interface RoadmapMigrateOptions {
|
|
57
|
+
/** The installagent/ workspace root (contains clients/). */
|
|
58
|
+
workspaceDir?: string;
|
|
59
|
+
/** One client, without the `client-` prefix. Give this or `all`. */
|
|
60
|
+
slug?: string;
|
|
61
|
+
all?: boolean;
|
|
62
|
+
/** Write labels and descriptions. Default false: report only. */
|
|
63
|
+
apply?: boolean;
|
|
64
|
+
/** Linear API key; defaults to $LINEAR_API_TOKEN. */
|
|
65
|
+
token?: string;
|
|
66
|
+
env?: NodeJS.ProcessEnv;
|
|
67
|
+
fetchImpl?: typeof fetch;
|
|
68
|
+
}
|
|
69
|
+
/** The rows of the roadmap's "## Ranked list" table. Fenced examples are skipped. */
|
|
70
|
+
export declare function parseRoadmapRows(md: string): RoadmapRow[];
|
|
71
|
+
/**
|
|
72
|
+
* Plan (and, with `apply`, write) the move of each client's roadmap rows into
|
|
73
|
+
* Linear. See the header of this file for what is read and what is written.
|
|
74
|
+
*/
|
|
75
|
+
export declare function roadmapMigrate(options: RoadmapMigrateOptions): Promise<RoadmapMigrateResult>;
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
// `ia roadmap-migrate` — move each client's docs/06-roadmap.md into Linear, once.
|
|
2
|
+
//
|
|
3
|
+
// The roadmap file is retired (2026-11-08): Linear owns the order of work, and
|
|
4
|
+
// the client portal reads Now / Next / Later from it. This operation reads the
|
|
5
|
+
// file's "## Ranked list" table and, per row, says what Linear needs so it
|
|
6
|
+
// holds the same facts:
|
|
7
|
+
//
|
|
8
|
+
// Status this week / next / later → state type started / unstarted / backlog
|
|
9
|
+
// Status parked → label `parked` (any state; never shown)
|
|
10
|
+
// Status done → Done (checked only, never written)
|
|
11
|
+
// Tag VALUE / CLIENT ASK / BOTH → labels `value` / `client-ask` / both
|
|
12
|
+
// Client line → one `Client line: …` line in the description
|
|
13
|
+
//
|
|
14
|
+
// The dry run (the default) only reads. `apply` writes ONLY labels (it creates
|
|
15
|
+
// a missing `value` / `client-ask` / `parked` label once, then adds labels to
|
|
16
|
+
// issues) and descriptions (it appends a Client line when the issue has none).
|
|
17
|
+
// It never changes a state, a title, a priority or an assignee: a state that
|
|
18
|
+
// does not match the row is a report line for a person. It refuses a Client
|
|
19
|
+
// line with `$` (Linear is shared by all staff: no dollar amounts), a ticket
|
|
20
|
+
// id, or more than 140 characters. Angello runs `--apply`.
|
|
21
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
22
|
+
import { join, resolve } from "node:path";
|
|
23
|
+
import { parseLinearProjectSlugId } from "./client-linear.js";
|
|
24
|
+
import { readManifestKey } from "./client-manifest.js";
|
|
25
|
+
import { findProjectBySlugId, LINEAR_API_TOKEN_ENV, linearRequest } from "./linear-project.js";
|
|
26
|
+
import { adhocReason, selectClientSlugs } from "./template-sync.js";
|
|
27
|
+
export const ROADMAP_SOURCES = ["docs/06-roadmap.md", "docs/archive/06-roadmap.md"];
|
|
28
|
+
export const CLIENT_LINE_MAX = 140;
|
|
29
|
+
export const ROADMAP_LABELS = ["value", "client-ask", "parked"];
|
|
30
|
+
const ISSUE_ID = /\bINS-\d+\b/g;
|
|
31
|
+
const TICKET_ID = /\b[A-Z][A-Z0-9]{1,9}-\d+\b/;
|
|
32
|
+
const HAS_CLIENT_LINE = /^\s*(?:[-*]\s+)?\**Client line:?\**\s*:?/im;
|
|
33
|
+
const PAGE_SIZE = 250;
|
|
34
|
+
const LABEL_COLORS = {
|
|
35
|
+
value: "#4CB782",
|
|
36
|
+
"client-ask": "#F2994A",
|
|
37
|
+
parked: "#9CA3AF",
|
|
38
|
+
};
|
|
39
|
+
/** The state types a row's status expects; parked accepts any state. */
|
|
40
|
+
const EXPECTED_STATE = {
|
|
41
|
+
done: ["completed"],
|
|
42
|
+
"this week": ["started"],
|
|
43
|
+
next: ["unstarted"],
|
|
44
|
+
later: ["backlog"],
|
|
45
|
+
parked: null,
|
|
46
|
+
};
|
|
47
|
+
const TAG_LABELS = {
|
|
48
|
+
VALUE: ["value"],
|
|
49
|
+
"CLIENT ASK": ["client-ask"],
|
|
50
|
+
BOTH: ["value", "client-ask"],
|
|
51
|
+
};
|
|
52
|
+
/** Split one markdown table row into trimmed cells (outer pipes dropped, `\|` kept as a pipe). */
|
|
53
|
+
function splitRow(line) {
|
|
54
|
+
const cells = [];
|
|
55
|
+
let cell = "";
|
|
56
|
+
for (let i = 0; i < line.length; i++) {
|
|
57
|
+
if (line[i] === "\\" && line[i + 1] === "|") {
|
|
58
|
+
cell += "|";
|
|
59
|
+
i += 1;
|
|
60
|
+
}
|
|
61
|
+
else if (line[i] === "|") {
|
|
62
|
+
cells.push(cell.trim());
|
|
63
|
+
cell = "";
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
cell += line[i];
|
|
67
|
+
}
|
|
68
|
+
cells.push(cell.trim());
|
|
69
|
+
if (cells[0] === "")
|
|
70
|
+
cells.shift();
|
|
71
|
+
if (cells[cells.length - 1] === "")
|
|
72
|
+
cells.pop();
|
|
73
|
+
return cells;
|
|
74
|
+
}
|
|
75
|
+
/** The rows of the roadmap's "## Ranked list" table. Fenced examples are skipped. */
|
|
76
|
+
export function parseRoadmapRows(md) {
|
|
77
|
+
const rows = [];
|
|
78
|
+
let inList = false;
|
|
79
|
+
let header = null;
|
|
80
|
+
let fenced = false;
|
|
81
|
+
for (const raw of md.split("\n")) {
|
|
82
|
+
const line = raw.trimEnd();
|
|
83
|
+
if (/^\s*```/.test(line))
|
|
84
|
+
fenced = !fenced;
|
|
85
|
+
if (fenced)
|
|
86
|
+
continue;
|
|
87
|
+
if (/^##\s/.test(line)) {
|
|
88
|
+
inList = /^##\s+Ranked list\b/i.test(line);
|
|
89
|
+
header = null;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (!inList || !line.startsWith("|"))
|
|
93
|
+
continue;
|
|
94
|
+
const cells = splitRow(line);
|
|
95
|
+
if (!header) {
|
|
96
|
+
header = cells.map((c) => c.toLowerCase());
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (cells.every((c) => /^:?-{2,}:?$/.test(c)))
|
|
100
|
+
continue;
|
|
101
|
+
const col = (name) => header?.includes(name) ? (cells[header.indexOf(name)] ?? "") : "";
|
|
102
|
+
const work = col("work");
|
|
103
|
+
const ids = [...new Set([...work.matchAll(ISSUE_ID)].map((m) => m[0]))];
|
|
104
|
+
const others = [...new Set(cells.join(" ").match(ISSUE_ID) ?? [])].filter((id) => id !== ids[0]);
|
|
105
|
+
rows.push({
|
|
106
|
+
rank: col("#"),
|
|
107
|
+
work,
|
|
108
|
+
tag: col("tag").toUpperCase(),
|
|
109
|
+
status: col("status").toLowerCase(),
|
|
110
|
+
clientLine: col("client line"),
|
|
111
|
+
id: ids[0] ?? null,
|
|
112
|
+
alsoNamed: others,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return rows;
|
|
116
|
+
}
|
|
117
|
+
/** Why a row's Client line may not go into Linear, or null when it may. */
|
|
118
|
+
function refusal(line) {
|
|
119
|
+
if (line.includes("$"))
|
|
120
|
+
return "has a $ — no dollar amounts in Linear (shared by all staff)";
|
|
121
|
+
if (TICKET_ID.test(line))
|
|
122
|
+
return "names a ticket id — the client never sees ticket numbers";
|
|
123
|
+
if (line.length > CLIENT_LINE_MAX)
|
|
124
|
+
return `is ${line.length} characters; the limit is ${CLIENT_LINE_MAX}`;
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const ISSUES_QUERY = `
|
|
128
|
+
query RoadmapMigrateIssues($project: String!, $projectId: ID!, $first: Int!, $after: String) {
|
|
129
|
+
project(id: $project) { teams { nodes { id key } } }
|
|
130
|
+
issues(filter: { project: { id: { eq: $projectId } } }, first: $first, after: $after) {
|
|
131
|
+
nodes { id identifier description state { type name } labels { nodes { id name } } }
|
|
132
|
+
pageInfo { hasNextPage endCursor }
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
const LABELS_QUERY = `
|
|
137
|
+
query RoadmapMigrateLabels($filter: IssueLabelFilter!) {
|
|
138
|
+
issueLabels(filter: $filter, first: 250) { nodes { id name team { id } } }
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
141
|
+
const LABEL_CREATE = `
|
|
142
|
+
mutation RoadmapMigrateLabelCreate($input: IssueLabelCreateInput!) {
|
|
143
|
+
issueLabelCreate(input: $input) { success issueLabel { id name } }
|
|
144
|
+
}
|
|
145
|
+
`;
|
|
146
|
+
const ISSUE_UPDATE = `
|
|
147
|
+
mutation RoadmapMigrateIssueUpdate($id: String!, $input: IssueUpdateInput!) {
|
|
148
|
+
issueUpdate(id: $id, input: $input) { success }
|
|
149
|
+
}
|
|
150
|
+
`;
|
|
151
|
+
async function projectIssues(request, projectId) {
|
|
152
|
+
const issues = [];
|
|
153
|
+
let teamIds = [];
|
|
154
|
+
let after = null;
|
|
155
|
+
for (let page = 0; page < 20; page++) {
|
|
156
|
+
const data = await request(ISSUES_QUERY, { project: projectId, projectId, first: PAGE_SIZE, after });
|
|
157
|
+
if (page === 0)
|
|
158
|
+
teamIds = data.project?.teams.nodes.map((t) => t.id) ?? [];
|
|
159
|
+
issues.push(...data.issues.nodes);
|
|
160
|
+
if (!data.issues.pageInfo.hasNextPage || !data.issues.pageInfo.endCursor)
|
|
161
|
+
break;
|
|
162
|
+
after = data.issues.pageInfo.endCursor;
|
|
163
|
+
}
|
|
164
|
+
return { issues, teamIds };
|
|
165
|
+
}
|
|
166
|
+
function planRow(row, issue) {
|
|
167
|
+
const plan = {
|
|
168
|
+
...row,
|
|
169
|
+
linearState: null,
|
|
170
|
+
stateMatches: null,
|
|
171
|
+
labelsToAdd: [],
|
|
172
|
+
clientLineToAdd: null,
|
|
173
|
+
refused: null,
|
|
174
|
+
problem: null,
|
|
175
|
+
};
|
|
176
|
+
if (!row.id) {
|
|
177
|
+
plan.problem =
|
|
178
|
+
"no INS id in Work — create the issue (with its Client line), or drop a done / parked row";
|
|
179
|
+
return plan;
|
|
180
|
+
}
|
|
181
|
+
if (!issue) {
|
|
182
|
+
plan.problem = `${row.id} is not in this client's Linear project — move it there, or fix the row`;
|
|
183
|
+
return plan;
|
|
184
|
+
}
|
|
185
|
+
plan.linearState = issue.state.type;
|
|
186
|
+
const expected = EXPECTED_STATE[row.status];
|
|
187
|
+
plan.stateMatches =
|
|
188
|
+
expected === undefined ? false : expected === null || expected.includes(issue.state.type);
|
|
189
|
+
if (expected === undefined)
|
|
190
|
+
plan.problem = `status "${row.status}" is not done / this week / next / later / parked`;
|
|
191
|
+
if (row.status === "done")
|
|
192
|
+
return plan; // Done issues never reach the portal: nothing to write.
|
|
193
|
+
const has = new Set(issue.labels.nodes.map((l) => l.name.toLowerCase()));
|
|
194
|
+
const wanted = [...(TAG_LABELS[row.tag] ?? []), ...(row.status === "parked" ? ["parked"] : [])];
|
|
195
|
+
plan.labelsToAdd = wanted.filter((name) => !has.has(name));
|
|
196
|
+
const line = row.clientLine.trim();
|
|
197
|
+
if (line && line.toLowerCase() !== "none" && !HAS_CLIENT_LINE.test(issue.description ?? "")) {
|
|
198
|
+
plan.refused = refusal(line);
|
|
199
|
+
if (!plan.refused)
|
|
200
|
+
plan.clientLineToAdd = line;
|
|
201
|
+
}
|
|
202
|
+
return plan;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Plan (and, with `apply`, write) the move of each client's roadmap rows into
|
|
206
|
+
* Linear. See the header of this file for what is read and what is written.
|
|
207
|
+
*/
|
|
208
|
+
export async function roadmapMigrate(options) {
|
|
209
|
+
const workspaceDir = resolve(options.workspaceDir ?? ".");
|
|
210
|
+
const { slugs, adhoc } = selectClientSlugs(workspaceDir, options, "roadmap-migrate");
|
|
211
|
+
const env = options.env ?? process.env;
|
|
212
|
+
const token = options.token ?? env[LINEAR_API_TOKEN_ENV];
|
|
213
|
+
if (!token)
|
|
214
|
+
throw new Error(`roadmap-migrate reads Linear: set ${LINEAR_API_TOKEN_ENV} (a personal API key)`);
|
|
215
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
216
|
+
const request = (query, variables) => linearRequest(fetchImpl, token, query, variables);
|
|
217
|
+
const apply = options.apply ?? false;
|
|
218
|
+
const clients = [];
|
|
219
|
+
const issuesBySlug = new Map();
|
|
220
|
+
const teamIds = new Set();
|
|
221
|
+
for (const slug of slugs) {
|
|
222
|
+
const dir = join(workspaceDir, "clients", `client-${slug}`);
|
|
223
|
+
const client = {
|
|
224
|
+
slug,
|
|
225
|
+
dir,
|
|
226
|
+
source: null,
|
|
227
|
+
project: null,
|
|
228
|
+
rows: [],
|
|
229
|
+
skipped: null,
|
|
230
|
+
};
|
|
231
|
+
clients.push(client);
|
|
232
|
+
const adhoc = adhocReason(dir);
|
|
233
|
+
if (adhoc) {
|
|
234
|
+
client.skipped = adhoc;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
const clientMd = existsSync(join(dir, "CLIENT.md"))
|
|
238
|
+
? readFileSync(join(dir, "CLIENT.md"), "utf8")
|
|
239
|
+
: "";
|
|
240
|
+
const url = readManifestKey(clientMd, "linear_project")?.split(/\s+/)[0];
|
|
241
|
+
const slugId = url?.startsWith("http") ? parseLinearProjectSlugId(url) : null;
|
|
242
|
+
if (!slugId) {
|
|
243
|
+
client.skipped =
|
|
244
|
+
"no Linear project in CLIENT.md (linear_project is none, missing or not a project link)";
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
client.source = ROADMAP_SOURCES.find((rel) => existsSync(join(dir, rel))) ?? null;
|
|
248
|
+
if (!client.source) {
|
|
249
|
+
client.skipped = "no docs/06-roadmap.md (nor one in docs/archive/)";
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
const project = await findProjectBySlugId(fetchImpl, token, slugId);
|
|
253
|
+
client.project = { name: project.name, url: project.url };
|
|
254
|
+
const read = await projectIssues(request, project.id);
|
|
255
|
+
for (const id of read.teamIds)
|
|
256
|
+
teamIds.add(id);
|
|
257
|
+
const byId = new Map(read.issues.map((i) => [i.identifier, i]));
|
|
258
|
+
issuesBySlug.set(slug, byId);
|
|
259
|
+
const rows = parseRoadmapRows(readFileSync(join(dir, client.source), "utf8"));
|
|
260
|
+
client.rows = rows.map((row) => planRow(row, row.id ? byId.get(row.id) : undefined));
|
|
261
|
+
}
|
|
262
|
+
// Labels: which ones the planned writes need, and which Linear already has.
|
|
263
|
+
const needed = [...new Set(clients.flatMap((c) => c.rows.flatMap((r) => r.labelsToAdd)))].sort();
|
|
264
|
+
const labelIds = new Map();
|
|
265
|
+
if (needed.length > 0) {
|
|
266
|
+
const { issueLabels } = await request(LABELS_QUERY, { filter: { or: needed.map((name) => ({ name: { eqIgnoreCase: name } })) } });
|
|
267
|
+
for (const label of issueLabels.nodes) {
|
|
268
|
+
const usable = !label.team || teamIds.has(label.team.id);
|
|
269
|
+
if (usable && !labelIds.has(label.name.toLowerCase()))
|
|
270
|
+
labelIds.set(label.name.toLowerCase(), label.id);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const labelsToCreate = needed.filter((name) => !labelIds.has(name));
|
|
274
|
+
const result = {
|
|
275
|
+
workspaceDir,
|
|
276
|
+
clients,
|
|
277
|
+
adhocSkipped: adhoc,
|
|
278
|
+
labelsToCreate,
|
|
279
|
+
createdLabels: [],
|
|
280
|
+
applied: apply,
|
|
281
|
+
writes: 0,
|
|
282
|
+
notes: [
|
|
283
|
+
apply
|
|
284
|
+
? "Applied: labels and descriptions only. No state, title, priority or assignee was changed."
|
|
285
|
+
: "Dry run: Linear GraphQL queries only. Nothing was written. Angello runs --apply.",
|
|
286
|
+
"A state that does not match the row is for a person to fix in Linear; --apply never moves a state.",
|
|
287
|
+
],
|
|
288
|
+
};
|
|
289
|
+
if (!apply)
|
|
290
|
+
return result;
|
|
291
|
+
const [teamId] = [...teamIds];
|
|
292
|
+
for (const name of labelsToCreate) {
|
|
293
|
+
if (!teamId)
|
|
294
|
+
throw new Error(`cannot create label "${name}": the project has no team`);
|
|
295
|
+
const { issueLabelCreate } = await request(LABEL_CREATE, { input: { name, teamId, color: LABEL_COLORS[name] } });
|
|
296
|
+
result.writes += 1;
|
|
297
|
+
if (!issueLabelCreate.success || !issueLabelCreate.issueLabel) {
|
|
298
|
+
throw new Error(`Linear did not create the label "${name}"`);
|
|
299
|
+
}
|
|
300
|
+
labelIds.set(name, issueLabelCreate.issueLabel.id);
|
|
301
|
+
result.createdLabels.push(name);
|
|
302
|
+
}
|
|
303
|
+
for (const client of clients) {
|
|
304
|
+
const byId = issuesBySlug.get(client.slug);
|
|
305
|
+
for (const row of client.rows) {
|
|
306
|
+
const issue = row.id ? byId?.get(row.id) : undefined;
|
|
307
|
+
if (!issue || (row.labelsToAdd.length === 0 && !row.clientLineToAdd))
|
|
308
|
+
continue;
|
|
309
|
+
const input = {};
|
|
310
|
+
if (row.labelsToAdd.length > 0) {
|
|
311
|
+
input.addedLabelIds = row.labelsToAdd.map((name) => labelIds.get(name));
|
|
312
|
+
}
|
|
313
|
+
if (row.clientLineToAdd) {
|
|
314
|
+
const current = (issue.description ?? "").trimEnd();
|
|
315
|
+
input.description = `${current ? `${current}\n\n` : ""}Client line: ${row.clientLineToAdd}`;
|
|
316
|
+
}
|
|
317
|
+
const { issueUpdate } = await request(ISSUE_UPDATE, {
|
|
318
|
+
id: issue.id,
|
|
319
|
+
input,
|
|
320
|
+
});
|
|
321
|
+
result.writes += 1;
|
|
322
|
+
if (!issueUpdate.success)
|
|
323
|
+
throw new Error(`Linear did not update ${row.id}`);
|
|
324
|
+
row.applied = true;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return result;
|
|
328
|
+
}
|