cognetivy 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.
Files changed (119) hide show
  1. package/README.md +204 -0
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +980 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/config.d.ts +27 -0
  7. package/dist/config.d.ts.map +1 -0
  8. package/dist/config.js +46 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/default-artifact-schema.d.ts +4 -0
  11. package/dist/default-artifact-schema.d.ts.map +1 -0
  12. package/dist/default-artifact-schema.js +5 -0
  13. package/dist/default-artifact-schema.js.map +1 -0
  14. package/dist/default-collection-schema.d.ts +3 -0
  15. package/dist/default-collection-schema.d.ts.map +1 -0
  16. package/dist/default-collection-schema.js +16 -0
  17. package/dist/default-collection-schema.js.map +1 -0
  18. package/dist/default-workflow.d.ts +7 -0
  19. package/dist/default-workflow.d.ts.map +1 -0
  20. package/dist/default-workflow.js +57 -0
  21. package/dist/default-workflow.js.map +1 -0
  22. package/dist/index.d.ts +9 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +9 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/install-tui.d.ts +14 -0
  27. package/dist/install-tui.d.ts.map +1 -0
  28. package/dist/install-tui.js +172 -0
  29. package/dist/install-tui.js.map +1 -0
  30. package/dist/installer-assets/favicon.png +0 -0
  31. package/dist/installer-assets/icon-pixelized.png +0 -0
  32. package/dist/installer-assets/icon-pixelized2.png +0 -0
  33. package/dist/kind-templates.d.ts +6 -0
  34. package/dist/kind-templates.d.ts.map +1 -0
  35. package/dist/kind-templates.js +47 -0
  36. package/dist/kind-templates.js.map +1 -0
  37. package/dist/mcp.d.ts +6 -0
  38. package/dist/mcp.d.ts.map +1 -0
  39. package/dist/mcp.js +732 -0
  40. package/dist/mcp.js.map +1 -0
  41. package/dist/models.d.ts +150 -0
  42. package/dist/models.d.ts.map +1 -0
  43. package/dist/models.js +23 -0
  44. package/dist/models.js.map +1 -0
  45. package/dist/mutation.d.ts +11 -0
  46. package/dist/mutation.d.ts.map +1 -0
  47. package/dist/mutation.js +24 -0
  48. package/dist/mutation.js.map +1 -0
  49. package/dist/skills.d.ts +127 -0
  50. package/dist/skills.d.ts.map +1 -0
  51. package/dist/skills.js +702 -0
  52. package/dist/skills.js.map +1 -0
  53. package/dist/studio/assets/html2canvas.esm-C5Fx4D8v.js +5 -0
  54. package/dist/studio/assets/html2canvas.esm-DXEQVQnt.js +5 -0
  55. package/dist/studio/assets/index-5HXAsU4p.js +74 -0
  56. package/dist/studio/assets/index-B1aL7jAk.js +57 -0
  57. package/dist/studio/assets/index-B2G_F__P.css +1 -0
  58. package/dist/studio/assets/index-BO2PmdDj.css +1 -0
  59. package/dist/studio/assets/index-Bbhu9ZEt.css +1 -0
  60. package/dist/studio/assets/index-BjW5ogyU.js +96 -0
  61. package/dist/studio/assets/index-BzAnUkaS.js +74 -0
  62. package/dist/studio/assets/index-C0crAUM8.css +1 -0
  63. package/dist/studio/assets/index-CXZmAIuY.js +91 -0
  64. package/dist/studio/assets/index-Cd1ymjRj.js +96 -0
  65. package/dist/studio/assets/index-CrMnnQO-.css +1 -0
  66. package/dist/studio/assets/index-D1J5_8Th.js +91 -0
  67. package/dist/studio/assets/index-DI1FMf0r.js +57 -0
  68. package/dist/studio/assets/index-DmV3GQK3.css +1 -0
  69. package/dist/studio/assets/index-DoIh_odG.js +57 -0
  70. package/dist/studio/assets/index-Dq9jftDf.js +91 -0
  71. package/dist/studio/assets/index-ZiR_njv1.js +96 -0
  72. package/dist/studio/assets/index-ctxo2E0F.css +1 -0
  73. package/dist/studio/assets/index-fTm91Iph.css +1 -0
  74. package/dist/studio/assets/index-uHQLfD-r.css +1 -0
  75. package/dist/studio/assets/index.es-BgB1THzs.js +5 -0
  76. package/dist/studio/assets/index.es-DhJ1KIdk.js +5 -0
  77. package/dist/studio/assets/index.es-DoO31ZM_.js +5 -0
  78. package/dist/studio/assets/index.es-dcgfUrS8.js +5 -0
  79. package/dist/studio/assets/index.es-j2tEOPI7.js +5 -0
  80. package/dist/studio/assets/index.es-zcnPOBL8.js +5 -0
  81. package/dist/studio/assets/jspdf.es.min-4bkGOR48.js +79 -0
  82. package/dist/studio/assets/jspdf.es.min-B7A3pncP.js +79 -0
  83. package/dist/studio/assets/jspdf.es.min-C-v2XVac.js +79 -0
  84. package/dist/studio/assets/jspdf.es.min-D4KCUvlV.js +79 -0
  85. package/dist/studio/assets/jspdf.es.min-DtNe0aer.js +79 -0
  86. package/dist/studio/assets/jspdf.es.min-SPz-8IlP.js +79 -0
  87. package/dist/studio/assets/marked.esm-Brtrz5BF.js +59 -0
  88. package/dist/studio/assets/purify.es-Bzr520pe.js +2 -0
  89. package/dist/studio/favicon.png +0 -0
  90. package/dist/studio/icon-pixelized.png +0 -0
  91. package/dist/studio/icon-pixelized2.png +0 -0
  92. package/dist/studio/icon.jpg +0 -0
  93. package/dist/studio/index.html +14 -0
  94. package/dist/studio/vite.svg +1 -0
  95. package/dist/studio-server.d.ts +17 -0
  96. package/dist/studio-server.d.ts.map +1 -0
  97. package/dist/studio-server.js +347 -0
  98. package/dist/studio-server.js.map +1 -0
  99. package/dist/terminal-png.d.ts +22 -0
  100. package/dist/terminal-png.d.ts.map +1 -0
  101. package/dist/terminal-png.js +100 -0
  102. package/dist/terminal-png.js.map +1 -0
  103. package/dist/validate-artifact.d.ts +16 -0
  104. package/dist/validate-artifact.d.ts.map +1 -0
  105. package/dist/validate-artifact.js +34 -0
  106. package/dist/validate-artifact.js.map +1 -0
  107. package/dist/validate-collection.d.ts +16 -0
  108. package/dist/validate-collection.d.ts.map +1 -0
  109. package/dist/validate-collection.js +67 -0
  110. package/dist/validate-collection.js.map +1 -0
  111. package/dist/validate.d.ts +12 -0
  112. package/dist/validate.d.ts.map +1 -0
  113. package/dist/validate.js +63 -0
  114. package/dist/validate.js.map +1 -0
  115. package/dist/workspace.d.ts +115 -0
  116. package/dist/workspace.d.ts.map +1 -0
  117. package/dist/workspace.js +509 -0
  118. package/dist/workspace.js.map +1 -0
  119. package/package.json +47 -0
