memnant 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.
- package/LICENSE +21 -0
- package/README.md +101 -0
- package/dist/cli/ask.d.ts +9 -0
- package/dist/cli/ask.d.ts.map +1 -0
- package/dist/cli/ask.js +103 -0
- package/dist/cli/ask.js.map +1 -0
- package/dist/cli/check-copy.d.ts +8 -0
- package/dist/cli/check-copy.d.ts.map +1 -0
- package/dist/cli/check-copy.js +68 -0
- package/dist/cli/check-copy.js.map +1 -0
- package/dist/cli/check-design.d.ts +8 -0
- package/dist/cli/check-design.d.ts.map +1 -0
- package/dist/cli/check-design.js +100 -0
- package/dist/cli/check-design.js.map +1 -0
- package/dist/cli/default-action.d.ts +10 -0
- package/dist/cli/default-action.d.ts.map +1 -0
- package/dist/cli/default-action.js +94 -0
- package/dist/cli/default-action.js.map +1 -0
- package/dist/cli/export.d.ts +10 -0
- package/dist/cli/export.d.ts.map +1 -0
- package/dist/cli/export.js +109 -0
- package/dist/cli/export.js.map +1 -0
- package/dist/cli/index.d.ts +12 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +77 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.d.ts +10 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +157 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/instructions.d.ts +12 -0
- package/dist/cli/instructions.d.ts.map +1 -0
- package/dist/cli/instructions.js +117 -0
- package/dist/cli/instructions.js.map +1 -0
- package/dist/cli/lint.d.ts +9 -0
- package/dist/cli/lint.d.ts.map +1 -0
- package/dist/cli/lint.js +131 -0
- package/dist/cli/lint.js.map +1 -0
- package/dist/cli/log.d.ts +10 -0
- package/dist/cli/log.d.ts.map +1 -0
- package/dist/cli/log.js +83 -0
- package/dist/cli/log.js.map +1 -0
- package/dist/cli/promote.d.ts +9 -0
- package/dist/cli/promote.d.ts.map +1 -0
- package/dist/cli/promote.js +70 -0
- package/dist/cli/promote.js.map +1 -0
- package/dist/cli/recall.d.ts +10 -0
- package/dist/cli/recall.d.ts.map +1 -0
- package/dist/cli/recall.js +98 -0
- package/dist/cli/recall.js.map +1 -0
- package/dist/cli/serve.d.ts +10 -0
- package/dist/cli/serve.d.ts.map +1 -0
- package/dist/cli/serve.js +17 -0
- package/dist/cli/serve.js.map +1 -0
- package/dist/cli/session.d.ts +10 -0
- package/dist/cli/session.d.ts.map +1 -0
- package/dist/cli/session.js +226 -0
- package/dist/cli/session.js.map +1 -0
- package/dist/cli/setup.d.ts +11 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +103 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/snapshot.d.ts +9 -0
- package/dist/cli/snapshot.d.ts.map +1 -0
- package/dist/cli/snapshot.js +126 -0
- package/dist/cli/snapshot.js.map +1 -0
- package/dist/cli/specs.d.ts +8 -0
- package/dist/cli/specs.d.ts.map +1 -0
- package/dist/cli/specs.js +96 -0
- package/dist/cli/specs.js.map +1 -0
- package/dist/cli/status.d.ts +8 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +40 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/cli/telegram.d.ts +8 -0
- package/dist/cli/telegram.d.ts.map +1 -0
- package/dist/cli/telegram.js +40 -0
- package/dist/cli/telegram.js.map +1 -0
- package/dist/cli/test-persona.d.ts +9 -0
- package/dist/cli/test-persona.d.ts.map +1 -0
- package/dist/cli/test-persona.js +176 -0
- package/dist/cli/test-persona.js.map +1 -0
- package/dist/config/defaults.d.ts +9 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +56 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/context/compile.d.ts +29 -0
- package/dist/context/compile.d.ts.map +1 -0
- package/dist/context/compile.js +415 -0
- package/dist/context/compile.js.map +1 -0
- package/dist/governor/copy-check.d.ts +24 -0
- package/dist/governor/copy-check.d.ts.map +1 -0
- package/dist/governor/copy-check.js +75 -0
- package/dist/governor/copy-check.js.map +1 -0
- package/dist/governor/design-check.d.ts +20 -0
- package/dist/governor/design-check.d.ts.map +1 -0
- package/dist/governor/design-check.js +40 -0
- package/dist/governor/design-check.js.map +1 -0
- package/dist/governor/specs.d.ts +58 -0
- package/dist/governor/specs.d.ts.map +1 -0
- package/dist/governor/specs.js +183 -0
- package/dist/governor/specs.js.map +1 -0
- package/dist/ledger/database.d.ts +12 -0
- package/dist/ledger/database.d.ts.map +1 -0
- package/dist/ledger/database.js +56 -0
- package/dist/ledger/database.js.map +1 -0
- package/dist/ledger/records.d.ts +19 -0
- package/dist/ledger/records.d.ts.map +1 -0
- package/dist/ledger/records.js +40 -0
- package/dist/ledger/records.js.map +1 -0
- package/dist/ledger/sessions.d.ts +15 -0
- package/dist/ledger/sessions.d.ts.map +1 -0
- package/dist/ledger/sessions.js +54 -0
- package/dist/ledger/sessions.js.map +1 -0
- package/dist/mcp/server.d.ts +9 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +295 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/orchestrator/context.d.ts +22 -0
- package/dist/orchestrator/context.d.ts.map +1 -0
- package/dist/orchestrator/context.js +142 -0
- package/dist/orchestrator/context.js.map +1 -0
- package/dist/orchestrator/providers.d.ts +17 -0
- package/dist/orchestrator/providers.d.ts.map +1 -0
- package/dist/orchestrator/providers.js +57 -0
- package/dist/orchestrator/providers.js.map +1 -0
- package/dist/orchestrator/router.d.ts +30 -0
- package/dist/orchestrator/router.d.ts.map +1 -0
- package/dist/orchestrator/router.js +83 -0
- package/dist/orchestrator/router.js.map +1 -0
- package/dist/snapshot/scanner.d.ts +63 -0
- package/dist/snapshot/scanner.d.ts.map +1 -0
- package/dist/snapshot/scanner.js +293 -0
- package/dist/snapshot/scanner.js.map +1 -0
- package/dist/telegram/bot.d.ts +14 -0
- package/dist/telegram/bot.d.ts.map +1 -0
- package/dist/telegram/bot.js +139 -0
- package/dist/telegram/bot.js.map +1 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/dist/vector/embeddings.d.ts +11 -0
- package/dist/vector/embeddings.d.ts.map +1 -0
- package/dist/vector/embeddings.js +30 -0
- package/dist/vector/embeddings.js.map +1 -0
- package/dist/vector/search.d.ts +26 -0
- package/dist/vector/search.d.ts.map +1 -0
- package/dist/vector/search.js +51 -0
- package/dist/vector/search.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memnant export — Export the ledger to portable formats.
|
|
3
|
+
*
|
|
4
|
+
* Story 1.5: Exports all records as markdown (one file per record, organised
|
|
5
|
+
* by type subdirectory) or as a single JSON file. Supports --since date filtering.
|
|
6
|
+
* Export is a full snapshot — previous files are overwritten.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, readFileSync, mkdirSync, writeFileSync, rmSync } from 'fs';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
import yaml from 'js-yaml';
|
|
11
|
+
import { openDatabase } from '../ledger/database.js';
|
|
12
|
+
const TYPE_SUBDIRS = {
|
|
13
|
+
decision: 'decisions',
|
|
14
|
+
session_log: 'session_logs',
|
|
15
|
+
framework_fix: 'framework_fixes',
|
|
16
|
+
spec_snapshot: 'spec_snapshots',
|
|
17
|
+
codebase_snapshot: 'codebase_snapshots',
|
|
18
|
+
orchestrator_task: 'orchestrator_tasks',
|
|
19
|
+
};
|
|
20
|
+
export function registerExportCommand(program) {
|
|
21
|
+
program
|
|
22
|
+
.command('export')
|
|
23
|
+
.description('Export the ledger to markdown or JSON')
|
|
24
|
+
.option('--format <format>', 'Export format: markdown or json', 'markdown')
|
|
25
|
+
.option('--since <date>', 'Export only records after YYYY-MM-DD')
|
|
26
|
+
.action((opts) => {
|
|
27
|
+
// Validate --format
|
|
28
|
+
if (opts.format !== 'markdown' && opts.format !== 'json') {
|
|
29
|
+
console.error(`Unknown export format '${opts.format}'. Valid formats: markdown, json`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
// Validate --since
|
|
33
|
+
if (opts.since && !/^\d{4}-\d{2}-\d{2}$/.test(opts.since)) {
|
|
34
|
+
console.error(`Invalid date format '${opts.since}'. Expected YYYY-MM-DD (e.g. 2025-01-01).`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
// Load project config
|
|
38
|
+
const cwd = process.cwd();
|
|
39
|
+
const configPath = join(cwd, 'memnant.yaml');
|
|
40
|
+
if (!existsSync(configPath)) {
|
|
41
|
+
console.error('No memnant project found. Run `memnant init` first.');
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
const config = yaml.load(readFileSync(configPath, 'utf-8'));
|
|
45
|
+
const dbPath = join(cwd, config.memory.db_path);
|
|
46
|
+
if (!existsSync(dbPath)) {
|
|
47
|
+
console.error(`Ledger database not found at ${config.memory.db_path}. Run \`memnant init\` to recreate.`);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
const db = openDatabase(dbPath);
|
|
51
|
+
// Query records
|
|
52
|
+
let query = 'SELECT id, type, content_text, tags, related_records, created_at FROM record';
|
|
53
|
+
const params = [];
|
|
54
|
+
if (opts.since) {
|
|
55
|
+
query += ' WHERE created_at >= ?';
|
|
56
|
+
params.push(opts.since + 'T00:00:00.000Z');
|
|
57
|
+
}
|
|
58
|
+
query += ' ORDER BY created_at ASC';
|
|
59
|
+
const records = db.all(query, params);
|
|
60
|
+
db.close();
|
|
61
|
+
const exportPath = join(cwd, config.memory.export_path);
|
|
62
|
+
if (opts.format === 'json') {
|
|
63
|
+
exportJson(records, exportPath);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
exportMarkdown(records, exportPath);
|
|
67
|
+
}
|
|
68
|
+
console.log(`Exported ${records.length} records to ${config.memory.export_path}`);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function exportMarkdown(records, exportPath) {
|
|
72
|
+
// Clear and recreate type subdirectories
|
|
73
|
+
for (const subdir of Object.values(TYPE_SUBDIRS)) {
|
|
74
|
+
const dirPath = join(exportPath, subdir);
|
|
75
|
+
rmSync(dirPath, { recursive: true, force: true });
|
|
76
|
+
mkdirSync(dirPath, { recursive: true });
|
|
77
|
+
}
|
|
78
|
+
for (const record of records) {
|
|
79
|
+
const date = record.created_at.slice(0, 10);
|
|
80
|
+
const shortId = record.id.slice(0, 4);
|
|
81
|
+
const filename = `${date}_${shortId}.md`;
|
|
82
|
+
const tags = JSON.parse(record.tags);
|
|
83
|
+
const relatedRecords = JSON.parse(record.related_records);
|
|
84
|
+
const frontmatter = yaml.dump({
|
|
85
|
+
id: record.id,
|
|
86
|
+
type: record.type,
|
|
87
|
+
created_at: record.created_at,
|
|
88
|
+
tags,
|
|
89
|
+
related_records: relatedRecords,
|
|
90
|
+
}, { lineWidth: -1 }).trim();
|
|
91
|
+
const content = `---\n${frontmatter}\n---\n\n${record.content_text}\n`;
|
|
92
|
+
const subdir = TYPE_SUBDIRS[record.type];
|
|
93
|
+
writeFileSync(join(exportPath, subdir, filename), content);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function exportJson(records, exportPath) {
|
|
97
|
+
mkdirSync(exportPath, { recursive: true });
|
|
98
|
+
const jsonPath = join(exportPath, 'export.json');
|
|
99
|
+
const data = records.map((r) => ({
|
|
100
|
+
id: r.id,
|
|
101
|
+
type: r.type,
|
|
102
|
+
content_text: r.content_text,
|
|
103
|
+
tags: JSON.parse(r.tags),
|
|
104
|
+
related_records: JSON.parse(r.related_records),
|
|
105
|
+
created_at: r.created_at,
|
|
106
|
+
}));
|
|
107
|
+
writeFileSync(jsonPath, JSON.stringify(data, null, 2) + '\n');
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.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+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* memnant — The context layer for agent-operated products.
|
|
4
|
+
*
|
|
5
|
+
* This is the CLI entry point. Each command is implemented in its own file
|
|
6
|
+
* under src/cli/ and registered here.
|
|
7
|
+
*
|
|
8
|
+
* Story 6.1: Default action router — `npx memnant` with no args auto-detects state.
|
|
9
|
+
* Story 6.6: Help reorganisation — one-command flow, grouped commands.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* memnant — The context layer for agent-operated products.
|
|
4
|
+
*
|
|
5
|
+
* This is the CLI entry point. Each command is implemented in its own file
|
|
6
|
+
* under src/cli/ and registered here.
|
|
7
|
+
*
|
|
8
|
+
* Story 6.1: Default action router — `npx memnant` with no args auto-detects state.
|
|
9
|
+
* Story 6.6: Help reorganisation — one-command flow, grouped commands.
|
|
10
|
+
*/
|
|
11
|
+
import { Command } from 'commander';
|
|
12
|
+
import { registerInitCommand } from './init.js';
|
|
13
|
+
import { registerStatusCommand } from './status.js';
|
|
14
|
+
import { registerLogCommand } from './log.js';
|
|
15
|
+
import { registerRecallCommand } from './recall.js';
|
|
16
|
+
import { registerServeCommand } from './serve.js';
|
|
17
|
+
import { registerExportCommand } from './export.js';
|
|
18
|
+
import { registerSessionCommand } from './session.js';
|
|
19
|
+
import { registerSnapshotCommand } from './snapshot.js';
|
|
20
|
+
import { registerAskCommand } from './ask.js';
|
|
21
|
+
import { registerTelegramCommand } from './telegram.js';
|
|
22
|
+
import { registerPromoteCommand } from './promote.js';
|
|
23
|
+
import { registerSpecsCommand } from './specs.js';
|
|
24
|
+
import { registerCheckCopyCommand } from './check-copy.js';
|
|
25
|
+
import { registerCheckDesignCommand } from './check-design.js';
|
|
26
|
+
import { registerTestPersonaCommand } from './test-persona.js';
|
|
27
|
+
import { registerLintCommand } from './lint.js';
|
|
28
|
+
import { registerSetupCommand } from './setup.js';
|
|
29
|
+
import { registerInstructionsCommand } from './instructions.js';
|
|
30
|
+
import { defaultAction } from './default-action.js';
|
|
31
|
+
const program = new Command();
|
|
32
|
+
program
|
|
33
|
+
.name('memnant')
|
|
34
|
+
.description('The context layer for agent-operated products')
|
|
35
|
+
.version('0.1.0')
|
|
36
|
+
.addHelpText('before', `
|
|
37
|
+
Usage: npx memnant
|
|
38
|
+
|
|
39
|
+
Run with no arguments to start. memnant auto-detects what to do:
|
|
40
|
+
- New project → guided setup
|
|
41
|
+
- No session → start session with compiled context
|
|
42
|
+
- In session → show session status
|
|
43
|
+
|
|
44
|
+
`)
|
|
45
|
+
.addHelpText('after', `
|
|
46
|
+
Command groups:
|
|
47
|
+
Agent commands (used via MCP, not typed by hand):
|
|
48
|
+
serve, log, recall, session, check-copy, check-design
|
|
49
|
+
|
|
50
|
+
Advanced (usually automatic):
|
|
51
|
+
init, setup, snapshot, export, instructions, lint, specs
|
|
52
|
+
`)
|
|
53
|
+
.action(async () => {
|
|
54
|
+
await defaultAction();
|
|
55
|
+
});
|
|
56
|
+
// Agent commands (used via MCP)
|
|
57
|
+
registerServeCommand(program);
|
|
58
|
+
registerLogCommand(program);
|
|
59
|
+
registerRecallCommand(program);
|
|
60
|
+
registerSessionCommand(program);
|
|
61
|
+
registerCheckCopyCommand(program);
|
|
62
|
+
registerCheckDesignCommand(program);
|
|
63
|
+
// Advanced commands
|
|
64
|
+
registerInitCommand(program);
|
|
65
|
+
registerSetupCommand(program);
|
|
66
|
+
registerStatusCommand(program);
|
|
67
|
+
registerSnapshotCommand(program);
|
|
68
|
+
registerExportCommand(program);
|
|
69
|
+
registerInstructionsCommand(program);
|
|
70
|
+
registerLintCommand(program);
|
|
71
|
+
registerSpecsCommand(program);
|
|
72
|
+
registerAskCommand(program);
|
|
73
|
+
registerTelegramCommand(program);
|
|
74
|
+
registerPromoteCommand(program);
|
|
75
|
+
registerTestPersonaCommand(program);
|
|
76
|
+
program.parse();
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,2B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
|
1
|
+
/**
|
|
2
|
+
* memnant init — Project initialisation command.
|
|
3
|
+
*
|
|
4
|
+
* Story 1.1: Creates memnant.yaml and .memnant/ledger.db.
|
|
5
|
+
* Story 6.2: Interactive init flow for TTY sessions.
|
|
6
|
+
*/
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
export declare function scaffoldSpecs(cwd: string): void;
|
|
9
|
+
export declare function registerInitCommand(program: Command): void;
|
|
10
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8CpC,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAkB/C;AAgGD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuB1D"}
|
package/dist/cli/init.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memnant init — Project initialisation command.
|
|
3
|
+
*
|
|
4
|
+
* Story 1.1: Creates memnant.yaml and .memnant/ledger.db.
|
|
5
|
+
* Story 6.2: Interactive init flow for TTY sessions.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
8
|
+
import { join, basename } from 'path';
|
|
9
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
10
|
+
import { createInterface } from 'readline';
|
|
11
|
+
import yaml from 'js-yaml';
|
|
12
|
+
import { createDefaultConfig } from '../config/defaults.js';
|
|
13
|
+
import { createDatabase } from '../ledger/database.js';
|
|
14
|
+
import { setupClaudeCode, setupCodex } from './setup.js';
|
|
15
|
+
const STARTER_COPY_STYLE = `---
|
|
16
|
+
type: copy_audit
|
|
17
|
+
applies_to: all
|
|
18
|
+
---
|
|
19
|
+
## Banned Phrases
|
|
20
|
+
- "leverage" — use "use"
|
|
21
|
+
- "utilize" — use "use"
|
|
22
|
+
|
|
23
|
+
## Discouraged Phrases
|
|
24
|
+
- "please" — unnecessary filler
|
|
25
|
+
- "simple" — subjective, often wrong
|
|
26
|
+
`;
|
|
27
|
+
const STARTER_DESIGN_SYSTEM = `---
|
|
28
|
+
type: design_system
|
|
29
|
+
applies_to: all
|
|
30
|
+
---
|
|
31
|
+
## Banned Components
|
|
32
|
+
- \`<marquee>\` — deprecated HTML element
|
|
33
|
+
- \`<blink>\` — deprecated HTML element
|
|
34
|
+
|
|
35
|
+
## Approved Components
|
|
36
|
+
- Use semantic HTML elements
|
|
37
|
+
`;
|
|
38
|
+
const STARTER_PERSONA = `---
|
|
39
|
+
type: persona
|
|
40
|
+
name: Default User
|
|
41
|
+
role: Primary user of this product
|
|
42
|
+
---
|
|
43
|
+
## Test Questions
|
|
44
|
+
- Can I complete the core task in under 2 minutes?
|
|
45
|
+
- Is the error message helpful when something goes wrong?
|
|
46
|
+
- Would I recommend this to a colleague?
|
|
47
|
+
`;
|
|
48
|
+
export function scaffoldSpecs(cwd) {
|
|
49
|
+
const docsDir = join(cwd, 'docs');
|
|
50
|
+
mkdirSync(docsDir, { recursive: true });
|
|
51
|
+
const specs = [
|
|
52
|
+
{ filename: 'copy-style.md', content: STARTER_COPY_STYLE },
|
|
53
|
+
{ filename: 'design-system.md', content: STARTER_DESIGN_SYSTEM },
|
|
54
|
+
{ filename: 'persona-user.md', content: STARTER_PERSONA },
|
|
55
|
+
];
|
|
56
|
+
for (const spec of specs) {
|
|
57
|
+
const specPath = join(docsDir, spec.filename);
|
|
58
|
+
if (!existsSync(specPath)) {
|
|
59
|
+
writeFileSync(specPath, spec.content, 'utf-8');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
console.log('Created starter specs in docs/. Edit them to match your project.');
|
|
63
|
+
}
|
|
64
|
+
function prompt(rl, question) {
|
|
65
|
+
return new Promise((resolve) => {
|
|
66
|
+
rl.question(question, (answer) => resolve(answer.trim()));
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function initProject(projectName, cwd) {
|
|
70
|
+
const configPath = join(cwd, 'memnant.yaml');
|
|
71
|
+
const projectId = uuidv4();
|
|
72
|
+
const config = createDefaultConfig(projectName, projectId);
|
|
73
|
+
writeFileSync(configPath, yaml.dump(config, { lineWidth: -1 }), 'utf-8');
|
|
74
|
+
const dbPath = join(cwd, config.memory.db_path);
|
|
75
|
+
const db = createDatabase(dbPath);
|
|
76
|
+
db.run('INSERT INTO project (id, name, root_path, created_at) VALUES (?, ?, ?, ?)', [projectId, projectName, cwd, new Date().toISOString()]);
|
|
77
|
+
db.close();
|
|
78
|
+
}
|
|
79
|
+
async function interactiveInit(cwd) {
|
|
80
|
+
const rl = createInterface({
|
|
81
|
+
input: process.stdin,
|
|
82
|
+
output: process.stdout,
|
|
83
|
+
});
|
|
84
|
+
try {
|
|
85
|
+
// 1. Project name
|
|
86
|
+
const defaultName = basename(cwd);
|
|
87
|
+
const nameAnswer = await prompt(rl, `Project name (${defaultName}): `);
|
|
88
|
+
const projectName = nameAnswer || defaultName;
|
|
89
|
+
// 2. Init the project
|
|
90
|
+
initProject(projectName, cwd);
|
|
91
|
+
console.log(`\nInitialised memnant project "${projectName}".`);
|
|
92
|
+
// 3. Agent setup
|
|
93
|
+
const agentAnswer = await prompt(rl, 'Configure for which agent? (claude-code / codex / skip): ');
|
|
94
|
+
const agent = agentAnswer.toLowerCase();
|
|
95
|
+
if (agent === 'claude-code' || agent === 'claude') {
|
|
96
|
+
setupClaudeCode();
|
|
97
|
+
}
|
|
98
|
+
else if (agent === 'codex') {
|
|
99
|
+
setupCodex();
|
|
100
|
+
}
|
|
101
|
+
// 4. Starter specs
|
|
102
|
+
const specsAnswer = await prompt(rl, 'Create starter spec documents? (y/N): ');
|
|
103
|
+
if (specsAnswer.toLowerCase() === 'y' || specsAnswer.toLowerCase() === 'yes') {
|
|
104
|
+
console.log('');
|
|
105
|
+
scaffoldSpecs(cwd);
|
|
106
|
+
}
|
|
107
|
+
// 5. Done
|
|
108
|
+
console.log('');
|
|
109
|
+
console.log('Add `.memnant/` to your .gitignore — the ledger is local, not version controlled.');
|
|
110
|
+
console.log('');
|
|
111
|
+
console.log("You're set. Run `npx memnant` to start your first session.");
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
rl.close();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function nonInteractiveInit(cwd, opts) {
|
|
118
|
+
const configPath = join(cwd, 'memnant.yaml');
|
|
119
|
+
if (existsSync(configPath)) {
|
|
120
|
+
console.log('memnant is already initialised in this project.');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const projectName = basename(cwd);
|
|
124
|
+
initProject(projectName, cwd);
|
|
125
|
+
console.log(`Initialised memnant project "${projectName}"`);
|
|
126
|
+
console.log(`Created: memnant.yaml`);
|
|
127
|
+
console.log(`Created: .memnant/ledger.db`);
|
|
128
|
+
console.log('');
|
|
129
|
+
console.log('Add `.memnant/` to your .gitignore — the ledger is local, not version controlled.');
|
|
130
|
+
if (opts.withSpecs) {
|
|
131
|
+
console.log('');
|
|
132
|
+
scaffoldSpecs(cwd);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export function registerInitCommand(program) {
|
|
136
|
+
program
|
|
137
|
+
.command('init')
|
|
138
|
+
.description('Initialise memnant in the current project')
|
|
139
|
+
.option('--with-specs', 'Scaffold starter spec documents in docs/')
|
|
140
|
+
.option('--non-interactive', 'Skip interactive prompts (for CI/scripts)')
|
|
141
|
+
.action(async (opts) => {
|
|
142
|
+
const cwd = process.cwd();
|
|
143
|
+
const configPath = join(cwd, 'memnant.yaml');
|
|
144
|
+
if (existsSync(configPath)) {
|
|
145
|
+
console.log('memnant is already initialised in this project.');
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const isInteractive = process.stdin.isTTY && !opts.nonInteractive;
|
|
149
|
+
if (isInteractive) {
|
|
150
|
+
await interactiveInit(cwd);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
nonInteractiveInit(cwd, opts);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,UAAU,EAA8B,MAAM,YAAY,CAAC;AAErF,MAAM,kBAAkB,GAAG;;;;;;;;;;;CAW1B,CAAC;AAEF,MAAM,qBAAqB,GAAG;;;;;;;;;;CAU7B,CAAC;AAEF,MAAM,eAAe,GAAG;;;;;;;;;CASvB,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAClC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAExC,MAAM,KAAK,GAAiD;QAC1D,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,kBAAkB,EAAE;QAC1D,EAAE,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAE,qBAAqB,EAAE;QAChE,EAAE,QAAQ,EAAE,iBAAiB,EA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2C,CAAC;SACxE,MAAM,CAAC,KAAK,EAAE,IAAuD,EAAE,EAAE;QACxE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAE7C,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;YAC/D,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;QAElE,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAChC,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memnant instructions — Output agent instruction snippets.
|
|
3
|
+
*
|
|
4
|
+
* Generates markdown that tells an AI agent how to use memnant's MCP tools.
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
export declare function claudeCodeInstructions(project: {
|
|
8
|
+
name: string;
|
|
9
|
+
dbPath: string;
|
|
10
|
+
} | null): string;
|
|
11
|
+
export declare function registerInstructionsCommand(program: Command): void;
|
|
12
|
+
//# sourceMappingURL=instructions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/cli/instructions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0CpC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,MAAM,CA0B/F;AA8BD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmBlE"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memnant instructions — Output agent instruction snippets.
|
|
3
|
+
*
|
|
4
|
+
* Generates markdown that tells an AI agent how to use memnant's MCP tools.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, readFileSync } from 'fs';
|
|
7
|
+
import { join } from 'path';
|
|
8
|
+
import yaml from 'js-yaml';
|
|
9
|
+
function getProjectInfo() {
|
|
10
|
+
const cwd = process.cwd();
|
|
11
|
+
const configPath = join(cwd, 'memnant.yaml');
|
|
12
|
+
if (!existsSync(configPath))
|
|
13
|
+
return null;
|
|
14
|
+
const config = yaml.load(readFileSync(configPath, 'utf-8'));
|
|
15
|
+
return { name: config.project.name, dbPath: config.memory.db_path };
|
|
16
|
+
}
|
|
17
|
+
function genericInstructions(project) {
|
|
18
|
+
const projectLine = project
|
|
19
|
+
? `Project: **${project.name}** (ledger: \`${project.dbPath}\`)`
|
|
20
|
+
: 'Project: not initialised — run `memnant init` first';
|
|
21
|
+
return `# memnant — Agent Instructions
|
|
22
|
+
|
|
23
|
+
${projectLine}
|
|
24
|
+
|
|
25
|
+
memnant is configured as an MCP server. Use the following tools to maintain project memory:
|
|
26
|
+
|
|
27
|
+
## Available Tools
|
|
28
|
+
|
|
29
|
+
- **recall** — Search the ledger by query, type, or tags. Use this to check for prior decisions before making new ones.
|
|
30
|
+
- **log** — Write a record (decision, framework_fix, session_log). Log every significant decision.
|
|
31
|
+
- **session_context** — Get compiled context for the current session. Call this at the start of every work session.
|
|
32
|
+
- **status** — Check project health: record count, session state, staleness warnings.
|
|
33
|
+
- **check_copy** — Validate text against copy audit specs (banned/discouraged phrases).
|
|
34
|
+
- **check_design** — Validate content against design system specs.
|
|
35
|
+
|
|
36
|
+
## Session Workflow
|
|
37
|
+
|
|
38
|
+
1. **Start of session:** Call \`session_context\` to get prior decisions, open TODOs, and framework fixes.
|
|
39
|
+
2. **During work:** Call \`log\` for every decision, trade-off, or framework discovery.
|
|
40
|
+
3. **Before finishing:** Call \`status\` to verify nothing is stale or unresolved.
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
export function claudeCodeInstructions(project) {
|
|
44
|
+
const projectLine = project
|
|
45
|
+
? `Project: ${project.name} (ledger: ${project.dbPath})`
|
|
46
|
+
: 'Project: not initialised — run `memnant init` first';
|
|
47
|
+
return `# memnant
|
|
48
|
+
|
|
49
|
+
${projectLine}
|
|
50
|
+
|
|
51
|
+
memnant is available as an MCP server. Use it for institutional memory.
|
|
52
|
+
|
|
53
|
+
## MCP Tools
|
|
54
|
+
|
|
55
|
+
- \`recall\` — Search prior decisions before making new ones
|
|
56
|
+
- \`log\` — Record decisions, framework fixes, session logs
|
|
57
|
+
- \`session_context\` — Get compiled context at session start
|
|
58
|
+
- \`status\` — Check project health and staleness
|
|
59
|
+
- \`check_copy\` — Validate text against copy specs
|
|
60
|
+
- \`check_design\` — Validate against design system specs
|
|
61
|
+
|
|
62
|
+
## Workflow
|
|
63
|
+
|
|
64
|
+
1. Call \`session_context\` at the start of every session
|
|
65
|
+
2. Call \`log\` for every significant decision during work
|
|
66
|
+
3. Call \`status\` before finishing to check for stale records
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
function codexInstructions(project) {
|
|
70
|
+
const projectLine = project
|
|
71
|
+
? `Project: ${project.name} (ledger: ${project.dbPath})`
|
|
72
|
+
: 'Project: not initialised — run `memnant init` first';
|
|
73
|
+
return `# memnant
|
|
74
|
+
|
|
75
|
+
${projectLine}
|
|
76
|
+
|
|
77
|
+
memnant is available as an MCP server for institutional memory.
|
|
78
|
+
|
|
79
|
+
## MCP Tools
|
|
80
|
+
|
|
81
|
+
- recall — Search prior decisions before making new ones
|
|
82
|
+
- log — Record decisions, framework fixes, session logs
|
|
83
|
+
- session_context — Get compiled context at session start
|
|
84
|
+
- status — Check project health and staleness
|
|
85
|
+
- check_copy — Validate text against copy specs
|
|
86
|
+
- check_design — Validate against design system specs
|
|
87
|
+
|
|
88
|
+
## Workflow
|
|
89
|
+
|
|
90
|
+
1. Call session_context at the start of every session
|
|
91
|
+
2. Call log for every significant decision during work
|
|
92
|
+
3. Call status before finishing to check for stale records
|
|
93
|
+
`;
|
|
94
|
+
}
|
|
95
|
+
export function registerInstructionsCommand(program) {
|
|
96
|
+
program
|
|
97
|
+
.command('instructions')
|
|
98
|
+
.description('Output agent instructions for using memnant')
|
|
99
|
+
.option('--tool <tool>', 'Format for a specific tool (claude-code, codex)')
|
|
100
|
+
.action((opts) => {
|
|
101
|
+
const project = getProjectInfo();
|
|
102
|
+
if (opts.tool === 'claude-code') {
|
|
103
|
+
process.stdout.write(claudeCodeInstructions(project));
|
|
104
|
+
}
|
|
105
|
+
else if (opts.tool === 'codex') {
|
|
106
|
+
process.stdout.write(codexInstructions(project));
|
|
107
|
+
}
|
|
108
|
+
else if (opts.tool) {
|
|
109
|
+
console.error(`Unknown tool '${opts.tool}'. Valid tools: claude-code, codex`);
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
process.stdout.write(genericInstructions(project));
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=instructions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/cli/instructions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,IAAI,MAAM,SAAS,CAAC;AAG3B,SAAS,cAAc;IACrB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,c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uB,EAAE,EAAE;QAClC,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;QAEjC,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC;QACxD,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;QACnD,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,iBAAiB,IAAI,CAAC,IAAI,oCAAoC,CAAC,CAAC;YAC9E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;QACrD,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memnant lint — CI integration for spec checks.
|
|
3
|
+
*
|
|
4
|
+
* Story 5.5: Runs all applicable spec checks (copy audit, design system
|
|
5
|
+
* validation) on source files. Designed for CI pipelines and pre-commit hooks.
|
|
6
|
+
*/
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
export declare function registerLintCommand(program: Command): void;
|
|
9
|
+
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/cli/lint.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAwF1D"}
|