@dalmasonto/taskflow-mcp 2.5.1 → 2.7.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/init.d.ts ADDED
@@ -0,0 +1,150 @@
1
+ /**
2
+ * `taskflow init` (also `taskflow-mcp init`) — the post-install walkthrough.
3
+ *
4
+ * Asks which coding agent(s) ("harnesses") to wire up and at what scope, then:
5
+ * 1. registers the `taskflow-mcp` server with each harness — through the
6
+ * harness's own CLI when it is on PATH, else by merging its config file;
7
+ * 2. for Claude Code, offers the lifecycle hooks;
8
+ * 3. finds `.taskflow.json`, or creates one by minting an agent when given a
9
+ * user token (reusing `--mint`'s request), or explains the manual step;
10
+ * 4. runs the `--doctor` check;
11
+ * 5. prints the next steps, ending at the web app.
12
+ *
13
+ * Everything that touches the outside world — files, PATH, child processes,
14
+ * the network, the terminal — comes in through {@link InitDeps}, so the plan
15
+ * and the merges are tested against fake paths and never the real home dir.
16
+ */
17
+ import { type TaskflowConfig } from "./config.js";
18
+ import { type FetchLike } from "./mint.js";
19
+ /** The hosted app. A self-hosted install passes `--app-url`. */
20
+ export declare const DEFAULT_APP_URL = "https://taskflow.supercodehive.com";
21
+ /** The hosted API — what `.taskflow.json`'s `server` points at. */
22
+ export declare const DEFAULT_SERVER_URL = "https://api.taskflow.supercodehive.com";
23
+ export declare const HARNESSES: readonly ["claude", "codex", "gemini", "cursor", "opencode"];
24
+ export type Harness = (typeof HARNESSES)[number];
25
+ export type Scope = "user" | "project";
26
+ export declare const HARNESS_LABEL: Record<Harness, string>;
27
+ /** A clear, user-facing failure. */
28
+ export declare class InitError extends Error {
29
+ constructor(message: string);
30
+ }
31
+ export interface InitArgs {
32
+ harnesses: Harness[];
33
+ scope: Scope | undefined;
34
+ yes: boolean;
35
+ dryRun: boolean;
36
+ /** undefined = ask (interactive) / yes (with --yes). */
37
+ hooks: boolean | undefined;
38
+ dir: string | undefined;
39
+ server: string | undefined;
40
+ project: number | undefined;
41
+ token: string | undefined;
42
+ profile: string;
43
+ displayName: string | undefined;
44
+ appUrl: string | undefined;
45
+ doctor: boolean;
46
+ help: boolean;
47
+ }
48
+ export declare const INIT_USAGE = "taskflow init \u2014 connect your coding agent to TaskFlow\n\n taskflow init Interactive walkthrough.\n taskflow init --harness claude --scope user --yes\n Non-interactive (scripts / CI).\n\nOptions:\n --harness <names> claude, codex, gemini, cursor, opencode (comma-separated,\n repeatable, or \"all\").\n --scope <s> user (global, every project) or project (this repo only).\n --dir <path> Project root for --scope project and .taskflow.json\n (default: the current directory).\n --hooks / --no-hooks\n Install the Claude Code lifecycle hooks (default: yes).\n --server <url> TaskFlow API for a new .taskflow.json\n (default: https://api.taskflow.supercodehive.com).\n --project <id> Project id to link an agent in.\n --token <t> YOUR user token (or TASKFLOW_USER_TOKEN) \u2014 with --project,\n mints an agent and writes .taskflow.json.\n --profile <name> Profile name for the minted agent (default: main).\n --display-name <s> Display name for the minted agent.\n --app-url <url> Your TaskFlow web app, when self-hosting\n (default: https://taskflow.supercodehive.com).\n --no-doctor Skip the connection check at the end.\n --dry-run Print what would run / be written; change nothing.\n -y, --yes Accept defaults; never prompt.\n -h, --help This message.";
49
+ export declare function parseHarnesses(value: string): Harness[];
50
+ export declare function parseScope(value: string): Scope;
51
+ /** Parse `init`'s arguments (without the `init` word itself). */
52
+ export declare function parseInitArgs(argv: string[], env?: NodeJS.ProcessEnv): InitArgs;
53
+ /** Read-only view of the machine, for planning. */
54
+ export interface PlanEnv {
55
+ home: string;
56
+ /** The project root (for project scope and `.taskflow.json`). */
57
+ dir: string;
58
+ env: NodeJS.ProcessEnv;
59
+ readFile(path: string): string | null;
60
+ exists(path: string): boolean;
61
+ /** Whether an executable is on PATH. */
62
+ which(cmd: string): boolean;
63
+ }
64
+ export type Action = {
65
+ kind: "exec";
66
+ harness: Harness;
67
+ summary: string;
68
+ cmd: string;
69
+ args: string[];
70
+ /** Tried when the command fails for a reason other than "already exists". */
71
+ fallback?: Action;
72
+ } | {
73
+ kind: "write";
74
+ harness: Harness | "taskflow";
75
+ summary: string;
76
+ path: string;
77
+ before: string | null;
78
+ after: string;
79
+ } | {
80
+ kind: "skip";
81
+ harness: Harness | "taskflow";
82
+ summary: string;
83
+ } | {
84
+ kind: "manual";
85
+ harness: Harness | "taskflow";
86
+ summary: string;
87
+ lines: string[];
88
+ };
89
+ /** Where each harness keeps its MCP config, per scope. `null` = no such scope. */
90
+ export declare function harnessConfigPath(h: Harness, scope: Scope, p: PlanEnv): string | null;
91
+ /** Manual instructions for one harness — the fallback when we won't write. */
92
+ export declare function manualInstructions(h: Harness, scope: Scope, p: PlanEnv): string[];
93
+ /** Plan the MCP registration for one harness. */
94
+ export declare function planRegistration(h: Harness, requested: Scope, p: PlanEnv): Action[];
95
+ /** Plan the Claude Code hooks. */
96
+ export declare function planHooks(scope: Scope, p: PlanEnv): Action;
97
+ export interface PlanInput {
98
+ harnesses: Harness[];
99
+ scope: Scope;
100
+ hooks: boolean;
101
+ }
102
+ /** The whole registration plan. Pure over {@link PlanEnv}. */
103
+ export declare function buildPlan(input: PlanInput, p: PlanEnv): Action[];
104
+ /** Render a plan for `--dry-run` (and for the confirm prompt). */
105
+ export declare function describePlan(actions: Action[], withDiffs: boolean): string[];
106
+ export interface ExecResult {
107
+ code: number;
108
+ stdout: string;
109
+ stderr: string;
110
+ }
111
+ /** Side-effecting operations. */
112
+ export interface ApplyDeps {
113
+ writeFile(path: string, text: string, mode?: number): void;
114
+ copyFile(from: string, to: string): void;
115
+ mkdirp(dir: string): void;
116
+ exists(path: string): boolean;
117
+ exec(cmd: string, args: string[]): ExecResult;
118
+ log(line: string): void;
119
+ }
120
+ /** Back `path` up to `<path>.bak` (or `.bak.N` when that is taken). Returns the backup path. */
121
+ export declare function backupPath(path: string, exists: (p: string) => boolean): string;
122
+ /** Apply a plan. Returns the manual steps still owed by the user. */
123
+ export declare function applyPlan(actions: Action[], d: ApplyDeps): string[];
124
+ /** The web app for a given API origin, when we can tell. */
125
+ export declare function appUrlFor(server: string | undefined, explicit: string | undefined): string | undefined;
126
+ /** Build a fresh single-profile `.taskflow.json` from a minted profile. */
127
+ export declare function newConfig(server: string, project: number, profileName: string, profile: TaskflowConfig["profiles"][string]): TaskflowConfig;
128
+ export interface Prompter {
129
+ ask(question: string): Promise<string>;
130
+ close(): void;
131
+ }
132
+ export interface InitDeps extends ApplyDeps {
133
+ plan: PlanEnv;
134
+ interactive: boolean;
135
+ prompter?: Prompter;
136
+ fetch?: FetchLike;
137
+ /** Runs the doctor from `dir`; returns its exit code. */
138
+ doctor(dir: string): Promise<number>;
139
+ }
140
+ /** Which harness CLIs / config dirs are present, for the default selection. */
141
+ export declare function detectHarnesses(p: PlanEnv): Harness[];
142
+ /**
143
+ * The walkthrough. Returns a process exit code: 0 when every registration went
144
+ * through (manual steps may remain), 1 on a usage error.
145
+ */
146
+ export declare function runInit(argv: string[], deps: InitDeps): Promise<number>;
147
+ /** Is `cmd` an executable on PATH? */
148
+ export declare function onPath(cmd: string, env?: NodeJS.ProcessEnv): boolean;
149
+ /** Wire {@link runInit} to the real machine and terminal. */
150
+ export declare function runInitCommand(argv: string[]): Promise<number>;