@shardworks/astrolabe-apparatus 0.1.132
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 +15 -0
- package/README.md +150 -0
- package/dist/astrolabe.d.ts +15 -0
- package/dist/astrolabe.d.ts.map +1 -0
- package/dist/astrolabe.js +319 -0
- package/dist/astrolabe.js.map +1 -0
- package/dist/engines/decision-review.d.ts +21 -0
- package/dist/engines/decision-review.d.ts.map +1 -0
- package/dist/engines/decision-review.js +225 -0
- package/dist/engines/decision-review.js.map +1 -0
- package/dist/engines/index.d.ts +4 -0
- package/dist/engines/index.d.ts.map +1 -0
- package/dist/engines/index.js +4 -0
- package/dist/engines/index.js.map +1 -0
- package/dist/engines/inventory-check.d.ts +11 -0
- package/dist/engines/inventory-check.d.ts.map +1 -0
- package/dist/engines/inventory-check.js +27 -0
- package/dist/engines/inventory-check.js.map +1 -0
- package/dist/engines/plan-init.d.ts +11 -0
- package/dist/engines/plan-init.d.ts.map +1 -0
- package/dist/engines/plan-init.js +39 -0
- package/dist/engines/plan-init.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +75 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +40 -0
- package/sage.md +11 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sean Boots
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# `@shardworks/astrolabe-apparatus`
|
|
2
|
+
|
|
3
|
+
The Astrolabe transforms patron briefs into structured work specifications. It drives a multi-stage planning pipeline — inventory, analysis, patron review, and specification writing — using a sequence of clockwork engines and anima sessions. It sits between the Clerk (writ lifecycle) and the Spider (rig execution), contributing kit pieces to both.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@shardworks/astrolabe-apparatus": "workspace:*"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The Astrolabe requires `stacks` and `clerk` and recommends `spider`, `loom`, `fabricator`, and `oculus`.
|
|
18
|
+
|
|
19
|
+
## API
|
|
20
|
+
|
|
21
|
+
The Astrolabe exposes an `AstrolabeApi` via `provides`, accessible at runtime via `guild().apparatus<AstrolabeApi>('astrolabe')`.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import type { AstrolabeApi } from '@shardworks/astrolabe-apparatus';
|
|
25
|
+
|
|
26
|
+
const astrolabe = guild().apparatus<AstrolabeApi>('astrolabe');
|
|
27
|
+
|
|
28
|
+
// Show a single plan
|
|
29
|
+
const plan = await astrolabe.show('w-abc123-def456');
|
|
30
|
+
|
|
31
|
+
// List plans with filters
|
|
32
|
+
const plans = await astrolabe.list({ status: 'writing', codex: 'my-codex', limit: 10 });
|
|
33
|
+
|
|
34
|
+
// Partially update a plan (engines and tools use this internally)
|
|
35
|
+
const updated = await astrolabe.patch('w-abc123-def456', { spec: '# Spec\n...' });
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### `AstrolabeApi`
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
interface AstrolabeApi {
|
|
42
|
+
/** Show a plan by id. Throws if not found. */
|
|
43
|
+
show(planId: string): Promise<PlanDoc>;
|
|
44
|
+
|
|
45
|
+
/** List plans with optional filters, ordered by createdAt descending. */
|
|
46
|
+
list(filters?: PlanFilters): Promise<PlanDoc[]>;
|
|
47
|
+
|
|
48
|
+
/** Partially update a plan. Returns the updated document. Throws if not found. */
|
|
49
|
+
patch(planId: string, fields: Partial<Omit<PlanDoc, 'id'>>): Promise<PlanDoc>;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### `PlanDoc`
|
|
54
|
+
|
|
55
|
+
A `PlanDoc` is keyed by the brief writ ID and tracks the full planning lifecycle:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
interface PlanDoc {
|
|
59
|
+
id: string; // Brief writ ID
|
|
60
|
+
codex: string; // Target codex
|
|
61
|
+
status: PlanStatus; // 'reading' | 'analyzing' | 'reviewing' | 'writing' | 'completed' | 'failed'
|
|
62
|
+
inventory?: string; // Markdown: affected files, types, interfaces, patterns
|
|
63
|
+
observations?: string; // Markdown: refactoring opportunities, risks, conventions
|
|
64
|
+
scope?: ScopeItem[]; // What's in and what's out
|
|
65
|
+
decisions?: Decision[]; // Architectural/design decisions with options
|
|
66
|
+
spec?: string; // The generated specification (markdown)
|
|
67
|
+
generatedWritId?: string; // ID of the generated mandate/configured writ type
|
|
68
|
+
createdAt: string;
|
|
69
|
+
updatedAt: string;
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### `PlanFilters`
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
interface PlanFilters {
|
|
77
|
+
status?: PlanStatus; // Filter by planning status
|
|
78
|
+
codex?: string; // Filter by codex name
|
|
79
|
+
limit?: number; // Max results (default: 20)
|
|
80
|
+
offset?: number; // Skip N results
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Configuration
|
|
85
|
+
|
|
86
|
+
Add an `astrolabe` section to `guild.json` to configure behaviour:
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"astrolabe": {
|
|
91
|
+
"generatedWritType": "mandate"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
| Field | Type | Default | Description |
|
|
97
|
+
|---|---|---|---|
|
|
98
|
+
| `generatedWritType` | `string` | `"mandate"` | Writ type posted by the spec-writer engine |
|
|
99
|
+
|
|
100
|
+
## Support Kit
|
|
101
|
+
|
|
102
|
+
### Books
|
|
103
|
+
|
|
104
|
+
The Astrolabe declares one book in Stacks:
|
|
105
|
+
|
|
106
|
+
| Book | Owner | Indexes |
|
|
107
|
+
|---|---|---|
|
|
108
|
+
| `plans` | `astrolabe` | `status`, `codex`, `createdAt` |
|
|
109
|
+
|
|
110
|
+
### Writ Types (contributed to Clerk)
|
|
111
|
+
|
|
112
|
+
| Name | Description |
|
|
113
|
+
|---|---|
|
|
114
|
+
| `brief` | A patron brief triggering the planning pipeline |
|
|
115
|
+
|
|
116
|
+
### Roles (contributed to Loom)
|
|
117
|
+
|
|
118
|
+
| Role | Qualified Name | Permissions | Strict |
|
|
119
|
+
|---|---|---|---|
|
|
120
|
+
| `sage` | `astrolabe.sage` | `astrolabe:read`, `astrolabe:write`, `clerk:read` | `true` |
|
|
121
|
+
|
|
122
|
+
### Engines (contributed to Fabricator)
|
|
123
|
+
|
|
124
|
+
| Engine ID | Description |
|
|
125
|
+
|---|---|
|
|
126
|
+
| `astrolabe.plan-init` | Creates a PlanDoc from the brief writ; validates codex presence |
|
|
127
|
+
| `astrolabe.inventory-check` | Validates that the reader produced a non-empty inventory |
|
|
128
|
+
| `astrolabe.decision-review` | Two-pass engine: blocks for patron review, then reconciles answers |
|
|
129
|
+
|
|
130
|
+
### Rig Templates (contributed to Spider)
|
|
131
|
+
|
|
132
|
+
| Template | Mapped Writ Type | Engines |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| `astrolabe.planning` | `brief` | plan-init → draft → reader → inventory-check → analyst → decision-review → spec-writer → seal |
|
|
135
|
+
|
|
136
|
+
The `resolutionEngine` is `spec-writer` — the rig's completion summary comes from the specification writer session.
|
|
137
|
+
|
|
138
|
+
### Tools
|
|
139
|
+
|
|
140
|
+
| Tool | Permission | Description |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| `plan-show` | `astrolabe:read` | Show full detail for a plan by ID |
|
|
143
|
+
| `plan-list` | `astrolabe:read` | List plans with optional status/codex filters |
|
|
144
|
+
| `inventory-write` | `astrolabe:write` | Write or replace the codebase inventory |
|
|
145
|
+
| `scope-write` | `astrolabe:write` | Write or replace the scope items array |
|
|
146
|
+
| `decisions-write` | `astrolabe:write` | Write or replace the decisions array |
|
|
147
|
+
| `observations-write` | `astrolabe:write` | Write or replace analyst observations |
|
|
148
|
+
| `spec-write` | `astrolabe:write` | Write or replace the generated specification |
|
|
149
|
+
|
|
150
|
+
Write tools only update their artifact field plus `updatedAt`. Status transitions are the exclusive responsibility of the clockwork engines.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Astrolabe — brief-to-specification planning apparatus.
|
|
3
|
+
*
|
|
4
|
+
* The Astrolabe transforms patron briefs into structured work specifications
|
|
5
|
+
* by driving a multi-stage planning pipeline: inventory → analysis →
|
|
6
|
+
* patron review → specification writing.
|
|
7
|
+
*
|
|
8
|
+
* See: docs/architecture/apparatus/astrolabe.md
|
|
9
|
+
*/
|
|
10
|
+
import type { Plugin } from '@shardworks/nexus-core';
|
|
11
|
+
import type { AstrolabeConfig } from './types.ts';
|
|
12
|
+
declare function resolveAstrolabeConfig(): AstrolabeConfig;
|
|
13
|
+
export declare function createAstrolabe(): Plugin;
|
|
14
|
+
export { resolveAstrolabeConfig };
|
|
15
|
+
//# sourceMappingURL=astrolabe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astrolabe.d.ts","sourceRoot":"","sources":["../src/astrolabe.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,wBAAwB,CAAC;AAQrE,OAAO,KAAK,EAEV,eAAe,EAGhB,MAAM,YAAY,CAAC;AAUpB,iBAAS,sBAAsB,IAAI,eAAe,CAEjD;AA0FD,wBAAgB,eAAe,IAAI,MAAM,CAwPxC;AAGD,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Astrolabe — brief-to-specification planning apparatus.
|
|
3
|
+
*
|
|
4
|
+
* The Astrolabe transforms patron briefs into structured work specifications
|
|
5
|
+
* by driving a multi-stage planning pipeline: inventory → analysis →
|
|
6
|
+
* patron review → specification writing.
|
|
7
|
+
*
|
|
8
|
+
* See: docs/architecture/apparatus/astrolabe.md
|
|
9
|
+
*/
|
|
10
|
+
import { guild } from '@shardworks/nexus-core';
|
|
11
|
+
import { tool } from '@shardworks/tools-apparatus';
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { createPlanInitEngine, createInventoryCheckEngine, createDecisionReviewEngine, } from "./engines/index.js";
|
|
14
|
+
// ── Config resolver ──────────────────────────────────────────────────
|
|
15
|
+
function resolveAstrolabeConfig() {
|
|
16
|
+
return guild().guildConfig().astrolabe ?? {};
|
|
17
|
+
}
|
|
18
|
+
// ── Rig template ─────────────────────────────────────────────────────
|
|
19
|
+
const planningTemplate = {
|
|
20
|
+
engines: [
|
|
21
|
+
{
|
|
22
|
+
id: 'plan-init',
|
|
23
|
+
designId: 'astrolabe.plan-init',
|
|
24
|
+
upstream: [],
|
|
25
|
+
givens: { writ: '${writ}' },
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'draft',
|
|
29
|
+
designId: 'draft',
|
|
30
|
+
upstream: ['plan-init'],
|
|
31
|
+
givens: { writ: '${writ}' },
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'reader',
|
|
35
|
+
designId: 'anima-session',
|
|
36
|
+
upstream: ['draft'],
|
|
37
|
+
givens: {
|
|
38
|
+
role: 'astrolabe.sage',
|
|
39
|
+
prompt: 'MODE: READER\n\nPlan ID: ${yields.plan-init.planId}\n\n' +
|
|
40
|
+
'You are beginning a new planning session. Use plan-show to read the plan, ' +
|
|
41
|
+
'then inventory the codebase and write the inventory using inventory-write.',
|
|
42
|
+
cwd: '${yields.draft.path}',
|
|
43
|
+
writ: '${writ}',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'inventory-check',
|
|
48
|
+
designId: 'astrolabe.inventory-check',
|
|
49
|
+
upstream: ['reader'],
|
|
50
|
+
givens: {
|
|
51
|
+
planId: '${yields.plan-init.planId}',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'analyst',
|
|
56
|
+
designId: 'anima-session',
|
|
57
|
+
upstream: ['inventory-check'],
|
|
58
|
+
givens: {
|
|
59
|
+
role: 'astrolabe.sage',
|
|
60
|
+
prompt: 'MODE: ANALYST\n\nPlan ID: ${yields.plan-init.planId}\n\n' +
|
|
61
|
+
'You are continuing the reader conversation. Use plan-show to read the current ' +
|
|
62
|
+
'plan state, then produce scope, decisions, and observations using the write tools.',
|
|
63
|
+
cwd: '${yields.draft.path}',
|
|
64
|
+
conversationId: '${yields.reader.conversationId}',
|
|
65
|
+
writ: '${writ}',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'decision-review',
|
|
70
|
+
designId: 'astrolabe.decision-review',
|
|
71
|
+
upstream: ['analyst'],
|
|
72
|
+
givens: {
|
|
73
|
+
planId: '${yields.plan-init.planId}',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 'spec-writer',
|
|
78
|
+
designId: 'anima-session',
|
|
79
|
+
upstream: ['decision-review'],
|
|
80
|
+
givens: {
|
|
81
|
+
role: 'astrolabe.sage',
|
|
82
|
+
prompt: 'MODE: WRITER\n\nPlan ID: ${yields.plan-init.planId}\n\n' +
|
|
83
|
+
'You are continuing the analyst conversation. Use plan-show to read the full ' +
|
|
84
|
+
'plan including patron-reviewed decisions, then write the specification using spec-write.',
|
|
85
|
+
cwd: '${yields.draft.path}',
|
|
86
|
+
conversationId: '${yields.analyst.conversationId}',
|
|
87
|
+
writ: '${writ}',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: 'seal',
|
|
92
|
+
designId: 'seal',
|
|
93
|
+
upstream: ['spec-writer'],
|
|
94
|
+
givens: { abandon: true },
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
resolutionEngine: 'spec-writer',
|
|
98
|
+
};
|
|
99
|
+
// ── Factory ──────────────────────────────────────────────────────────
|
|
100
|
+
export function createAstrolabe() {
|
|
101
|
+
let plansBook;
|
|
102
|
+
// ── Engines ────────────────────────────────────────────────────
|
|
103
|
+
const planInitEngine = createPlanInitEngine(() => plansBook);
|
|
104
|
+
const inventoryCheckEngine = createInventoryCheckEngine(() => plansBook);
|
|
105
|
+
const decisionReviewEngine = createDecisionReviewEngine(() => plansBook);
|
|
106
|
+
// ── API ────────────────────────────────────────────────────────
|
|
107
|
+
const api = {
|
|
108
|
+
async show(planId) {
|
|
109
|
+
const plan = await plansBook.get(planId);
|
|
110
|
+
if (!plan) {
|
|
111
|
+
throw new Error(`Plan "${planId}" not found.`);
|
|
112
|
+
}
|
|
113
|
+
return plan;
|
|
114
|
+
},
|
|
115
|
+
async list(filters) {
|
|
116
|
+
const conditions = [];
|
|
117
|
+
if (filters?.status)
|
|
118
|
+
conditions.push(['status', '=', filters.status]);
|
|
119
|
+
if (filters?.codex)
|
|
120
|
+
conditions.push(['codex', '=', filters.codex]);
|
|
121
|
+
const limit = filters?.limit ?? 20;
|
|
122
|
+
const offset = filters?.offset;
|
|
123
|
+
return plansBook.find({
|
|
124
|
+
where: conditions.length > 0 ? conditions : undefined,
|
|
125
|
+
orderBy: ['createdAt', 'desc'],
|
|
126
|
+
limit,
|
|
127
|
+
...(offset !== undefined ? { offset } : {}),
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
async patch(planId, fields) {
|
|
131
|
+
return plansBook.patch(planId, fields);
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
// ── Tools ──────────────────────────────────────────────────────
|
|
135
|
+
const planShowTool = tool({
|
|
136
|
+
name: 'plan-show',
|
|
137
|
+
description: 'Show full detail for a plan',
|
|
138
|
+
instructions: 'Returns the complete plan document including inventory, scope, decisions, ' +
|
|
139
|
+
'observations, and spec fields. The planId is the brief writ ID.',
|
|
140
|
+
params: {
|
|
141
|
+
planId: z.string().describe('Plan id (same as the brief writ id)'),
|
|
142
|
+
},
|
|
143
|
+
permission: 'astrolabe:read',
|
|
144
|
+
handler: async ({ planId }) => {
|
|
145
|
+
const plan = await plansBook.get(planId);
|
|
146
|
+
if (!plan)
|
|
147
|
+
throw new Error(`Plan "${planId}" not found.`);
|
|
148
|
+
return plan;
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
const planListTool = tool({
|
|
152
|
+
name: 'plan-list',
|
|
153
|
+
description: 'List plans with optional filters',
|
|
154
|
+
instructions: 'Returns plan summaries ordered by createdAt descending (newest first). ' +
|
|
155
|
+
'Filter by status or codex to narrow results.',
|
|
156
|
+
params: {
|
|
157
|
+
status: z
|
|
158
|
+
.enum(['reading', 'analyzing', 'reviewing', 'writing', 'completed', 'failed'])
|
|
159
|
+
.optional()
|
|
160
|
+
.describe('Filter by plan status'),
|
|
161
|
+
codex: z.string().optional().describe('Filter by codex name'),
|
|
162
|
+
limit: z.number().optional().default(20).describe('Maximum results (default: 20)'),
|
|
163
|
+
offset: z.number().optional().describe('Number of results to skip'),
|
|
164
|
+
},
|
|
165
|
+
permission: 'astrolabe:read',
|
|
166
|
+
handler: async (params) => {
|
|
167
|
+
const where = [];
|
|
168
|
+
if (params.status)
|
|
169
|
+
where.push(['status', '=', params.status]);
|
|
170
|
+
if (params.codex)
|
|
171
|
+
where.push(['codex', '=', params.codex]);
|
|
172
|
+
return plansBook.find({
|
|
173
|
+
where: where.length > 0 ? where : undefined,
|
|
174
|
+
orderBy: ['createdAt', 'desc'],
|
|
175
|
+
limit: params.limit,
|
|
176
|
+
...(params.offset !== undefined ? { offset: params.offset } : {}),
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
const inventoryWriteTool = tool({
|
|
181
|
+
name: 'inventory-write',
|
|
182
|
+
description: 'Write the codebase inventory for a plan',
|
|
183
|
+
instructions: 'Writes or replaces the inventory field on the plan. The inventory should be a ' +
|
|
184
|
+
'markdown document describing affected files, types, interfaces, and patterns.',
|
|
185
|
+
params: {
|
|
186
|
+
planId: z.string().describe('Plan id'),
|
|
187
|
+
inventory: z.string().describe('Inventory content (markdown)'),
|
|
188
|
+
},
|
|
189
|
+
permission: 'astrolabe:write',
|
|
190
|
+
handler: async ({ planId, inventory }) => {
|
|
191
|
+
return plansBook.patch(planId, { inventory, updatedAt: new Date().toISOString() });
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
const scopeWriteTool = tool({
|
|
195
|
+
name: 'scope-write',
|
|
196
|
+
description: 'Write or replace the scope items for a plan',
|
|
197
|
+
instructions: 'Writes the full scope array. Each scope item has an id, description, rationale, ' +
|
|
198
|
+
'and included flag.',
|
|
199
|
+
params: {
|
|
200
|
+
planId: z.string().describe('Plan id'),
|
|
201
|
+
scope: z
|
|
202
|
+
.array(z.object({
|
|
203
|
+
id: z.string(),
|
|
204
|
+
description: z.string(),
|
|
205
|
+
rationale: z.string(),
|
|
206
|
+
included: z.boolean(),
|
|
207
|
+
}))
|
|
208
|
+
.describe('Scope items'),
|
|
209
|
+
},
|
|
210
|
+
permission: 'astrolabe:write',
|
|
211
|
+
handler: async ({ planId, scope }) => {
|
|
212
|
+
return plansBook.patch(planId, { scope, updatedAt: new Date().toISOString() });
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
const decisionsWriteTool = tool({
|
|
216
|
+
name: 'decisions-write',
|
|
217
|
+
description: 'Write or replace the decisions for a plan',
|
|
218
|
+
instructions: 'Writes the full decisions array. Each decision has an id, scope references, question, ' +
|
|
219
|
+
'options, and optional recommendation/rationale fields.',
|
|
220
|
+
params: {
|
|
221
|
+
planId: z.string().describe('Plan id'),
|
|
222
|
+
decisions: z
|
|
223
|
+
.array(z.object({
|
|
224
|
+
id: z.string(),
|
|
225
|
+
scope: z.array(z.string()),
|
|
226
|
+
question: z.string(),
|
|
227
|
+
context: z.string().optional(),
|
|
228
|
+
options: z.record(z.string(), z.string()),
|
|
229
|
+
recommendation: z.string().optional(),
|
|
230
|
+
rationale: z.string().optional(),
|
|
231
|
+
selected: z.string().optional(),
|
|
232
|
+
patronOverride: z.string().optional(),
|
|
233
|
+
}))
|
|
234
|
+
.describe('Decision items'),
|
|
235
|
+
},
|
|
236
|
+
permission: 'astrolabe:write',
|
|
237
|
+
handler: async ({ planId, decisions }) => {
|
|
238
|
+
return plansBook.patch(planId, { decisions, updatedAt: new Date().toISOString() });
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
const observationsWriteTool = tool({
|
|
242
|
+
name: 'observations-write',
|
|
243
|
+
description: 'Write analyst observations for a plan',
|
|
244
|
+
instructions: 'Writes or replaces the observations field. The observations should be a markdown ' +
|
|
245
|
+
'document noting refactoring opportunities, risks, and conventions.',
|
|
246
|
+
params: {
|
|
247
|
+
planId: z.string().describe('Plan id'),
|
|
248
|
+
observations: z.string().describe('Observations content (markdown)'),
|
|
249
|
+
},
|
|
250
|
+
permission: 'astrolabe:write',
|
|
251
|
+
handler: async ({ planId, observations }) => {
|
|
252
|
+
return plansBook.patch(planId, { observations, updatedAt: new Date().toISOString() });
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
const specWriteTool = tool({
|
|
256
|
+
name: 'spec-write',
|
|
257
|
+
description: 'Write the generated specification for a plan',
|
|
258
|
+
instructions: 'Writes or replaces the spec field. The spec should be a markdown document ' +
|
|
259
|
+
'containing the implementation specification.',
|
|
260
|
+
params: {
|
|
261
|
+
planId: z.string().describe('Plan id'),
|
|
262
|
+
spec: z.string().describe('Specification content (markdown)'),
|
|
263
|
+
},
|
|
264
|
+
permission: 'astrolabe:write',
|
|
265
|
+
handler: async ({ planId, spec }) => {
|
|
266
|
+
return plansBook.patch(planId, { spec, updatedAt: new Date().toISOString() });
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
// ── Apparatus ──────────────────────────────────────────────────
|
|
270
|
+
return {
|
|
271
|
+
apparatus: {
|
|
272
|
+
requires: ['stacks', 'clerk'],
|
|
273
|
+
recommends: ['spider', 'loom', 'fabricator', 'oculus'],
|
|
274
|
+
supportKit: {
|
|
275
|
+
books: {
|
|
276
|
+
plans: { indexes: ['status', 'codex', 'createdAt'] },
|
|
277
|
+
},
|
|
278
|
+
writTypes: [
|
|
279
|
+
{ name: 'brief', description: 'A patron brief triggering the planning pipeline' },
|
|
280
|
+
],
|
|
281
|
+
roles: {
|
|
282
|
+
sage: {
|
|
283
|
+
permissions: ['astrolabe:read', 'astrolabe:write', 'clerk:read'],
|
|
284
|
+
strict: true,
|
|
285
|
+
instructionsFile: 'sage.md',
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
engines: {
|
|
289
|
+
'astrolabe.plan-init': planInitEngine,
|
|
290
|
+
'astrolabe.inventory-check': inventoryCheckEngine,
|
|
291
|
+
'astrolabe.decision-review': decisionReviewEngine,
|
|
292
|
+
},
|
|
293
|
+
rigTemplates: {
|
|
294
|
+
planning: planningTemplate,
|
|
295
|
+
},
|
|
296
|
+
rigTemplateMappings: {
|
|
297
|
+
brief: 'astrolabe.planning',
|
|
298
|
+
},
|
|
299
|
+
tools: [
|
|
300
|
+
planShowTool,
|
|
301
|
+
planListTool,
|
|
302
|
+
inventoryWriteTool,
|
|
303
|
+
scopeWriteTool,
|
|
304
|
+
decisionsWriteTool,
|
|
305
|
+
observationsWriteTool,
|
|
306
|
+
specWriteTool,
|
|
307
|
+
],
|
|
308
|
+
},
|
|
309
|
+
provides: api,
|
|
310
|
+
start(_ctx) {
|
|
311
|
+
const stacks = guild().apparatus('stacks');
|
|
312
|
+
plansBook = stacks.book('astrolabe', 'plans');
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
// Export resolveAstrolabeConfig for external use (lazy config access)
|
|
318
|
+
export { resolveAstrolabeConfig };
|
|
319
|
+
//# sourceMappingURL=astrolabe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astrolabe.js","sourceRoot":"","sources":["../src/astrolabe.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAInD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAE5B,wEAAwE;AAExE,SAAS,sBAAsB;IAC7B,OAAO,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC;AAC/C,CAAC;AAED,wEAAwE;AAExE,MAAM,gBAAgB,GAAg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OAAO,CAAC,CAAC;YACzD,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAED,sEAAsE;AACtE,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* decision-review clockwork engine.
|
|
3
|
+
*
|
|
4
|
+
* Two-pass engine:
|
|
5
|
+
*
|
|
6
|
+
* First run (plan status 'analyzing'):
|
|
7
|
+
* - Maps decisions to ChoiceQuestionSpec and scope items to BooleanQuestionSpec.
|
|
8
|
+
* - Creates an InputRequestDoc in spider/input-requests.
|
|
9
|
+
* - Blocks with 'patron-input' block type.
|
|
10
|
+
* - If no decisions and no scope items, completes immediately.
|
|
11
|
+
*
|
|
12
|
+
* Re-run (plan status 'reviewing'):
|
|
13
|
+
* - Reads the completed InputRequestDoc.
|
|
14
|
+
* - Reconciles answers back into the PlanDoc.
|
|
15
|
+
* - Yields a human-readable decisionSummary markdown string.
|
|
16
|
+
*/
|
|
17
|
+
import type { EngineDesign } from '@shardworks/fabricator-apparatus';
|
|
18
|
+
import type { Book } from '@shardworks/stacks-apparatus';
|
|
19
|
+
import type { PlanDoc } from '../types.ts';
|
|
20
|
+
export declare function createDecisionReviewEngine(getPlansBook: () => Book<PlanDoc>): EngineDesign;
|
|
21
|
+
//# sourceMappingURL=decision-review.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision-review.d.ts","sourceRoot":"","sources":["../../src/engines/decision-review.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAqC,MAAM,kCAAkC,CAAC;AACxG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAUzD,OAAO,KAAK,EAAE,OAAO,EAAuB,MAAM,aAAa,CAAC;AAiDhE,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,YAAY,CA8L1F"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* decision-review clockwork engine.
|
|
3
|
+
*
|
|
4
|
+
* Two-pass engine:
|
|
5
|
+
*
|
|
6
|
+
* First run (plan status 'analyzing'):
|
|
7
|
+
* - Maps decisions to ChoiceQuestionSpec and scope items to BooleanQuestionSpec.
|
|
8
|
+
* - Creates an InputRequestDoc in spider/input-requests.
|
|
9
|
+
* - Blocks with 'patron-input' block type.
|
|
10
|
+
* - If no decisions and no scope items, completes immediately.
|
|
11
|
+
*
|
|
12
|
+
* Re-run (plan status 'reviewing'):
|
|
13
|
+
* - Reads the completed InputRequestDoc.
|
|
14
|
+
* - Reconciles answers back into the PlanDoc.
|
|
15
|
+
* - Yields a human-readable decisionSummary markdown string.
|
|
16
|
+
*/
|
|
17
|
+
import { guild, generateId } from '@shardworks/nexus-core';
|
|
18
|
+
// ── Helpers ──────────────────────────────────────────────────────────
|
|
19
|
+
function composeDetails(context, rationale) {
|
|
20
|
+
if (context && rationale) {
|
|
21
|
+
return `${context}\n\nRecommendation rationale: ${rationale}`;
|
|
22
|
+
}
|
|
23
|
+
if (context)
|
|
24
|
+
return context;
|
|
25
|
+
if (rationale)
|
|
26
|
+
return `Recommendation rationale: ${rationale}`;
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
function buildDecisionSummary(decisions, scope) {
|
|
30
|
+
const parts = [];
|
|
31
|
+
if (decisions.length > 0) {
|
|
32
|
+
parts.push('## Decisions');
|
|
33
|
+
parts.push('');
|
|
34
|
+
for (const decision of decisions) {
|
|
35
|
+
parts.push(`### ${decision.id}: ${decision.question}`);
|
|
36
|
+
const selectedKey = decision.selected ?? decision.recommendation;
|
|
37
|
+
if (selectedKey && decision.options[selectedKey]) {
|
|
38
|
+
parts.push(`**Selected:** ${decision.options[selectedKey]}`);
|
|
39
|
+
}
|
|
40
|
+
else if (selectedKey) {
|
|
41
|
+
parts.push(`**Selected:** ${selectedKey}`);
|
|
42
|
+
}
|
|
43
|
+
if (decision.patronOverride) {
|
|
44
|
+
parts.push(`**Patron override:** ${decision.patronOverride}`);
|
|
45
|
+
}
|
|
46
|
+
parts.push('');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (scope.length > 0) {
|
|
50
|
+
parts.push('## Scope');
|
|
51
|
+
parts.push('');
|
|
52
|
+
for (const item of scope) {
|
|
53
|
+
const check = item.included ? '[x]' : '[ ]';
|
|
54
|
+
const suffix = item.included ? '' : ' (excluded)';
|
|
55
|
+
parts.push(`- ${check} ${item.id}: ${item.description}${suffix}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return parts.join('\n').trim();
|
|
59
|
+
}
|
|
60
|
+
// ── Engine factory ───────────────────────────────────────────────────
|
|
61
|
+
export function createDecisionReviewEngine(getPlansBook) {
|
|
62
|
+
return {
|
|
63
|
+
id: 'astrolabe.decision-review',
|
|
64
|
+
async run(givens, context) {
|
|
65
|
+
const planId = givens.planId;
|
|
66
|
+
const book = getPlansBook();
|
|
67
|
+
const plan = await book.get(planId);
|
|
68
|
+
if (!plan) {
|
|
69
|
+
throw new Error(`Plan "${planId}" not found.`);
|
|
70
|
+
}
|
|
71
|
+
// ── First run: status === 'analyzing' ─────────────────────────
|
|
72
|
+
if (plan.status === 'analyzing') {
|
|
73
|
+
const decisions = plan.decisions ?? [];
|
|
74
|
+
const scopeItems = plan.scope ?? [];
|
|
75
|
+
// Fast-path: no decisions and no scope
|
|
76
|
+
if (decisions.length === 0 && scopeItems.length === 0) {
|
|
77
|
+
await book.patch(planId, {
|
|
78
|
+
status: 'writing',
|
|
79
|
+
updatedAt: new Date().toISOString(),
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
status: 'completed',
|
|
83
|
+
yields: { decisionSummary: '' },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// Build questions
|
|
87
|
+
const questions = {};
|
|
88
|
+
const answers = {};
|
|
89
|
+
for (const decision of decisions) {
|
|
90
|
+
const choiceSpec = {
|
|
91
|
+
type: 'choice',
|
|
92
|
+
label: decision.question,
|
|
93
|
+
details: composeDetails(decision.context, decision.rationale),
|
|
94
|
+
options: decision.options,
|
|
95
|
+
allowCustom: true,
|
|
96
|
+
};
|
|
97
|
+
questions[decision.id] = choiceSpec;
|
|
98
|
+
if (decision.recommendation) {
|
|
99
|
+
answers[decision.id] = { selected: decision.recommendation };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
for (const item of scopeItems) {
|
|
103
|
+
const boolSpec = {
|
|
104
|
+
type: 'boolean',
|
|
105
|
+
label: item.description,
|
|
106
|
+
details: item.rationale,
|
|
107
|
+
};
|
|
108
|
+
questions[`scope:${item.id}`] = boolSpec;
|
|
109
|
+
answers[`scope:${item.id}`] = item.included;
|
|
110
|
+
}
|
|
111
|
+
// Compose message
|
|
112
|
+
let message;
|
|
113
|
+
try {
|
|
114
|
+
const clerk = guild().apparatus('clerk');
|
|
115
|
+
const writ = await clerk.show(planId);
|
|
116
|
+
const includedScope = scopeItems.filter(s => s.included).map(s => s.description);
|
|
117
|
+
const scopeSummary = includedScope.length > 0
|
|
118
|
+
? `\n\nIn-scope items: ${includedScope.join(', ')}`
|
|
119
|
+
: '';
|
|
120
|
+
message = `Planning review for: ${writ.title} (codex: ${plan.codex})${scopeSummary}`;
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
message = `Planning review for plan: ${planId} (codex: ${plan.codex})`;
|
|
124
|
+
}
|
|
125
|
+
// Create InputRequestDoc
|
|
126
|
+
const requestId = generateId('ir', 4);
|
|
127
|
+
const now = new Date().toISOString();
|
|
128
|
+
const inputRequest = {
|
|
129
|
+
id: requestId,
|
|
130
|
+
rigId: context.rigId,
|
|
131
|
+
engineId: context.engineId,
|
|
132
|
+
status: 'pending',
|
|
133
|
+
message,
|
|
134
|
+
questions,
|
|
135
|
+
answers,
|
|
136
|
+
createdAt: now,
|
|
137
|
+
updatedAt: now,
|
|
138
|
+
};
|
|
139
|
+
const stacks = guild().apparatus('stacks');
|
|
140
|
+
const inputRequestsBook = stacks.book('spider', 'input-requests');
|
|
141
|
+
await inputRequestsBook.put(inputRequest);
|
|
142
|
+
// Update plan status to 'reviewing'
|
|
143
|
+
await book.patch(planId, {
|
|
144
|
+
status: 'reviewing',
|
|
145
|
+
updatedAt: now,
|
|
146
|
+
});
|
|
147
|
+
return {
|
|
148
|
+
status: 'blocked',
|
|
149
|
+
blockType: 'patron-input',
|
|
150
|
+
condition: { requestId },
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
// ── Re-run: status === 'reviewing' ────────────────────────────
|
|
154
|
+
if (plan.status === 'reviewing') {
|
|
155
|
+
// Extract requestId from priorBlock or query book
|
|
156
|
+
let requestId;
|
|
157
|
+
if (context.priorBlock?.condition) {
|
|
158
|
+
const cond = context.priorBlock.condition;
|
|
159
|
+
requestId = cond.requestId;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
// Fallback: query by rigId + engineId
|
|
163
|
+
const stacks = guild().apparatus('stacks');
|
|
164
|
+
const inputRequestsBook = stacks.book('spider', 'input-requests');
|
|
165
|
+
const found = await inputRequestsBook.find({
|
|
166
|
+
where: [
|
|
167
|
+
['rigId', '=', context.rigId],
|
|
168
|
+
['engineId', '=', context.engineId],
|
|
169
|
+
],
|
|
170
|
+
limit: 1,
|
|
171
|
+
});
|
|
172
|
+
if (found.length === 0) {
|
|
173
|
+
throw new Error(`No InputRequestDoc found for rig "${context.rigId}" engine "${context.engineId}".`);
|
|
174
|
+
}
|
|
175
|
+
requestId = found[0].id;
|
|
176
|
+
}
|
|
177
|
+
const stacks = guild().apparatus('stacks');
|
|
178
|
+
const inputRequestsBook = stacks.book('spider', 'input-requests');
|
|
179
|
+
const inputRequest = await inputRequestsBook.get(requestId);
|
|
180
|
+
if (!inputRequest) {
|
|
181
|
+
throw new Error(`InputRequestDoc "${requestId}" not found.`);
|
|
182
|
+
}
|
|
183
|
+
// Reconcile answers back into the plan
|
|
184
|
+
const decisions = (plan.decisions ?? []).map(d => ({ ...d }));
|
|
185
|
+
const scopeItems = (plan.scope ?? []).map(s => ({ ...s }));
|
|
186
|
+
for (const [key, answer] of Object.entries(inputRequest.answers)) {
|
|
187
|
+
if (key.startsWith('scope:')) {
|
|
188
|
+
const scopeId = key.slice('scope:'.length);
|
|
189
|
+
const item = scopeItems.find(s => s.id === scopeId);
|
|
190
|
+
if (item) {
|
|
191
|
+
item.included = answer;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
const decision = decisions.find(d => d.id === key);
|
|
196
|
+
if (decision) {
|
|
197
|
+
const choiceAnswer = answer;
|
|
198
|
+
if ('selected' in choiceAnswer) {
|
|
199
|
+
decision.selected = choiceAnswer.selected;
|
|
200
|
+
}
|
|
201
|
+
else if ('custom' in choiceAnswer) {
|
|
202
|
+
decision.patronOverride = choiceAnswer.custom;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const decisionSummary = buildDecisionSummary(decisions, scopeItems);
|
|
208
|
+
const now = new Date().toISOString();
|
|
209
|
+
await book.patch(planId, {
|
|
210
|
+
decisions,
|
|
211
|
+
scope: scopeItems,
|
|
212
|
+
status: 'writing',
|
|
213
|
+
updatedAt: now,
|
|
214
|
+
});
|
|
215
|
+
return {
|
|
216
|
+
status: 'completed',
|
|
217
|
+
yields: { decisionSummary },
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
throw new Error(`decision-review: unexpected plan status "${plan.status}" for plan "${planId}". ` +
|
|
221
|
+
`Expected 'analyzing' or 'reviewing'.`);
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=decision-review.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision-review.js","sourceRoot":"","sources":["../../src/engines/decision-review.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;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C;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engines/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/engines/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inventory-check clockwork engine.
|
|
3
|
+
*
|
|
4
|
+
* Validates that the reader stage produced a non-empty inventory on the PlanDoc.
|
|
5
|
+
* Throws if the plan is missing or has no inventory content.
|
|
6
|
+
*/
|
|
7
|
+
import type { EngineDesign } from '@shardworks/fabricator-apparatus';
|
|
8
|
+
import type { Book } from '@shardworks/stacks-apparatus';
|
|
9
|
+
import type { PlanDoc } from '../types.ts';
|
|
10
|
+
export declare function createInventoryCheckEngine(getPlansBook: () => Book<PlanDoc>): EngineDesign;
|
|
11
|
+
//# sourceMappingURL=inventory-check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inventory-check.d.ts","sourceRoot":"","sources":["../../src/engines/inventory-check.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAqC,MAAM,kCAAkC,CAAC;AACxG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,YAAY,CA4B1F"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inventory-check clockwork engine.
|
|
3
|
+
*
|
|
4
|
+
* Validates that the reader stage produced a non-empty inventory on the PlanDoc.
|
|
5
|
+
* Throws if the plan is missing or has no inventory content.
|
|
6
|
+
*/
|
|
7
|
+
export function createInventoryCheckEngine(getPlansBook) {
|
|
8
|
+
return {
|
|
9
|
+
id: 'astrolabe.inventory-check',
|
|
10
|
+
async run(givens, _context) {
|
|
11
|
+
const planId = givens.planId;
|
|
12
|
+
const book = getPlansBook();
|
|
13
|
+
const plan = await book.get(planId);
|
|
14
|
+
if (!plan) {
|
|
15
|
+
throw new Error(`Plan "${planId}" not found.`);
|
|
16
|
+
}
|
|
17
|
+
if (typeof plan.inventory !== 'string' || plan.inventory.length === 0) {
|
|
18
|
+
throw new Error(`Plan "${planId}" has no inventory — reader stage did not produce output.`);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
status: 'completed',
|
|
22
|
+
yields: {},
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=inventory-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inventory-check.js","sourceRoot":"","sources":["../../src/engines/inventory-check.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,UAAU,0BAA0B,CAAC,YAAiC;IAC1E,OAAO;QACL,EAAE,EAAE,2BAA2B;QAE/B,KAAK,CAAC,GAAG,CACP,MAA+B,EAC/B,QAA0B;YAE1B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAgB,CAAC;YACvC,MAAM,IAAI,GAAG,YAAY,EAAE,CAAC;YAE5B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CAAC,SAAS,MAAM,cAAc,CAAC,CAAC;YACjD,CAAC;YAED,IAAI,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACtE,MAAM,IAAI,KAAK,CACb,SAAS,MAAM,2DAA2D,CAC3E,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,MAAM,EAAE,WAAW;gBACnB,MAAM,EAAE,EAAE;aACX,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* plan-init clockwork engine.
|
|
3
|
+
*
|
|
4
|
+
* Creates a PlanDoc keyed by the brief writ ID. Validates that the writ
|
|
5
|
+
* has a codex and that no plan already exists for this writ.
|
|
6
|
+
*/
|
|
7
|
+
import type { EngineDesign } from '@shardworks/fabricator-apparatus';
|
|
8
|
+
import type { Book } from '@shardworks/stacks-apparatus';
|
|
9
|
+
import type { PlanDoc } from '../types.ts';
|
|
10
|
+
export declare function createPlanInitEngine(getPlansBook: () => Book<PlanDoc>): EngineDesign;
|
|
11
|
+
//# sourceMappingURL=plan-init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-init.d.ts","sourceRoot":"","sources":["../../src/engines/plan-init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAqC,MAAM,kCAAkC,CAAC;AACxG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,YAAY,CAwCpF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* plan-init clockwork engine.
|
|
3
|
+
*
|
|
4
|
+
* Creates a PlanDoc keyed by the brief writ ID. Validates that the writ
|
|
5
|
+
* has a codex and that no plan already exists for this writ.
|
|
6
|
+
*/
|
|
7
|
+
export function createPlanInitEngine(getPlansBook) {
|
|
8
|
+
return {
|
|
9
|
+
id: 'astrolabe.plan-init',
|
|
10
|
+
async run(givens, _context) {
|
|
11
|
+
const writ = givens.writ;
|
|
12
|
+
const book = getPlansBook();
|
|
13
|
+
// Validate codex
|
|
14
|
+
if (!writ.codex || typeof writ.codex !== 'string' || writ.codex.trim() === '') {
|
|
15
|
+
throw new Error(`Writ "${writ.id}" has no codex — cannot create a plan.`);
|
|
16
|
+
}
|
|
17
|
+
// Check for duplicate
|
|
18
|
+
const existing = await book.get(writ.id);
|
|
19
|
+
if (existing !== null) {
|
|
20
|
+
throw new Error(`Plan "${writ.id}" already exists.`);
|
|
21
|
+
}
|
|
22
|
+
// Create plan
|
|
23
|
+
const now = new Date().toISOString();
|
|
24
|
+
const plan = {
|
|
25
|
+
id: writ.id,
|
|
26
|
+
codex: writ.codex,
|
|
27
|
+
status: 'reading',
|
|
28
|
+
createdAt: now,
|
|
29
|
+
updatedAt: now,
|
|
30
|
+
};
|
|
31
|
+
await book.put(plan);
|
|
32
|
+
return {
|
|
33
|
+
status: 'completed',
|
|
34
|
+
yields: { planId: writ.id },
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=plan-init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-init.js","sourceRoot":"","sources":["../../src/engines/plan-init.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,UAAU,oBAAoB,CAAC,YAAiC;IACpE,OAAO;QACL,EAAE,EAAE,qBAAqB;QAEzB,KAAK,CAAC,GAAG,CACP,MAA+B,EAC/B,QAA0B;YAE1B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAe,CAAC;YACpC,MAAM,IAAI,GAAG,YAAY,EAAE,CAAC;YAE5B,iBAAiB;YACjB,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;gBAC9E,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,EAAE,wCAAwC,CAAC,CAAC;YAC5E,CAAC;YAED,sBAAsB;YACtB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACzC,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,EAAE,mBAAmB,CAAC,CAAC;YACvD,CAAC;YAED,cAAc;YACd,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YACrC,MAAM,IAAI,GAAY;gBACpB,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,SAAS;gBACjB,SAAS,EAAE,GAAG;gBACd,SAAS,EAAE,GAAG;aACf,CAAC;YAEF,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAErB,OAAO;gBACL,MAAM,EAAE,WAAW;gBACnB,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;aAC5B,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @shardworks/astrolabe-apparatus — The Astrolabe.
|
|
3
|
+
*
|
|
4
|
+
* Brief-to-specification planning: transforms patron briefs into structured
|
|
5
|
+
* work specifications through a multi-stage pipeline of inventory, analysis,
|
|
6
|
+
* patron review, and specification writing.
|
|
7
|
+
*
|
|
8
|
+
* See: docs/architecture/apparatus/astrolabe.md
|
|
9
|
+
*/
|
|
10
|
+
export type { PlanDoc, ScopeItem, Decision, PlanStatus, PlanFilters, AstrolabeConfig, AstrolabeApi, } from './types.ts';
|
|
11
|
+
export { createAstrolabe } from './astrolabe.ts';
|
|
12
|
+
declare const _default: import("@shardworks/nexus-core").Plugin;
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,YAAY,EACV,OAAO,EACP,SAAS,EACT,QAAQ,EACR,UAAU,EACV,WAAW,EACX,eAAe,EACf,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;;AAKjD,wBAAiC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @shardworks/astrolabe-apparatus — The Astrolabe.
|
|
3
|
+
*
|
|
4
|
+
* Brief-to-specification planning: transforms patron briefs into structured
|
|
5
|
+
* work specifications through a multi-stage pipeline of inventory, analysis,
|
|
6
|
+
* patron review, and specification writing.
|
|
7
|
+
*
|
|
8
|
+
* See: docs/architecture/apparatus/astrolabe.md
|
|
9
|
+
*/
|
|
10
|
+
export { createAstrolabe } from "./astrolabe.js";
|
|
11
|
+
// ── Default export: the apparatus plugin ──────────────────────────────
|
|
12
|
+
import { createAstrolabe } from "./astrolabe.js";
|
|
13
|
+
export default createAstrolabe();
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAcH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,yEAAyE;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,eAAe,eAAe,EAAE,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Astrolabe — public types.
|
|
3
|
+
*
|
|
4
|
+
* PlanDoc, ScopeItem, Decision, and supporting types for the brief-to-spec
|
|
5
|
+
* planning pipeline.
|
|
6
|
+
*/
|
|
7
|
+
export type PlanStatus = 'reading' | 'analyzing' | 'reviewing' | 'writing' | 'completed' | 'failed';
|
|
8
|
+
export interface PlanDoc {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
/** The brief writ ID — primary key. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** The codex this plan targets. */
|
|
13
|
+
codex: string;
|
|
14
|
+
/** Planning status. */
|
|
15
|
+
status: PlanStatus;
|
|
16
|
+
/** Codebase inventory: affected files, types, interfaces, patterns. */
|
|
17
|
+
inventory?: string;
|
|
18
|
+
/** Analyst observations: refactoring opportunities, risks, conventions. */
|
|
19
|
+
observations?: string;
|
|
20
|
+
/** Scope items: what's in and what's out. */
|
|
21
|
+
scope?: ScopeItem[];
|
|
22
|
+
/** Architectural/design decisions with options and analysis. */
|
|
23
|
+
decisions?: Decision[];
|
|
24
|
+
/** The generated specification. */
|
|
25
|
+
spec?: string;
|
|
26
|
+
/** The writ ID of the generated mandate (or configured type). */
|
|
27
|
+
generatedWritId?: string;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
updatedAt: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ScopeItem {
|
|
32
|
+
id: string;
|
|
33
|
+
description: string;
|
|
34
|
+
rationale: string;
|
|
35
|
+
included: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface Decision {
|
|
38
|
+
id: string;
|
|
39
|
+
scope: string[];
|
|
40
|
+
question: string;
|
|
41
|
+
context?: string;
|
|
42
|
+
options: Record<string, string>;
|
|
43
|
+
recommendation?: string;
|
|
44
|
+
rationale?: string;
|
|
45
|
+
selected?: string;
|
|
46
|
+
patronOverride?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface PlanFilters {
|
|
49
|
+
/** Filter by status. */
|
|
50
|
+
status?: PlanStatus;
|
|
51
|
+
/** Filter by codex name. */
|
|
52
|
+
codex?: string;
|
|
53
|
+
/** Maximum number of results (default: 20). */
|
|
54
|
+
limit?: number;
|
|
55
|
+
/** Number of results to skip. */
|
|
56
|
+
offset?: number;
|
|
57
|
+
}
|
|
58
|
+
export interface AstrolabeConfig {
|
|
59
|
+
/** The writ type posted by the spec-writer engine. Default: 'mandate'. */
|
|
60
|
+
generatedWritType?: string;
|
|
61
|
+
}
|
|
62
|
+
declare module '@shardworks/nexus-core' {
|
|
63
|
+
interface GuildConfig {
|
|
64
|
+
astrolabe?: AstrolabeConfig;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export interface AstrolabeApi {
|
|
68
|
+
/** Show a plan by id. Throws if not found. */
|
|
69
|
+
show(planId: string): Promise<PlanDoc>;
|
|
70
|
+
/** List plans with optional filters, ordered by createdAt descending. */
|
|
71
|
+
list(filters?: PlanFilters): Promise<PlanDoc[]>;
|
|
72
|
+
/** Partially update a plan. Returns the updated document. Throws if not found. */
|
|
73
|
+
patch(planId: string, fields: Partial<Omit<PlanDoc, 'id'>>): Promise<PlanDoc>;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAIpG,MAAM,WAAW,OAAO;IACtB,CAAC,GAAG,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MAAM,CAAC;IACf,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID,MAAM,WAAW,eAAe;IAC9B,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,OAAO,QAAQ,wBAAwB,CAAC;IACtC,UAAU,WAAW;QACnB,SAAS,CAAC,EAAE,eAAe,CAAC;KAC7B;CACF;AAID,MAAM,WAAW,YAAY;IAC3B,8CAA8C;IAC9C,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,yEAAyE;IACzE,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAChD,kFAAkF;IAClF,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/E"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shardworks/astrolabe-apparatus",
|
|
3
|
+
"version": "0.1.132",
|
|
4
|
+
"license": "ISC",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/shardworks/nexus",
|
|
8
|
+
"directory": "packages/plugins/astrolabe"
|
|
9
|
+
},
|
|
10
|
+
"description": "The Astrolabe — brief-to-specification planning apparatus",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"zod": "4.3.6",
|
|
20
|
+
"@shardworks/stacks-apparatus": "0.1.132",
|
|
21
|
+
"@shardworks/tools-apparatus": "0.1.132",
|
|
22
|
+
"@shardworks/clerk-apparatus": "0.1.132",
|
|
23
|
+
"@shardworks/fabricator-apparatus": "0.1.132",
|
|
24
|
+
"@shardworks/spider-apparatus": "0.1.132",
|
|
25
|
+
"@shardworks/loom-apparatus": "0.1.132",
|
|
26
|
+
"@shardworks/nexus-core": "0.1.132"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "25.5.0"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"sage.md"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"test": "node --disable-warning=ExperimentalWarning --experimental-transform-types --test 'src/**/*.test.ts'",
|
|
38
|
+
"typecheck": "tsc --noEmit"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/sage.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Astrolabe Sage
|
|
2
|
+
|
|
3
|
+
You are the Astrolabe sage — a planning anima that refines patron briefs into structured specifications.
|
|
4
|
+
|
|
5
|
+
Your role is to guide the planning pipeline through its stages:
|
|
6
|
+
|
|
7
|
+
- **Reader**: Inventory the codebase, identifying affected files, types, interfaces, and patterns.
|
|
8
|
+
- **Analyst**: Produce scope items, architectural decisions, and observations from the inventory.
|
|
9
|
+
- **Writer**: Synthesize patron-reviewed decisions into a complete implementation specification.
|
|
10
|
+
|
|
11
|
+
Always use the available tools to read and write plan artifacts. Do not assume state — query the plan with `plan-show` before writing.
|