package/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # cognetivy
2
+
3
+ Reasoning orchestration state: workflow structure, run logs, versioned mutations, and **structured artifacts**. **No LLMs** — cognetivy stores workflow definitions, run metadata, append-only event logs (NDJSON), workflow mutations (JSON Patch), and schema-backed artifact entities (sources, collected data, ideas) that agents can read and write with a known, modifiable schema.
4
+
5
+ - **Global CLI**: install once, use in any folder. All project state lives in a folder-local workspace (`.cognetivy/`).
6
+ - **Config**: user-level defaults in `~/.config/cognetivy/config.json` (via [env-paths](https://www.npmjs.com/package/env-paths)); local overrides in `.cognetivy/config.json`.
7
+ - **MCP server**: same operations exposed as tools for Cursor/agents via `cognetivy mcp [--workspace <path>]`.
8
+ - **Studio**: read-only browser UI for workflow, runs, events, artifacts, and mutations via `cognetivy studio [--workspace <path>] [--port <port>]`.
9
+
10
+ ## Quickstart
11
+
12
+ ```bash
13
+ npm i -g . # or: npm i -g cognetivy
14
+ cognetivy init
15
+ cognetivy workflow get
16
+ cognetivy run start --input sample_input.json
17
+ ```
18
+
19
+ ## Workspace layout (created by `cognetivy init`)
20
+
21
+ ```
22
+ ./.cognetivy/
23
+ workflow.json # pointer to current workflow version
24
+ artifact-schema.json # entity kinds and schema (agent-defined; empty by default)
25
+ workflow.versions/
26
+ wf_v1.json # immutable workflow version files
27
+ runs/
28
+ <run_id>.json # run metadata
29
+ events/
30
+ <run_id>.ndjson # append-only event log per run
31
+ mutations/
32
+ <mutation_id>.json # proposed mutation patches + status
33
+ artifacts/
34
+ <run_id>/
35
+ <kind>.json # per-run artifact data (when kind has global: false)
36
+ data/
37
+ <kind>.json # cross-run entity data (when kind has global: true)
38
+ ```
39
+
40
+ By default, `cognetivy init` adds a `.gitignore` snippet so `runs/`, `events/`, `mutations/`, and `artifacts/` are ignored; `workflow.versions/` and `artifact-schema.json` are intended to be committed. Use `--no-gitignore` to skip.
41
+
42
+ ## CLI commands
43
+
44
+ | Command | Description |
45
+ |--------|--------------|
46
+ | `cognetivy init` | Create `.cognetivy/` and default workflow. Options: `--no-gitignore`, `--force` |
47
+ | `cognetivy workflow get` | Print current workflow version JSON to stdout |
48
+ | `cognetivy workflow set --file <path>` | Set workflow from JSON file (creates new version, updates pointer) |
49
+ | `cognetivy run start --input <path> [--name <string>] [--by <string>]` | Start a run; prints `run_id` then `COGNETIVY_RUN_ID=...` (machine-readable) |
50
+ | `cognetivy run status --run <run_id> [--json]` | Run status: node completion and collection item counts; optional `--json` |
51
+ | `cognetivy run set-name --run <run_id> --name <string>` | Set human-readable name for an existing run |
52
+ | `cognetivy event append --run <run_id> [--file <path>] [--by <string>]` | Append one event (JSON from file or stdin) to run's NDJSON log |
53
+ | `cognetivy node start --run <run_id> --node <node_id>` | Append step_started, create started node result; prints `COGNETIVY_NODE_RESULT_ID=...` |
54
+ | `cognetivy node complete` (run, node, status; optional output, collection-kind with file or stdin) | Create node result, optional collection write, append step_completed; prints `COGNETIVY_NODE_RESULT_ID=...` |
55
+ | `cognetivy mutate propose --patch <path> --reason "<text>" [--by <string>]` | Propose a mutation (JSON Patch); prints `mutation_id` |
56
+ | `cognetivy mutate apply <mutation_id> [--by <string>]` | Apply a proposed mutation (new version, update pointer) |
57
+ | `cognetivy artifact-schema get` | Print artifact schema (kinds + required fields) to stdout |
58
+ | `cognetivy artifact-schema set --file <path>` | Set artifact schema from JSON file |
59
+ | `cognetivy artifact list --run <run_id>` | List artifact kinds that have data for a run |
60
+ | `cognetivy artifact get --run <run_id> --kind <kind>` | Get all artifacts of a kind for a run |
61
+ | `cognetivy artifact set --run <run_id> --kind <kind> --file <path>` | Replace artifacts of a kind (JSON array) |
62
+ | `cognetivy artifact append --run <run_id> --kind <kind> --file <path> [--id <id>]` | Append one artifact item (validated) |
63
+ | `cognetivy install claude \| openclaw \| workspace [--force]` | Install skills from current directory (SKILL.md or skills/*) into target |
64
+ | `cognetivy skills list [--source <agent\|openclaw\|workspace>] [--eligible]` | List skills from configured sources |
65
+ | `cognetivy skills info <name>` | Show one skill (path, frontmatter, body preview) |
66
+ | `cognetivy skills check [path]` | Validate SKILL.md (path = skill dir; omit to check all) |
67
+ | `cognetivy skills paths` | Print discovery and install target paths |
68
+ | `cognetivy skills install [source] [--target agent\|openclaw\|workspace] [--force]` | Install from local path or git URL (omit source = current directory) |
69
+ | `cognetivy skills update [name] [--target <target>] [--all] [--dry-run]` | Update skill(s) from recorded origin |
70
+ | `cognetivy mcp [--workspace <path>]` | Start MCP server over stdio for Cursor/agents |
71
+ | `cognetivy studio [--workspace <path>] [--port <port>]` | Start read-only Studio and open in browser |
72
+ | `cognetivy studio --api-only [--workspace <path>] [--port <port>]` | Serve only the Studio API (for dev with Vite; see Studio dev mode below) |
73
+
74
+ **Tip:** Collection payload for `node complete` can be piped from stdin when `--collection-file` is omitted (e.g. `echo '<json>' | cognetivy node complete --run <id> --node <id> --status completed --collection-kind <kind>`).
75
+
76
+ ## Skills (Agent skills and OpenClaw skills)
77
+
78
+ cognetivy supports the **SKILL.md** format (Agent skills / OpenClaw skills): a directory containing `SKILL.md` with YAML frontmatter (`name`, `description`, optional `license`, `compatibility`, `metadata`, `allowed-tools`) and markdown instructions. You can manage skills **without using MCP** — install, update, list, and validate from the CLI so that agents (e.g. OpenClaw, Cursor, and other compatible tools) load them from disk.
79
+
80
+ - **Discovery sources**: `agent` (e.g. `~/.cursor/skills`, `.cursor/skills`), `openclaw` (`~/.openclaw/workspace/skills` and `skills.load.extraDirs` from `~/.openclaw/openclaw.json`), `workspace` (`.cognetivy/skills` and user config dir).
81
+ - **Install (target-specific)**: From the current directory, run `cognetivy install claude`, `cognetivy install openclaw`, or `cognetivy install workspace`. Supports two folder layouts: a single skill with `SKILL.md` in the current directory, or a pack with `skills/<skill-name>/SKILL.md` for each skill. Installs into the standard dirs for that target (e.g. claude → `~/.claude/skills` and `.claude/skills`; openclaw → `~/.openclaw/workspace/skills`).
82
+ - **Install (skills subcommand)**: `cognetivy skills install` (or with a path/git URL) installs from current directory or source; use `--target` or default `workspace`. Same folder layout (SKILL.md in cwd or `skills/*/SKILL.md`). Origin is recorded for `skills update`.
83
+ - **Config** (in `~/.config/cognetivy/config.json` or `.cognetivy/config.json`):
84
+ - `skills.sources` — which sources to scan when listing (default: all).
85
+ - `skills.extraDirs` — extra directories to scan.
86
+ - `skills.default_install_target` — default for `install` / `update` when `--target` is omitted.
87
+
88
+ When using the cognetivy MCP server (e.g. in Cursor), the tools **skills_list** and **skills_get** let the agent discover and load skill content on demand.
89
+
90
+ ## MCP tools (1:1 with CLI)
91
+
92
+ - `workflow_get()` — get current workflow JSON
93
+ - `workflow_set(workflow_json)` — set workflow (new version)
94
+ - `run_start(input_json, name?, by?)` — start run; returns `run_id`
95
+ - `run_status(run_id)` — run status (nodes + collection counts)
96
+ - `event_append(run_id, event_json, by?)` — append event to run
97
+ - `node_start(run_id, node_id, by?)` — append step_started, create started node result; returns `{ node_result_id }`
98
+ - `node_complete(run_id, node_id, status, output?, collection_kind?, collection_items?|collection_payload?, ...)` — create node result, optional collection, append step_completed; returns `{ node_result_id }`
99
+ - `mutate_propose(patch_json, reason, by?)` — propose mutation; returns `mutation_id`
100
+ - `mutate_apply(mutation_id, by?)` — apply mutation
101
+ - `artifact_schema_get()` — get artifact schema (kinds and required fields)
102
+ - `artifact_schema_set(schema_json)` — set artifact schema (agent defines kinds; use `global: true` for cross-run kinds)
103
+ - `artifact_list(run_id)` — list artifact kinds with data for run
104
+ - `artifact_get(run_id, kind)` — get structured artifacts for a kind
105
+ - `artifact_set(run_id, kind, items)` — replace all items for a kind (schema-validated)
106
+ - `artifact_append(run_id, kind, payload, id?)` — append one item (schema-validated); returns item with `id`, `created_at`
107
+ - `skills_list(sources?)` — list Agent/OpenClaw skills (name, description, path, source)
108
+ - `skills_get(name)` — get full SKILL.md content for a skill by name
109
+
110
+ If the workspace is missing, the MCP server exits with a message to run `cognetivy init`.
111
+
112
+ ## Connecting Cursor to cognetivy MCP
113
+
114
+ So Cursor (or another MCP client) can call cognetivy tools:
115
+
116
+ 1. **Install cognetivy** (if not already):
117
+ `npm i -g cognetivy` or from this repo: `npm i -g ./cli`
118
+
119
+ 2. **Add the MCP server** in Cursor:
120
+
121
+ - **Settings → Tools & MCP → Add new MCP server**, then:
122
+ - **Name**: `cognetivy`
123
+ - **Type**: `command`
124
+ - **Command**: `cognetivy` (or full path to the CLI)
125
+ - **Args**: `mcp` — or `mcp`, `--workspace`, `/path/to/your/project` if the project with `.cognetivy/` is not the current folder.
126
+
127
+ - **Or** put a config file in your project (the one that has `.cognetivy/`):
128
+
129
+ **Project-level** — in the project root (e.g. `example-usage/.cursor/mcp.json`):
130
+
131
+ ```json
132
+ {
133
+ "mcpServers": {
134
+ "cognetivy": {
135
+ "command": "cognetivy",
136
+ "args": ["mcp"]
137
+ }
138
+ }
139
+ }
140
+ ```
141
+
142
+ Cursor usually starts the server with the project root as cwd, so `cognetivy mcp` will use that project’s `.cognetivy/`.
143
+
144
+ - **Or** use a **global** config at `~/.cursor/mcp.json` with the same `mcpServers.cognetivy` entry. Then the workspace is the folder you have open in Cursor; if your repo root is not the folder with `.cognetivy/`, use:
145
+
146
+ ```json
147
+ "args": ["mcp", "--workspace", "/absolute/path/to/folder/with/.cognetivy"]
148
+ ```
149
+
150
+ 3. **Restart Cursor** so it picks up the new MCP server.
151
+
152
+ 4. In chat, the cognetivy tools (workflow, run, event, mutate, and **artifact** / **artifact_schema**) should appear and be callable by the agent.
153
+
154
+ In this repo, the root `.cursor/mcp.json` is set to `--workspace example-usage` so the agent uses the `example-usage` workspace when you have the cognetivy repo open.
155
+
156
+ ## Studio (read-only visualization)
157
+
158
+ Run `cognetivy studio [--workspace <path>] [--port <port>]` to start a local HTTP server and open a browser to a read-only UI that shows the current workflow (DAG), runs, events, artifacts, mutations, and artifact schema. Default port is 3742. The server binds to 127.0.0.1. No write operations; the UI polls the API every few seconds for updates.
159
+
160
+ From the repo, build the CLI and Studio together so the Studio app is embedded: `cd cli && npm run build:full`. Then run `cognetivy studio --workspace example-usage` (or `node cli/dist/cli.js studio --workspace example-usage`).
161
+
162
+ ### Studio dev mode (hot reload with a selected workspace)
163
+
164
+ To run the Studio UI in **development mode** (Vite hot reload) against a specific workspace:
165
+
166
+ 1. **Terminal 1 — API only** (from repo root or any directory):
167
+ ```bash
168
+ cognetivy studio --api-only --workspace <path-to-workspace> [--port 3742]
169
+ ```
170
+ Example: `cognetivy studio --api-only --workspace example-usage`
171
+ Leave this running. Default port is 3742; if you use a different `--port`, update the proxy in `studio/vite.config.ts` to match.
172
+
173
+ 2. **Terminal 2 — Vite dev server**:
174
+ ```bash
175
+ cd studio && npm run dev
176
+ ```
177
+ Then open **http://localhost:5173** in your browser. The app proxies `/api` to the API server, so the UI uses the workspace you started in terminal 1.
178
+
179
+ ## Data formats
180
+
181
+ - **workflow.json**: `{ "workflow_id", "current_version" }`
182
+ - **workflow.versions/wf_vN.json**: `{ "workflow_id", "version", "nodes", "edges" }` (nodes have `id`, `type`, `contract`, optional `description`)
183
+ - **artifact-schema.json**: `{ "kinds": { "<kind>": { "description", "required": [], "properties": {} } } }` — modifiable; default kinds: `sources`, `collected`, `ideas`
184
+ - **artifacts/<run_id>/<kind>.json**: `{ "run_id", "kind", "updated_at", "items": [ { "id?", "created_at?", ...payload } ] }` — items validated against schema
185
+ - **runs/<run_id>.json**: `{ "run_id", optional "name", "workflow_id", "workflow_version", "status", "input", "created_at" }`
186
+ - **events/<run_id>.ndjson**: one JSON object per line (`ts`, `type`, `by`, `data`)
187
+ - **mutations/<mutation_id>.json**: RFC 6902 JSON Patch + `target`, `reason`, `status`, `applied_to_version` when applied
188
+
189
+ ## Development
190
+
191
+ ```bash
192
+ cd cli
193
+ npm install
194
+ npm run build
195
+ npm test
196
+ ```
197
+
198
+ To build the CLI with the Studio app embedded (so `cognetivy studio` serves the UI): `npm run build:full` from the `cli` directory (builds the sibling `studio/` app and copies its output into `cli/dist/studio`).
199
+
200
+ Tests use Node's built-in test runner and cover: init structure, run start + event append, artifact schema/storage, and mutate apply (v2 + pointer update).
201
+
202
+ ## License
203
+
204
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}