memorix 1.1.7 → 1.1.8
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/CHANGELOG.md +13 -0
- package/CLAUDE.md +6 -1
- package/README.md +21 -0
- package/README.zh-CN.md +21 -0
- package/TEAM.md +86 -86
- package/dist/cli/index.js +730 -150
- package/dist/cli/index.js.map +1 -1
- package/dist/dashboard/static/index.html +201 -201
- package/dist/dashboard/static/style.css +3584 -3584
- package/dist/index.js +15 -8
- package/dist/index.js.map +1 -1
- package/dist/memcode-runtime/CHANGELOG.md +13 -0
- package/dist/memcode-runtime/package.json +4 -4
- package/dist/sdk.js +15 -8
- package/dist/sdk.js.map +1 -1
- package/docs/AGENT_OPERATOR_PLAYBOOK.md +18 -0
- package/docs/DESIGN_DECISIONS.md +357 -357
- package/docs/SETUP.md +10 -0
- package/docs/dev-log/progress.txt +35 -26
- package/package.json +1 -1
- package/src/audit/index.ts +156 -156
- package/src/cli/commands/agent-integrations.ts +623 -0
- package/src/cli/commands/audit-list.ts +89 -89
- package/src/cli/commands/background.ts +659 -659
- package/src/cli/commands/cleanup.ts +255 -255
- package/src/cli/commands/doctor.ts +23 -0
- package/src/cli/commands/formation.ts +48 -48
- package/src/cli/commands/git-hook-install.ts +111 -111
- package/src/cli/commands/handoff.ts +66 -66
- package/src/cli/commands/hooks-status.ts +63 -63
- package/src/cli/commands/ingest-commit.ts +153 -153
- package/src/cli/commands/ingest-image.ts +73 -73
- package/src/cli/commands/ingest-log.ts +180 -180
- package/src/cli/commands/ingest.ts +44 -44
- package/src/cli/commands/integrate-shared.ts +15 -15
- package/src/cli/commands/lock.ts +96 -96
- package/src/cli/commands/message.ts +121 -121
- package/src/cli/commands/poll.ts +70 -70
- package/src/cli/commands/purge-all-memory.ts +85 -85
- package/src/cli/commands/purge-project-memory.ts +83 -83
- package/src/cli/commands/reasoning.ts +132 -132
- package/src/cli/commands/repair.ts +60 -0
- package/src/cli/commands/retention.ts +108 -108
- package/src/cli/commands/serve-shared.ts +118 -118
- package/src/cli/commands/setup.ts +3 -3
- package/src/cli/commands/skills.ts +123 -123
- package/src/cli/commands/task.ts +192 -192
- package/src/cli/commands/transfer.ts +73 -73
- package/src/cli/commands/uninstall-project-artifacts.ts +85 -85
- package/src/cli/index.ts +3 -1
- package/src/cli/tui/ChatView.tsx +234 -234
- package/src/cli/tui/CommandBar.tsx +312 -312
- package/src/cli/tui/ContextRail.tsx +118 -118
- package/src/cli/tui/HeaderBar.tsx +72 -72
- package/src/cli/tui/LogoBanner.tsx +51 -51
- package/src/cli/tui/Panels.tsx +632 -632
- package/src/cli/tui/Sidebar.tsx +179 -179
- package/src/cli/tui/chat-service.ts +742 -742
- package/src/cli/tui/data.ts +547 -547
- package/src/cli/tui/index.ts +41 -41
- package/src/cli/tui/markdown-render.tsx +371 -371
- package/src/cli/tui/theme.ts +178 -178
- package/src/cli/tui/use-mouse.ts +157 -157
- package/src/cli/tui/useNavigation.ts +56 -56
- package/src/cli/update-checker.ts +211 -211
- package/src/cli/version.ts +7 -7
- package/src/cli/workbench.ts +1 -1
- package/src/codegraph/context-pack.ts +5 -1
- package/src/codegraph/lite-provider.ts +5 -1
- package/src/codegraph/project-context.ts +5 -1
- package/src/compact/token-budget.ts +74 -74
- package/src/config/behavior.ts +59 -59
- package/src/dashboard/project-classification.ts +64 -64
- package/src/dashboard/static/index.html +201 -201
- package/src/dashboard/static/style.css +3584 -3584
- package/src/embedding/fastembed-provider.ts +142 -142
- package/src/embedding/transformers-provider.ts +111 -111
- package/src/git/extractor.ts +209 -209
- package/src/git/hooks-path.ts +85 -85
- package/src/git/noise-filter.ts +210 -210
- package/src/hooks/installers/index.ts +4 -4
- package/src/hooks/official-skills.ts +1 -1
- package/src/hooks/pattern-detector.ts +173 -173
- package/src/hooks/rules/memorix-agent-rules.md +2 -2
- package/src/hooks/significance-filter.ts +250 -250
- package/src/llm/memory-manager.ts +328 -328
- package/src/llm/provider.ts +885 -885
- package/src/llm/quality.ts +248 -248
- package/src/memory/attribution-guard.ts +249 -249
- package/src/memory/auto-relations.ts +107 -107
- package/src/memory/consolidation.ts +302 -302
- package/src/memory/disclosure-policy.ts +141 -141
- package/src/memory/entity-extractor.ts +197 -197
- package/src/memory/formation/evaluate.ts +217 -217
- package/src/memory/formation/extract.ts +361 -361
- package/src/memory/formation/index.ts +417 -417
- package/src/memory/formation/resolve.ts +344 -344
- package/src/memory/formation/types.ts +315 -315
- package/src/memory/freshness.ts +122 -122
- package/src/memory/graph.ts +197 -197
- package/src/memory/refs.ts +94 -94
- package/src/memory/retention.ts +433 -433
- package/src/memory/secret-filter.ts +79 -79
- package/src/memory/session.ts +523 -523
- package/src/multimodal/image-loader.ts +143 -143
- package/src/orchestrate/adapters/claude-stream.ts +192 -192
- package/src/orchestrate/adapters/claude.ts +111 -111
- package/src/orchestrate/adapters/codex-stream.ts +134 -134
- package/src/orchestrate/adapters/codex.ts +41 -41
- package/src/orchestrate/adapters/gemini-stream.ts +166 -166
- package/src/orchestrate/adapters/gemini.ts +42 -42
- package/src/orchestrate/adapters/index.ts +73 -73
- package/src/orchestrate/adapters/opencode-stream.ts +143 -143
- package/src/orchestrate/adapters/opencode.ts +47 -47
- package/src/orchestrate/adapters/spawn-helper.ts +286 -286
- package/src/orchestrate/adapters/types.ts +77 -77
- package/src/orchestrate/capability-router.ts +284 -284
- package/src/orchestrate/context-compact.ts +188 -188
- package/src/orchestrate/cost-tracker.ts +219 -219
- package/src/orchestrate/error-recovery.ts +191 -191
- package/src/orchestrate/evidence.ts +140 -140
- package/src/orchestrate/ledger.ts +110 -110
- package/src/orchestrate/memorix-bridge.ts +380 -380
- package/src/orchestrate/output-budget.ts +80 -80
- package/src/orchestrate/permission.ts +152 -152
- package/src/orchestrate/pipeline-trace.ts +131 -131
- package/src/orchestrate/prompt-builder.ts +155 -155
- package/src/orchestrate/ring-buffer.ts +37 -37
- package/src/orchestrate/task-graph.ts +389 -389
- package/src/orchestrate/verify-gate.ts +219 -219
- package/src/orchestrate/worktree.ts +232 -232
- package/src/project/aliases.ts +374 -374
- package/src/project/detector.ts +268 -268
- package/src/rules/adapters/claude-code.ts +99 -99
- package/src/rules/adapters/codex.ts +97 -97
- package/src/rules/adapters/copilot.ts +124 -124
- package/src/rules/adapters/cursor.ts +114 -114
- package/src/rules/adapters/kiro.ts +126 -126
- package/src/rules/adapters/trae.ts +56 -56
- package/src/rules/adapters/windsurf.ts +83 -83
- package/src/rules/syncer.ts +235 -235
- package/src/sdk.ts +327 -327
- package/src/search/intent-detector.ts +289 -289
- package/src/search/query-expansion.ts +52 -52
- package/src/server/formation-timeout.ts +27 -27
- package/src/skills/mini-skills.ts +386 -386
- package/src/store/chat-store.ts +119 -119
- package/src/store/file-lock.ts +100 -100
- package/src/store/graph-store.ts +249 -249
- package/src/store/mini-skill-store.ts +349 -349
- package/src/store/obs-store.ts +255 -255
- package/src/store/persistence-json.ts +212 -212
- package/src/store/persistence.ts +291 -291
- package/src/store/project-affinity.ts +195 -195
- package/src/store/session-store.ts +259 -259
- package/src/store/sqlite-store.ts +339 -339
- package/src/team/event-bus.ts +76 -76
- package/src/team/file-locks.ts +173 -173
- package/src/team/handoff.ts +167 -167
- package/src/team/messages.ts +203 -203
- package/src/team/poll.ts +132 -132
- package/src/team/tasks.ts +211 -211
- package/src/wiki/generator.ts +237 -237
- package/src/wiki/knowledge-graph.ts +334 -334
- package/src/wiki/types.ts +85 -85
- package/src/workspace/mcp-adapters/codex.ts +191 -191
- package/src/workspace/mcp-adapters/copilot.ts +105 -105
- package/src/workspace/mcp-adapters/cursor.ts +53 -53
- package/src/workspace/mcp-adapters/kiro.ts +64 -64
- package/src/workspace/mcp-adapters/opencode.ts +123 -123
- package/src/workspace/mcp-adapters/trae.ts +134 -134
- package/src/workspace/mcp-adapters/windsurf.ts +91 -91
- package/src/workspace/sanitizer.ts +60 -60
- package/src/workspace/workflow-sync.ts +131 -131
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
import { defineCommand } from 'citty';
|
|
2
|
-
import type { AgentTarget } from '../../types.js';
|
|
3
|
-
import { getObservationStore } from '../../store/obs-store.js';
|
|
4
|
-
import { emitError, emitResult, getCliProjectContext } from './operator-shared.js';
|
|
5
|
-
|
|
6
|
-
export default defineCommand({
|
|
7
|
-
meta: {
|
|
8
|
-
name: 'skills',
|
|
9
|
-
description: 'Discover, generate, and inspect project skills from the CLI',
|
|
10
|
-
},
|
|
11
|
-
args: {
|
|
12
|
-
name: { type: 'string', description: 'Skill name for "show"' },
|
|
13
|
-
target: { type: 'string', description: 'Target agent for generated skills' },
|
|
14
|
-
write: { type: 'boolean', description: 'Write generated skills to disk' },
|
|
15
|
-
json: { type: 'boolean', description: 'Emit machine-readable JSON output' },
|
|
16
|
-
},
|
|
17
|
-
run: async ({ args }) => {
|
|
18
|
-
const action = (args._ as string[])?.[0] || '';
|
|
19
|
-
const asJson = !!args.json;
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
const { project } = await getCliProjectContext();
|
|
23
|
-
const { SkillsEngine } = await import('../../skills/engine.js');
|
|
24
|
-
const engine = new SkillsEngine(project.rootPath);
|
|
25
|
-
|
|
26
|
-
switch (action) {
|
|
27
|
-
case 'list': {
|
|
28
|
-
const skills = engine.listSkills();
|
|
29
|
-
emitResult(
|
|
30
|
-
{ project, skills },
|
|
31
|
-
skills.length === 0
|
|
32
|
-
? 'No skills found in project or global agent directories.'
|
|
33
|
-
: skills.map((skill) => `- ${skill.name} (${skill.sourceAgent})`).join('\n'),
|
|
34
|
-
asJson,
|
|
35
|
-
);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
case 'generate': {
|
|
40
|
-
const observations = (await getObservationStore().loadAll())
|
|
41
|
-
.filter((obs) => obs.projectId === project.id)
|
|
42
|
-
.map((obs) => ({
|
|
43
|
-
id: obs.id,
|
|
44
|
-
entityName: obs.entityName,
|
|
45
|
-
type: obs.type,
|
|
46
|
-
title: obs.title,
|
|
47
|
-
narrative: obs.narrative,
|
|
48
|
-
facts: obs.facts,
|
|
49
|
-
concepts: obs.concepts,
|
|
50
|
-
filesModified: obs.filesModified,
|
|
51
|
-
createdAt: obs.createdAt,
|
|
52
|
-
status: obs.status,
|
|
53
|
-
source: obs.source,
|
|
54
|
-
}));
|
|
55
|
-
const skills = engine.generateFromObservations(observations);
|
|
56
|
-
const written: string[] = [];
|
|
57
|
-
if (args.write && args.target) {
|
|
58
|
-
for (const skill of skills) {
|
|
59
|
-
const writtenPath = engine.writeSkill(skill, args.target as AgentTarget);
|
|
60
|
-
if (writtenPath) written.push(writtenPath);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
emitResult(
|
|
64
|
-
{ project, skills, written },
|
|
65
|
-
skills.length === 0
|
|
66
|
-
? 'No skill-worthy patterns found yet.'
|
|
67
|
-
: skills.map((skill) => `- ${skill.name}: ${skill.description}`).join('\n'),
|
|
68
|
-
asJson,
|
|
69
|
-
);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
case 'show': {
|
|
74
|
-
const name = (args.name as string | undefined)?.trim();
|
|
75
|
-
if (!name) {
|
|
76
|
-
emitError('name is required for "memorix skills show"', asJson);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const direct = engine.injectSkill(name);
|
|
80
|
-
if (direct) {
|
|
81
|
-
emitResult({ project, skill: direct }, direct.content, asJson);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const observations = (await getObservationStore().loadAll())
|
|
86
|
-
.filter((obs) => obs.projectId === project.id)
|
|
87
|
-
.map((obs) => ({
|
|
88
|
-
id: obs.id,
|
|
89
|
-
entityName: obs.entityName,
|
|
90
|
-
type: obs.type,
|
|
91
|
-
title: obs.title,
|
|
92
|
-
narrative: obs.narrative,
|
|
93
|
-
facts: obs.facts,
|
|
94
|
-
concepts: obs.concepts,
|
|
95
|
-
filesModified: obs.filesModified,
|
|
96
|
-
createdAt: obs.createdAt,
|
|
97
|
-
status: obs.status,
|
|
98
|
-
source: obs.source,
|
|
99
|
-
}));
|
|
100
|
-
const generated = engine.generateFromObservations(observations);
|
|
101
|
-
const skill = generated.find((entry) => entry.name.toLowerCase() === name.toLowerCase());
|
|
102
|
-
if (!skill) {
|
|
103
|
-
emitError(`Skill "${name}" not found`, asJson);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
emitResult({ project, skill }, skill.content, asJson);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
default:
|
|
111
|
-
console.log('Memorix Skills Commands');
|
|
112
|
-
console.log('');
|
|
113
|
-
console.log('Usage:');
|
|
114
|
-
console.log(' memorix skills list');
|
|
115
|
-
console.log(' memorix skills generate [--write --target codex]');
|
|
116
|
-
console.log(' memorix skills show --name <skill>');
|
|
117
|
-
}
|
|
118
|
-
} catch (error) {
|
|
119
|
-
emitError(error instanceof Error ? error.message : String(error), asJson);
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
import type { AgentTarget } from '../../types.js';
|
|
3
|
+
import { getObservationStore } from '../../store/obs-store.js';
|
|
4
|
+
import { emitError, emitResult, getCliProjectContext } from './operator-shared.js';
|
|
5
|
+
|
|
6
|
+
export default defineCommand({
|
|
7
|
+
meta: {
|
|
8
|
+
name: 'skills',
|
|
9
|
+
description: 'Discover, generate, and inspect project skills from the CLI',
|
|
10
|
+
},
|
|
11
|
+
args: {
|
|
12
|
+
name: { type: 'string', description: 'Skill name for "show"' },
|
|
13
|
+
target: { type: 'string', description: 'Target agent for generated skills' },
|
|
14
|
+
write: { type: 'boolean', description: 'Write generated skills to disk' },
|
|
15
|
+
json: { type: 'boolean', description: 'Emit machine-readable JSON output' },
|
|
16
|
+
},
|
|
17
|
+
run: async ({ args }) => {
|
|
18
|
+
const action = (args._ as string[])?.[0] || '';
|
|
19
|
+
const asJson = !!args.json;
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const { project } = await getCliProjectContext();
|
|
23
|
+
const { SkillsEngine } = await import('../../skills/engine.js');
|
|
24
|
+
const engine = new SkillsEngine(project.rootPath);
|
|
25
|
+
|
|
26
|
+
switch (action) {
|
|
27
|
+
case 'list': {
|
|
28
|
+
const skills = engine.listSkills();
|
|
29
|
+
emitResult(
|
|
30
|
+
{ project, skills },
|
|
31
|
+
skills.length === 0
|
|
32
|
+
? 'No skills found in project or global agent directories.'
|
|
33
|
+
: skills.map((skill) => `- ${skill.name} (${skill.sourceAgent})`).join('\n'),
|
|
34
|
+
asJson,
|
|
35
|
+
);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
case 'generate': {
|
|
40
|
+
const observations = (await getObservationStore().loadAll())
|
|
41
|
+
.filter((obs) => obs.projectId === project.id)
|
|
42
|
+
.map((obs) => ({
|
|
43
|
+
id: obs.id,
|
|
44
|
+
entityName: obs.entityName,
|
|
45
|
+
type: obs.type,
|
|
46
|
+
title: obs.title,
|
|
47
|
+
narrative: obs.narrative,
|
|
48
|
+
facts: obs.facts,
|
|
49
|
+
concepts: obs.concepts,
|
|
50
|
+
filesModified: obs.filesModified,
|
|
51
|
+
createdAt: obs.createdAt,
|
|
52
|
+
status: obs.status,
|
|
53
|
+
source: obs.source,
|
|
54
|
+
}));
|
|
55
|
+
const skills = engine.generateFromObservations(observations);
|
|
56
|
+
const written: string[] = [];
|
|
57
|
+
if (args.write && args.target) {
|
|
58
|
+
for (const skill of skills) {
|
|
59
|
+
const writtenPath = engine.writeSkill(skill, args.target as AgentTarget);
|
|
60
|
+
if (writtenPath) written.push(writtenPath);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
emitResult(
|
|
64
|
+
{ project, skills, written },
|
|
65
|
+
skills.length === 0
|
|
66
|
+
? 'No skill-worthy patterns found yet.'
|
|
67
|
+
: skills.map((skill) => `- ${skill.name}: ${skill.description}`).join('\n'),
|
|
68
|
+
asJson,
|
|
69
|
+
);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
case 'show': {
|
|
74
|
+
const name = (args.name as string | undefined)?.trim();
|
|
75
|
+
if (!name) {
|
|
76
|
+
emitError('name is required for "memorix skills show"', asJson);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const direct = engine.injectSkill(name);
|
|
80
|
+
if (direct) {
|
|
81
|
+
emitResult({ project, skill: direct }, direct.content, asJson);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const observations = (await getObservationStore().loadAll())
|
|
86
|
+
.filter((obs) => obs.projectId === project.id)
|
|
87
|
+
.map((obs) => ({
|
|
88
|
+
id: obs.id,
|
|
89
|
+
entityName: obs.entityName,
|
|
90
|
+
type: obs.type,
|
|
91
|
+
title: obs.title,
|
|
92
|
+
narrative: obs.narrative,
|
|
93
|
+
facts: obs.facts,
|
|
94
|
+
concepts: obs.concepts,
|
|
95
|
+
filesModified: obs.filesModified,
|
|
96
|
+
createdAt: obs.createdAt,
|
|
97
|
+
status: obs.status,
|
|
98
|
+
source: obs.source,
|
|
99
|
+
}));
|
|
100
|
+
const generated = engine.generateFromObservations(observations);
|
|
101
|
+
const skill = generated.find((entry) => entry.name.toLowerCase() === name.toLowerCase());
|
|
102
|
+
if (!skill) {
|
|
103
|
+
emitError(`Skill "${name}" not found`, asJson);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
emitResult({ project, skill }, skill.content, asJson);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
default:
|
|
111
|
+
console.log('Memorix Skills Commands');
|
|
112
|
+
console.log('');
|
|
113
|
+
console.log('Usage:');
|
|
114
|
+
console.log(' memorix skills list');
|
|
115
|
+
console.log(' memorix skills generate [--write --target codex]');
|
|
116
|
+
console.log(' memorix skills show --name <skill>');
|
|
117
|
+
}
|
|
118
|
+
} catch (error) {
|
|
119
|
+
emitError(error instanceof Error ? error.message : String(error), asJson);
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
|
package/src/cli/commands/task.ts
CHANGED
|
@@ -1,192 +1,192 @@
|
|
|
1
|
-
import { defineCommand } from 'citty';
|
|
2
|
-
import { emitError, emitResult, getCliProjectContext, parseCsvList, parseOptionalJsonObject, shortId } from './operator-shared.js';
|
|
3
|
-
|
|
4
|
-
export default defineCommand({
|
|
5
|
-
meta: {
|
|
6
|
-
name: 'task',
|
|
7
|
-
description: 'Create, claim, complete, and inspect team tasks',
|
|
8
|
-
},
|
|
9
|
-
args: {
|
|
10
|
-
description: { type: 'string', description: 'Task description (for create)' },
|
|
11
|
-
deps: { type: 'string', description: 'Comma-separated dependency task IDs' },
|
|
12
|
-
taskId: { type: 'string', description: 'Task ID for claim, complete, fail, or release' },
|
|
13
|
-
agentId: { type: 'string', description: 'Agent ID for claim, complete, fail, release, or agent-aware list' },
|
|
14
|
-
result: { type: 'string', description: 'Completion or failure summary' },
|
|
15
|
-
status: { type: 'string', description: 'Filter by status for list' },
|
|
16
|
-
available: { type: 'boolean', description: 'Show only claimable tasks' },
|
|
17
|
-
metadata: { type: 'string', description: 'JSON metadata object for create' },
|
|
18
|
-
requiredRole: { type: 'string', description: 'Required role for this task' },
|
|
19
|
-
preferredRole: { type: 'string', description: 'Preferred role for this task' },
|
|
20
|
-
json: { type: 'boolean', description: 'Emit machine-readable JSON output' },
|
|
21
|
-
},
|
|
22
|
-
run: async ({ args }) => {
|
|
23
|
-
const action = (args._ as string[])?.[0] || '';
|
|
24
|
-
const asJson = !!args.json;
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
const { project, teamStore } = await getCliProjectContext();
|
|
28
|
-
|
|
29
|
-
switch (action) {
|
|
30
|
-
case 'create': {
|
|
31
|
-
if (!args.description) {
|
|
32
|
-
emitError('description is required for "memorix task create"', asJson);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const metadata = parseOptionalJsonObject(args.metadata as string | undefined, 'metadata');
|
|
37
|
-
if (metadata) {
|
|
38
|
-
const { checkPipelineGuards } = await import('../../orchestrate/planner.js');
|
|
39
|
-
const guard = checkPipelineGuards({
|
|
40
|
-
existingTasks: teamStore.listTasks(project.id),
|
|
41
|
-
newTaskMeta: metadata,
|
|
42
|
-
});
|
|
43
|
-
if (!guard.allowed) {
|
|
44
|
-
emitError(guard.reason, asJson);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const task = teamStore.createTask({
|
|
50
|
-
projectId: project.id,
|
|
51
|
-
description: args.description as string,
|
|
52
|
-
deps: parseCsvList(args.deps as string | undefined),
|
|
53
|
-
metadata,
|
|
54
|
-
createdBy: args.agentId as string | undefined,
|
|
55
|
-
requiredRole: args.requiredRole as string | undefined,
|
|
56
|
-
preferredRole: args.preferredRole as string | undefined,
|
|
57
|
-
});
|
|
58
|
-
const deps = teamStore.getTaskDeps(task.task_id);
|
|
59
|
-
emitResult(
|
|
60
|
-
{ project, task, deps },
|
|
61
|
-
`Task created: ${shortId(task.task_id)} "${task.description}"${deps.length > 0 ? ` (${deps.length} dep)` : ''}`,
|
|
62
|
-
asJson,
|
|
63
|
-
);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
case 'claim': {
|
|
68
|
-
if (!args.taskId || !args.agentId) {
|
|
69
|
-
emitError('taskId and agentId are required for "memorix task claim"', asJson);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const result = teamStore.claimTask(args.taskId as string, args.agentId as string);
|
|
73
|
-
if (!result.success) {
|
|
74
|
-
emitError(result.reason ?? 'Unable to claim task', asJson);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
emitResult(
|
|
78
|
-
{ project, result },
|
|
79
|
-
`Task claimed: ${result.task?.description ?? args.taskId}${result.hint ? `\nHint: ${result.hint}` : ''}`,
|
|
80
|
-
asJson,
|
|
81
|
-
);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
case 'complete': {
|
|
86
|
-
if (!args.taskId || !args.agentId || !args.result) {
|
|
87
|
-
emitError('taskId, agentId, and result are required for "memorix task complete"', asJson);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const result = teamStore.completeTask(args.taskId as string, args.agentId as string, args.result as string);
|
|
91
|
-
if (!result.success) {
|
|
92
|
-
emitError(result.reason ?? 'Unable to complete task', asJson);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
emitResult(
|
|
96
|
-
{ project, task: teamStore.getTask(args.taskId as string), result: args.result },
|
|
97
|
-
`Task completed: ${shortId(args.taskId as string)}`,
|
|
98
|
-
asJson,
|
|
99
|
-
);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
case 'fail': {
|
|
104
|
-
if (!args.taskId || !args.agentId || !args.result) {
|
|
105
|
-
emitError('taskId, agentId, and result are required for "memorix task fail"', asJson);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
const result = teamStore.failTask(args.taskId as string, args.agentId as string, args.result as string);
|
|
109
|
-
if (!result.success) {
|
|
110
|
-
emitError(result.reason ?? 'Unable to fail task', asJson);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
emitResult(
|
|
114
|
-
{ project, task: teamStore.getTask(args.taskId as string), result: args.result },
|
|
115
|
-
`Task failed: ${shortId(args.taskId as string)}`,
|
|
116
|
-
asJson,
|
|
117
|
-
);
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
case 'release': {
|
|
122
|
-
if (!args.taskId || !args.agentId) {
|
|
123
|
-
emitError('taskId and agentId are required for "memorix task release"', asJson);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const result = teamStore.releaseTask(args.taskId as string, args.agentId as string);
|
|
127
|
-
if (!result.success) {
|
|
128
|
-
emitError(result.reason ?? 'Unable to release task', asJson);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
emitResult(
|
|
132
|
-
{ project, task: teamStore.getTask(args.taskId as string) },
|
|
133
|
-
`Task released: ${shortId(args.taskId as string)}`,
|
|
134
|
-
asJson,
|
|
135
|
-
);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
case 'list': {
|
|
140
|
-
const tasks =
|
|
141
|
-
args.available && args.agentId
|
|
142
|
-
? teamStore.listTasksForAgent(project.id, args.agentId as string)
|
|
143
|
-
: teamStore.listTasks(
|
|
144
|
-
project.id,
|
|
145
|
-
args.available
|
|
146
|
-
? { available: true }
|
|
147
|
-
: args.status
|
|
148
|
-
? { status: args.status as string }
|
|
149
|
-
: undefined,
|
|
150
|
-
);
|
|
151
|
-
const payload = tasks.map((task) => ({
|
|
152
|
-
...task,
|
|
153
|
-
deps: teamStore.getTaskDeps(task.task_id),
|
|
154
|
-
}));
|
|
155
|
-
emitResult(
|
|
156
|
-
{ project, tasks: payload },
|
|
157
|
-
tasks.length === 0
|
|
158
|
-
? 'No tasks found.'
|
|
159
|
-
: payload
|
|
160
|
-
.map((task) => {
|
|
161
|
-
const assignee = task.assignee_agent_id
|
|
162
|
-
? teamStore.getAgent(task.assignee_agent_id)?.name ?? shortId(task.assignee_agent_id)
|
|
163
|
-
: 'unassigned';
|
|
164
|
-
const roleTag = task.required_role
|
|
165
|
-
? `[${task.required_role}${task.preferred_role && task.preferred_role !== task.required_role ? ` -> ${task.preferred_role}` : ''}]`
|
|
166
|
-
: task.preferred_role
|
|
167
|
-
? `[~${task.preferred_role}]`
|
|
168
|
-
: '';
|
|
169
|
-
return `- ${task.status}: ${shortId(task.task_id)} "${task.description}" - ${assignee} ${roleTag}`.trim();
|
|
170
|
-
})
|
|
171
|
-
.join('\n'),
|
|
172
|
-
asJson,
|
|
173
|
-
);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
default:
|
|
178
|
-
console.log('Memorix Task Commands');
|
|
179
|
-
console.log('');
|
|
180
|
-
console.log('Usage:');
|
|
181
|
-
console.log(' memorix task create --description "..." [--agentId <id>] [--deps id1,id2]');
|
|
182
|
-
console.log(' memorix task claim --taskId <id> --agentId <id>');
|
|
183
|
-
console.log(' memorix task complete --taskId <id> --agentId <id> --result "..."');
|
|
184
|
-
console.log(' memorix task fail --taskId <id> --agentId <id> --result "..."');
|
|
185
|
-
console.log(' memorix task release --taskId <id> --agentId <id>');
|
|
186
|
-
console.log(' memorix task list [--status pending|in_progress|completed|failed] [--available --agentId <id>]');
|
|
187
|
-
}
|
|
188
|
-
} catch (error) {
|
|
189
|
-
emitError(error instanceof Error ? error.message : String(error), asJson);
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
});
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
import { emitError, emitResult, getCliProjectContext, parseCsvList, parseOptionalJsonObject, shortId } from './operator-shared.js';
|
|
3
|
+
|
|
4
|
+
export default defineCommand({
|
|
5
|
+
meta: {
|
|
6
|
+
name: 'task',
|
|
7
|
+
description: 'Create, claim, complete, and inspect team tasks',
|
|
8
|
+
},
|
|
9
|
+
args: {
|
|
10
|
+
description: { type: 'string', description: 'Task description (for create)' },
|
|
11
|
+
deps: { type: 'string', description: 'Comma-separated dependency task IDs' },
|
|
12
|
+
taskId: { type: 'string', description: 'Task ID for claim, complete, fail, or release' },
|
|
13
|
+
agentId: { type: 'string', description: 'Agent ID for claim, complete, fail, release, or agent-aware list' },
|
|
14
|
+
result: { type: 'string', description: 'Completion or failure summary' },
|
|
15
|
+
status: { type: 'string', description: 'Filter by status for list' },
|
|
16
|
+
available: { type: 'boolean', description: 'Show only claimable tasks' },
|
|
17
|
+
metadata: { type: 'string', description: 'JSON metadata object for create' },
|
|
18
|
+
requiredRole: { type: 'string', description: 'Required role for this task' },
|
|
19
|
+
preferredRole: { type: 'string', description: 'Preferred role for this task' },
|
|
20
|
+
json: { type: 'boolean', description: 'Emit machine-readable JSON output' },
|
|
21
|
+
},
|
|
22
|
+
run: async ({ args }) => {
|
|
23
|
+
const action = (args._ as string[])?.[0] || '';
|
|
24
|
+
const asJson = !!args.json;
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const { project, teamStore } = await getCliProjectContext();
|
|
28
|
+
|
|
29
|
+
switch (action) {
|
|
30
|
+
case 'create': {
|
|
31
|
+
if (!args.description) {
|
|
32
|
+
emitError('description is required for "memorix task create"', asJson);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const metadata = parseOptionalJsonObject(args.metadata as string | undefined, 'metadata');
|
|
37
|
+
if (metadata) {
|
|
38
|
+
const { checkPipelineGuards } = await import('../../orchestrate/planner.js');
|
|
39
|
+
const guard = checkPipelineGuards({
|
|
40
|
+
existingTasks: teamStore.listTasks(project.id),
|
|
41
|
+
newTaskMeta: metadata,
|
|
42
|
+
});
|
|
43
|
+
if (!guard.allowed) {
|
|
44
|
+
emitError(guard.reason, asJson);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const task = teamStore.createTask({
|
|
50
|
+
projectId: project.id,
|
|
51
|
+
description: args.description as string,
|
|
52
|
+
deps: parseCsvList(args.deps as string | undefined),
|
|
53
|
+
metadata,
|
|
54
|
+
createdBy: args.agentId as string | undefined,
|
|
55
|
+
requiredRole: args.requiredRole as string | undefined,
|
|
56
|
+
preferredRole: args.preferredRole as string | undefined,
|
|
57
|
+
});
|
|
58
|
+
const deps = teamStore.getTaskDeps(task.task_id);
|
|
59
|
+
emitResult(
|
|
60
|
+
{ project, task, deps },
|
|
61
|
+
`Task created: ${shortId(task.task_id)} "${task.description}"${deps.length > 0 ? ` (${deps.length} dep)` : ''}`,
|
|
62
|
+
asJson,
|
|
63
|
+
);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
case 'claim': {
|
|
68
|
+
if (!args.taskId || !args.agentId) {
|
|
69
|
+
emitError('taskId and agentId are required for "memorix task claim"', asJson);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const result = teamStore.claimTask(args.taskId as string, args.agentId as string);
|
|
73
|
+
if (!result.success) {
|
|
74
|
+
emitError(result.reason ?? 'Unable to claim task', asJson);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
emitResult(
|
|
78
|
+
{ project, result },
|
|
79
|
+
`Task claimed: ${result.task?.description ?? args.taskId}${result.hint ? `\nHint: ${result.hint}` : ''}`,
|
|
80
|
+
asJson,
|
|
81
|
+
);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
case 'complete': {
|
|
86
|
+
if (!args.taskId || !args.agentId || !args.result) {
|
|
87
|
+
emitError('taskId, agentId, and result are required for "memorix task complete"', asJson);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const result = teamStore.completeTask(args.taskId as string, args.agentId as string, args.result as string);
|
|
91
|
+
if (!result.success) {
|
|
92
|
+
emitError(result.reason ?? 'Unable to complete task', asJson);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
emitResult(
|
|
96
|
+
{ project, task: teamStore.getTask(args.taskId as string), result: args.result },
|
|
97
|
+
`Task completed: ${shortId(args.taskId as string)}`,
|
|
98
|
+
asJson,
|
|
99
|
+
);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
case 'fail': {
|
|
104
|
+
if (!args.taskId || !args.agentId || !args.result) {
|
|
105
|
+
emitError('taskId, agentId, and result are required for "memorix task fail"', asJson);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const result = teamStore.failTask(args.taskId as string, args.agentId as string, args.result as string);
|
|
109
|
+
if (!result.success) {
|
|
110
|
+
emitError(result.reason ?? 'Unable to fail task', asJson);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
emitResult(
|
|
114
|
+
{ project, task: teamStore.getTask(args.taskId as string), result: args.result },
|
|
115
|
+
`Task failed: ${shortId(args.taskId as string)}`,
|
|
116
|
+
asJson,
|
|
117
|
+
);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
case 'release': {
|
|
122
|
+
if (!args.taskId || !args.agentId) {
|
|
123
|
+
emitError('taskId and agentId are required for "memorix task release"', asJson);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const result = teamStore.releaseTask(args.taskId as string, args.agentId as string);
|
|
127
|
+
if (!result.success) {
|
|
128
|
+
emitError(result.reason ?? 'Unable to release task', asJson);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
emitResult(
|
|
132
|
+
{ project, task: teamStore.getTask(args.taskId as string) },
|
|
133
|
+
`Task released: ${shortId(args.taskId as string)}`,
|
|
134
|
+
asJson,
|
|
135
|
+
);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
case 'list': {
|
|
140
|
+
const tasks =
|
|
141
|
+
args.available && args.agentId
|
|
142
|
+
? teamStore.listTasksForAgent(project.id, args.agentId as string)
|
|
143
|
+
: teamStore.listTasks(
|
|
144
|
+
project.id,
|
|
145
|
+
args.available
|
|
146
|
+
? { available: true }
|
|
147
|
+
: args.status
|
|
148
|
+
? { status: args.status as string }
|
|
149
|
+
: undefined,
|
|
150
|
+
);
|
|
151
|
+
const payload = tasks.map((task) => ({
|
|
152
|
+
...task,
|
|
153
|
+
deps: teamStore.getTaskDeps(task.task_id),
|
|
154
|
+
}));
|
|
155
|
+
emitResult(
|
|
156
|
+
{ project, tasks: payload },
|
|
157
|
+
tasks.length === 0
|
|
158
|
+
? 'No tasks found.'
|
|
159
|
+
: payload
|
|
160
|
+
.map((task) => {
|
|
161
|
+
const assignee = task.assignee_agent_id
|
|
162
|
+
? teamStore.getAgent(task.assignee_agent_id)?.name ?? shortId(task.assignee_agent_id)
|
|
163
|
+
: 'unassigned';
|
|
164
|
+
const roleTag = task.required_role
|
|
165
|
+
? `[${task.required_role}${task.preferred_role && task.preferred_role !== task.required_role ? ` -> ${task.preferred_role}` : ''}]`
|
|
166
|
+
: task.preferred_role
|
|
167
|
+
? `[~${task.preferred_role}]`
|
|
168
|
+
: '';
|
|
169
|
+
return `- ${task.status}: ${shortId(task.task_id)} "${task.description}" - ${assignee} ${roleTag}`.trim();
|
|
170
|
+
})
|
|
171
|
+
.join('\n'),
|
|
172
|
+
asJson,
|
|
173
|
+
);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
default:
|
|
178
|
+
console.log('Memorix Task Commands');
|
|
179
|
+
console.log('');
|
|
180
|
+
console.log('Usage:');
|
|
181
|
+
console.log(' memorix task create --description "..." [--agentId <id>] [--deps id1,id2]');
|
|
182
|
+
console.log(' memorix task claim --taskId <id> --agentId <id>');
|
|
183
|
+
console.log(' memorix task complete --taskId <id> --agentId <id> --result "..."');
|
|
184
|
+
console.log(' memorix task fail --taskId <id> --agentId <id> --result "..."');
|
|
185
|
+
console.log(' memorix task release --taskId <id> --agentId <id>');
|
|
186
|
+
console.log(' memorix task list [--status pending|in_progress|completed|failed] [--available --agentId <id>]');
|
|
187
|
+
}
|
|
188
|
+
} catch (error) {
|
|
189
|
+
emitError(error instanceof Error ? error.message : String(error), asJson);
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
});
|