@compilr-dev/sdk 0.35.0 → 0.37.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/dist/index.d.ts CHANGED
@@ -64,7 +64,7 @@ export { detectProject, suggestProjectType, detectCommon } from './detection/ind
64
64
  export type { DetectProjectOptions, DetectionResult, ContentSummary } from './detection/index.js';
65
65
  export { createGuideTool, SHARED_GUIDE_ENTRIES, searchGuideEntries, topicToGuideEntry, } from './guide/index.js';
66
66
  export type { GuideEntry, ContentTopic, ContentSection, GuideToolConfig } from './guide/index.js';
67
- export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, createCanvasTools, createSceneTools, SCENE_TOOL_NAMES, createSceneWriter, SCENE_JOURNAL_SIZE, createImageTools, ProjectAnchorStore, FileArtifactService, } from './platform/index.js';
67
+ export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, createCanvasTools, createSceneTools, SCENE_TOOL_NAMES, resolveSelfAlias, createSceneWriter, SCENE_JOURNAL_SIZE, createImageTools, ProjectAnchorStore, FileArtifactService, } from './platform/index.js';
68
68
  export type { ProjectAnchorStoreConfig, FileArtifactServiceConfig, ImageToolsConfig, ImageResizer, } from './platform/index.js';
69
69
  export { STEP_ORDER, GUIDED_STEP_CRITERIA, getNextStep, isValidTransition, getStepCriteria, formatStepDisplay, getStepNumber, } from './platform/index.js';
70
70
  export type { CustomSkill, CompilrSkillExtension, ForkedFromMarker, InstalledFromMarker, SkillEligibilityContext, SkillCollision, SkillDiffLine, SkillValidationIssue, ScopeConfig, SkillResolution, } from './skills/index.js';
package/dist/index.js CHANGED
@@ -147,7 +147,7 @@ export { createGuideTool, SHARED_GUIDE_ENTRIES, searchGuideEntries, topicToGuide
147
147
  // =============================================================================
148
148
  // Platform Tools (runtime — createPlatformTools factory + individual factories)
149
149
  // =============================================================================
150
- export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, createCanvasTools, createSceneTools, SCENE_TOOL_NAMES, createSceneWriter, SCENE_JOURNAL_SIZE, createImageTools, ProjectAnchorStore, FileArtifactService, } from './platform/index.js';
150
+ export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, createCanvasTools, createSceneTools, SCENE_TOOL_NAMES, resolveSelfAlias, createSceneWriter, SCENE_JOURNAL_SIZE, createImageTools, ProjectAnchorStore, FileArtifactService, } from './platform/index.js';
151
151
  // =============================================================================
152
152
  // Platform Workflow (pure step-criteria logic)
153
153
  // =============================================================================
@@ -47,9 +47,29 @@ export interface PlatformHooks {
47
47
  id: number;
48
48
  name: string;
49
49
  }) => void;
50
- /** Resolve owner aliases (e.g., 'self' → active agent ID) */
50
+ /**
51
+ * Resolve owner aliases (e.g., 'self' → active agent ID).
52
+ *
53
+ * ⚠️ MUST read the agent executing RIGHT NOW, not the one that was active when the tools were
54
+ * built — platform tools are built once and memoised by every host, so a captured value freezes
55
+ * for the session. Same trap as `cwd`, below. Implement it with {@link resolveSelfAlias}.
56
+ */
51
57
  resolveOwner?: (alias: 'self') => string | undefined;
52
58
  }
