@orqint/cli 0.1.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.
@@ -0,0 +1,49 @@
1
+ /** Canonical Orqint memory (PRD §10 + edge_cases / unknowns / requires_input for CGR-005). */
2
+ export type ProjectMeta = {
3
+ name: string;
4
+ type: string;
5
+ description?: string;
6
+ };
7
+ export type OrqintMemory = {
8
+ project: ProjectMeta;
9
+ goals: string[];
10
+ features: unknown[];
11
+ pages: unknown[];
12
+ flows: unknown[];
13
+ states: unknown[];
14
+ edge_cases: string[];
15
+ design_system: Record<string, unknown>;
16
+ tech_stack: Record<string, unknown>;
17
+ integrations: unknown[];
18
+ mcp: unknown[];
19
+ rules: string[];
20
+ decisions: unknown[];
21
+ confidence: number;
22
+ unknowns: string[];
23
+ requires_input: boolean;
24
+ open_questions: string[];
25
+ validation: Record<string, unknown>;
26
+ tests: Record<string, unknown>;
27
+ version: Record<string, unknown>;
28
+ override: Record<string, boolean | string>;
29
+ };
30
+ export type ThinkApplyPayload = {
31
+ project?: Partial<ProjectMeta> & {
32
+ type?: string;
33
+ name?: string;
34
+ };
35
+ project_type?: string;
36
+ goals?: string[];
37
+ open_questions?: string[];
38
+ confidence: number;
39
+ unknowns?: string[];
40
+ requires_input?: boolean;
41
+ tech_stack?: Record<string, unknown>;
42
+ };
43
+ export type PlanApplyPayload = {
44
+ features?: unknown[];
45
+ flows?: unknown[];
46
+ pages?: unknown[];
47
+ states?: unknown[];
48
+ edge_cases?: string[];
49
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ /** Canonical Orqint memory (PRD §10 + edge_cases / unknowns / requires_input for CGR-005). */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export type LogLevel = "debug" | "info" | "warn" | "error";
2
+ export declare function log(level: LogLevel, event: string, data?: Record<string, unknown>): void;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.log = log;
4
+ function log(level, event, data) {
5
+ const line = JSON.stringify({
6
+ ts: new Date().toISOString(),
7
+ level,
8
+ event,
9
+ ...data,
10
+ });
11
+ console.error(line);
12
+ }
@@ -0,0 +1,8 @@
1
+ import type { OrqintMemory } from "../types/memory";
2
+ export type { OrqintMemory } from "../types/memory";
3
+ export declare const EMPTY_MEMORY: OrqintMemory;
4
+ export declare function ensureDefaults(data: unknown): OrqintMemory;
5
+ export declare function validateFoundation(m: OrqintMemory): void;
6
+ export declare function readMemory(cwd: string): Promise<OrqintMemory>;
7
+ export declare function writeMemory(cwd: string, m: OrqintMemory): Promise<void>;
8
+ export declare function deepMergeTechStack(current: Record<string, unknown>, patch: Record<string, unknown>): Record<string, unknown>;
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.EMPTY_MEMORY = void 0;
37
+ exports.ensureDefaults = ensureDefaults;
38
+ exports.validateFoundation = validateFoundation;
39
+ exports.readMemory = readMemory;
40
+ exports.writeMemory = writeMemory;
41
+ exports.deepMergeTechStack = deepMergeTechStack;
42
+ const path = __importStar(require("path"));
43
+ const fs = __importStar(require("fs-extra"));
44
+ const paths_1 = require("../engine/paths");
45
+ const FOUNDATION_KEYS = [
46
+ "project",
47
+ "goals",
48
+ "features",
49
+ "tech_stack",
50
+ "rules",
51
+ "confidence",
52
+ "open_questions",
53
+ ];
54
+ exports.EMPTY_MEMORY = {
55
+ project: { name: "", type: "" },
56
+ goals: [],
57
+ features: [],
58
+ pages: [],
59
+ flows: [],
60
+ states: [],
61
+ edge_cases: [],
62
+ design_system: {},
63
+ tech_stack: {},
64
+ integrations: [],
65
+ mcp: [],
66
+ rules: [],
67
+ decisions: [],
68
+ confidence: 0.3,
69
+ unknowns: [],
70
+ requires_input: false,
71
+ open_questions: [],
72
+ validation: {},
73
+ tests: {},
74
+ version: {},
75
+ override: {},
76
+ };
77
+ function ensureDefaults(data) {
78
+ const raw = (data ?? {});
79
+ const projectIn = raw.project;
80
+ const project = {
81
+ name: typeof projectIn?.name === "string" ? projectIn.name : "",
82
+ type: typeof projectIn?.type === "string" ? projectIn.type : "",
83
+ ...(typeof projectIn?.description === "string"
84
+ ? { description: projectIn.description }
85
+ : {}),
86
+ };
87
+ const merged = {
88
+ ...exports.EMPTY_MEMORY,
89
+ ...raw,
90
+ project,
91
+ goals: Array.isArray(raw.goals) ? raw.goals : [],
92
+ features: Array.isArray(raw.features) ? raw.features : [],
93
+ pages: Array.isArray(raw.pages) ? raw.pages : [],
94
+ flows: Array.isArray(raw.flows) ? raw.flows : [],
95
+ states: Array.isArray(raw.states) ? raw.states : [],
96
+ edge_cases: Array.isArray(raw.edge_cases)
97
+ ? raw.edge_cases
98
+ : [],
99
+ design_system: isPlainObject(raw.design_system) ? raw.design_system : {},
100
+ tech_stack: isPlainObject(raw.tech_stack) ? raw.tech_stack : {},
101
+ integrations: Array.isArray(raw.integrations) ? raw.integrations : [],
102
+ mcp: Array.isArray(raw.mcp) ? raw.mcp : [],
103
+ rules: Array.isArray(raw.rules) ? raw.rules : [],
104
+ decisions: Array.isArray(raw.decisions) ? raw.decisions : [],
105
+ confidence: typeof raw.confidence === "number" ? raw.confidence : exports.EMPTY_MEMORY.confidence,
106
+ unknowns: Array.isArray(raw.unknowns) ? raw.unknowns : [],
107
+ requires_input: typeof raw.requires_input === "boolean"
108
+ ? raw.requires_input
109
+ : exports.EMPTY_MEMORY.requires_input,
110
+ open_questions: Array.isArray(raw.open_questions)
111
+ ? raw.open_questions
112
+ : [],
113
+ validation: isPlainObject(raw.validation) ? raw.validation : {},
114
+ tests: isPlainObject(raw.tests) ? raw.tests : {},
115
+ version: isPlainObject(raw.version) ? raw.version : {},
116
+ override: isPlainObject(raw.override)
117
+ ? raw.override
118
+ : {},
119
+ };
120
+ return merged;
121
+ }
122
+ function isPlainObject(v) {
123
+ return typeof v === "object" && v !== null && !Array.isArray(v);
124
+ }
125
+ function validateFoundation(m) {
126
+ for (const key of FOUNDATION_KEYS) {
127
+ if (!(key in m) || m[key] === undefined) {
128
+ throw new Error(`memory.json missing foundation key: ${key}`);
129
+ }
130
+ }
131
+ if (typeof m.confidence !== "number" || Number.isNaN(m.confidence)) {
132
+ throw new Error("memory.confidence must be a number");
133
+ }
134
+ if (!m.project || typeof m.project !== "object") {
135
+ throw new Error("memory.project must be an object");
136
+ }
137
+ }
138
+ async function readMemory(cwd) {
139
+ const p = (0, paths_1.memoryJsonPath)(cwd);
140
+ const exists = await fs.pathExists(p);
141
+ if (!exists) {
142
+ throw new Error(`memory not found at ${p}. Run: orqint init`);
143
+ }
144
+ const raw = await fs.readJson(p);
145
+ const m = ensureDefaults(raw);
146
+ validateFoundation(m);
147
+ return m;
148
+ }
149
+ async function writeMemory(cwd, m) {
150
+ validateFoundation(m);
151
+ const p = (0, paths_1.memoryJsonPath)(cwd);
152
+ await fs.ensureDir(path.dirname(p));
153
+ await fs.writeJson(p, m, { spaces: 2 });
154
+ }
155
+ function deepMergeTechStack(current, patch) {
156
+ return { ...current, ...patch };
157
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Extract the first JSON value from raw text (handles ```json fences and prose).
3
+ */
4
+ export declare function parseJsonFromText(raw: string): unknown;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseJsonFromText = parseJsonFromText;
4
+ /**
5
+ * Extract the first JSON value from raw text (handles ```json fences and prose).
6
+ */
7
+ function parseJsonFromText(raw) {
8
+ const trimmed = raw.trim();
9
+ const direct = tryParse(trimmed);
10
+ if (direct !== undefined) {
11
+ return direct;
12
+ }
13
+ const fence = /```(?:json)?\s*([\s\S]*?)```/i.exec(trimmed);
14
+ if (fence) {
15
+ const inner = tryParse(fence[1].trim());
16
+ if (inner !== undefined) {
17
+ return inner;
18
+ }
19
+ }
20
+ const firstBrace = trimmed.indexOf("{");
21
+ const lastBrace = trimmed.lastIndexOf("}");
22
+ if (firstBrace !== -1 && lastBrace > firstBrace) {
23
+ const inner = tryParse(trimmed.slice(firstBrace, lastBrace + 1));
24
+ if (inner !== undefined) {
25
+ return inner;
26
+ }
27
+ }
28
+ throw new Error("No valid JSON object found in input");
29
+ }
30
+ function tryParse(s) {
31
+ try {
32
+ const v = JSON.parse(s);
33
+ return v;
34
+ }
35
+ catch {
36
+ return undefined;
37
+ }
38
+ }
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@orqint/cli",
3
+ "version": "0.1.0",
4
+ "description": "CLI orchestration for Cursor-native think/plan workflows (Orqint)",
5
+ "keywords": [
6
+ "orqint",
7
+ "cursor",
8
+ "cli",
9
+ "orchestration"
10
+ ],
11
+ "license": "UNLICENSED",
12
+ "engines": {
13
+ "node": ">=18"
14
+ },
15
+ "bin": {
16
+ "orqint": "dist/orqint/index.js"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md",
24
+ "AGENTS.md"
25
+ ],
26
+ "scripts": {
27
+ "prepublishOnly": "npm run build",
28
+ "build": "tsc && mkdir -p dist/orqint/prompts && cp packages/cli/prompts/*.txt dist/orqint/prompts/",
29
+ "orqint": "node dist/orqint/index.js",
30
+ "cli:install": "bash scripts/setup-cli.sh",
31
+ "cli:install:pnpm": "pnpm install && pnpm run build && pnpm link --global",
32
+ "cli:upgrade": "bash scripts/update-cli.sh",
33
+ "cli:upgrade:pnpm": "pnpm install --no-frozen-lockfile && pnpm run build"
34
+ },
35
+ "dependencies": {
36
+ "fs-extra": "^11.3.4"
37
+ },
38
+ "devDependencies": {
39
+ "@types/fs-extra": "^11.0.4",
40
+ "@types/node": "^22.15.3",
41
+ "typescript": "^6.0.2"
42
+ }
43
+ }