soltask 0.0.0-stage → 0.1.1

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.
@@ -0,0 +1,254 @@
1
+ /** How live the server's sync view of a community is. */
2
+ export type LinkState = "connecting" | "live" | "degraded" | "closed";
3
+ export type Priority = "low" | "normal" | "high" | "urgent";
4
+ export type ColumnId = "backlog" | "queued" | "working" | "needs" | "shipping" | "done" | "canceled";
5
+ export type TemplateId = "brainstorm" | "agent" | "bug" | "canon" | "hackathons" | "plan" | "discovery" | "ask" | "requirement" | "fixrun";
6
+ export type TaskKindId = "brainstorm" | "canon" | "hackathons" | "implementation" | "bug" | "ask";
7
+ export type ReasonType = "approve" | "answer" | "publish" | "decide" | "nudge" | "retry" | "unblock";
8
+ export type RiskLevel = "LOW" | "MEDIUM" | "HIGH";
9
+ export interface MeProfile {
10
+ name: string | null;
11
+ picture: string | null;
12
+ }
13
+ export interface MeCommunity {
14
+ id: string;
15
+ role: "owner" | "member";
16
+ relay: string;
17
+ }
18
+ export interface MeResponse {
19
+ pubkey: string;
20
+ profile: MeProfile;
21
+ communities: MeCommunity[];
22
+ }
23
+ export interface SignInResponse extends MeResponse {
24
+ unlock: string;
25
+ }
26
+ export interface ChannelView {
27
+ id: string;
28
+ slug: string;
29
+ visibility: "open" | "private";
30
+ /** Per-agent channel rules describing who a person may mention and for what. */
31
+ people: Record<string, string>;
32
+ }
33
+ export interface CommunityView {
34
+ id: string;
35
+ relay: string;
36
+ status: LinkState;
37
+ lagSeconds: number;
38
+ channels: ChannelView[];
39
+ }
40
+ export interface SyncStatus {
41
+ state: LinkState;
42
+ degradedSince: number | null;
43
+ lagSeconds?: number;
44
+ }
45
+ export interface TaskReason {
46
+ type: ReasonType;
47
+ label: string;
48
+ at: number;
49
+ by: string;
50
+ forWho: string[];
51
+ cardId?: string;
52
+ need?: number;
53
+ level?: RiskLevel;
54
+ blocked?: string;
55
+ until?: number;
56
+ }
57
+ export interface TaskTick {
58
+ at: number;
59
+ k: "a" | "p" | "m" | "card" | "ok" | "bad";
60
+ }
61
+ export interface TaskLinks {
62
+ mr?: string;
63
+ pipeline?: string;
64
+ path?: string;
65
+ }
66
+ export interface TaskTyping {
67
+ by: string;
68
+ until: number;
69
+ }
70
+ export interface TaskState {
71
+ col: ColumnId;
72
+ stage: string | null;
73
+ stageIdx: number;
74
+ reason: TaskReason | null;
75
+ approvals: string[];
76
+ agentMsgs: number;
77
+ personMsgs: number;
78
+ ticks: TaskTick[];
79
+ since: number;
80
+ last: number;
81
+ links: TaskLinks;
82
+ stageAt: Record<string, number>;
83
+ budget?: number;
84
+ active: string[];
85
+ }
86
+ export interface TaskSummary {
87
+ key: string;
88
+ community: string;
89
+ root: string;
90
+ channel: string;
91
+ template: TemplateId;
92
+ title: string;
93
+ requester: string | null;
94
+ col: ColumnId;
95
+ stage: string | null;
96
+ stageLabel: string | null;
97
+ reason?: TaskReason;
98
+ forMe: boolean;
99
+ since: number;
100
+ last: number;
101
+ agentMsgs: number;
102
+ budget?: number;
103
+ ticks: TaskTick[];
104
+ active: string[];
105
+ typing?: TaskTyping;
106
+ links: TaskLinks;
107
+ priority: Priority;
108
+ labels: string[];
109
+ version: number;
110
+ }
111
+ export interface TaskListResponse {
112
+ status: SyncStatus & {
113
+ lagSeconds: number;
114
+ };
115
+ version: number;
116
+ tasks: TaskSummary[];
117
+ }
118
+ export interface NostrEvent {
119
+ id: string;
120
+ pubkey: string;
121
+ created_at: number;
122
+ kind: number;
123
+ tags: string[][];
124
+ content: string;
125
+ sig: string;
126
+ }
127
+ export interface TaskDetailResponse {
128
+ task: TaskSummary & {
129
+ state: TaskState;
130
+ };
131
+ events: NostrEvent[];
132
+ }
133
+ export type AgentPresence = "online" | "away" | "offline" | "unknown";
134
+ export interface AgentHealthCheck {
135
+ at: number;
136
+ revision: string;
137
+ }
138
+ export interface AgentView {
139
+ id: string;
140
+ name: string;
141
+ kind: string;
142
+ home: string;
143
+ channels: string[];
144
+ description: string;
145
+ pubkey: string | null;
146
+ presence: AgentPresence;
147
+ tasks: string[];
148
+ checked: AgentHealthCheck | null;
149
+ }
150
+ export interface AgentsResponse {
151
+ agents: AgentView[];
152
+ }
153
+ export interface PersonView {
154
+ pubkey: string;
155
+ name: string;
156
+ picture: string | null;
157
+ }
158
+ export interface PeopleResponse {
159
+ people: PersonView[];
160
+ }
161
+ export interface ActivityItem {
162
+ event: NostrEvent;
163
+ task: {
164
+ key: string;
165
+ root: string;
166
+ title: string;
167
+ };
168
+ }
169
+ export interface ActivityResponse {
170
+ items: ActivityItem[];
171
+ }
172
+ export interface DraftDelivery {
173
+ channel: string;
174
+ entry: string;
175
+ }
176
+ export interface Draft {
177
+ id: string;
178
+ community: string;
179
+ body: string;
180
+ createdAt: number;
181
+ updatedAt: number;
182
+ delivery?: DraftDelivery;
183
+ }
184
+ export interface DraftsResponse {
185
+ drafts: Draft[];
186
+ }
187
+ export interface StreamTaskEvent {
188
+ event: "task";
189
+ data: {
190
+ community: string;
191
+ root: string;
192
+ version: number;
193
+ };
194
+ }
195
+ export interface StreamTypingEvent {
196
+ event: "typing";
197
+ data: {
198
+ community: string;
199
+ channel: string;
200
+ root: string | null;
201
+ pubkey: string;
202
+ };
203
+ }
204
+ export interface StreamStatusEvent {
205
+ event: "status";
206
+ data: {
207
+ community: string;
208
+ state: LinkState;
209
+ degradedSince: number | null;
210
+ };
211
+ }
212
+ export type StreamEvent = StreamTaskEvent | StreamTypingEvent | StreamStatusEvent;
213
+ export interface ColumnInfo {
214
+ readonly id: Exclude<ColumnId, "canceled">;
215
+ readonly name: string;
216
+ readonly icon: string;
217
+ readonly hint: string;
218
+ }
219
+ export interface TemplateInfo {
220
+ readonly id: TemplateId;
221
+ readonly name: string;
222
+ readonly icon: string;
223
+ readonly channel: string | null;
224
+ readonly entry: string | null;
225
+ readonly budget?: number;
226
+ readonly blurb: string;
227
+ readonly approver: string;
228
+ readonly outcome: string;
229
+ readonly stages: ReadonlyArray<readonly [string, string, ColumnId]>;
230
+ readonly on: Readonly<Record<string, string | null>>;
231
+ readonly stall?: {
232
+ readonly stages: readonly string[];
233
+ readonly minutes: number;
234
+ readonly nudge: string;
235
+ readonly nudgeName: string;
236
+ };
237
+ readonly quiet?: {
238
+ readonly from: string;
239
+ readonly to: string;
240
+ readonly hours: number;
241
+ };
242
+ }
243
+ export interface TaskKindInfo {
244
+ readonly id: TaskKindId;
245
+ readonly name: string;
246
+ readonly icon: string;
247
+ readonly channel: string | null;
248
+ readonly entry: string | null;
249
+ }
250
+ export interface ReasonInfo {
251
+ readonly label: string;
252
+ readonly icon: string;
253
+ readonly verb: string;
254
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/util.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ export type JsonPrimitive = string | number | boolean | null;
2
+ export type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
3
+ export type JsonObject = {
4
+ [key: string]: unknown;
5
+ };
6
+ export declare function isObject(value: unknown): value is JsonObject;
7
+ export declare function asObject(value: unknown): JsonObject;
8
+ export declare function asArray(value: unknown): unknown[];
9
+ export declare function asString(value: unknown): string | undefined;
10
+ /** A trimmed, non-empty string, or undefined. */
11
+ export declare function nonEmptyString(value: unknown): string | undefined;
12
+ /** Every string element of an array, in order; anything else is dropped. */
13
+ export declare function stringList(value: unknown): string[];
14
+ /** Display text for a table cell or a summary line: null and undefined show as a dash. */
15
+ export declare function cellText(value: unknown, fallback?: string): string;
16
+ /** `YYYY-MM-DDTHH:MM:SSZ`, the second-resolution UTC stamp stored in config files. */
17
+ export declare function utcNowIso(now?: Date): string;
18
+ /** Comma-separated and repeated values flattened into one de-duplicated list that keeps first-seen order. */
19
+ export declare function splitCsvList(items: readonly string[] | undefined): string[];
20
+ /** One line of safe text: every control character, newlines included, becomes a space. */
21
+ export declare function oneLine(value: string): string;
22
+ /** Multi-line text with only the dangerous control characters removed (tabs, newlines and CR stay). */
23
+ export declare function stripControls(value: string): string;
24
+ /** True when `value` contains any control character other than tab, LF or CR. */
25
+ export declare function hasDisallowedControls(value: string): boolean;
26
+ export declare function truncate(value: string, max: number): string;
27
+ export declare function errorCode(err: unknown): string | undefined;
28
+ export declare function errorMessage(err: unknown): string;
29
+ /** Parses a positive safe integer option value or throws a validation `CliError`. */
30
+ export declare function parsePositiveInt(flag: string, raw: string): number;
31
+ /** Compact relative age for Unix epoch seconds (e.g. "just now", "12s ago", "5m ago", "3h ago", "2d ago"). */
32
+ export declare function formatRelativeAge(epochSeconds: number, nowSeconds?: number): string;
package/dist/util.js ADDED
@@ -0,0 +1,116 @@
1
+ import { CliError, EXIT_VALIDATION } from "./errors.js";
2
+ export function isObject(value) {
3
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4
+ }
5
+ export function asObject(value) {
6
+ return isObject(value) ? value : {};
7
+ }
8
+ export function asArray(value) {
9
+ return Array.isArray(value) ? value : [];
10
+ }
11
+ export function asString(value) {
12
+ return typeof value === "string" ? value : undefined;
13
+ }
14
+ /** A trimmed, non-empty string, or undefined. */
15
+ export function nonEmptyString(value) {
16
+ if (typeof value !== "string") {
17
+ return undefined;
18
+ }
19
+ const trimmed = value.trim();
20
+ return trimmed === "" ? undefined : trimmed;
21
+ }
22
+ /** Every string element of an array, in order; anything else is dropped. */
23
+ export function stringList(value) {
24
+ return asArray(value).filter((item) => typeof item === "string");
25
+ }
26
+ /** Display text for a table cell or a summary line: null and undefined show as a dash. */
27
+ export function cellText(value, fallback = "-") {
28
+ if (value === null || value === undefined) {
29
+ return fallback;
30
+ }
31
+ if (typeof value === "string") {
32
+ return value;
33
+ }
34
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
35
+ return String(value);
36
+ }
37
+ return JSON.stringify(value);
38
+ }
39
+ /** `YYYY-MM-DDTHH:MM:SSZ`, the second-resolution UTC stamp stored in config files. */
40
+ export function utcNowIso(now = new Date()) {
41
+ return now.toISOString().replace(/\.\d{3}Z$/, "Z");
42
+ }
43
+ /** Comma-separated and repeated values flattened into one de-duplicated list that keeps first-seen order. */
44
+ export function splitCsvList(items) {
45
+ const result = [];
46
+ const seen = new Set();
47
+ for (const raw of items ?? []) {
48
+ for (const part of raw.split(",")) {
49
+ const value = part.trim();
50
+ if (value !== "" && !seen.has(value)) {
51
+ seen.add(value);
52
+ result.push(value);
53
+ }
54
+ }
55
+ }
56
+ return result;
57
+ }
58
+ // C0 controls (except tab and newline when `keepLayout`), DEL and C1 controls. Server-provided text reaches a
59
+ // terminal through these helpers, and a stray escape byte must not be able to rewrite the user's screen.
60
+ // eslint-disable-next-line no-control-regex -- matching control characters is the whole point
61
+ const CONTROL_ALL = /[\u0000-\u001f\u007f-\u009f]/g;
62
+ // eslint-disable-next-line no-control-regex -- matching control characters is the whole point
63
+ const CONTROL_KEEP_LAYOUT = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g;
64
+ // eslint-disable-next-line no-control-regex -- matching control characters is the whole point
65
+ const CONTROL_KEEP_LAYOUT_TEST = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/;
66
+ /** One line of safe text: every control character, newlines included, becomes a space. */
67
+ export function oneLine(value) {
68
+ return value.replace(CONTROL_ALL, " ");
69
+ }
70
+ /** Multi-line text with only the dangerous control characters removed (tabs, newlines and CR stay). */
71
+ export function stripControls(value) {
72
+ return value.replace(CONTROL_KEEP_LAYOUT, "");
73
+ }
74
+ /** True when `value` contains any control character other than tab, LF or CR. */
75
+ export function hasDisallowedControls(value) {
76
+ return CONTROL_KEEP_LAYOUT_TEST.test(value);
77
+ }
78
+ export function truncate(value, max) {
79
+ const chars = Array.from(value);
80
+ return chars.length <= max ? value : `${chars.slice(0, Math.max(0, max - 1)).join("")}\u2026`;
81
+ }
82
+ export function errorCode(err) {
83
+ return typeof err === "object" && err !== null && "code" in err && typeof err.code === "string" ? err.code : undefined;
84
+ }
85
+ export function errorMessage(err) {
86
+ return err instanceof Error ? err.message : String(err);
87
+ }
88
+ /** Parses a positive safe integer option value or throws a validation `CliError`. */
89
+ export function parsePositiveInt(flag, raw) {
90
+ const trimmed = raw.trim();
91
+ const value = Number(trimmed);
92
+ if (!/^\d+$/.test(trimmed) || !Number.isSafeInteger(value) || value <= 0) {
93
+ throw new CliError(`--${flag} must be a positive whole number.`, { exitCode: EXIT_VALIDATION });
94
+ }
95
+ return value;
96
+ }
97
+ /** Compact relative age for Unix epoch seconds (e.g. "just now", "12s ago", "5m ago", "3h ago", "2d ago"). */
98
+ export function formatRelativeAge(epochSeconds, nowSeconds = Math.floor(Date.now() / 1000)) {
99
+ if (!Number.isFinite(epochSeconds) || !Number.isFinite(nowSeconds)) {
100
+ return "-";
101
+ }
102
+ const diff = Math.max(0, Math.floor(nowSeconds - epochSeconds));
103
+ if (diff < 5) {
104
+ return "just now";
105
+ }
106
+ if (diff < 60) {
107
+ return `${diff}s ago`;
108
+ }
109
+ if (diff < 3_600) {
110
+ return `${Math.floor(diff / 60)}m ago`;
111
+ }
112
+ if (diff < 86_400) {
113
+ return `${Math.floor(diff / 3_600)}h ago`;
114
+ }
115
+ return `${Math.floor(diff / 86_400)}d ago`;
116
+ }
@@ -0,0 +1,3 @@
1
+ export declare const VERSION: string;
2
+ export declare const PROGRAM = "soltask";
3
+ export declare const PROTOCOL_VERSION = 1;
@@ -0,0 +1,13 @@
1
+ import { readFileSync } from "node:fs";
2
+ // package.json ships in the tarball next to dist/, so one file stays the single source of the version.
3
+ function readVersion() {
4
+ const raw = readFileSync(new URL("../package.json", import.meta.url), "utf8");
5
+ const parsed = JSON.parse(raw);
6
+ if (typeof parsed === "object" && parsed !== null && "version" in parsed && typeof parsed.version === "string") {
7
+ return parsed.version;
8
+ }
9
+ throw new Error("package.json has no version");
10
+ }
11
+ export const VERSION = readVersion();
12
+ export const PROGRAM = "soltask";
13
+ export const PROTOCOL_VERSION = 1;
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "soltask",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Zero-dependency CLI for task board management, workflow automation, and realtime monitoring",
5
+ "type": "module",
6
+ "bin": {
7
+ "soltask": "dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "engines": {
15
+ "node": ">=22"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "scripts": {
21
+ "build": "node -e \"import('node:fs').then(fs=>fs.rmSync('dist',{recursive:true,force:true}))\" && tsc && node -e \"import('node:fs').then(fs=>fs.chmodSync('dist/index.js',0o755))\"",
22
+ "typecheck": "tsc -p tsconfig.typecheck.json",
23
+ "lint": "eslint .",
24
+ "test": "vitest run",
25
+ "test:ci": "vitest run --coverage",
26
+ "verify:package": "node scripts/verify-package.mjs",
27
+ "neutrality": "node scripts/check-neutrality.mjs",
28
+ "prepare": "husky",
29
+ "prepack": "npm run build",
30
+ "prepublishOnly": "npm run typecheck && npm run lint && npm run test:ci && npm run neutrality -- --history && npm run verify:package && npm run neutrality -- --tarball"
31
+ },
32
+ "lint-staged": {
33
+ "*.{ts,js,mjs}": [
34
+ "eslint --fix"
35
+ ]
36
+ },
37
+ "keywords": [
38
+ "task-board",
39
+ "workflow",
40
+ "cli",
41
+ "zero-dependency",
42
+ "sse"
43
+ ],
44
+ "author": "Dong Tran <thiendong.iuh@gmail.com>",
45
+ "license": "MIT",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/dongitran/soltask.git"
49
+ },
50
+ "homepage": "https://github.com/dongitran/soltask#readme",
51
+ "bugs": {
52
+ "url": "https://github.com/dongitran/soltask/issues"
53
+ },
54
+ "devDependencies": {
55
+ "@eslint/js": "^10.0.1",
56
+ "@types/node": "^26.6.11",
57
+ "@vitest/coverage-v8": "^5.1.2",
58
+ "eslint": "^10.15.0",
59
+ "husky": "^9.1.7",
60
+ "lint-staged": "^17.6.2",
61
+ "typescript": "~5.9.0",
62
+ "typescript-eslint": "^8.68.0",
63
+ "vitest": "^5.1.2"
64
+ }
65
+ }