@sprucelabs/spruce-cli 28.1.4 → 28.2.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/CHANGELOG.md +19 -0
- package/build/.spruce/errors/errors.types.d.ts +22 -0
- package/build/.spruce/errors/options.types.d.ts +4 -1
- package/build/.spruce/errors/spruceCli/agentAlreadyRegistered.schema.d.ts +3 -0
- package/build/.spruce/errors/spruceCli/agentAlreadyRegistered.schema.js +21 -0
- package/build/.spruce/errors/spruceCli/agentAlreadyRegistered.schema.js.map +1 -0
- package/build/__tests__/behavioral/agents/RegisteringAnAgentAtBoot.test.d.ts +15 -0
- package/build/__tests__/behavioral/agents/RegisteringAnAgentAtBoot.test.js +94 -0
- package/build/__tests__/behavioral/agents/RegisteringAnAgentAtBoot.test.js.map +1 -0
- package/build/__tests__/behavioral/onboard/StartingOnboarding.test.js +0 -7
- package/build/__tests__/behavioral/onboard/StartingOnboarding.test.js.map +1 -1
- package/build/__tests__/behavioral/permissions/SyncingPermissions.test.d.ts +7 -0
- package/build/__tests__/behavioral/permissions/SyncingPermissions.test.js +116 -14
- package/build/__tests__/behavioral/permissions/SyncingPermissions.test.js.map +1 -1
- package/build/__tests__/behavioral/{SettingRemote.test.d.ts → remote/SettingRemote.test.d.ts} +2 -2
- package/build/__tests__/behavioral/{SettingRemote.test.js → remote/SettingRemote.test.js} +2 -2
- package/build/__tests__/behavioral/remote/SettingRemote.test.js.map +1 -0
- package/build/__tests__/behavioral/remote/SettingRemoteDoesNotAskTwice.test.d.ts +10 -0
- package/build/__tests__/behavioral/remote/SettingRemoteDoesNotAskTwice.test.js +67 -0
- package/build/__tests__/behavioral/remote/SettingRemoteDoesNotAskTwice.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/CreatingATest.test.js +1 -1
- package/build/__tests__/behavioral/tests/CreatingATest.test.js.map +1 -1
- package/build/__tests__/behavioral/tests/SelectingAnAbstractTestClass.test.js +1 -1
- package/build/__tests__/behavioral/tests/SelectingAnAbstractTestClass.test.js.map +1 -1
- package/build/__tests__/behavioral/tests/TestingDataStores.test.js +3 -3
- package/build/__tests__/behavioral/tests/TestingDataStores.test.js.map +1 -1
- package/build/__tests__/support/EventFaker.d.ts +2 -0
- package/build/__tests__/support/EventFaker.js +7 -0
- package/build/__tests__/support/EventFaker.js.map +1 -1
- package/build/errors/SpruceError.js +3 -0
- package/build/errors/SpruceError.js.map +1 -1
- package/build/errors/agentAlreadyRegistered.builder.d.ts +13 -0
- package/build/errors/agentAlreadyRegistered.builder.js +16 -0
- package/build/errors/agentAlreadyRegistered.builder.js.map +1 -0
- package/build/features/ActionExecuter.js.map +1 -1
- package/build/features/FeatureInstaller.d.ts +1 -1
- package/build/features/FeatureInstallerFactory.js +3 -0
- package/build/features/FeatureInstallerFactory.js.map +1 -1
- package/build/features/agent/AgentFeature.d.ts +22 -0
- package/build/features/agent/AgentFeature.js +24 -0
- package/build/features/agent/AgentFeature.js.map +1 -0
- package/build/features/agent/actions/RegisterAction.d.ts +54 -0
- package/build/features/agent/actions/RegisterAction.js +76 -0
- package/build/features/agent/actions/RegisterAction.js.map +1 -0
- package/build/features/agent/stores/AgentStore.d.ts +5 -0
- package/build/features/agent/stores/AgentStore.js +18 -0
- package/build/features/agent/stores/AgentStore.js.map +1 -0
- package/build/features/agent/writers/AgentWriter.d.ts +8 -0
- package/build/features/agent/writers/AgentWriter.js +31 -0
- package/build/features/agent/writers/AgentWriter.js.map +1 -0
- package/build/features/event/EventFeature.js +1 -0
- package/build/features/event/EventFeature.js.map +1 -1
- package/build/features/permission/writers/PermissionWriter.js +10 -1
- package/build/features/permission/writers/PermissionWriter.js.map +1 -1
- package/build/stores/StoreFactory.d.ts +2 -0
- package/build/stores/StoreFactory.js +2 -0
- package/build/stores/StoreFactory.js.map +1 -1
- package/build/tests/buildTestCache.js +7 -1
- package/build/tests/buildTestCache.js.map +1 -1
- package/build/tests/utilities/test.utility.js +3 -3
- package/build/writers/WriterFactory.d.ts +2 -0
- package/build/writers/WriterFactory.js +2 -0
- package/build/writers/WriterFactory.js.map +1 -1
- package/package.json +24 -24
- package/src/.spruce/errors/errors.types.ts +40 -9
- package/src/.spruce/errors/options.types.ts +4 -1
- package/src/.spruce/errors/spruceCli/agentAlreadyRegistered.schema.ts +24 -0
- package/src/__tests__/behavioral/agents/RegisteringAnAgentAtBoot.test.ts +99 -0
- package/src/__tests__/behavioral/onboard/StartingOnboarding.test.ts +2 -7
- package/src/__tests__/behavioral/permissions/SyncingPermissions.test.ts +185 -52
- package/src/__tests__/behavioral/{SettingRemote.test.ts → remote/SettingRemote.test.ts} +3 -3
- package/src/__tests__/behavioral/remote/SettingRemoteDoesNotAskTwice.test.ts +68 -0
- package/src/__tests__/behavioral/tests/CreatingATest.test.ts +1 -1
- package/src/__tests__/behavioral/tests/SelectingAnAbstractTestClass.test.ts +1 -1
- package/src/__tests__/behavioral/tests/TestingDataStores.test.ts +11 -3
- package/src/__tests__/support/EventFaker.ts +10 -0
- package/src/errors/SpruceError.ts +4 -0
- package/src/errors/agentAlreadyRegistered.builder.ts +14 -0
- package/src/features/ActionExecuter.ts +5 -4
- package/src/features/FeatureInstallerFactory.ts +3 -0
- package/src/features/agent/AgentFeature.ts +31 -0
- package/src/features/agent/actions/RegisterAction.ts +79 -0
- package/src/features/agent/stores/AgentStore.ts +16 -0
- package/src/features/agent/writers/AgentWriter.ts +54 -0
- package/src/features/event/EventFeature.ts +1 -0
- package/src/features/permission/writers/PermissionWriter.ts +11 -1
- package/src/stores/StoreFactory.ts +3 -0
- package/src/tests/buildTestCache.ts +9 -2
- package/src/tests/utilities/test.utility.ts +3 -3
- package/src/writers/WriterFactory.ts +3 -0
- package/build/__tests__/behavioral/SettingRemote.test.js.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
|
+
import AbstractWriter from '../../../writers/AbstractWriter'
|
|
3
|
+
|
|
4
|
+
export default class AgentWriter extends AbstractWriter {
|
|
5
|
+
public async writePlugin(cwd: string) {
|
|
6
|
+
const destination = diskUtil.resolveHashSprucePath(
|
|
7
|
+
cwd,
|
|
8
|
+
'features',
|
|
9
|
+
'agent.plugin.ts'
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
const pluginContents = this.templates.agentPlugin()
|
|
13
|
+
|
|
14
|
+
const results = await this.writeFileIfChangedMixinResults(
|
|
15
|
+
destination,
|
|
16
|
+
pluginContents,
|
|
17
|
+
'Supports your skill with registering ai agents.'
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
return results
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public async writeSystemPrompt(
|
|
24
|
+
destinationDir: string,
|
|
25
|
+
options: {
|
|
26
|
+
name: string
|
|
27
|
+
}
|
|
28
|
+
) {
|
|
29
|
+
const { name } = options
|
|
30
|
+
|
|
31
|
+
const destination = this.resolveSystemPromptPath(destinationDir)
|
|
32
|
+
const promptContents = this.templates.agentSystemPrompt({
|
|
33
|
+
name,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const results = await this.writeFileIfChangedMixinResults(
|
|
37
|
+
destination,
|
|
38
|
+
promptContents,
|
|
39
|
+
`The prompt file that defines how your AI Platform Agent behaves.`
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
return results
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public resolveSystemPromptPath(destinationDir: string) {
|
|
46
|
+
const filename = 'SYSTEM_PROMPT.md'
|
|
47
|
+
const destination = diskUtil.resolvePath(
|
|
48
|
+
destinationDir,
|
|
49
|
+
'agents',
|
|
50
|
+
filename
|
|
51
|
+
)
|
|
52
|
+
return destination
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -104,6 +104,7 @@ export default class EventFeature extends AbstractFeature {
|
|
|
104
104
|
(featureCode === 'event' ||
|
|
105
105
|
featureCode === 'eventContract' ||
|
|
106
106
|
actionCode === 'login') &&
|
|
107
|
+
this.initiatingAction !== 'event.setRemote' &&
|
|
107
108
|
actionCode !== 'setRemote'
|
|
108
109
|
|
|
109
110
|
if (isRemoteRelevant) {
|
|
@@ -11,7 +11,17 @@ export default class PermissionWriter extends AbstractWriter {
|
|
|
11
11
|
'permissions.types.ts'
|
|
12
12
|
)
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const keys = Object.keys(map)
|
|
15
|
+
keys.sort()
|
|
16
|
+
const sorted: Partial<PermissionContractMap> = {}
|
|
17
|
+
for (const key of keys) {
|
|
18
|
+
map[key].sort((a, b) => a.localeCompare(b))
|
|
19
|
+
sorted[key] = map[key]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const contents = this.templates.permissionTypes({
|
|
23
|
+
contracts: sorted as PermissionContractMap,
|
|
24
|
+
})
|
|
15
25
|
|
|
16
26
|
const files = await this.writeFileIfChangedMixinResults(
|
|
17
27
|
destination,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import AgentStore from '../features/agent/stores/AgentStore'
|
|
1
2
|
import ConversationStore from '../features/conversation/stores/ConversationStore'
|
|
2
3
|
import EventStore from '../features/event/stores/EventStore'
|
|
3
4
|
import ListenerStore from '../features/event/stores/ListenerStore'
|
|
@@ -78,6 +79,7 @@ export interface StoreMap {
|
|
|
78
79
|
view: ViewStore
|
|
79
80
|
listener: ListenerStore
|
|
80
81
|
permission: PermissionStore
|
|
82
|
+
agent: AgentStore
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
const storeMap = {
|
|
@@ -91,6 +93,7 @@ const storeMap = {
|
|
|
91
93
|
view: ViewStore,
|
|
92
94
|
listener: ListenerStore,
|
|
93
95
|
permission: PermissionStore,
|
|
96
|
+
agent: AgentStore,
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
export type StoreCode = keyof StoreMap
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execSync } from 'child_process'
|
|
3
|
-
import {
|
|
3
|
+
import { RemoteService } from '@sprucelabs/spruce-event-utils'
|
|
4
|
+
import { diskUtil, EnvService } from '@sprucelabs/spruce-skill-utils'
|
|
4
5
|
import dotenv from 'dotenv'
|
|
5
6
|
import TerminalInterface from '../interfaces/TerminalInterface'
|
|
6
7
|
import ImportService from '../services/ImportService'
|
|
@@ -206,11 +207,17 @@ async function run() {
|
|
|
206
207
|
diskUtil.deleteDir(cwd)
|
|
207
208
|
}
|
|
208
209
|
|
|
209
|
-
renderLine(lineNum, `
|
|
210
|
+
renderLine(lineNum, `Building '${cacheKey}'...`, [
|
|
210
211
|
GraphicsTextEffect.Green,
|
|
211
212
|
])
|
|
212
213
|
|
|
213
214
|
try {
|
|
215
|
+
const env = new EnvService(cwd)
|
|
216
|
+
const remote = new RemoteService(env)
|
|
217
|
+
if (!remote.getHost()) {
|
|
218
|
+
remote.set('local')
|
|
219
|
+
}
|
|
220
|
+
|
|
214
221
|
await fixture.installFeatures(options, cacheKey)
|
|
215
222
|
renderLine(
|
|
216
223
|
lineNum,
|
|
@@ -89,9 +89,9 @@ const testUtil = {
|
|
|
89
89
|
name: string | RegExp,
|
|
90
90
|
files: GeneratedFile[] | undefined
|
|
91
91
|
): string {
|
|
92
|
-
const
|
|
92
|
+
const path = (files ?? []).find((f) => f.name.search(name) > -1)?.path
|
|
93
93
|
assert.isTruthy(
|
|
94
|
-
|
|
94
|
+
path,
|
|
95
95
|
`file named '${name}' not found in generated files.\n\n${JSON.stringify(
|
|
96
96
|
files ?? [],
|
|
97
97
|
null,
|
|
@@ -99,7 +99,7 @@ const testUtil = {
|
|
|
99
99
|
)}`
|
|
100
100
|
)
|
|
101
101
|
|
|
102
|
-
return
|
|
102
|
+
return path
|
|
103
103
|
},
|
|
104
104
|
|
|
105
105
|
assertFileByPathInGeneratedFiles(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SettingsService } from '@sprucelabs/spruce-skill-utils'
|
|
2
2
|
import { Templates } from '@sprucelabs/spruce-templates'
|
|
3
|
+
import AgentWriter from '../features/agent/writers/AgentWriter'
|
|
3
4
|
import ConversationWriter from '../features/conversation/writers/ConversationWriter'
|
|
4
5
|
import DeployWriter from '../features/deploy/writers/DeployWriter'
|
|
5
6
|
import ErrorWriter from '../features/error/writers/ErrorWriter'
|
|
@@ -26,6 +27,7 @@ const classMap = {
|
|
|
26
27
|
schema: SchemaWriter,
|
|
27
28
|
skill: SkillGenerator,
|
|
28
29
|
test: TestWriter,
|
|
30
|
+
agent: AgentWriter,
|
|
29
31
|
node: NodeWriter,
|
|
30
32
|
vscode: VsCodeWriter,
|
|
31
33
|
conversation: ConversationWriter,
|
|
@@ -102,6 +104,7 @@ export interface WriterMap {
|
|
|
102
104
|
log: LogWriter
|
|
103
105
|
polish: PolishWriter
|
|
104
106
|
permission: PermissionWriter
|
|
107
|
+
agent: AgentWriter
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
export type WriterCode = keyof WriterMap
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SettingRemote.test.js","sourceRoot":"","sources":["../../../src/__tests__/behavioral/SettingRemote.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uEAKuC;AACvC,uDAAqD;AAErD,2FAAkE;AAClE,sFAA6D;AAE7D,MAAqB,iBAAkB,SAAQ,2BAAiB;IAClD,MAAM,CAAC,aAAa,GAAG,QAAQ,CAAA;IAGlB,AAAb,MAAM,CAAC,KAAK,CAAC,kBAAkB;QACrC,mBAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,CAAA;IAChE,CAAC;IAMsB,AAAb,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAc,EAAE,QAAgB;QAC/D,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;QAE3D,MAAM,GAAG,GAAG,IAAI,CAAC,OAA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