intentional-cognition-os 1.0.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/LICENSE +21 -0
- package/README.md +171 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +12989 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/001-initial-schema.sql +136 -0
- package/dist/migrations/002-add-source-hash.sql +9 -0
- package/dist/migrations/003-add-failure-statuses.sql +46 -0
- package/package.json +74 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
-- Migration: 001-initial-schema
|
|
2
|
+
-- Description: Create all initial tables, indexes, and pragmas
|
|
3
|
+
-- Date: 2026-04-06
|
|
4
|
+
|
|
5
|
+
-- === UP ===
|
|
6
|
+
|
|
7
|
+
CREATE TABLE sources (
|
|
8
|
+
id TEXT PRIMARY KEY,
|
|
9
|
+
path TEXT NOT NULL,
|
|
10
|
+
mount_id TEXT REFERENCES mounts(id),
|
|
11
|
+
type TEXT NOT NULL CHECK (type IN ('pdf', 'markdown', 'html', 'text')),
|
|
12
|
+
title TEXT,
|
|
13
|
+
author TEXT,
|
|
14
|
+
ingested_at TEXT NOT NULL,
|
|
15
|
+
word_count INTEGER,
|
|
16
|
+
hash TEXT NOT NULL,
|
|
17
|
+
metadata TEXT,
|
|
18
|
+
UNIQUE (path, hash)
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
CREATE TABLE mounts (
|
|
22
|
+
id TEXT PRIMARY KEY,
|
|
23
|
+
name TEXT NOT NULL UNIQUE,
|
|
24
|
+
path TEXT NOT NULL,
|
|
25
|
+
created_at TEXT NOT NULL,
|
|
26
|
+
last_indexed_at TEXT
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
CREATE TABLE compilations (
|
|
30
|
+
id TEXT PRIMARY KEY,
|
|
31
|
+
source_id TEXT REFERENCES sources(id),
|
|
32
|
+
type TEXT NOT NULL CHECK (type IN (
|
|
33
|
+
'summary', 'concept', 'topic',
|
|
34
|
+
'entity', 'contradiction', 'open-question'
|
|
35
|
+
)),
|
|
36
|
+
output_path TEXT NOT NULL,
|
|
37
|
+
compiled_at TEXT NOT NULL,
|
|
38
|
+
stale INTEGER NOT NULL DEFAULT 0 CHECK (stale IN (0, 1)),
|
|
39
|
+
model TEXT NOT NULL,
|
|
40
|
+
tokens_used INTEGER,
|
|
41
|
+
UNIQUE (source_id, type, output_path)
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
CREATE TABLE tasks (
|
|
45
|
+
id TEXT PRIMARY KEY,
|
|
46
|
+
brief TEXT NOT NULL,
|
|
47
|
+
status TEXT NOT NULL DEFAULT 'created' CHECK (status IN (
|
|
48
|
+
'created', 'collecting', 'synthesizing',
|
|
49
|
+
'critiquing', 'rendering', 'completed', 'archived'
|
|
50
|
+
)),
|
|
51
|
+
created_at TEXT NOT NULL,
|
|
52
|
+
updated_at TEXT NOT NULL,
|
|
53
|
+
completed_at TEXT,
|
|
54
|
+
archived_at TEXT,
|
|
55
|
+
workspace_path TEXT NOT NULL
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
CREATE TABLE promotions (
|
|
59
|
+
id TEXT PRIMARY KEY,
|
|
60
|
+
source_path TEXT NOT NULL,
|
|
61
|
+
target_path TEXT NOT NULL,
|
|
62
|
+
target_type TEXT NOT NULL CHECK (target_type IN (
|
|
63
|
+
'topic', 'concept', 'entity', 'reference'
|
|
64
|
+
)),
|
|
65
|
+
promoted_at TEXT NOT NULL,
|
|
66
|
+
promoted_by TEXT NOT NULL CHECK (promoted_by IN ('user', 'system'))
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
CREATE TABLE recall_results (
|
|
70
|
+
id TEXT PRIMARY KEY,
|
|
71
|
+
concept TEXT NOT NULL,
|
|
72
|
+
topic TEXT,
|
|
73
|
+
correct INTEGER NOT NULL CHECK (correct IN (0, 1)),
|
|
74
|
+
tested_at TEXT NOT NULL,
|
|
75
|
+
confidence REAL CHECK (confidence >= 0.0 AND confidence <= 1.0),
|
|
76
|
+
source_card TEXT
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
CREATE TABLE traces (
|
|
80
|
+
id TEXT PRIMARY KEY,
|
|
81
|
+
event_type TEXT NOT NULL,
|
|
82
|
+
correlation_id TEXT,
|
|
83
|
+
timestamp TEXT NOT NULL,
|
|
84
|
+
file_path TEXT NOT NULL,
|
|
85
|
+
line_offset INTEGER NOT NULL,
|
|
86
|
+
summary TEXT
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
CREATE TABLE compilation_sources (
|
|
90
|
+
compilation_id TEXT NOT NULL REFERENCES compilations(id) ON DELETE CASCADE,
|
|
91
|
+
source_id TEXT NOT NULL REFERENCES sources(id),
|
|
92
|
+
PRIMARY KEY (compilation_id, source_id)
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
-- Indexes
|
|
96
|
+
CREATE INDEX idx_sources_hash ON sources(hash);
|
|
97
|
+
CREATE INDEX idx_sources_type ON sources(type);
|
|
98
|
+
CREATE INDEX idx_sources_mount_id ON sources(mount_id);
|
|
99
|
+
CREATE INDEX idx_compilations_source_id ON compilations(source_id);
|
|
100
|
+
CREATE INDEX idx_compilations_type ON compilations(type);
|
|
101
|
+
CREATE INDEX idx_compilations_stale ON compilations(stale) WHERE stale = 1;
|
|
102
|
+
CREATE INDEX idx_compilations_output_path ON compilations(output_path);
|
|
103
|
+
CREATE INDEX idx_tasks_status ON tasks(status);
|
|
104
|
+
CREATE INDEX idx_tasks_created_at ON tasks(created_at);
|
|
105
|
+
CREATE INDEX idx_recall_results_concept ON recall_results(concept);
|
|
106
|
+
CREATE INDEX idx_recall_results_tested_at ON recall_results(tested_at);
|
|
107
|
+
CREATE INDEX idx_traces_event_type ON traces(event_type);
|
|
108
|
+
CREATE INDEX idx_traces_correlation_id ON traces(correlation_id) WHERE correlation_id IS NOT NULL;
|
|
109
|
+
CREATE INDEX idx_traces_timestamp ON traces(timestamp);
|
|
110
|
+
CREATE INDEX idx_compilation_sources_source_id ON compilation_sources(source_id);
|
|
111
|
+
|
|
112
|
+
-- === DOWN ===
|
|
113
|
+
|
|
114
|
+
DROP INDEX IF EXISTS idx_compilation_sources_source_id;
|
|
115
|
+
DROP INDEX IF EXISTS idx_traces_timestamp;
|
|
116
|
+
DROP INDEX IF EXISTS idx_traces_correlation_id;
|
|
117
|
+
DROP INDEX IF EXISTS idx_traces_event_type;
|
|
118
|
+
DROP INDEX IF EXISTS idx_recall_results_tested_at;
|
|
119
|
+
DROP INDEX IF EXISTS idx_recall_results_concept;
|
|
120
|
+
DROP INDEX IF EXISTS idx_tasks_created_at;
|
|
121
|
+
DROP INDEX IF EXISTS idx_tasks_status;
|
|
122
|
+
DROP INDEX IF EXISTS idx_compilations_output_path;
|
|
123
|
+
DROP INDEX IF EXISTS idx_compilations_stale;
|
|
124
|
+
DROP INDEX IF EXISTS idx_compilations_type;
|
|
125
|
+
DROP INDEX IF EXISTS idx_compilations_source_id;
|
|
126
|
+
DROP INDEX IF EXISTS idx_sources_mount_id;
|
|
127
|
+
DROP INDEX IF EXISTS idx_sources_type;
|
|
128
|
+
DROP INDEX IF EXISTS idx_sources_hash;
|
|
129
|
+
DROP TABLE IF EXISTS compilation_sources;
|
|
130
|
+
DROP TABLE IF EXISTS traces;
|
|
131
|
+
DROP TABLE IF EXISTS recall_results;
|
|
132
|
+
DROP TABLE IF EXISTS promotions;
|
|
133
|
+
DROP TABLE IF EXISTS tasks;
|
|
134
|
+
DROP TABLE IF EXISTS compilations;
|
|
135
|
+
DROP TABLE IF EXISTS mounts;
|
|
136
|
+
DROP TABLE IF EXISTS sources;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- Migration: 002-add-source-hash
|
|
2
|
+
-- Description: Add source_hash column to promotions table
|
|
3
|
+
-- Date: 2026-04-06
|
|
4
|
+
|
|
5
|
+
-- === UP ===
|
|
6
|
+
ALTER TABLE promotions ADD COLUMN source_hash TEXT;
|
|
7
|
+
|
|
8
|
+
-- === DOWN ===
|
|
9
|
+
-- SQLite doesn't support DROP COLUMN, so this is a no-op comment
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
-- Migration: 003-add-failure-statuses
|
|
2
|
+
-- Description: Expand tasks.status CHECK constraint to include four
|
|
3
|
+
-- recoverable failure states used by the research orchestrator
|
|
4
|
+
-- (E9-B06): failed_collecting, failed_synthesizing,
|
|
5
|
+
-- failed_critiquing, failed_rendering.
|
|
6
|
+
--
|
|
7
|
+
-- SQLite does not support ALTER COLUMN on CHECK constraints, so
|
|
8
|
+
-- this migration rewrites the tasks table: create a new table
|
|
9
|
+
-- with the expanded constraint, copy rows, drop the old one,
|
|
10
|
+
-- rename. Indexes are rebuilt after the rename. No data loss.
|
|
11
|
+
-- Date: 2026-04-15
|
|
12
|
+
|
|
13
|
+
-- === UP ===
|
|
14
|
+
CREATE TABLE tasks_new (
|
|
15
|
+
id TEXT PRIMARY KEY,
|
|
16
|
+
brief TEXT NOT NULL,
|
|
17
|
+
status TEXT NOT NULL DEFAULT 'created' CHECK (status IN (
|
|
18
|
+
'created', 'collecting', 'synthesizing',
|
|
19
|
+
'critiquing', 'rendering', 'completed', 'archived',
|
|
20
|
+
'failed_collecting', 'failed_synthesizing',
|
|
21
|
+
'failed_critiquing', 'failed_rendering'
|
|
22
|
+
)),
|
|
23
|
+
created_at TEXT NOT NULL,
|
|
24
|
+
updated_at TEXT NOT NULL,
|
|
25
|
+
completed_at TEXT,
|
|
26
|
+
archived_at TEXT,
|
|
27
|
+
workspace_path TEXT NOT NULL
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
INSERT INTO tasks_new (id, brief, status, created_at, updated_at, completed_at, archived_at, workspace_path)
|
|
31
|
+
SELECT id, brief, status, created_at, updated_at, completed_at, archived_at, workspace_path
|
|
32
|
+
FROM tasks;
|
|
33
|
+
|
|
34
|
+
DROP INDEX IF EXISTS idx_tasks_status;
|
|
35
|
+
DROP INDEX IF EXISTS idx_tasks_created_at;
|
|
36
|
+
DROP TABLE tasks;
|
|
37
|
+
ALTER TABLE tasks_new RENAME TO tasks;
|
|
38
|
+
|
|
39
|
+
CREATE INDEX idx_tasks_status ON tasks(status);
|
|
40
|
+
CREATE INDEX idx_tasks_created_at ON tasks(created_at);
|
|
41
|
+
|
|
42
|
+
-- === DOWN ===
|
|
43
|
+
-- Narrowing the CHECK back would require migrating any failure-state rows
|
|
44
|
+
-- to a legal value first. Intentionally no-op: rolling back this migration
|
|
45
|
+
-- on a populated database would silently discard state. Restore from a
|
|
46
|
+
-- pre-migration backup instead.
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "intentional-cognition-os",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Local-first knowledge operating system. Compile knowledge for the machine; distill understanding for the human.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"ico": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"knowledge-management",
|
|
22
|
+
"ai",
|
|
23
|
+
"claude",
|
|
24
|
+
"anthropic",
|
|
25
|
+
"rag",
|
|
26
|
+
"research",
|
|
27
|
+
"cli",
|
|
28
|
+
"local-first",
|
|
29
|
+
"knowledge-graph"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=22.0.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsup",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"lint": "eslint .",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"clean": "rm -rf dist .tsbuildinfo",
|
|
40
|
+
"prepublishOnly": "pnpm -w build && pnpm -w lint && pnpm -w typecheck && pnpm -w test",
|
|
41
|
+
"verify-pack": "bash ../../scripts/verify-npm-pack.sh"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@anthropic-ai/sdk": "^0.82.0",
|
|
45
|
+
"better-sqlite3": "^11.9.0",
|
|
46
|
+
"commander": "^13.0.0",
|
|
47
|
+
"gray-matter": "^4.0.3",
|
|
48
|
+
"js-yaml": "^4.1.1",
|
|
49
|
+
"pdf-parse": "^2.4.5",
|
|
50
|
+
"turndown": "^7.2.4"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@ico/compiler": "workspace:*",
|
|
54
|
+
"@ico/kernel": "workspace:*",
|
|
55
|
+
"@ico/types": "workspace:*",
|
|
56
|
+
"tsup": "^8.4.0",
|
|
57
|
+
"typescript": "^5.8.0",
|
|
58
|
+
"vitest": "^4.1.2"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
62
|
+
},
|
|
63
|
+
"repository": {
|
|
64
|
+
"type": "git",
|
|
65
|
+
"url": "https://github.com/jeremylongshore/intentional-cognition-os.git",
|
|
66
|
+
"directory": "packages/cli"
|
|
67
|
+
},
|
|
68
|
+
"bugs": {
|
|
69
|
+
"url": "https://github.com/jeremylongshore/intentional-cognition-os/issues"
|
|
70
|
+
},
|
|
71
|
+
"homepage": "https://github.com/jeremylongshore/intentional-cognition-os#readme",
|
|
72
|
+
"license": "MIT",
|
|
73
|
+
"author": "Jeremy Longshore <jeremy@intentsolutions.io> (https://intentsolutions.io)"
|
|
74
|
+
}
|