59
+ /**
60
+ * Turn a host's notion of "the agent running now" into an owner alias.
61
+ *
62
+ * `'default'` is the coordinator slot every single-agent session uses, not an identity, so it
63
+ * resolves to `undefined` — which callers then render as their own fallback (`'agent'` for a work
64
+ * item's author) rather than writing the literal string `default` into stored data.
65
+ *
66
+ * ⚠️ This lives here because BOTH hosts need the same answer and only one of them had it. The CLI
67
+ * implemented the rule inline; Desktop passed no `resolveOwner` at all, so every scene edit
68
+ * recorded no agent and `consumeUserEdits` keyed every agent on the empty string — one shared
69
+ * "already told" mark, so only the FIRST agent to touch a canvas was ever told about the user's
70
+ * edits to it. The rule being in one host and not the other is a bug in both.
71
+ */
72
+ export declare function resolveSelfAlias(agentId: string | null | undefined): string | undefined;
53
73
  export interface PlatformToolsConfig {
54
74
  /** Data access layer */
55
75
  context: PlatformContext;
@@ -4,6 +4,24 @@
4
4
  * Provides a single entry point for data access, abstracting over the
5
5
  * underlying storage backend (SQLite in CLI, PostgreSQL in web/API).
6
6
  */
7
+ /**
8
+ * Turn a host's notion of "the agent running now" into an owner alias.
9
+ *
10
+ * `'default'` is the coordinator slot every single-agent session uses, not an identity, so it
11
+ * resolves to `undefined` — which callers then render as their own fallback (`'agent'` for a work
12
+ * item's author) rather than writing the literal string `default` into stored data.
13
+ *
14
+ * ⚠️ This lives here because BOTH hosts need the same answer and only one of them had it. The CLI
15
+ * implemented the rule inline; Desktop passed no `resolveOwner` at all, so every scene edit
16
+ * recorded no agent and `consumeUserEdits` keyed every agent on the empty string — one shared
17
+ * "already told" mark, so only the FIRST agent to touch a canvas was ever told about the user's
18
+ * edits to it. The rule being in one host and not the other is a bug in both.
19
+ */
20
+ export function resolveSelfAlias(agentId) {
21
+ if (!agentId || agentId === 'default')
22
+ return undefined;
23
+ return agentId;
24
+ }
7
25
  /**
8
26
  * Resolve a `cwd` that may be a value or a getter.
9
27
  *
@@ -5,6 +5,8 @@ export type { ProjectType, ProjectStatus, RepoPattern, WorkflowMode, LifecycleSt
5
5
  export type { IProjectRepository, IWorkItemRepository, IDocumentRepository, IPlanRepository, ICommentRepository, ICanvasRepository, } from './repositories.js';
6
6
  export type { IAnchorService, IArtifactService, IEpisodeService, ICanvasRenderer, RenderedCanvasImage, AnchorData, ArtifactType, ArtifactData, ArtifactSummaryData, WorkEpisode, ProjectWorkSummary, } from './services.js';
7
7
  export type { PlatformContext, PlatformToolsConfig, PlatformHooks } from './context.js';
8
+ /** Owner-alias rule shared by every host — see its doc comment for why it lives here. */
9
+ export { resolveSelfAlias } from './context.js';
8
10
  export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, createCanvasTools, createSceneTools, SCENE_TOOL_NAMES, sceneOutline, createImageTools, } from './tools/index.js';
9
11
  export { createSceneWriter, SCENE_JOURNAL_SIZE } from './scene-writer.js';
10
12
  export type { ISceneWriter, SceneReadResult, SceneApplyResult, SceneCreateResult, SceneLastEdit, } from './scene-writer.js';
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Platform — Repository interfaces, data models, tools, and workflow.
3
3
  */
4
+ /** Owner-alias rule shared by every host — see its doc comment for why it lives here. */
5
+ export { resolveSelfAlias } from './context.js';
4
6
  // Platform tools (runtime)
5
7
  export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, createCanvasTools, createSceneTools, SCENE_TOOL_NAMES, sceneOutline, createImageTools, } from './tools/index.js';
6
8
  // The scene writer — one per host process, shared by the scene tools and the host's own
@@ -8,7 +8,7 @@
8
8
  * - Optional tool filtering
9
9
  */
10
10
  import type { Agent, AgentConfig, ContextManager } from '@compilr-dev/agents';
11
- import type { TeamAgentConfig, SerializedTeamAgent, MascotExpression, AgentRole, ToolProfile } from './types.js';
11
+ import type { TeamAgentConfig, SerializedTeamAgent, AgentRole, ToolProfile } from './types.js';
12
12
  import type { ModelTier } from '../models/index.js';
13
13
  import type { ProviderType } from '../config.js';
14
14
  import type { SharedContextManager } from './shared-context.js';
