@agentproto/corpus 0.1.0-alpha.4 → 0.1.1
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/dist/{chunk-UPX26MYH.mjs → chunk-WF5KGEL6.mjs} +7 -2
- package/dist/chunk-WF5KGEL6.mjs.map +1 -0
- package/dist/index.mjs +34 -4
- package/dist/index.mjs.map +1 -1
- package/dist/sidecar-WZTZS2I6.mjs +3 -0
- package/dist/{sidecar-TTWQD5R3.mjs.map → sidecar-WZTZS2I6.mjs.map} +1 -1
- package/package.json +4 -4
- package/dist/chunk-UPX26MYH.mjs.map +0 -1
- package/dist/sidecar-TTWQD5R3.mjs +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"sidecar-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"sidecar-WZTZS2I6.mjs"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentproto/corpus",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "@agentproto/corpus — canonical composition of AIP-10 KNOWLEDGE, AIP-12 PLAYBOOK, AIP-18 COLLECTION, AIP-9 OPERATOR, AIP-15 WORKFLOW, AIP-41 ROUTINE into an autonomous knowledge-improvement system. Pure: zero runtime, zero filesystem, zero HTTP — all I/O via injected ports.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentproto",
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
"yaml": "^2.7.0",
|
|
61
61
|
"zod": "^4.4.3",
|
|
62
62
|
"@agentproto/collection": "0.1.0-alpha.1",
|
|
63
|
-
"@agentproto/registry": "0.1.0-alpha.1",
|
|
64
63
|
"@agentproto/knowledge": "0.1.0-alpha.1",
|
|
65
64
|
"@agentproto/operator": "0.1.0-alpha.1",
|
|
66
65
|
"@agentproto/playbook": "0.1.0-alpha.1",
|
|
67
|
-
"@agentproto/
|
|
68
|
-
"@agentproto/routine": "0.1.
|
|
66
|
+
"@agentproto/registry": "0.1.0-alpha.1",
|
|
67
|
+
"@agentproto/routine": "0.1.1",
|
|
68
|
+
"@agentproto/workflow": "0.1.0-alpha.1"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/node": "^25.6.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/workspace/sidecar.ts"],"names":["yamlParse","yamlStringify"],"mappings":";;;;;;;AA6CO,IAAM,oBAAN,MAAwB;AAAA,EAC7B,YAA6B,IAAA,EAAgC;AAAhC,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAiC;AAAA;AAAA;AAAA;AAAA;AAAA,EAM9D,MAAM,IAAA,GAAyC;AAC7C,IAAA,IAAI,CAAE,MAAM,IAAA,CAAK,IAAA,CAAK,EAAA,CAAG,MAAA,CAAO,IAAA,CAAK,IAAA,CAAK,IAAI,CAAA,EAAI,OAAO,EAAC;AAC1D,IAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CAAK,IAAA,CAAK,GAAG,QAAA,CAAS,IAAA,CAAK,KAAK,IAAI,CAAA;AAC1D,IAAA,IAAI,CAAC,OAAA,CAAQ,IAAA,EAAK,SAAU,EAAC;AAC7B,IAAA,MAAM,MAAA,GAASA,MAAU,OAAO,CAAA;AAChC,IAAA,IAAI,CAAC,UAAU,CAAC,KAAA,CAAM,QAAQ,MAAA,CAAO,UAAU,CAAA,EAAG,OAAO,EAAC;AAC1D,IAAA,OAAO,MAAA,CAAO,UAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,GAAA,EAAqD;AAChE,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,IAAA,EAAK;AACjC,IAAA,IAAI,QAAA,CAAS,KAAK,CAAC,CAAA,KAAM,EAAE,EAAA,KAAO,GAAA,CAAI,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,IAAA,GAAO,sBAAA;AAAA,EACd;AACF","file":"chunk-UPX26MYH.mjs","sourcesContent":["/**\n * CandidatesSidecar — accessor for `collections/<name>/_candidates.yaml`.\n *\n * The plan calls out lazy materialization (so-so #6): the\n * \"discovered\" state has high volume and short lifespan; AIP-18 ITEM\n * files only materialize when a candidate transitions to `analyzed`.\n * Until then, candidates live in a YAML sidecar keyed by id.\n *\n * Sidecar shape:\n * candidates:\n * - id: <slug>\n * status: discovered # may also be transitioning (rare)\n * sourceUrl: ... # collection-specific fields are free-form\n * contentHash: ...\n * discoveredAt: ISO\n * discoveredBy: ws://operators/<slug>\n *\n * The accessor enforces:\n * - id uniqueness within the file\n * - atomic full-file writes (no partial sidecar)\n * - status transition discipline (a row stays here only while\n * `status === \"discovered\"`; transitions out remove the row and\n * return the data so the caller can materialize ITEM.md)\n */\n\nimport { parse as yamlParse, stringify as yamlStringify } from \"yaml\"\nimport type { FsPort } from \"../ports/fs.port.js\"\n\nexport interface CandidateRow {\n readonly id: string\n readonly status: \"discovered\" | string\n /** Open-ended — collection schema's `fields` defines what's allowed. */\n readonly [key: string]: unknown\n}\n\ninterface SidecarShape {\n readonly candidates: readonly CandidateRow[]\n}\n\nexport interface CandidatesSidecarOptions {\n readonly fs: FsPort\n /** Workspace-relative path of the sidecar file. */\n readonly path: string\n}\n\nexport class CandidatesSidecar {\n constructor(private readonly opts: CandidatesSidecarOptions) {}\n\n /**\n * Load every row from disk. Returns an empty list if the file\n * doesn't exist (a fresh corpus has no candidates yet).\n */\n async load(): Promise<readonly CandidateRow[]> {\n if (!(await this.opts.fs.exists(this.opts.path))) return []\n const content = await this.opts.fs.readFile(this.opts.path)\n if (!content.trim()) return []\n const parsed = yamlParse(content) as Partial<SidecarShape> | null\n if (!parsed || !Array.isArray(parsed.candidates)) return []\n return parsed.candidates as readonly CandidateRow[]\n }\n\n /**\n * Append a new candidate. Refuses if `id` already exists — sidecar\n * keys are unique. Returns the full updated list.\n */\n async append(row: CandidateRow): Promise<readonly CandidateRow[]> {\n const existing = await this.load()\n if (existing.some((r) => r.id === row.id)) {\n throw new SidecarDuplicateError(this.opts.path, row.id)\n }\n const next = [...existing, row]\n await this.write(next)\n return next\n }\n\n /**\n * Mutate one row in-place. Throws if not found.\n */\n async update(\n id: string,\n patch: Readonly<Record<string, unknown>>\n ): Promise<CandidateRow> {\n const existing = await this.load()\n let updated: CandidateRow | null = null\n const next = existing.map((r) => {\n if (r.id !== id) return r\n updated = { ...r, ...patch, id: r.id } as CandidateRow\n return updated\n })\n if (!updated) throw new SidecarNotFoundError(this.opts.path, id)\n await this.write(next)\n return updated\n }\n\n /**\n * Remove a row by id. Returns the removed row so the caller can\n * materialize an ITEM.md from its fields. Throws if not found.\n *\n * Use this when a candidate transitions out of `discovered`: pull\n * it from the sidecar, write the ITEM.md, append an event.\n */\n async take(id: string): Promise<CandidateRow> {\n const existing = await this.load()\n const idx = existing.findIndex((r) => r.id === id)\n if (idx === -1) throw new SidecarNotFoundError(this.opts.path, id)\n const removed = existing[idx]!\n const next = [...existing.slice(0, idx), ...existing.slice(idx + 1)]\n await this.write(next)\n return removed\n }\n\n /**\n * Whole-file replace. Used in tests and by the indexer for\n * bulk migrations. Prefer append/update/take for normal flow.\n */\n async write(candidates: readonly CandidateRow[]): Promise<void> {\n const shape: SidecarShape = { candidates }\n const content = yamlStringify(shape, {\n // Stable output: sort keys alphabetically across rows for\n // greppable diffs. Each row's id key is preserved by the\n // stringifier; the rest is dictionary order.\n sortMapEntries: false,\n })\n await this.opts.fs.writeFile(this.opts.path, content)\n }\n}\n\nexport class SidecarDuplicateError extends Error {\n constructor(\n readonly path: string,\n readonly id: string\n ) {\n super(\n `SidecarDuplicateError: candidate id \"${id}\" already exists in ${path}`\n )\n this.name = \"SidecarDuplicateError\"\n }\n}\n\nexport class SidecarNotFoundError extends Error {\n constructor(\n readonly path: string,\n readonly id: string\n ) {\n super(`SidecarNotFoundError: candidate id \"${id}\" not in ${path}`)\n this.name = \"SidecarNotFoundError\"\n }\n}\n"]}
|