@postnesia/cli 0.1.6 → 0.1.7

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 (2) hide show
  1. package/dist/index.js +33 -0
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -124,6 +124,39 @@ memory
124
124
  const relationships = queries.getMemoryRelationships(db).all(id, id);
125
125
  process.stdout.write(JSON.stringify(relationships, null, 2) + '\n');
126
126
  });
127
+ memory
128
+ .command('link <fromId> <toId>')
129
+ .description('Create a typed relationship between two memories')
130
+ .requiredOption('-t, --type <type>', 'related|supersedes|supports|contradicts|derives_from')
131
+ .action((fromId, toId, opts) => {
132
+ const from = parseInt(fromId, 10);
133
+ const to = parseInt(toId, 10);
134
+ const fromMem = db.prepare('SELECT id FROM memory WHERE id = ?').get(from);
135
+ if (!fromMem)
136
+ throw new Error(`Memory #${from} not found`);
137
+ const toMem = db.prepare('SELECT id FROM memory WHERE id = ?').get(to);
138
+ if (!toMem)
139
+ throw new Error(`Memory #${to} not found`);
140
+ const existing = queries.findRelationshipBetween(db).get(from, to, opts.type);
141
+ if (existing) {
142
+ process.stdout.write(`Relationship already exists (id: ${existing.id})\n`);
143
+ return;
144
+ }
145
+ const result = queries.insertRelationship(db).run(from, to, opts.type);
146
+ const id = Number(result.lastInsertRowid);
147
+ process.stdout.write(`✓ Created relationship #${id}: #${from} -[${opts.type}]-> #${to}\n`);
148
+ });
149
+ memory
150
+ .command('unlink <relationshipId>')
151
+ .description('Remove a relationship by its ID')
152
+ .action((relationshipId) => {
153
+ const id = parseInt(relationshipId, 10);
154
+ const existing = db.prepare('SELECT id FROM relationship WHERE id = ?').get(id);
155
+ if (!existing)
156
+ throw new Error(`Relationship #${id} not found`);
157
+ queries.deleteRelationship(db).run(id);
158
+ process.stdout.write(`✓ Deleted relationship #${id}\n`);
159
+ });
127
160
  // ---------------------------------------------------------------------------
128
161
  // journal
129
162
  // ---------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postnesia/cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Commander CLI for Postnesia — direct tool access for agents",
5
5
  "type": "module",
6
6
  "private": false,
@@ -11,9 +11,9 @@
11
11
  "postnesia": "./dist/index.js"
12
12
  },
13
13
  "dependencies": {
14
- "@postnesia/db": "^0.1.5",
15
14
  "commander": "^14.0.3",
16
- "dotenv": "^17.3.1"
15
+ "dotenv": "^17.3.1",
16
+ "@postnesia/db": "0.1.7"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/node": "^22.10.5",