@@ -60,7 +60,8 @@ export interface TeamAgentUpdate {
60
60
  * model change), so `applyUpdate` delegates rather than reimplementing it.
61
61
  */
62
62
  modelTier?: ModelTier;
63
- mascot?: MascotExpression;
63
+ /** See `TeamAgentConfig.mascot`: custom mascots are not in `MascotExpression`. */
64
+ mascot?: string;
64
65
  description?: string;
65
66
  systemPromptAddition?: string;
66
67
  /** Tone only. Composed into the prompt at build time — see `TeamAgent.personality`. */
@@ -150,10 +151,8 @@ export declare class TeamAgent {
150
151
  * Display name shown in UI
151
152
  */
152
153
  displayName: string;
153
- /**
154
- * Mascot expression for visual differentiation
155
- */
156
- mascot: MascotExpression;
154
+ /** See `TeamAgentConfig.mascot`: custom mascots are not in `MascotExpression`. */
155
+ mascot: string;
157
156
  /**
158
157
  * Role type
159
158
  */
@@ -165,9 +165,7 @@ export class TeamAgent {
165
165
  * Display name shown in UI
166
166
  */
167
167
  displayName;
168
- /**
169
- * Mascot expression for visual differentiation
170
- */
168
+ /** See `TeamAgentConfig.mascot`: custom mascots are not in `MascotExpression`. */
171
169
  mascot;
172
170
  /**
173
171
  * Role type
@@ -96,9 +96,17 @@ export interface TeamAgentConfig {
96
96
  */
97
97
  displayName: string;
98
98
  /**
99
- * Mascot expression for visual differentiation
99
+ * The agent's mascot face, e.g. "[◈_◈]".
100
+ *
101
+ * ⚠️ `string`, NOT `MascotExpression`. That union lists only the BUILT-IN role faces
102
+ * (`ROLE_METADATA`), while a custom agent's mascot comes from `CUSTOM_MASCOTS` — a disjoint
103
+ * pool (`[⊡_⊡]`, `[⊞_⊞]`, …) whose `assignMascot()` falls back to a random pick, and which
104
+ * the CLI's editor lets the user type freely. So every custom agent carried a mascot that was
105
+ * not a legal value of its own declared type; the mismatch was papered over by two `as`
106
+ * casts and only surfaced when the tests were first typechecked. `MascotExpression` keeps its
107
+ * real job on `RoleMetadata`, where the set genuinely is closed.
100
108
  */
101
- mascot: MascotExpression;
109
+ mascot: string;
102
110
  /**
103
111
  * Role type (for presets)
104
112
  */
@@ -179,7 +187,8 @@ export interface TeamAgentConfig {
179
187
  export interface SerializedTeamAgent {
180
188
  id: string;
181
189
  displayName: string;
182
- mascot: MascotExpression;
190
+ /** See `TeamAgentConfig.mascot` — a custom agent's face is not in `MascotExpression`. */
191
+ mascot: string;
183
192
  role: AgentRole;
184
193
  description?: string;
185
194
  systemPromptAddition?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.35.0",
3
+ "version": "0.37.0",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -45,15 +45,16 @@
45
45
  "scripts": {
46
46
  "build": "tsc",
47
47
  "clean": "rm -rf dist",
48
- "lint": "eslint src/",
49
- "lint:fix": "eslint src/ --fix",
48
+ "lint": "eslint src/ tests/",
49
+ "lint:fix": "eslint src/ tests/ --fix",
50
50
  "format": "prettier --write \"src/**/*.ts\"",
51
51
  "format:check": "prettier --check \"src/**/*.ts\"",
52
52
  "test": "vitest run",
53
53
  "test:watch": "vitest",
54
54
  "test:coverage": "vitest run --coverage",
55
55
  "prepublishOnly": "npm run clean && npm run lint && npm run test && npm run build",
56
- "typecheck": "tsc --noEmit"
56
+ "typecheck": "tsc --noEmit && npm run typecheck:tests",
57
+ "typecheck:tests": "tsc --noEmit -p tsconfig.test.json"
57
58
  },
58
59
  "repository": {
59
60
  "type": "git",