@agent-workspace/cli 0.2.0 → 0.4.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/README.md +100 -0
- package/dist/commands/artifact.d.ts +1 -0
- package/dist/commands/artifact.d.ts.map +1 -1
- package/dist/commands/artifact.js +76 -15
- package/dist/commands/artifact.js.map +1 -1
- package/dist/commands/contract.d.ts +32 -0
- package/dist/commands/contract.d.ts.map +1 -0
- package/dist/commands/contract.js +237 -0
- package/dist/commands/contract.js.map +1 -0
- package/dist/commands/identity.d.ts.map +1 -1
- package/dist/commands/identity.js +3 -2
- package/dist/commands/identity.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +6 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/inspect.d.ts.map +1 -1
- package/dist/commands/inspect.js +30 -0
- package/dist/commands/inspect.js.map +1 -1
- package/dist/commands/memory.d.ts +12 -1
- package/dist/commands/memory.d.ts.map +1 -1
- package/dist/commands/memory.js +72 -18
- package/dist/commands/memory.js.map +1 -1
- package/dist/commands/project.d.ts +23 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +181 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/reputation.d.ts +25 -0
- package/dist/commands/reputation.d.ts.map +1 -0
- package/dist/commands/reputation.js +227 -0
- package/dist/commands/reputation.js.map +1 -0
- package/dist/commands/status.d.ts +5 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +182 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/task.d.ts +33 -0
- package/dist/commands/task.d.ts.map +1 -0
- package/dist/commands/task.js +282 -0
- package/dist/commands/task.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +101 -3
- package/dist/commands/validate.js.map +1 -1
- package/dist/index.js +146 -20
- package/dist/index.js.map +1 -1
- package/dist/lib/artifact.d.ts.map +1 -1
- package/dist/lib/artifact.js.map +1 -1
- package/dist/lib/artifact.test.d.ts +2 -0
- package/dist/lib/artifact.test.d.ts.map +1 -0
- package/dist/lib/artifact.test.js +41 -0
- package/dist/lib/artifact.test.js.map +1 -0
- package/dist/lib/contract.d.ts +27 -0
- package/dist/lib/contract.d.ts.map +1 -0
- package/dist/lib/contract.js +83 -0
- package/dist/lib/contract.js.map +1 -0
- package/dist/lib/project.d.ts +54 -0
- package/dist/lib/project.d.ts.map +1 -0
- package/dist/lib/project.js +153 -0
- package/dist/lib/project.js.map +1 -0
- package/dist/lib/reputation.d.ts +36 -0
- package/dist/lib/reputation.d.ts.map +1 -0
- package/dist/lib/reputation.js +101 -0
- package/dist/lib/reputation.js.map +1 -0
- package/dist/lib/reputation.test.d.ts +2 -0
- package/dist/lib/reputation.test.d.ts.map +1 -0
- package/dist/lib/reputation.test.js +112 -0
- package/dist/lib/reputation.test.js.map +1 -0
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/schema.js +9 -5
- package/dist/lib/schema.js.map +1 -1
- package/dist/lib/workspace.d.ts +1 -1
- package/dist/lib/workspace.d.ts.map +1 -1
- package/dist/lib/workspace.js +1 -1
- package/dist/lib/workspace.js.map +1 -1
- package/dist/lib/workspace.test.d.ts +2 -0
- package/dist/lib/workspace.test.d.ts.map +1 -0
- package/dist/lib/workspace.test.js +36 -0
- package/dist/lib/workspace.test.js.map +1 -0
- package/package.json +7 -2
package/dist/index.js
CHANGED
|
@@ -4,14 +4,16 @@ import { AWP_VERSION } from "@agent-workspace/core";
|
|
|
4
4
|
import { initCommand } from "./commands/init.js";
|
|
5
5
|
import { validateCommand } from "./commands/validate.js";
|
|
6
6
|
import { inspectCommand } from "./commands/inspect.js";
|
|
7
|
-
import { identityGenerateCommand, identityExportCommand
|
|
7
|
+
import { identityGenerateCommand, identityExportCommand } from "./commands/identity.js";
|
|
8
8
|
import { memoryLogCommand, memorySearchCommand } from "./commands/memory.js";
|
|
9
9
|
import { artifactCreateCommand, artifactCommitCommand, artifactLogCommand, artifactListCommand, artifactSearchCommand, artifactMergeCommand, } from "./commands/artifact.js";
|
|
10
|
+
import { reputationQueryCommand, reputationSignalCommand, reputationListCommand, } from "./commands/reputation.js";
|
|
11
|
+
import { contractCreateCommand, contractListCommand, contractShowCommand, contractEvaluateCommand, } from "./commands/contract.js";
|
|
12
|
+
import { projectCreateCommand, projectListCommand, projectShowCommand, projectCloseCommand, } from "./commands/project.js";
|
|
13
|
+
import { taskCreateCommand, taskListCommand, taskUpdateCommand, taskShowCommand, } from "./commands/task.js";
|
|
14
|
+
import { statusCommand } from "./commands/status.js";
|
|
10
15
|
const program = new Command();
|
|
11
|
-
program
|
|
12
|
-
.name("awp")
|
|
13
|
-
.description("Agent Workspace Protocol — CLI tool")
|
|
14
|
-
.version(AWP_VERSION);
|
|
16
|
+
program.name("awp").description("Agent Workspace Protocol — CLI tool").version(AWP_VERSION);
|
|
15
17
|
// awp init [dir]
|
|
16
18
|
program
|
|
17
19
|
.command("init")
|
|
@@ -23,16 +25,12 @@ program
|
|
|
23
25
|
program
|
|
24
26
|
.command("validate")
|
|
25
27
|
.description("Validate the current AWP workspace")
|
|
28
|
+
.option("--quick", "Only validate core files (skip content directories)")
|
|
26
29
|
.action(validateCommand);
|
|
27
30
|
// awp inspect
|
|
28
|
-
program
|
|
29
|
-
.command("inspect")
|
|
30
|
-
.description("Show workspace summary")
|
|
31
|
-
.action(inspectCommand);
|
|
31
|
+
program.command("inspect").description("Show workspace summary").action(inspectCommand);
|
|
32
32
|
// awp identity
|
|
33
|
-
const identity = program
|
|
34
|
-
.command("identity")
|
|
35
|
-
.description("Agent identity operations");
|
|
33
|
+
const identity = program.command("identity").description("Agent identity operations");
|
|
36
34
|
identity
|
|
37
35
|
.command("generate")
|
|
38
36
|
.description("Generate a DID for this agent")
|
|
@@ -43,9 +41,7 @@ identity
|
|
|
43
41
|
.option("-f, --format <format>", "Output format (json)", "json")
|
|
44
42
|
.action(identityExportCommand);
|
|
45
43
|
// awp memory
|
|
46
|
-
const memory = program
|
|
47
|
-
.command("memory")
|
|
48
|
-
.description("Memory operations");
|
|
44
|
+
const memory = program.command("memory").description("Memory operations");
|
|
49
45
|
memory
|
|
50
46
|
.command("log")
|
|
51
47
|
.description("Append an entry to today's memory log")
|
|
@@ -54,13 +50,16 @@ memory
|
|
|
54
50
|
.action(memoryLogCommand);
|
|
55
51
|
memory
|
|
56
52
|
.command("search")
|
|
57
|
-
.description("Search memory entries")
|
|
53
|
+
.description("Search memory entries with optional fuzzy matching and date filters")
|
|
58
54
|
.argument("<query>", "Search query")
|
|
55
|
+
.option("--from <date>", "Start date (YYYY-MM-DD)")
|
|
56
|
+
.option("--to <date>", "End date (YYYY-MM-DD)")
|
|
57
|
+
.option("--tag <tag>", "Filter by tag")
|
|
58
|
+
.option("--fuzzy", "Enable fuzzy matching")
|
|
59
|
+
.option("--limit <n>", "Limit number of results")
|
|
59
60
|
.action(memorySearchCommand);
|
|
60
61
|
// awp artifact
|
|
61
|
-
const artifact = program
|
|
62
|
-
.command("artifact")
|
|
63
|
-
.description("Knowledge artifact operations (SMP)");
|
|
62
|
+
const artifact = program.command("artifact").description("Knowledge artifact operations (SMP)");
|
|
64
63
|
artifact
|
|
65
64
|
.command("create")
|
|
66
65
|
.description("Create a new knowledge artifact")
|
|
@@ -93,10 +92,137 @@ artifact
|
|
|
93
92
|
.action(artifactSearchCommand);
|
|
94
93
|
artifact
|
|
95
94
|
.command("merge")
|
|
96
|
-
.description("Merge source artifact into target
|
|
95
|
+
.description("Merge source artifact into target")
|
|
97
96
|
.argument("<target>", "Target artifact slug")
|
|
98
97
|
.argument("<source>", "Source artifact slug")
|
|
99
98
|
.option("-m, --message <message>", "Merge message")
|
|
99
|
+
.option("-s, --strategy <strategy>", "Merge strategy (additive, authority)", "additive")
|
|
100
100
|
.action(artifactMergeCommand);
|
|
101
|
+
// awp reputation
|
|
102
|
+
const reputation = program
|
|
103
|
+
.command("reputation")
|
|
104
|
+
.description("Reputation tracking operations (RDP)");
|
|
105
|
+
reputation
|
|
106
|
+
.command("query")
|
|
107
|
+
.description("Query an agent's reputation profile")
|
|
108
|
+
.argument("[slug]", "Agent reputation slug (omit to list all)")
|
|
109
|
+
.option("-d, --dimension <dim>", "Filter by dimension")
|
|
110
|
+
.option("--domain <domain>", "Filter by domain competence")
|
|
111
|
+
.option("--raw", "Show raw scores without decay")
|
|
112
|
+
.action(reputationQueryCommand);
|
|
113
|
+
reputation
|
|
114
|
+
.command("signal")
|
|
115
|
+
.description("Log a reputation signal for an agent")
|
|
116
|
+
.argument("<slug>", "Agent reputation slug")
|
|
117
|
+
.requiredOption("--dimension <dim>", "Dimension (reliability, epistemic-hygiene, coordination, domain-competence)")
|
|
118
|
+
.requiredOption("--score <n>", "Score (0.0-1.0)")
|
|
119
|
+
.option("--domain <domain>", "Domain (required for domain-competence)")
|
|
120
|
+
.option("--evidence <ref>", "Evidence reference (e.g., contract:slug, artifact:slug)")
|
|
121
|
+
.option("--message <msg>", "Human-readable note")
|
|
122
|
+
.option("--agent-did <did>", "Agent DID (required for first signal)")
|
|
123
|
+
.option("--agent-name <name>", "Agent name (required for first signal)")
|
|
124
|
+
.action(reputationSignalCommand);
|
|
125
|
+
reputation.command("list").description("List all tracked agents").action(reputationListCommand);
|
|
126
|
+
// awp contract
|
|
127
|
+
const contract = program.command("contract").description("Delegation contract operations (RDP)");
|
|
128
|
+
contract
|
|
129
|
+
.command("create")
|
|
130
|
+
.description("Create a new delegation contract")
|
|
131
|
+
.argument("<slug>", "Contract slug")
|
|
132
|
+
.requiredOption("--delegate <did>", "Delegate agent DID")
|
|
133
|
+
.requiredOption("--delegate-slug <slug>", "Delegate reputation profile slug")
|
|
134
|
+
.requiredOption("--description <text>", "Task description")
|
|
135
|
+
.option("--delegator <did>", "Delegator DID (defaults to workspace agent)")
|
|
136
|
+
.option("--deadline <date>", "Deadline (ISO 8601)")
|
|
137
|
+
.option("--output-format <type>", "Expected output type")
|
|
138
|
+
.option("--output-slug <slug>", "Expected output artifact slug")
|
|
139
|
+
.action(contractCreateCommand);
|
|
140
|
+
contract
|
|
141
|
+
.command("list")
|
|
142
|
+
.description("List all contracts")
|
|
143
|
+
.option("--status <state>", "Filter by status (draft, active, completed, evaluated)")
|
|
144
|
+
.action(contractListCommand);
|
|
145
|
+
contract
|
|
146
|
+
.command("show")
|
|
147
|
+
.description("Show contract details")
|
|
148
|
+
.argument("<slug>", "Contract slug")
|
|
149
|
+
.action(contractShowCommand);
|
|
150
|
+
contract
|
|
151
|
+
.command("evaluate")
|
|
152
|
+
.description("Evaluate a contract and generate reputation signals")
|
|
153
|
+
.argument("<slug>", "Contract slug")
|
|
154
|
+
.option("--completeness <n>", "Completeness score (0.0-1.0)")
|
|
155
|
+
.option("--accuracy <n>", "Accuracy score (0.0-1.0)")
|
|
156
|
+
.option("--clarity <n>", "Clarity score (0.0-1.0)")
|
|
157
|
+
.option("--timeliness <n>", "Timeliness score (0.0-1.0)")
|
|
158
|
+
.action(contractEvaluateCommand);
|
|
159
|
+
// awp project
|
|
160
|
+
const project = program.command("project").description("Project coordination operations (CDP)");
|
|
161
|
+
project
|
|
162
|
+
.command("create")
|
|
163
|
+
.description("Create a new project")
|
|
164
|
+
.argument("<slug>", "Project slug (e.g., q3-product-launch)")
|
|
165
|
+
.option("-t, --title <title>", "Project title")
|
|
166
|
+
.option("--deadline <date>", "Deadline (ISO 8601 date or YYYY-MM-DD)")
|
|
167
|
+
.option("--tags <tags>", "Comma-separated tags")
|
|
168
|
+
.action(projectCreateCommand);
|
|
169
|
+
project
|
|
170
|
+
.command("list")
|
|
171
|
+
.description("List all projects")
|
|
172
|
+
.option("--status <state>", "Filter by status (draft, active, paused, completed, archived)")
|
|
173
|
+
.action(projectListCommand);
|
|
174
|
+
project
|
|
175
|
+
.command("show")
|
|
176
|
+
.description("Show project details with task summary")
|
|
177
|
+
.argument("<slug>", "Project slug")
|
|
178
|
+
.action(projectShowCommand);
|
|
179
|
+
project
|
|
180
|
+
.command("close")
|
|
181
|
+
.description("Mark a project as completed")
|
|
182
|
+
.argument("<slug>", "Project slug")
|
|
183
|
+
.action(projectCloseCommand);
|
|
184
|
+
// awp task
|
|
185
|
+
const task = program.command("task").description("Task management operations (CDP)");
|
|
186
|
+
task
|
|
187
|
+
.command("create")
|
|
188
|
+
.description("Create a task within a project")
|
|
189
|
+
.argument("<project>", "Project slug")
|
|
190
|
+
.argument("<slug>", "Task slug")
|
|
191
|
+
.option("-t, --title <title>", "Task title")
|
|
192
|
+
.option("--assignee <did>", "Assignee agent DID")
|
|
193
|
+
.option("--assignee-slug <slug>", "Assignee reputation profile slug")
|
|
194
|
+
.option("--priority <level>", "Priority (low, medium, high, critical)", "medium")
|
|
195
|
+
.option("--deadline <date>", "Deadline (ISO 8601 date or YYYY-MM-DD)")
|
|
196
|
+
.option("--blocked-by <ids>", "Comma-separated task IDs that block this task")
|
|
197
|
+
.option("--output-artifact <slug>", "Output artifact slug")
|
|
198
|
+
.option("--contract <slug>", "Associated contract slug")
|
|
199
|
+
.action(taskCreateCommand);
|
|
200
|
+
task
|
|
201
|
+
.command("list")
|
|
202
|
+
.description("List tasks for a project")
|
|
203
|
+
.argument("<project>", "Project slug")
|
|
204
|
+
.option("--status <state>", "Filter by status")
|
|
205
|
+
.option("--assignee <slug>", "Filter by assignee slug")
|
|
206
|
+
.action(taskListCommand);
|
|
207
|
+
task
|
|
208
|
+
.command("update")
|
|
209
|
+
.description("Update a task's status or assignee")
|
|
210
|
+
.argument("<project>", "Project slug")
|
|
211
|
+
.argument("<slug>", "Task slug")
|
|
212
|
+
.option("--status <state>", "New status (pending, in-progress, blocked, review, completed, cancelled)")
|
|
213
|
+
.option("--assignee <did>", "New assignee DID")
|
|
214
|
+
.option("--assignee-slug <slug>", "New assignee reputation profile slug")
|
|
215
|
+
.action(taskUpdateCommand);
|
|
216
|
+
task
|
|
217
|
+
.command("show")
|
|
218
|
+
.description("Show task details")
|
|
219
|
+
.argument("<project>", "Project slug")
|
|
220
|
+
.argument("<slug>", "Task slug")
|
|
221
|
+
.action(taskShowCommand);
|
|
222
|
+
// awp status
|
|
223
|
+
program
|
|
224
|
+
.command("status")
|
|
225
|
+
.description("Rich workspace overview — projects, tasks, reputation, health")
|
|
226
|
+
.action(statusCommand);
|
|
101
227
|
program.parse();
|
|
102
228
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB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M,GACX,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAG7C;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAwB/C;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOxE"}
|
package/dist/lib/artifact.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact.js","sourceRoot":"","sources":["../../src/lib/artifact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"artifact.js","sourceRoot":"","sources":["../../src/lib/artifact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAE5C;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,YAAY,IAAI,EAAE,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,OAAO,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,aAAqB,EAAE,IAAY;IAC5D,OAAO,IAAI,CAAC,aAAa,EAA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,CAAC,aAAa,CAAC,CAAC;QACnD,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,WAAW,CAAC;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,WAAW,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.test.d.ts","sourceRoot":"","sources":["../../src/lib/artifact.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { validateSlug, idFromSlug, slugFromId, slugToPath } from "./artifact.js";
|
|
3
|
+
describe("artifact utilities", () => {
|
|
4
|
+
describe("validateSlug", () => {
|
|
5
|
+
it("accepts valid lowercase alphanumeric slugs", () => {
|
|
6
|
+
expect(validateSlug("my-artifact")).toBe(true);
|
|
7
|
+
expect(validateSlug("artifact123")).toBe(true);
|
|
8
|
+
expect(validateSlug("a")).toBe(true);
|
|
9
|
+
expect(validateSlug("test-slug-name")).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
it("rejects invalid slugs", () => {
|
|
12
|
+
expect(validateSlug("")).toBe(false);
|
|
13
|
+
expect(validateSlug("MyArtifact")).toBe(false);
|
|
14
|
+
expect(validateSlug("my_artifact")).toBe(false);
|
|
15
|
+
expect(validateSlug("-starts-with-hyphen")).toBe(false);
|
|
16
|
+
expect(validateSlug("has spaces")).toBe(false);
|
|
17
|
+
expect(validateSlug("special!chars")).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe("idFromSlug", () => {
|
|
21
|
+
it("converts slug to artifact ID", () => {
|
|
22
|
+
expect(idFromSlug("my-artifact")).toBe("artifact:my-artifact");
|
|
23
|
+
expect(idFromSlug("test")).toBe("artifact:test");
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe("slugFromId", () => {
|
|
27
|
+
it("extracts slug from artifact ID", () => {
|
|
28
|
+
expect(slugFromId("artifact:my-artifact")).toBe("my-artifact");
|
|
29
|
+
expect(slugFromId("artifact:test")).toBe("test");
|
|
30
|
+
});
|
|
31
|
+
it("handles IDs without prefix", () => {
|
|
32
|
+
expect(slugFromId("plain-slug")).toBe("plain-slug");
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe("slugToPath", () => {
|
|
36
|
+
it("generates correct file path", () => {
|
|
37
|
+
expect(slugToPath("/workspace", "my-artifact")).toBe("/workspace/artifacts/my-artifact.md");
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=artifact.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.test.js","sourceRoot":"","sources":["../../src/lib/artifact.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEjF,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;YACpD,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/C,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/C,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;YAC/B,MAAM,CAAC,YAAY,CAAC,EAAE,C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AC,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;YACrC,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QAC9F,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DelegationContractFrontmatter, ReputationSignal } from "@agent-workspace/core";
|
|
2
|
+
import type { WorkspaceFile } from "@agent-workspace/core";
|
|
3
|
+
/**
|
|
4
|
+
* Validate a contract slug
|
|
5
|
+
*/
|
|
6
|
+
export declare function validateSlug(slug: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Get the file path for a contract slug
|
|
9
|
+
*/
|
|
10
|
+
export declare function slugToContractPath(workspaceRoot: string, slug: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Load a contract by slug
|
|
13
|
+
*/
|
|
14
|
+
export declare function loadContract(workspaceRoot: string, slug: string): Promise<WorkspaceFile<DelegationContractFrontmatter>>;
|
|
15
|
+
/**
|
|
16
|
+
* List all contracts in the workspace
|
|
17
|
+
*/
|
|
18
|
+
export declare function listContracts(workspaceRoot: string): Promise<WorkspaceFile<DelegationContractFrontmatter>[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Evaluate a contract: compute weighted score and generate reputation signals.
|
|
21
|
+
* Returns the weighted score and the generated signals.
|
|
22
|
+
*/
|
|
23
|
+
export declare function evaluateContract(contract: DelegationContractFrontmatter, scores: Record<string, number>, evaluatorDid: string, now?: Date): {
|
|
24
|
+
weightedScore: number;
|
|
25
|
+
signals: ReputationSignal[];
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/lib/contract.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,6BAA6B,EAC7B,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAI3D;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GACX,MAAM,CAER;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,aAAa,CAAC,6BAA6B,CAAC,CAAC,CAGvD;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,aAAa,CAAC,6BAA6B,CAAC,EAAE,CAAC,CA2BzD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,6BAA6B,EACvC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,YAAY,EAAE,MAAM,EACpB,GAAG,GAAE,IAAiB,GACrB;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAAE,CA8BxD"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { readdir } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { CONTRACTS_DIR } from "@agent-workspace/core";
|
|
4
|
+
import { parseWorkspaceFile } from "./frontmatter.js";
|
|
5
|
+
const SLUG_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
6
|
+
/**
|
|
7
|
+
* Validate a contract slug
|
|
8
|
+
*/
|
|
9
|
+
export function validateSlug(slug) {
|
|
10
|
+
return SLUG_PATTERN.test(slug);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get the file path for a contract slug
|
|
14
|
+
*/
|
|
15
|
+
export function slugToContractPath(workspaceRoot, slug) {
|
|
16
|
+
return join(workspaceRoot, CONTRACTS_DIR, `${slug}.md`);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Load a contract by slug
|
|
20
|
+
*/
|
|
21
|
+
export async function loadContract(workspaceRoot, slug) {
|
|
22
|
+
const filePath = slugToContractPath(workspaceRoot, slug);
|
|
23
|
+
return parseWorkspaceFile(filePath);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* List all contracts in the workspace
|
|
27
|
+
*/
|
|
28
|
+
export async function listContracts(workspaceRoot) {
|
|
29
|
+
const contractsDir = join(workspaceRoot, CONTRACTS_DIR);
|
|
30
|
+
let files;
|
|
31
|
+
try {
|
|
32
|
+
files = await readdir(contractsDir);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
const mdFiles = files.filter((f) => f.endsWith(".md")).sort();
|
|
38
|
+
const contracts = [];
|
|
39
|
+
for (const f of mdFiles) {
|
|
40
|
+
try {
|
|
41
|
+
const parsed = await parseWorkspaceFile(join(contractsDir, f));
|
|
42
|
+
if (parsed.frontmatter.type === "delegation-contract") {
|
|
43
|
+
contracts.push(parsed);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Skip unparseable files
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return contracts;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Evaluate a contract: compute weighted score and generate reputation signals.
|
|
54
|
+
* Returns the weighted score and the generated signals.
|
|
55
|
+
*/
|
|
56
|
+
export function evaluateContract(contract, scores, evaluatorDid, now = new Date()) {
|
|
57
|
+
const { criteria } = contract.evaluation;
|
|
58
|
+
// Compute weighted score
|
|
59
|
+
let weightedScore = 0;
|
|
60
|
+
for (const [criterion, weight] of Object.entries(criteria)) {
|
|
61
|
+
const score = scores[criterion];
|
|
62
|
+
if (score === undefined) {
|
|
63
|
+
throw new Error(`Missing score for criterion: ${criterion}`);
|
|
64
|
+
}
|
|
65
|
+
weightedScore += weight * score;
|
|
66
|
+
}
|
|
67
|
+
weightedScore = Math.round(weightedScore * 1000) / 1000;
|
|
68
|
+
const timestamp = now.toISOString();
|
|
69
|
+
const evidence = contract.id;
|
|
70
|
+
// Generate reputation signals
|
|
71
|
+
const signals = [
|
|
72
|
+
{
|
|
73
|
+
source: evaluatorDid,
|
|
74
|
+
dimension: "reliability",
|
|
75
|
+
score: weightedScore,
|
|
76
|
+
timestamp,
|
|
77
|
+
evidence,
|
|
78
|
+
message: `Contract evaluation: ${contract.task.description}`,
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
return { weightedScore, signals };
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/lib/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAKtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGtD,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAE5C;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,aAAqB,EACrB,IAAY;IAEZ,OAAO,IAAI,CAAC,aAAa,EAAE,aAAa,EAAE,GAAG,IAAI,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU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,CAAC,CAAC;IACtB,KAAK,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3D,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,gCAAgC,SAAS,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,aAAa,IAAI,MAAM,GAAG,KAAK,CAAC;IAClC,CAAC;IACD,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAExD,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IACpC,MAAM,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAC;IAE7B,8BAA8B;IAC9B,MAAM,OAAO,GAAuB;QAClC;YACE,MAAM,EAAE,YAAY;YACpB,SAAS,EAAE,aAAa;YACxB,KAAK,EAAE,aAAa;YACpB,SAAS;YACT,QAAQ;YACR,OAAO,EAAE,wBAAwB,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE;SAC7D;KACF,CAAC;IAEF,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ProjectFrontmatter, TaskFrontmatter, ProjectMember, ReputationDimension } from "@agent-workspace/core";
|
|
2
|
+
import type { WorkspaceFile } from "@agent-workspace/core";
|
|
3
|
+
/**
|
|
4
|
+
* Validate a slug
|
|
5
|
+
*/
|
|
6
|
+
export declare function validateSlug(slug: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Get the file path for a project slug
|
|
9
|
+
*/
|
|
10
|
+
export declare function slugToProjectPath(workspaceRoot: string, slug: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Get the tasks directory for a project slug
|
|
13
|
+
*/
|
|
14
|
+
export declare function slugToTaskDir(workspaceRoot: string, projectSlug: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Get the file path for a task within a project
|
|
17
|
+
*/
|
|
18
|
+
export declare function slugToTaskPath(workspaceRoot: string, projectSlug: string, taskSlug: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Load a project by slug
|
|
21
|
+
*/
|
|
22
|
+
export declare function loadProject(workspaceRoot: string, slug: string): Promise<WorkspaceFile<ProjectFrontmatter>>;
|
|
23
|
+
/**
|
|
24
|
+
* List all projects in the workspace
|
|
25
|
+
*/
|
|
26
|
+
export declare function listProjects(workspaceRoot: string): Promise<WorkspaceFile<ProjectFrontmatter>[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Load a task by project slug and task slug
|
|
29
|
+
*/
|
|
30
|
+
export declare function loadTask(workspaceRoot: string, projectSlug: string, taskSlug: string): Promise<WorkspaceFile<TaskFrontmatter>>;
|
|
31
|
+
/**
|
|
32
|
+
* List all tasks for a project
|
|
33
|
+
*/
|
|
34
|
+
export declare function listTasks(workspaceRoot: string, projectSlug: string): Promise<WorkspaceFile<TaskFrontmatter>[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Ensure the tasks directory exists for a project
|
|
37
|
+
*/
|
|
38
|
+
export declare function ensureTaskDir(workspaceRoot: string, projectSlug: string): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Recalculate taskCount and completedCount for a project from its tasks.
|
|
41
|
+
*/
|
|
42
|
+
export declare function computeProjectCounts(workspaceRoot: string, projectSlug: string): Promise<{
|
|
43
|
+
taskCount: number;
|
|
44
|
+
completedCount: number;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Check reputation gates for a project member.
|
|
48
|
+
* Returns warnings for any scores below the threshold.
|
|
49
|
+
*/
|
|
50
|
+
export declare function checkReputationGates(member: ProjectMember, dimensions: Record<string, ReputationDimension> | undefined, domainCompetence: Record<string, ReputationDimension> | undefined, now?: Date): {
|
|
51
|
+
passed: boolean;
|
|
52
|
+
warnings: string[];
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/lib/project.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAK3D;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GACX,MAAM,CAER;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAClB,MAAM,CAER;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,MAAM,CAER;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAG5C;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,EAAE,CAAC,CA0B9C;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAGzC;AAED;;GAEG;AACH,wBAAsB,SAAS,CAC7B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,EAAE,CAAC,CA0B3C;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAGf;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAAC,CAOxD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,SAAS,EAC3D,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,SAAS,EACjE,GAAG,GAAE,IAAiB,GACrB;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CA2CzC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { readdir, mkdir } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { PROJECTS_DIR } from "@agent-workspace/core";
|
|
4
|
+
import { parseWorkspaceFile } from "./frontmatter.js";
|
|
5
|
+
import { computeDecayedScore } from "./reputation.js";
|
|
6
|
+
const SLUG_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
7
|
+
/**
|
|
8
|
+
* Validate a slug
|
|
9
|
+
*/
|
|
10
|
+
export function validateSlug(slug) {
|
|
11
|
+
return SLUG_PATTERN.test(slug);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get the file path for a project slug
|
|
15
|
+
*/
|
|
16
|
+
export function slugToProjectPath(workspaceRoot, slug) {
|
|
17
|
+
return join(workspaceRoot, PROJECTS_DIR, `${slug}.md`);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get the tasks directory for a project slug
|
|
21
|
+
*/
|
|
22
|
+
export function slugToTaskDir(workspaceRoot, projectSlug) {
|
|
23
|
+
return join(workspaceRoot, PROJECTS_DIR, projectSlug, "tasks");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the file path for a task within a project
|
|
27
|
+
*/
|
|
28
|
+
export function slugToTaskPath(workspaceRoot, projectSlug, taskSlug) {
|
|
29
|
+
return join(workspaceRoot, PROJECTS_DIR, projectSlug, "tasks", `${taskSlug}.md`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Load a project by slug
|
|
33
|
+
*/
|
|
34
|
+
export async function loadProject(workspaceRoot, slug) {
|
|
35
|
+
const filePath = slugToProjectPath(workspaceRoot, slug);
|
|
36
|
+
return parseWorkspaceFile(filePath);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* List all projects in the workspace
|
|
40
|
+
*/
|
|
41
|
+
export async function listProjects(workspaceRoot) {
|
|
42
|
+
const projDir = join(workspaceRoot, PROJECTS_DIR);
|
|
43
|
+
let entries;
|
|
44
|
+
try {
|
|
45
|
+
entries = await readdir(projDir);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const mdFiles = entries.filter((f) => f.endsWith(".md")).sort();
|
|
51
|
+
const projects = [];
|
|
52
|
+
for (const f of mdFiles) {
|
|
53
|
+
try {
|
|
54
|
+
const parsed = await parseWorkspaceFile(join(projDir, f));
|
|
55
|
+
if (parsed.frontmatter.type === "project") {
|
|
56
|
+
projects.push(parsed);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Skip unparseable files
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return projects;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Load a task by project slug and task slug
|
|
67
|
+
*/
|
|
68
|
+
export async function loadTask(workspaceRoot, projectSlug, taskSlug) {
|
|
69
|
+
const filePath = slugToTaskPath(workspaceRoot, projectSlug, taskSlug);
|
|
70
|
+
return parseWorkspaceFile(filePath);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* List all tasks for a project
|
|
74
|
+
*/
|
|
75
|
+
export async function listTasks(workspaceRoot, projectSlug) {
|
|
76
|
+
const taskDir = slugToTaskDir(workspaceRoot, projectSlug);
|
|
77
|
+
let entries;
|
|
78
|
+
try {
|
|
79
|
+
entries = await readdir(taskDir);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
const mdFiles = entries.filter((f) => f.endsWith(".md")).sort();
|
|
85
|
+
const tasks = [];
|
|
86
|
+
for (const f of mdFiles) {
|
|
87
|
+
try {
|
|
88
|
+
const parsed = await parseWorkspaceFile(join(taskDir, f));
|
|
89
|
+
if (parsed.frontmatter.type === "task") {
|
|
90
|
+
tasks.push(parsed);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Skip unparseable files
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return tasks;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Ensure the tasks directory exists for a project
|
|
101
|
+
*/
|
|
102
|
+
export async function ensureTaskDir(workspaceRoot, projectSlug) {
|
|
103
|
+
const taskDir = slugToTaskDir(workspaceRoot, projectSlug);
|
|
104
|
+
await mkdir(taskDir, { recursive: true });
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Recalculate taskCount and completedCount for a project from its tasks.
|
|
108
|
+
*/
|
|
109
|
+
export async function computeProjectCounts(workspaceRoot, projectSlug) {
|
|
110
|
+
const tasks = await listTasks(workspaceRoot, projectSlug);
|
|
111
|
+
const taskCount = tasks.length;
|
|
112
|
+
const completedCount = tasks.filter((t) => t.frontmatter.status === "completed").length;
|
|
113
|
+
return { taskCount, completedCount };
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Check reputation gates for a project member.
|
|
117
|
+
* Returns warnings for any scores below the threshold.
|
|
118
|
+
*/
|
|
119
|
+
export function checkReputationGates(member, dimensions, domainCompetence, now = new Date()) {
|
|
120
|
+
const warnings = [];
|
|
121
|
+
if (!member.minReputation) {
|
|
122
|
+
return { passed: true, warnings };
|
|
123
|
+
}
|
|
124
|
+
for (const [gate, minScore] of Object.entries(member.minReputation)) {
|
|
125
|
+
// Handle domain-competence gates (e.g., "domain-competence:ai-research")
|
|
126
|
+
if (gate.startsWith("domain-competence:")) {
|
|
127
|
+
const domain = gate.slice("domain-competence:".length);
|
|
128
|
+
const dim = domainCompetence?.[domain];
|
|
129
|
+
if (!dim) {
|
|
130
|
+
warnings.push(`No domain data for "${domain}" (required: ${minScore})`);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const decayed = computeDecayedScore(dim, now);
|
|
134
|
+
if (decayed < minScore) {
|
|
135
|
+
warnings.push(`${domain} domain score ${decayed.toFixed(2)} < required ${minScore}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
// Standard dimension gate
|
|
140
|
+
const dim = dimensions?.[gate];
|
|
141
|
+
if (!dim) {
|
|
142
|
+
warnings.push(`No data for dimension "${gate}" (required: ${minScore})`);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const decayed = computeDecayedScore(dim, now);
|
|
146
|
+
if (decayed < minScore) {
|
|
147
|
+
warnings.push(`${gate} score ${decayed.toFixed(2)} < required ${minScore}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return { passed: warnings.length === 0, warnings };
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=project.js.map
|